News for hackers. Stuff that matters.
Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by ocamlskeptic on Sunday August 02, 2020 @01:55PM (#24030199)
Curious question: If you are picking OCaml over Rust in 2020 for a new project, what is your reason for doing so (other than being already familiar with OCaml through college courses, or wanting to try out something new for fun) ?

The only reason I could think of was being able to compile to JS, but other than that Rust seems to be a superior choice for all the use cases I could have used practically used OCaml for.

Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by smabie on Sunday August 02, 2020 @02:20PM (#24030376)
I've never really seen them as comparable. But I would choose Ocaml over Rust because OCaml is easier, less complex, and more expressive. Also, Rust doesn't support functional programming. OCaml's performance is really quite good and I've never had problems with the GC.

Unless the project absolutely couldn't tolerate GC, why would I choose a low level language like Rust over a high level language like Ocaml?

Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by Ar-Curunir on Sunday August 02, 2020 @08:23PM (#24032947)
Rust offers a better alternative to functional programming: you can mix and match imperative and functional programming without the pitfalls of arbitrary mutable state (which is where most attempts to mix and match run into problems)
Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by scns on Monday August 03, 2020 @06:23AM (#24036030)
OCaml can do the same
Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by ddek on Sunday August 02, 2020 @02:26PM (#24030435)
They’re quite different languages in almost every way.

Rust is a low level systems language, where you care about memory. You may not be malloc’ing, but you’re borrowing.

Conversely OCaml is an interpreted functional language. It has a much richer and more concise syntax than rust.

You can’t define operators in rust. That means no ‘|>’, no parser combinators. I doubt I’ll ever write a parser in a non-ML language, after my experiences with FParsec.

Rust can’t do partial application properly. I can’t compose functions in rust.

Don’t get me wrong though - Rust is a fantastic language and miles ahead of similar languages in terms of functional features. The only popular C-like language that’s catching up is C#, but discriminated unions aren’t due until next autumn.

Rust is better for manipulating a computer, OCaml is better for math-ey things such as parsers.

You should try OCaml, even if you don’t use it you’ll learn about programming from it.

Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by jon_smark on Sunday August 02, 2020 @03:14PM (#24030851)
> Conversely OCaml is an interpreted functional language.

Correction: OCaml is not an interpreted language. OCaml programmes are compiled down to native code (or bytecode, or Javascript).

Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by ddek on Monday August 03, 2020 @09:32AM (#24037527)
Ahh, I didn’t know that. I just assumed that (smooth) REPL == interpreter. Thanks :)
Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by TheAsprngHacker on Sunday August 02, 2020 @03:49PM (#24031128)
OCaml supports functional programming more idiomatically: for example, it has implicit currying, and it has a single function type instead of several function traits. OCaml is garbage collected, if you don't want to think about ownership. OCaml has the ML module system, which has tradeoffs when compared with typeclasses or traits.
Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by vbrandl on Sunday August 02, 2020 @01:59PM (#24030226)
There is some cool stuff for OCaml, that is not (yet) possible in Rust, e.g. building a unikernel using MirageOS (https://mirage.io/)
Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by sidkshatriya on Sunday August 02, 2020 @04:45PM (#24031572)
It’s very much possible to build a unikernel in rust. Google ‘rust unikernel’ and you’ll get results.

In fact I would argue that rust is much more suited to write low level things like operating systems and unikernels than ocaml. Having said that mirage is very cool. It is a unikernel and it has garbage collection. So it’s easy to write robust and secure services! Yeah anything written in rust will probably be faster but then unless you’re a mega company and have mega size deployments this should not really matter to you. Mirage should serve your needs well if you need unikernels

Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by frou_dh on Sunday August 02, 2020 @02:48PM (#24030634)
The community has the vibe of sedate unix greybeards, rather than hypebeasts.
Re:OCaml for the Skeptical: OCaml in a Nutshell (2006) by dwdz on Sunday August 02, 2020 @02:00PM (#24030234)
1. No borrow checker

2. Compilation times