Live data from Hacker News

Why I love OCaml (2023)

mccd.space

281–290 of 313 posts

Re: Why I love OCaml (2023)

#281
post #96

> why isn’t OCaml more popular I've used OCaml a bit and found various issues with it: * Terrible Windows support. With OCaml 5 it's upgraded to "pretty bad". * The syntax is hard to parse for humans. Often it turns into a word soup, without any helpful punctuation to tell you what things are. It's like reading a book with no paragraphs, capitalisation or punctuation. * The syntax isn't recoverable. Sometimes you can…

I just don't get these comments about syntax...

Just taking the first example I can find of some auto-formatted OCaml code

https://github.com/janestreet/core/blob/master/command/src/c...

It doesn't look more a soup of words than any other language. Not sure what's hard to parse for humans.

Re: Why I love OCaml (2023)

#282

Why isn't it more popular? I think Richard Feldman [0] proposed some of the most reasonable theories as to why functional programming isn't the norm. Your language needs to be the platform-exclusive language for a widely used platform, have a killer application for a highly desired application domain, or be backed by a monster war-chest of marketing money to sway opinions. Since Feldman's talk, Python has grown much…

I look at how people write TypeScript these days, and think about how the world might have been different if, 10-15 years ago, these functional languages had been a bit closer to the imperative world. OCaml allows mutation and side effects and could even feel a bit imperative if it weren't for the "let ... in" syntax. Let's face it, syntax matters. We saw that with Elixir becoming much more popular than Erlang ever d…

Could you explain how Reason syntax isn't "really willing to modernize in ways that would attract your average programmer"? I'm trying to understand what do you even mean.

Re: Why I love OCaml (2023)

#283

Earlier quoted context omitted.

I would suggest that people interested in using OCaml on Windows (or indeed, OCaml at all) try F# instead. It is still an ML-family language. Incidentally, by targeting the CLR, F# is considerably more deployable (both to users and to developers) than OCaml is. Plus, any old NuGet library written in C# or VB.NET can be used almost trivially in F#. This also solves the problem OP listed about a tiny ecosystem, because…

To decide on a language for a math research project, I implemented a toy problem in many languages: What is the distribution of cycle counts for signed permutations on n letters? Use all cores in parallel. C++ 100 19.57s Rust 96 20.40s F# 95 20.52s Nim 75 26.04s Julia 64 30.40s Ocaml 48 41.07s Haskell 41 47.64s Chez 39 49.53s Swift 33 58.46s Lean 7 278.88s Tarjan, n = 10 Nyx - Apple M4 Max - 12 performance and 4 effi…

F# is a nice language, but it depends on .NET, so a direct comparison to OCaml is not possible. The .NET runtime dependency often makes things unnecessarily complex and fragile. There must be a reason why Golang (no VM runtime) is successful despite entering the market very late after Java and C# had already established clear dominance.

Re: Why I love OCaml (2023)

#284

Earlier quoted context omitted.

+10 for bad windows support, i think this is a key and weirdly underestimated reason just to give an idea how bad, until recently, you could not just go to ocaml.org and download ocaml for windows, you had to either download one for mingw or wsl so for many it was just not installable, i.e. for many we didnt have ocaml for windows, until very very recently

Opam on Windows is a masterpiece of engineering

can you elaborate, or maybe share a blog post about it

Re: Why I love OCaml (2023)

#285

Earlier quoted context omitted.

To decide on a language for a math research project, I implemented a toy problem in many languages: What is the distribution of cycle counts for signed permutations on n letters? Use all cores in parallel. C++ 100 19.57s Rust 96 20.40s F# 95 20.52s Nim 75 26.04s Julia 64 30.40s Ocaml 48 41.07s Haskell 41 47.64s Chez 39 49.53s Swift 33 58.46s Lean 7 278.88s Tarjan, n = 10 Nyx - Apple M4 Max - 12 performance and 4 effi…

