5 ms·
I'd say Rust is the closest thing. Cargo is fantastic, super ergonomic and with an excellent package ecosystem. Rust doesn't have the pretense of purity or immu
by _hardwaregeek 8y ago
I'd say Rust is the closest thing. Cargo is fantastic, super ergonomic and with an excellent package ecosystem. Rust doesn't have the pretense of purity or immutability, but honestly, you can very easily write pure functional Rust (and it'll save you a lot of pain with lifetimes). Performance is excellent, of course.
- weberc2 8y agoI agree that Rust is the exception--it has a fantastic tooling story, but it's actually the _language_ that holds it back for the sorts of applications I tend to write. The performance and even correctness benefits it affords me over Go are just too small for the cognitive burden it imposes (and yes much of the gap closes with time--I've been kicking the tires on and off for 5 years now--but every year the returns diminish and it's looking like the gap will remain significant). Hopefully I'll be proven wrong in the next few years.
- Ar-Curunir 8y agoWould you mind elaborating on the cognitive burden you find Rust imposes? I find that after roughly two years of writing Rust, I can architect and re-architect big projects fairly clearly, and the type system gives me strong reassurances that refactors haven't screwed things up. Not to mention the advantage of even simple things like enums, which most languages (including Go) tend to lack.
- lolive 8y agoI have heard about Rust. But I wonder if you can do something that a OO programmer (like me :) would call "string subclasses" so you do not manipulate a generic type called string, but a meaningful subclass such as "FirstName" or "LastName", or "TownName".
- steveklabnik 8y agoYou wouldn’t do it as a “subclass”, as Rust doesn’t have classes or inheritance. You’d use the “new type pattern”, which is like a named 1-tuple: struct FirstName(String);
- lolive 8y agois this type interchangeable with String?
- steveklabnik 8y agoNot exactly. That is, you can't pass it directly to a function that takes a String, but if we made the inner string public, we could extract it with two characters. If we don't want to make it public, we can write an accessor as well, etc.
- lolive 8y agoAs far as i understand, Rust is strongly typed, has generics and no type erasure. I also suppose String is some kind of a primitive type. Could it be possible to make it parametrizable, so we can manipulate a String<FirstName> as a String, but the compiler will never confound it with (for example) String<LastName>.
- steveklabnik 8y agoString is a library type, not a primitive type. You could write your own string parameterized in this way, but it would be incompatible with the standard library String and so you’d need the same conversion steps.
- lolive 8y agoWhat would happen if the Rust core team decided to parametrize String? Would it work with legacy code? (that creates something like String<?> and consume String<?>).
- christophilus 8y agoI'd be curious to hear about your edit -> recompile -> run experience with Rust. My typical dev process is edit -> auto-recompile in the background -> refresh the browser / whatever I need to do to see how my edits affected the thing I'm working on. Rust's compilation speed seems like a non-starter for me.
- Ar-Curunir 8y agoDepending on the project I'm working on, I do need a server class machine for running benchmarks, but that might not be the case for most projects (I work with heavy cryptographic things, so tests sometimes take a while to run). However, for compilation errors, feedback is instant, because cargo check (which runs everything except codegen) is almost instantaneous. I've also set up neovim to give run it on every save (via a plugin), so I don't have to leave my editor for this. I know that VS Code and IntelliJ also do this.
- pjmlp 8y agoTry to write GUI applications without sprikling the code with RC<RefCell<>> everywhere, due to callbacks and access to widget fields.
- weberc2 8y ago> Would you mind elaborating on the cognitive burden you find Rust imposes? Millions of little decisions with respect to which lifetimes to use, which types to use, which type of pointer to use, whether to pass by ref or by copy, and so on. > I find that after roughly two years of writing Rust, I can architect and re-architect big projects fairly clearly, and the type system gives me strong reassurances that refactors haven't screwed things up. > Not to mention the advantage of even simple things like enums, which most languages (including Go) tend to lack. I don't doubt it. I think these are really cool properties of Rust. They just don't pay for the cognitive burden, since the applications I write aren't critical systems (I can afford _some_ unsafety, but I can't afford to slow my development process). To put it differently, if I write in Go, I can quickly ship a feature with a high degree of confidence that it's overwhelmingly correct, and the few errors that do slip into production can be quickly fixed because I can iterate so quickly. If I write in Go, I will eventually ship a feature with a very high degree of confidence that it's overwhelmingly correct, but even if I find zero bugs in production, the time spent shipping the first iteration in Rust is much larger than the time it would spend me to ship _and_ iterate on bugfixes in Go. I'm sure the extent to which this is true shrinks as I get more experience with Rust, but there's a law of diminishing returns at play, and no indication that the gap will ever vanish entirely.
- Ar-Curunir 8y agoWhat kind of code have you been writing? For most Rust code that I write and read, I find almost no lifetime annotations are needed.
- twic 8y agoRust is lovely - but you definitely do have to guess about what string types to use!
- mseri 8y agoI think that’s more of a problem (or at least used to be one) in Haskell. In Rust it mostly boils down to how much speed or ergonomics you want
- cix_pkez 8y agoLove Rust, but there's room for garbage collection over borrowchecking if we're talking about replacing scripting languages. It would be hard for a decent statically-typed FP language to be slower than Ruby, for example.