4 ms·
This is exactly the scenario I found so confusing, and why I wrote this. I can understand not wanting to use F# or Scala for sysadmin work, but OCaml or Haskell
by lmm 11y ago
This is exactly the scenario I found so confusing, and why I wrote this. I can understand not wanting to use F# or Scala for sysadmin work, but OCaml or Haskell would give you the safely and 95% of the performance (i.e. much better than Python) without the need for manual memory management.
Did you consider either of those? Were your reasons for preferring Rust similar to what I put in the article?
- gmjosack 11y agoI answered a similar question to a sibling comment but I think it boils down to, I didn't come to Rust for functional features but I definitely enjoy them. The languages you mention in the post have a much higher learning curve coming out of Python. I spent a few tries "learning" Haskell and I really didn't enjoy it. In general when I've looked at Scala/Haskell/F# they use so many multi-char operators that it starts to look like line noise. OCaml always felt a bit too niche for me too I think, though that may be bias of the industry I'm in.
- MichaelGG 11y agoIt's important to note that F# doesn't really have many operators at all. The one most people see, |> which "pipes" an argument, is defined in an F# library, not in the compiler or part of the core language. You can define it yourself to be anything you like, or not use it at all. The language is unaware of it and treats it like anything else. The definition is just: let (|>) x f = f x That's literally function application, in reverse. That's all. It comes in handy for type inference and to make things look nice, but isn't special in any way. I mention this as one comment as to why Rust doesn't have such an operator was that "Rust uses channels for data flow" which is a non-sequiter. Rust just doesn't value conciseness as much, and I'm guessing the safety/perf restrictions might complicate matters. In fact, even the + and - operators are implemented in F# and shouldn't count as part of the language (just very commonly used bits of the stdlib). I fear that perhaps not enough intros to F# focus on the relatively simple underlying language, and that everything else on top is just an application of said language. With the type system, it's actually easy to figure out the operators, based on the type alone. Looking at |> for instance, we see a type of: 'a -> ('a -> 'b) -> 'b This makes it entirely obvious. There's only one implementation for such a type definition. This holds true for so much of the stdlib that the "noise" quickly fades away. This is relevant as magic cannot hide, and misuse will quickly be identified by the compiler. But it's a valuable comment as it illustrates that the simplicity is not being marketed correctly and turning away potential users.
- eru 11y agoBy 95% of performance you are surely measuring throughput on a logarithmic scale or something? Haskell is great, but getting within C performance requires careful very careful Haskell writing at least.
- conceit 11y agoWell of course but you need to know what you are doing in C as well. Isn't the point just, a lot of people do, as compared to Haskell? Granted, the C compilers make a difference, too.
- eru 11y agoYes. In Haskell you get correct by default and have to work for speed. In C your program is fast by default, but wrong, and you have to work for correctness.
- lambda 11y agoOne of the major reasons for being interested in Rust is that it is something that is much easier to convince coworkers of. OCaml and Haskell have somewhat odd syntax, for someone who is coming from C like languages or even Python. You need to learn a bunch of functional programming concepts to use them effectively. You are still limited in what you can do, such as writing a native extension module for your existing Python code base. And they don't really help on one of the major selling points of Rust, which is to be able to write safe multi-threaded code with shared, mutable data structures. While there may be lots of good high-level parallelism available, at some point for certain problems you really just want to be able to use a shared, mutable data structure, but doing so in almost any language but Rust makes it very easy to make a mistake and have aliased, mutable references to it that can invalidate all of your logic, even if it isn't actually memory unsafe.