F# is a nice language, but it depends on .NET, so a direct comparison to OCaml is not possible. The .NET runtime dependency often makes things unnecessarily complex and fragile. There must be a reason why Golang (no VM runtime) is successful despite entering the market very late after Java and C# had already established clear dominance.

[dead]

Re: Why I love OCaml (2023)

#286

Earlier quoted context omitted.

I look at how people write TypeScript these days, and think about how the world might have been different if, 10-15 years ago, these functional languages had been a bit closer to the imperative world. OCaml allows mutation and side effects and could even feel a bit imperative if it weren't for the "let ... in" syntax. Let's face it, syntax matters. We saw that with Elixir becoming much more popular than Erlang ever d…

Could you explain how Reason syntax isn't "really willing to modernize in ways that would attract your average programmer"? I'm trying to understand what do you even mean.

[deleted]

Re: Why I love OCaml (2023)

#287
post #286

Earlier quoted context omitted.

Could you explain how Reason syntax isn't "really willing to modernize in ways that would attract your average programmer"? I'm trying to understand what do you even mean.

[deleted]

[deleted]

Re: Why I love OCaml (2023)

#288

Earlier quoted context omitted.

I look at how people write TypeScript these days, and think about how the world might have been different if, 10-15 years ago, these functional languages had been a bit closer to the imperative world. OCaml allows mutation and side effects and could even feel a bit imperative if it weren't for the "let ... in" syntax. Let's face it, syntax matters. We saw that with Elixir becoming much more popular than Erlang ever d…

Could you explain how Reason syntax isn't "really willing to modernize in ways that would attract your average programmer"? I'm trying to understand what do you even mean.

Reason still looks like an ML-style language rather than something from the C family of things (where JavaScript ultimately comes from).

For example, in Reason, a function is:

    let x: (int, int) => int = (a, b) => a + b;
A more JS-like syntax might be:

    fn x(a, b int): int {
      a + b
    }
Or at least:

    let x = fn(a, b int): int {
      a + b
    }

Re: Why I love OCaml (2023)

#289

Earlier quoted context omitted.

Could you explain how Reason syntax isn't "really willing to modernize in ways that would attract your average programmer"? I'm trying to understand what do you even mean.

Reason still looks like an ML-style language rather than something from the C family of things (where JavaScript ultimately comes from). For example, in Reason, a function is: let x: (int, int) => int = (a, b) => a + b; A more JS-like syntax might be: fn x(a, b int): int { a + b } Or at least: let x = fn(a, b int): int { a + b }

But the Reason example you shared is almost valid TypeScript already!

https://www.typescriptlang.org/play/?#code/DYUwLgBAHgXBAUBDO...

I've seen JS using lambdas instead of classic functions like that in the wild. And that Reason can be made more JS-idiomatic without changes to the syntax:

    let x = (a: int, b: int): int => a + b;

Re: Why I love OCaml (2023)

#290
post #91

Why isn't it more popular if it's so good? Because popularity and merit are not the same thing. People confuse them all the time though. Check out the most popular music today. Like the top ten songs currently. Do you think those are really the best songs out there? Popularity is mostly driven by either trends or momentum.

> Why isn't it more popular if it's so good? Because popularity and merit are not the same thing.

Yes! To add to that, the question itself is wrong. We should be asking, how is OCaml able to be so good without being popular? People get the whole thing backward.

The popular languages are typically popular first, then get good later as a result of that popularity. They have to work, they have to be good, they're too big to fail.

This is what happened with Java. It was marketed like crazy at first and only later got refined in terms of tooling and the JVM itself. The R programming language was a mess for data wrangling, but once it was popular, people built things like the tidyverse or the data.table library. The Python ecosystem was disaster with all different testing packages, build tools, and ways to create and manage virtual environments, until the relatively recent arrival of uv, more than three decades after the creation of Python itself. And then there's javascript that's had more money, blood, sweat, and tears poured into it to be improved in one way or another because that's what practically anything running in a browser is using.

Post reply on HN