News for hackers. Stuff that matters.
Re:The New OCaml Website by _benj on Friday April 29, 2022 @01:00PM (#31207706)
What is OCaml mostly used for? Like Ada for aerospace or Erlang for concurrency, does OCaml has a niche like that?
Re:The New OCaml Website by sweetsocks21 on Friday April 29, 2022 @03:52PM (#31209887)
It's surprisingly general purpose. I mostly use it for toy side projects. I've used it for basic CRUD apps, like a reddit aggregator. I've written a couple opengl graphics libraries with it. Used it instead of JS for a web implementation of a board game. a toy Datomic clone, and I'm currently working on an alternative unix shell.

It's pretty comfortable for organizing and refactoring because of the nice module and type system. And once you grok Dune (the build system) you can get going pretty quick. Builds are very fast compared to most of the languages I use at work. And if you're not doing anything egregious the optimizing compiler (Flambda) can usually be within ~2x of C for most things. When it's not dropping down to C is very easy because the FFI system is very straight forward, and has built in support in Dune.

It is lacking a bit in libraries and when you need to drop down to imperative features you may find it a bit rough. For example not having a return keyword can make it annoying to port over libraries.

Overall I like it because I think the pros outweigh the cons, but I've also been using it for a decade so I'm probably getting set in my ways now. I'd say it's worth trying at least to understand Sum types (and maybe GADTs), and use a language with first class modules, it can change your approach to problems once you see some extra tools.

Re:The New OCaml Website by hyperhopper on Friday April 29, 2022 @02:22PM (#31208882)
This is totally a biased cop out, but I'd say "most things".

Like, what's java's niche? I'd say it doesn't really have one anymore, it's just a generalist language. Ocaml is also a generalist language, but it has much better language paradigms, is safer, more concise, has more features with less baggage, etc. It's just good all around.

As a functional programming advocate, I'd point to safety, readability, and development velocity as features, but those are all around good and desirable, not really a niche.

I wish more companies were using languages like ocaml/f#/clojure vs c++/python/java when there is no specific reason to use the former.

Re:The New OCaml Website by progre on Friday April 29, 2022 @03:19PM (#31209551)
Maybe it's more usefull to talk about a 'slant'? Like, you can totaly do desktop apps with custom GUI components in Java but those tends to be written in C++ for some reason.

Like java, python, c# 'slants' towards web services and maaybe CRUD apps, C++ 'slants' towards games and graphicly complex apps.

Re:The New OCaml Website by nicoburns on Friday April 29, 2022 @04:45PM (#31210378)
I have no personal experience, but I've heard OCaml is particularly excellent for writing compilers.
Re:The New OCaml Website by afandian on Friday April 29, 2022 @03:06PM (#31209400)
Which side would you put Kotlin in? Feels equidistant between Clojure and Java.
Re:The New OCaml Website by anuragsoni on Friday April 29, 2022 @01:28PM (#31208163)
I've used OCaml at day-jobs for the past couple of years. It has an excellent concurrency story, and I've used OCaml for lots of "boring" work (web services, database drivers, data processing, etc).
Re:The New OCaml Website by giraffe_lady on Friday April 29, 2022 @01:56PM (#31208591)
I really think it's such a good fit for most of the daily non-web work I've had to do. It lets you keep the core logic clean & fun and then you can just shrug and let rip with the mutations or whatever when that makes the most sense.

I'm well out of my FP fanboy phase now but ocaml feels great for my favorite parts of that without being judgmental when I'm not in the mood.

Re:The New OCaml Website by anuragsoni on Friday April 29, 2022 @02:12PM (#31208755)
> It lets you keep the core logic clean & fun and then you can just shrug and let rip with the mutations or whatever when that makes the most sense.

Very true! I've used mutations and imperative OCaml quite a few times. Sometimes it was for performance reasons (I've been working on a web server library), and other times when loops either made the implementation a little easier to read, and/or helped avoid some allocations. I am glad that the language is pragmatic enough that I can still use mutation or imperative code where it makes sense, while still being able to present a nice clean api on top.

Re:The New OCaml Website by giraffe_lady on Friday April 29, 2022 @02:08PM (#31208714)
Wait how did you go about finding ocaml day jobs? I pretty much never even tried it seems so niche, and jane street doesn't appeal to me at all.

I sneak it in at my jobs when I can justify it but it seems like there are very very few jobs that use it primarily.

Re:The New OCaml Website by anuragsoni on Friday April 29, 2022 @02:18PM (#31208839)
The first time was hearing about a startup that used OCaml on one of the monthly hackernews Who is hiring thread. The current day job was also somewhat similar in that I had read about a startup's job listing on the OCaml forum [1], checked with them again a while later (the startup was acquired by another company), and found an open role on the team that continued to use OCaml after the acquisition.

> it but it seems like there are very very few jobs that use it primarily.

I completely agree. I never tried looking for an OCaml job mostly because there weren't enough options at-least in the US (I'm based in USA), and I am picky about who I work for and wasn't interested in exploring job opportunities at companies working on cryptocurrencies. I just got lucky that I stumbled upon two different companies that used OCaml. The first time around I applied for the job because of OCaml, the second time around it was because I liked the company and OCaml was an added bonus on top.

[1] https://discuss.ocaml.org/

Re:The New OCaml Website by giraffe_lady on Friday April 29, 2022 @02:23PM (#31208902)
Ugh yeah that pretty much confirms what I suspected. It's a few huge players using it for small internal projects, jane street, and a bunch of crypto shit I'm not willing to touch.

The language I work in is not even one of my top priorities when looking for work, but still it would be cool. I'm lucky enough to have enough freedom to work in it from time to time, which is good enough for me.

Thanks for the response!

Re:The New OCaml Website by anuragsoni on Friday April 29, 2022 @02:39PM (#31209079)
> The language I work in is not even one of my top priorities when looking for work, but still it would be cool.

Same! I've made the mistake of overlooking certain things just because I wanted to get some real world OCaml experience in the past, and I will not make the same mistake again.

At my current job I mostly use OCaml and Python, with some Typescript for whenever I need to touch a frontend application. As much as I like using OCaml, I'm more thrilled about working on a team where I enjoy working with everyone, and having a work environment that provides flexibility about picking the best tool for a job. Most of my OCaml hacking still takes place on my free time, and on my personal open-source explorations :-)

> Thanks for the response!

You are welcome! Sorry if my responses weren't too useful with respect to using OCaml at work.

Re:The New OCaml Website by zumu on Friday April 29, 2022 @07:18PM (#31211720)
What companies if you don't mind sharing?
Re:The New OCaml Website by whimsicalism on Friday April 29, 2022 @02:13PM (#31208771)
I think FB uses OCaml at least to some extent.
Re:The New OCaml Website by giraffe_lady on Friday April 29, 2022 @02:21PM (#31208867)
Yeah I think that's a good example of what I mean though. That'll be a couple tiny teams within a huge org, with a lot of people willing/desiring to transfer internally onto it. Those rarely if ever get filled from outside the org, and when they do they're looking for experts not competent part-time users.
Re:The New OCaml Website by melissalobos on Friday April 29, 2022 @01:03PM (#31207776)
People will mention Jane Street for financial stuff, but mostly academia and compilers.
Re:The New OCaml Website by curiousgal on Friday April 29, 2022 @02:05PM (#31208681)
There's also LexiFi for finance.
Re:The New OCaml Website by fancyfredbot on Friday April 29, 2022 @03:59PM (#31209966)
Does LexiFi use vanilla OCaml now? I remember that in the past they had created their own custom dialect.
Re:The New OCaml Website by bhawks on Friday April 29, 2022 @01:51PM (#31208529)
Tezos's reference node Octez is written in OCaml and one of the main smart contract languages Ligo really shows it's OCaml roots.

https://tezos.gitlab.io/

https://ligolang.org/

It's a nice change of pace from the Ethereum ecosystem.

Re:The New OCaml Website by jamal-kumar on Friday April 29, 2022 @03:02PM (#31209336)
Yeah especially considering the safety guarantees that ocaml offers over say solidity. If tezos ever went above 10$ maybe I'd be able to convince people who are going all in on ethereum to start projects with it.
Re:The New OCaml Website by UncleOxidant on Friday April 29, 2022 @02:13PM (#31208770)
In addition to what others have mentioned, it's a great language for writing compilers and interpreters.
Re:The New OCaml Website by junon on Friday April 29, 2022 @03:04PM (#31209362)
I've seen it in things where performance isn't super important (OCaml is slow as per my experience). Many, many provers/theorum solvers use OCaml because it reduces the bugs in the provers themselves.
Re:The New OCaml Website by agravier on Saturday April 30, 2022 @05:36AM (#31214619)
OCaml is not slow in my experience, but we should probably look at what big teams using OCaml in a performance sensitive setting have to say. https://www.janestreet.com/tech-talks/safe-at-any-speed/
Re:The New OCaml Website by WastingMyTime89 on Friday April 29, 2022 @06:15PM (#31211204)
It was written in tandem with a prover and is generally very nice to use to develop compilers and analysers. The biggest company using it does algorithmic trading with it.
Re:The New OCaml Website by chazeon on Friday April 29, 2022 @03:36PM (#31209725)
I know Jane Street use the hell out of OCaml, the whole company is almost built on top of it.
Re:The New OCaml Website by xvilka on Friday April 29, 2022 @01:56PM (#31208585)
Program analysis and formal verification.