Live data from Hacker News

OCaml as my primary language

xvw.lol

261–270 of 296 posts

Re: OCaml as my primary language

#261
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…

Ada has been held back primary by an image problem that traces back to the high cost and poor performance of a lot of early Ada 83 compilers. Ada adoption has never really recovered from that despite its many technical advantages, and despite the low cost and good performance of several current compilers.

The GNAT Ada compiler, always open source and quite good, has been freely available since the 1990's. It has been part of GCC since about 2003.

There are plenty of open source Ada projects on GitHub and other places although not nearly as many as some other languages.

The Ada ecosystem is mature and complete, particularly the GNAT related tools supported by directly or indirectly AdaCore (https://github.com/AdaCore and https://alire.ada.dev/).

The language evolution has been stable and is still on-going. I have worked primarily with Ada for 30 years. I still work on new Ada projects on a mid-sized team. Most of us just don't participate in forums like this.

Re: OCaml as my primary language

#262
post #158

Earlier quoted context omitted.

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…

Ada has been held back primary by an image problem that traces back to the high cost and poor performance of a lot of early Ada 83 compilers. Ada adoption has never really recovered from that despite its many technical advantages, and despite the low cost and good performance of several current compilers. The GNAT Ada compiler, always open source and quite good, has been freely available since the 1990's. It has been…

For people who were actually interested in using Ada, the early poor tooling was the main impediment. However, I think the bigger issue is that it was moving directly against the cultural headwinds at the time.

The immediate response I heard anytime Ada was mentioned was that it was a designed-by-committee language[1] that couldn't even be fully implemented due to a theoretically impossible specification[2]. It was made by a bunch of bureaucratic stiffs and was all about constraining the developer with stupid rules and bogging them down with verbosity. It was contrary to the freewheeling nature of the PC developer culture that sprung up in the 70's and continued through the 80's, and then evolved into the dot-com developers of the 90's and 00's.

It took decades of wandering through the deserts of "Real Developers don't write buffer overflows" on one end, and "Performance doesn't matter, and a sufficiently smart compiler will provide it anyway" on the other to get to the point where mainstream developers wanted a language that combined the safety of high-level languages with the control of low-level languages.

[1] This is false, it was selected in a contest with each entry developed independently.

[2] True but overrated

Re: OCaml as my primary language

#263

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 around about 2010 with multicore and a few other annoyances[1] OCaml had its act together. It was significantly nicer than Python when I used it professionally in 2010. Just look at what JaneStreet achieved with it. The main impediment to OCaml was always that it was not American nor mainly developed from the US. People like to believe there is some technical merit to langua…

Hear, hear. This theory also explains why other languages such as Scala were never really mainstream despite allowing Java- and Kotlin- style programming and having a much broader follower base in Europe. Lack of outreach, concerted marketing, and advocacy from American companies that have always dominated the narrative.

Re: OCaml as my primary language

#264
post #15

Earlier quoted context omitted.

My completely non-objective experiment of writing a simple CLI game in C++ and Haskell shows that the lines of code were indeed less in case of Haskell.. but the number of words were roughly the same, meaning the Haskell code just "wider" instead of "higher". And then I didn't even make this "experiment" with Java or another managed, more imperative language which could have shed some weight due to not caring about m…

My experience is that width is faster than height to type- mostly from lack of time spent indenting. This is _completely_ fixed by using a decent auto-formatter, but at least for me the bias towards width lingers on, because it took me years to notice that I needed an auto-formatter

May be faster to type - but does it matter? I have never ever been even close to being bottlenecked from typing speed. The only difference is that I "buffer" between lines or between different segments within a single line (but possibly both).

Re: OCaml as my primary language

#265

OCaml is probably my favourite language. The most involved project I did with it was a CRUD app for organising Writer's Festivals. The app was 100% OCaml (ReasonML so I could get JSX) + Dream + HTMX + DataTables. I used modules to get reusable front end templates. I loved being able to make a change to one of my data models and have the compiler tell me almost instantly where the change broke the front end. The main…

What is the idiomatic way to handle the results from the database in a strongly typed functional language?

Re: OCaml as my primary language

#266

> At present, I don’t know anyone who has seriously used languages like OCaml or Haskell and was happy to return to languages with less sophisticated type systems (though an interesting project can sometimes justify such a technological regression). Recovered typeaholic here. I still occasionally use OCaml and I primarily wrote F# and Haskell for years. I've been quite deep down the typing rabbit hole, and I used to…

I've had a similar experience. After many years of strict typing, including two years of writing full-time Rust, I've come completely around on dynamic typing. Attempting to encode a system in types creates a host of consequent issues, that in turn need their own complex solutions. At some point you lose sight of the business logic and are sort of just building artifice for the sake of feeding earlier artifice.

(Sort of like how OOP was introduced to solve the problem of structuring code, but then we needed a profusion of ever-more-complex design patterns to fix the issues only ever introduced by OOP in the first place.)

I'm coming to be a big fan of functional dynamic languages. You can just let go of entire categories of CS complexity. No need for generics without types, no need for locks without mutability, etc. Actual fearless concurrency.

This in turn has freed me to write actual business logic, without the constant need to stop and make sacrifices to the CS complexity god.

Re: OCaml as my primary language

#267
post #92

ocaml is one of my favourite languages too, but I've found myself being drawn towards rust for my latest project due to its major superpower - you can write a rust library that looks like a c library from the outside, and can be called from other languages via their existing c ffi mechanisms. I feel like by writing the library in ocaml I would have a better experience developing it, but be giving up on that free inte…

You can call OCaml code like a C library: https://ocaml.org/manual/5.3/intfc.html#s%3Ac-callback

Re: OCaml as my primary language

#268
post #71

I'm sure there's merit to the language, but the syntax seems absolutely alien to me. Some attempt to look like verbose imperative code, a bunch of semicolons, and for some strange reason, hate of parenthesis. Real life sample: let print_expr exp = (* Local function definitions *) let open_paren prec op_prec = if prec > op_prec then print_string "(" in let close_paren prec op_prec = if prec > op_prec then print_string…

> the syntax seems absolutely alien to me

Syntax is one of those funny things. The more you look at it, the more sense it makes. The more you learn about it and the reasons behind why it's designed that way–the more sense it makes.

> Also, you need to end the declaration with `in`?

Not all of them, just the ones that need to refer to previously defined bindings. So eg you could do:

    let print_expr exp =
      (* Local function definitions *)
      let open_paren prec op_prec = if prec > op_prec then print_string "("
      and close_paren prec op_prec = if prec > op_prec then print_string ")"
      in
      let rec print prec = function (* prec is the current precedence *)
        | Const c -> print_float c
        | Var v -> print_string v
        | Sum (f, g) ->
          open_paren prec 0;
          print 0 f; print_string " + "; print 0 g;
          close_paren prec 0
        | Diff (f, g) ->
          open_paren prec 0;
          print 0 f; print_string " - "; print 1 g;
          close_paren prec 0
        | Prod (f, g) ->
          open_paren prec 2;
          print 2 f; print_string " * "; print 2 g;
          close_paren prec 2
        | Quot (f, g) ->
          open_paren prec 2;
          print 2 f; print_string " / "; print 3 g;
          close_paren prec 2
      in
      print 0 exp

Re: OCaml as my primary language

#269

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 around about 2010 with multicore and a few other annoyances[1] OCaml had its act together. It was significantly nicer than Python when I used it professionally in 2010. Just look at what JaneStreet achieved with it. The main impediment to OCaml was always that it was not American nor mainly developed from the US. People like to believe there is some technical merit to langua…

Python, PHP, Ruby: all not American though, right? Do you mean those only got hockey stick growth when they happened to get picked up by the USA ? But then couldn’t the same have happened for ocaml? And if so: why didn’t it, as it supposedly did for the others

Not to mention Linux I guess

Post reply on HN