Earlier quoted context omitted.
ML with a borrow checker is a bit of an oxymoron though. Because proper closures (the kind Rust can't do) are essential for the classic functional programming that ML represents.
Can you explain "proper closures"?
OCaml: a Rust developer's first impressions
41–50 of 157 posts
Re: OCaml: a Rust developer's first impressions
#42OCaml is great, we learned it in class back in college, then we learned Rust right afterwards. Oftentimes people say OCaml is Rust without the borrow checker (or that Rust is OCaml with a borrow checker), but that's not quite true. Since it is entirely functional and recursive, it takes more time to wrap your head around. Now with OCaml 5, we also have algebraic effect support, something that Rust is looking to add i…
People say that OCaml is like Rust, but unlike Rust, OCaml has Exceptions that could appear everywhere. How is that safe?
Re: OCaml: a Rust developer's first impressions
#43Earlier quoted context omitted.
Yes and no, Rust is ML inspired but it is still way too imperative and not as functional to be called a true ML. But yes, things like Result and Option types, do-notion via "?," at least for Results and Options, algebraic data types are all part of the appeal. There sadly are still no higher kinded types though, but that is a difficult problem to solve and most won't encounter such problems anyway in day-to-day codin…
True. In this case the author is speaking specifically about OCaml, which is quite comfortable to write imperatively. I think the thing that tickles most people about Rust is the thoroughness of the type inference and type checking, which one generally gets from any ML.
Re: OCaml: a Rust developer's first impressions
#44Earlier quoted context omitted.
Safety was something added to Rust as it developed, not one of the original goals. As I recall it. And you're working with multiple definitions of "safety" here, and Rust sorta conflates them all via borrow checker, but the one people are usually most concerned with is memory safety which is not a concern for a garbage collected language. I do seem to recall that StandardML did not have exceptions though. And I alway…
From the presentation introducing Rust to Mozilla: http://venge.net/graydon/talks/intro-talk-2.pdf > I have been writing a compiled, concurrent, safe, systems programming language for the past four and a half years. Safety was always part of it.
I guess I should have been more specific. If that's what we mean by safe, then OCaml is safe as well.
Anyways, I followed it at the time. The borrow checker came later.
Re: OCaml: a Rust developer's first impressions
#45Earlier quoted context omitted.
At least in my piece of corporate software engineering, I'm looking at Rust as a "gateway drug" for FP. Management doesn't want to take the risk of investing in FP, so reliable choices like Java and C++ are usually endorsed; the safety aspects of Rust are a much stronger argument for them.
I don't think the safety aspects are a much stronger argument. Managed languages like Java and C# are safe. The garbage collector isn't going to let you ++ your way into remote code execution and most corporate software engineering isn't heavily concurrent. I think a stronger argument would be to advocate for a more functional language on the same runtime, like Scala or F#.
Re: OCaml: a Rust developer's first impressions
#46Earlier quoted context omitted.
From the presentation introducing Rust to Mozilla: http://venge.net/graydon/talks/intro-talk-2.pdf > I have been writing a compiled, concurrent, safe, systems programming language for the past four and a half years. Safety was always part of it.
But those "Safety" definitions are all not like what Rust folks mean by safety now. He's talking about immutability and bounds checking and avoiding memory corruption but not at all about borrowing. I guess I should have been more specific. If that's what we mean by safe, then OCaml is safe as well. Anyways, I followed it at the time. The borrow checker came later.
Re: OCaml: a Rust developer's first impressions
#47Earlier quoted context omitted.
From the presentation introducing Rust to Mozilla: http://venge.net/graydon/talks/intro-talk-2.pdf > I have been writing a compiled, concurrent, safe, systems programming language for the past four and a half years. Safety was always part of it.
But those "Safety" definitions are all not like what Rust folks mean by safety now. He's talking about immutability and bounds checking and avoiding memory corruption but not at all about borrowing. I guess I should have been more specific. If that's what we mean by safe, then OCaml is safe as well. Anyways, I followed it at the time. The borrow checker came later.
Re: OCaml: a Rust developer's first impressions
#48Yeah my semi-hot take is that type annotations in functions is a feature not a bug. It forces legible interfaces (with the exception of nasty generics I suppose).
But they can just be auto-generated in documentation. It gets pretty annoying to type annotate everything for nothing but warm fuzzies when the compiler can figure it all out for you. Also, any decent IDE will show the types any way. The complaint about the types is just strange and shows a failure in getting Rust out of their head. Once you get used to F# and OCaml, then going back to a language that forces type ann…
Re: OCaml: a Rust developer's first impressions
#49Earlier quoted context omitted.
True. In this case the author is speaking specifically about OCaml, which is quite comfortable to write imperatively. I think the thing that tickles most people about Rust is the thoroughness of the type inference and type checking, which one generally gets from any ML.
Yeah but traditional ML languages are ass slow. If I want to write applications that are that slow, why not use something that targets the browser or something like Ruby or Python that has a much deeper ecosystem to leverage? Unless you’re just playing around with building a language and trying out different ideas or you think it’s better at some other axis (eg lower defect rate). But I’ve generally found that my inc…
If we have three stages: (1) system languages, (2) higher level languages like Dart, Java, C#, (3) very high level languages like Python and Ruby, then the those among the most popular languages in the ML family (OCaml and F#) comfortably occupy the same level as (2).
Maybe that's not what you're after. OCaml's more rare bytecode implementation (instead of native code) is about on par with Python and SML/NJ is pretty slow as well (although faster SML implementations like MLTon exist).
Re: OCaml: a Rust developer's first impressions
#50Earlier quoted context omitted.
But those "Safety" definitions are all not like what Rust folks mean by safety now. He's talking about immutability and bounds checking and avoiding memory corruption but not at all about borrowing. I guess I should have been more specific. If that's what we mean by safe, then OCaml is safe as well. Anyways, I followed it at the time. The borrow checker came later.
I absolutely agree the borrow checker came later. I think of it as that the goals have always been the same, but the enforcement mechanism changed over time, as more and more static ways were found to achieve the goal.