Live data from Hacker News

OCaml as my primary language

xvw.lol

161–170 of 296 posts

Re: OCaml as my primary language

#162

I tried to like OCaml for a few years. The things that hold me back the most are niggling things that are largely solved in more "modern" langs, the biggest being the inability to "print" arbitrary objects. There are ppx things that can automatically derive "to string" functions, but it's a bit of effort to set up, it's not as nice to use as what's available in Rust, and it can't handle things like Set and Map types…

Go's %v leaves a lot to be desired, even when using %+#v to print even more info. I wish there was a format string to deeply traverse into pointers. Currently I have to import go-spew for that, which is a huge annoyance.

Python does it best from what I've seen so far, with its __repr__ method.

Re: OCaml as my primary language

#163

I saw a talk by someone from Google about their experiences using Rust in the Android team. Two points stuck out: they migrated many projects from Python, so performance can't have been that much of a concern, and in their surveys the features people liked most were basics like pattern matching and ADTs. My conclusion is that for a lot of tasks the benefit from Rust came from ML cicra 1990, not lifetimes etc. I feel…

Yeah I was initially drawn to rust because I loved ocaml but wished it were more practical.

Re: OCaml as my primary language

#164
post #158

Earlier quoted context omitted.

In 2010, Ada 2005 was the most bare-metal-worthy expressive language. Now that would be Ada 2022.

While at it: what was / is holding Ada back? I haven't seen a single open-source project built in Ada, nor did I hear about any closed-source corporate project that uses Ada's superpowers. (Most likely these exist! But I did not see any available, or at least well-publicized.) People agree to go to great lengths to use a tool that has some kind of superpower, despite syntactic weirdness or tooling deficiencies. Peopl…

Take a look here: https://news.ycombinator.com/item?id=7824570

Re: OCaml as my primary language

#165
post #55

Earlier quoted context omitted.

I'd say that Google strives to have a reasonably short list of languages approved for production-touching code. Rust can replace / complement C++, while OCaml cannot (it could replace Go instead... fat chance!). So I suspect that the team picked Rust because it was the only blessed language with ADTs, not because they won't like something with faster compile times. No way OCaml could have stolen the Rust's thunder: w…

Wouldn’t Kotlin be a more reasonable choice in that case? It has ADTs and a lot of the same niceties of Rust.

I think GP means "algebraic data types" not "abstract data types", probably specifically tagged unions. Both Kotlin and Java can (now) do something similar with sealed classes but it's quite less ergonomic.

Re: OCaml as my primary language

#166

Earlier quoted context omitted.

Scala was always going to be hamstrung by the fact that it's a JVM language and yes, the crazy stuff people did with the language didn't help.

I agree w that, but I think Scala has deeper problems. It tries to be a better Java and a better OCaml at the same time. This split personality led to Scala’s many dialects, which made it notorious for being difficult to read and reason about, particularly as a mainstream language contender. Above all, Scala is considered a functional language with imperative OOP qualities. And it more or less fits that description.…

To me Scala is first and foremost a research language. It’s even how it’s developed.

Re: OCaml as my primary language

#167

Earlier quoted context omitted.

This is one of the wilder conspiracy theories to me, and that says a lot in 2025.

The RESF is not a conspiracy theory, its a known thing. Especially on HN: https://news.ycombinator.com/item?id=14178950

What is that link? A thread from 2017? What am I supposed to get from it?

Re: OCaml as my primary language

#168

Earlier quoted context omitted.

It's real, and as someone who loves rust, it's embarrassing, and difficult to avoid. The OSS embedded rust users in particular are nuts.

Really appreciate a fairminded Rust person chiming in. It's a disservice to the language (which is cool!), and it makes the community look bad. Rust might gain some adoption among people who are new to high performance software and see a narrative that its the only game in town, but it turns off a lot of older folks like myself who know it isn't and that community matters. gl to you and people like you trying to get…

Can we be clear here: You are accusing people in this thread of "inorganically" bringing up Rust. The implication being that there is some shadowy group or organization coordinating the bombing of random forum threads to talk about Rust, or what are we saying here?

Rust is an exciting language. It comes up because many people like it.

Re: OCaml as my primary language

#169

I saw a talk by someone from Google about their experiences using Rust in the Android team. Two points stuck out: they migrated many projects from Python, so performance can't have been that much of a concern, and in their surveys the features people liked most were basics like pattern matching and ADTs. My conclusion is that for a lot of tasks the benefit from Rust came from ML cicra 1990, not lifetimes etc. I feel…

doesnt rust still have the advantage of having no gc? I dont like writing rust, but the selling point of being able to write performative code with memory safety guarantees has always stuck with me

OCaml was[0] very popular in the high-frequency trade programming, especially because of its high performance and predictable latency despite having a garbage collector, plus, of course, because of the correctness of the code written in it.

OCaml's GC design is a pretty simple one: two heaps, one for short-lived objects and another one for the long-lived objects, and it is a generational and mostly non-moving design. Another thing that helps tremendously is the fact that OCaml is a functional programming language[1], which means that, since values are never mutated, most GC objects are short or very short-lived and never hit the other heap reserved for the long-lived objects, and the short-lived objects perish often and do so quickly.

So, to recap, OCaml’s GC is tuned for simplicity, predictable short pauses, and easy interoperability, whereas Java’s GC is tuned for maximum throughput and large-scale heap management with sophisticated concurrency and compaction.

[0] Maybe it still is – I am not sure.

[1] It is actually a multiparadigm design, although most code written in OCaml is functional in its style.

Re: OCaml as my primary language

#170

Earlier quoted context omitted.

I would say ReasonML also needed more follow-through. It seems like the OCaml community hasn't really rallied behind it.

Maybe it's good it died? Now we have moonbit lang.

Moonbit the fast, compact and user friendly language for WebAssembly? Or Moonbit the language for industrial usage? Or Moonbit the AI-native general-purpose programming language?

(They are the same language)

Reason at least was an active collaboration between several projects in the OCaml space with some feedback into OCaml proper (even though there was a lot of initial resistance IIRC).

Post reply on HN