News for hackers. Stuff that matters.
Re:Rust Is Surprisingly Good as a Server Language by bad_user on Monday July 13, 2020 @04:12AM (#23818379)
In dynamic languages like JavaScript or Python it's necessary to continually run your code in order to validate that the API (of the standard library or of dependencies) was used correctly, that the types match, etc.

Rerunning your code continually is no longer necessary in a language like Rust, because the compiler already does that for you.

People complaining about slow compile times in static languages like Rust, Haskell, Scala miss the forest from the trees, which is that the compiler eliminates entire bug categories, logic you'd otherwise need to check at runtime, either via unit tests or at least by running the code locally. Compiler times can always be better, but the compiler works as a theorem prover and the slowness is entirely justified, overall yielding a better ROI.

N.B. I'm not saying that with Rust you don't need to run your code or have unit tests. There's only so much a compiler can prove. But you no longer need to do it as often.

You can't switch to a language like Rust and expect Python and if you do, then the experience is going to be horrible, because Rust is a very different language.

Re:Rust Is Surprisingly Good as a Server Language by raziel2p on Monday July 13, 2020 @05:08AM (#23818729)
> In dynamic languages like JavaScript or Python it's necessary to continually run your code

No it's not. It's just preferable to do your work in smaller batches so that your feedback loop is fast and you know exactly which change broke things, rather than making 10 changes and then having to figure out which of those changes 4 bugs relate to. And it's better to discover a flaw in your implementation early rather than late, which is also easier when working in small increments.

Re:Rust Is Surprisingly Good as a Server Language by tjoff on Monday July 13, 2020 @06:00AM (#23819038)
You get used to it and adapt. That might sound bad but comes with benefits as well. You will train yourself to think and be thorough to get it right the first time without it slowing you down.

Getting feedback quickly can be useful (especially when trying something new), but not needing it is liberating (especially when trying something new).

Re:Rust Is Surprisingly Good as a Server Language by avh02 on Monday July 13, 2020 @05:14AM (#23818767)
For me the problem would be learning how something does or does not work, even with a compiled language.

The reason I hate Spring for example (not that I've worked with it extensively) is that the documentation gives you zero feel for what you expect the behaviour to be. It will compile, but until you run it and check what it's doing, very often you'll be developing with no idea of what you're actually building.

Especially if you're trying to get specific behaviour of what you want to see (e.g: figuring out why it won't send mail, or why it doesn't ignore a certain json key or whatever), it still needs many runs to get right.

Re:Rust Is Surprisingly Good as a Server Language by neutronicus on Monday July 13, 2020 @08:36AM (#23820065)
Rust's type system doesn't have a notion of "looks right visually," so the compiler is ipso facto unhelpful there
Re:Rust Is Surprisingly Good as a Server Language by estebank on Monday July 13, 2020 @11:19AM (#23821677)
Could you expand on this? It seems like you might have a really interesting point to make but I can't tell what it is :)
Re:Rust Is Surprisingly Good as a Server Language by neutronicus on Monday July 13, 2020 @02:27PM (#23823926)
Short compile times are beneficial when development involves a lot of trial-and-error.

The parent comment was insinuating that, when developing in Rust, one can leverage its type system to replace this trial-and-error with static verification. And, indeed, if what you're worried about is a dangling or null reference error, the Rust type system has a rich language for specifying expected behavior so you don't have to run your code to check it.

If, on the other hand, your job description includes the nebulous mandate to "make it look right," there isn't any feasible way to design your types so that Rust can check that. For example, sometimes I have to do something like "make sure the dialog box is wide enough that it doesn't truncate the title string on any relevant platform." The Rust type system has no way for me to query several versions of macOS and Windows about when they start truncating dialog-box title strings and size my dialog that way, so here I am, still performing this task by trial-and-error, waiting forever to compile my code each time.

Nothing about this is Rust-specific by the way. I'm similarly bearish on statically-verified cross-platform dialog boxen in Haskell. And that's one of my dumber "make it look right" tasks - I work on CAD software so most of them involve 3-D graphics and/or computational geometry.

And, returning to the parent comment, waiting for C++ to compile in order to test things is a giant fucking time-sink and drain on my productivity. It can't really be automated, or, if it can, it's way beyond the reach of this organization's know-how.

In summary, I call bullshit on static verification replacing snappy trial-and-error in the UI / Graphics space. In practice, you're left shifting UI / Graphics customization out of the host language and into "content" so that you can tweak it without re-compiling. But this is another massive fucking time and complexity sink that only exists because at some point you let your compile-times get so far out of control that your people couldn't do their job ("make it look right") in a reasonable amount of time.

Re:Rust Is Surprisingly Good as a Server Language by estebank on Monday July 13, 2020 @02:50PM (#23824192)
I see, the type system cannot ensure logic bugs, specifically with an applied example of the visual aspect of an application. Got it. Thank you for expanding on it!
Re:Rust Is Surprisingly Good as a Server Language by tastyminerals2 on Monday July 13, 2020 @05:31AM (#23818866)
In theory and to some degree in practice. The compiler won't fix the code that compiles but runs incorrectly. Besides, there are statically typed functional languages where compiling time is not a problem, see D.
Re:Rust Is Surprisingly Good as a Server Language by bad_user on Monday July 13, 2020 @05:33AM (#23818875)
I haven't worked with D, but D isn't a functional programming language ;-)
Re:Rust Is Surprisingly Good as a Server Language by tastyminerals2 on Monday July 13, 2020 @05:46AM (#23818954)
You will be surprised if you do ;) Multi-paradigm to be exact. Scala is a multi-paradigm as well btw.

http://beza1e1.tuxen.de/stuff/FunctionalD.pdf

Re:Rust Is Surprisingly Good as a Server Language by Recurecur on Tuesday July 14, 2020 @01:49PM (#23835204)
Julia also has plenty of functional features, but is above all a practical, fast, and fast-compiling language.

The elegance is free.

Re:Rust Is Surprisingly Good as a Server Language by dean177 on Monday July 13, 2020 @06:06AM (#23819064)
You can have your cake and eat it too, Ocaml & Go both have type systems and compilers that are fast enough to work iteratively
Re:Rust Is Surprisingly Good as a Server Language by wwright on Monday July 13, 2020 @07:57AM (#23819789)
Ocaml is a somewhat fair comparison, but I have to say that Go is really in no way comparable to Rust. Rust is massively more complex.
Re:Rust Is Surprisingly Good as a Server Language by entha_saava on Monday July 13, 2020 @09:11AM (#23820366)
I'd say Go is a fair comparison here.

Type checking and Parsing isn't bottleneck in Rust compilation. Code generation is. LLVM is particularly heavy and while it generates optimized code, it is quite slow.

Go Authors didn't pick LLVM because of compile speed reasons (as well as complexity), and that turned out to be worthwhile tradeoff.

Re:Rust Is Surprisingly Good as a Server Language by monadic2 on Monday July 13, 2020 @10:07AM (#23820927)
Well, worthwhile in terms of compile times, which makes sense knowing google’s codebase. Most people aren’t compiling massive dependency trees that can’t fit on any single computer when they push a commit.

Anyway in C++ land massive compile times are just as much of a problem. Fast code is expensive. Go’s a lot of things, but being good at generating fast code ain’t one of them (looking holistically anyway).

Re:Rust Is Surprisingly Good as a Server Language by entha_saava on Monday July 13, 2020 @12:39PM (#23822708)
> Fast code is expensive.

Indeed, because all bigtech can invest on is LLVM and C++.

The research on compilers and optimizations has not been getting the attention because of LLVM monoculture and the monstrosity that is C++.

Re:Rust Is Surprisingly Good as a Server Language by monadic2 on Tuesday July 14, 2020 @11:19AM (#23832943)
Well, rust is modularizing, so there will be opportunities for alternative backend (crane lift?).
Re:Rust Is Surprisingly Good as a Server Language by atombender on Monday July 13, 2020 @03:44PM (#23824813)
Go's authors didn't pick LLVM because they weren't sufficiently familiar with it to implement what they needed (e.g. segmented stacks). See https://news.ycombinator.com/item?id=8817990 for the full explanation.
Re:Rust Is Surprisingly Good as a Server Language by deleuze on Monday July 13, 2020 @10:11AM (#23820963)
The reason it's not a fair comparison is because go is a barely typed language that requires casting to interface non stop
Re:Rust Is Surprisingly Good as a Server Language by entha_saava on Monday July 13, 2020 @12:32PM (#23822611)
I told type system is not the bottleneck, codegen is.

Even if you count the size of ode after monomorphization, I am pretty sure the Go compiler compiles it much faster. Because the compiler is not in the benchmarks rat race of adding one optimization pass from every academic paper in the world for diminishing returns. That would be unnecessary for a development compiler.

Go compiler could have an optimized slow build option, in ideal world, but that's a different matter altogether.

Re:Rust Is Surprisingly Good as a Server Language by 65a on Monday July 13, 2020 @11:58AM (#23822169)
If you're casting to interface{} non-stop, you are doing something against the grain of the language. It works, but there's probably a better way of getting the result you are looking for.
Re:Rust Is Surprisingly Good as a Server Language by deleuze on Monday July 13, 2020 @12:45PM (#23822781)
Right, building generic, reusable code is against the grain of the language.
Re:Rust Is Surprisingly Good as a Server Language by tomp on Monday July 13, 2020 @08:20AM (#23819940)
But the compiler checks your code, and if the compiler is slow, the problem remains.
Re:Rust Is Surprisingly Good as a Server Language by staticassertion on Monday July 13, 2020 @08:50AM (#23820189)
The compiler is slow at building code. It's much, much faster at checking it.
Re:Rust Is Surprisingly Good as a Server Language by Larrikin on Monday July 13, 2020 @08:25AM (#23819977)
A good IDE effectively checks your code continuously.