Live data from Hacker News

OCaml as my primary language

xvw.lol

131–140 of 296 posts

Re: OCaml as my primary language

#131

Earlier quoted context omitted.

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

Yes. It can also be compiled to native. I just think it was held back too much by the java/jvm backwards compatibility but then again that's probably also the justification for its existence. I definitely find it (and jetpack compose) make developing android apps a much better experience than it used to be. What I like a lot about Kotlin are its well written documentation and the trailing lambdas feature. That is def…

I wouldn't say it's doomed. For projects in large organizations that have a large amount of java already, it provides better ergonomics while allowing interop with the existing company ecosystem.

Re: OCaml as my primary language

#132
post #55

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…

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…

[deleted]

Re: OCaml as my primary language

#133

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.

flix also looks pretty nice

Re: OCaml as my primary language

#134
post #6

I haven't worked in OCaml but I have worked a bit in F# and found it to be a pleasant experience. One thing I am wondering about in the age of LLMs is if we should all take a harder look at functional languages again. My thought is that if FP languages like OCaml / Haskell / etc. let us compress a lot of information into a small amount of text, then that's better for the context window. Possibly we might be able to p…

If LLMs get a little better at writing code, we might want to use really powerful type systems and effect systems to limit what they can do and ensure it is correct.

For instance, dependent types allow us to say something like "this function will return a sorted list", or even "this function will return a valid Sudoku solution", and these things will be checked at compile time--again, at compile time.

Combine this with an effect system and we can suddenly say things like "this function will return a valid Sudoku solution, and it will not access the network or filesystem", and then you let the LLM run wild. You don't even have to review the LLM output, if it produces code that compiles, you know it works, and you know it doesn't access the network or filesystem.

Of course, if LLMs get a lot better, they can probably just do all this in Python just as well, but if they only get a little better, then we might want to build better deterministic systems around the unreliable LLMs to make them reliable.

Re: OCaml as my primary language

#135

Earlier quoted context omitted.

> With your shape example, you cannot express in the type system "this function won't return a point". Sure you can, that's just subtyping. If it returns a value that's not a point, the domain has changed from the shape type and you should probably indicate that. structure Shape = struct datatype shape = Circle of real | Rectangle of real * real | Point end structure Bound = struct datatype shape = Circle of real | R…

You wrote a lot of words to say very little. Anyway, to translate your example: sealed interface Shape permits Point, Bound {} final class Point implements Shape {} sealed interface Bound extends Shape permits Circle, Rectangle {} record Circle(double radius) implements Bound {} record Rectangle(double width, double height) implements Bound {} A `Rectangle` is both a `Bound` (weird name choice but whatever), and a `S…

> You wrote a lot of words to say very little.

Substantiate this.

> weird name choice but whatever

I don't think this kind of snarky potshot is in line with the commentary guidelines. Perhaps you could benefit from a refresher?

https://news.ycombinator.com/newsguidelines.html#comments

> Thanks to subtyping, no contortion needed

I see the same degree of contortion, actually. Far more noisy, at that.

> No need to use 7 more lines to create a separate, unrelated type.

You're still creating a type, because you understand that a sum-type with a different set of cases is fundamentally a different type. Just like a class with a different set of inheritance is a different type. And while it's very cute to compress it all into a single line, it's really not compelling in the context of readability and "write once, use many". Which is the point you were making, although it was on an entirely different part of the grammar.

> Great analogy, except for the fact that someone from the Java team explicitly said they're drawing inspirations from ML.

ML didn't invent ADTs, and I think you know it's more than disingenuous to imply the quotation means that the type-system in Java which hasn't undergone any fundamental changes in the history of the language (nor could it without drastically changing the grammar of the language and breaking the close relationship to the JVM) was lifted from ML.

Re: OCaml as my primary language

#136

Earlier quoted context omitted.

You wrote a lot of words to say very little. Anyway, to translate your example: sealed interface Shape permits Point, Bound {} final class Point implements Shape {} sealed interface Bound extends Shape permits Circle, Rectangle {} record Circle(double radius) implements Bound {} record Rectangle(double width, double height) implements Bound {} A `Rectangle` is both a `Bound` (weird name choice but whatever), and a `S…

> You wrote a lot of words to say very little. Substantiate this. > weird name choice but whatever I don't think this kind of snarky potshot is in line with the commentary guidelines. Perhaps you could benefit from a refresher? https://news.ycombinator.com/newsguidelines.html#comments > Thanks to subtyping, no contortion needed I see the same degree of contortion, actually. Far more noisy, at that. > No need to use 7…

> Substantiate this.

You never gave an example how sum types in Java/Kotlin cannot do what "real" sum types can.

>> weird name choice but whatever

> snarky potshot

Sorry that you read snark. What I meant was "I find naming this 'Bound' weird. But since I am translating your example, I'll reuse it".

> You're still creating an unrelated type

How can a type participating in the inheritance hierarchy be "unrelated"?

> I see the same degree of contortion, actually. Far more noisy, at that.

At this point I can only hope you're a Haskeller and do not represent an average OCaml programmer.

Re: OCaml as my primary language

#137

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…

"I feel if OCaml had got its act together ..."

The great thing is we have choice. We have a huge number of ways to express ideas and ... do them!

I might draw a parallel with the number of spoken languages extent in the UK (only ~65M people). You are probably familiar with English. There are rather a lot more languages here. Irish, Scottish, Welsh - these are the thriving Brythonic languages (and they probably have some sub-types). Cornish formally died out in the sixties (the last two sisters that spoke it natively, passed away) but it has been revived by some locals and given that living people who could communicate with relos with first hand experience, I think we can count that a language that is largely saved. Cumbric ... counting still used by shepherds - something like: yan, tan, tithera toe.

I am looking at OCAML because I'm the next generation to worry about genealogy in my family and my uncle has picked Geneweb to store the data, taking over from TMG - a Windows app. His database contains roughly 140,000 individuals. Geneweb is programmed in OCAML.

If you think that programming languages are complicated ... have a go at genealogy. You will soon discover something called GEDCOM and then you will weep!

Re: OCaml as my primary language

#139

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…

[deleted]

Re: OCaml as my primary language

#140
As someone who uses OCaml for hobby projects, I appreciate how little the language gets in your way when you want to just “get shit done”, despite the language’s origins in academia and industrial uses.

The type system usually means that I might take longer to get my code to compile, but that I won’t spend much (if any) time debugging it once I’m done.

I’m in the middle of pulling together bits of a third party library and refactoring them over several days work, and I’m pretty confident that most of the issues I’ll face when done will be relatively obvious runtime ones.

Post reply on HN