News for hackers. Stuff that matters.
Re:OCaml 4.02: Everything else by andrewstuart on Sunday May 18, 2014 @09:55PM (#7765272)
I'd like to like ocaml but its not clear to me why I would choose it above anything else to write an application. I have the sense vaguely it might be a good thing. A little reading and examination of some example source hasn't thrown much light.

What's it good for? Why should I use it? Why is it a better choice than language X or Y?

Re:OCaml 4.02: Everything else by avsm on Sunday May 18, 2014 @10:03PM (#7765298)
The overview of Real World OCaml might help answer that:

https://realworldocaml.org/v1/en/html/prologue.html#why-ocam...

"Among this worthy set of languages, OCaml stands apart because it manages to provide a great deal of power while remaining highly pragmatic. The compiler has a straightforward compilation strategy that produces performant code without requiring heavy optimization and without the complexities of dynamic just-in-time (JIT) compilation. This, along with OCaml's strict evaluation model, makes runtime behavior easy to predict. The garbage collector is incremental, letting you avoid large garbage collection (GC)-related pauses, and precise, meaning it will collect all unreferenced data (unlike many reference-counting collectors), and the runtime is simple and highly portable."

Re:OCaml 4.02: Everything else by andrewstuart on Sunday May 18, 2014 @10:07PM (#7765311)
The brief look I had at some of the source examples seemed a little arcane. To be fair that's probably same as any unfamiliar language I suppose.
Re:OCaml 4.02: Everything else by jgg on Monday May 19, 2014 @01:25AM (#7765839)
It's really fast, has minimal boiler plate and supports functional programming without any of the "orthodoxy" of Haskell. That is, you can write a recursive function but also write a for loop.

Imagine something that can compete with C and C++, but doesn't require all of the low-level reinvention and memory management. It's like a high-level language for smart people that doesn't feel entirely impractical. It has some things that people bitch about (like having to use +. to add two floats and + to add two ints), which don't really bother me that much.

If it were more popular and had better libraries/platform support (unless that's changed drastically in the past year or so), it would be a serious contender for general development. Being completely honest, I think Jane Street is probably the biggest organization pulling OCaml, and from a navel-gazing standpoint you can either view that as good or bad.

Use it because you learned it and thought it didn't suck, I guess?

EDIT: changed some phrasing

Re:OCaml 4.02: Everything else by amirmc on Monday May 19, 2014 @05:36AM (#7766553)
> "... unless that's changed drastically in the past year or so ..."

Actually a lot has happened in the last year or so. If you're not aware of it, you could start by looking over the end-of-year post from OCaml Labs [1]. I'm aware that it's difficult to keep a central overview of all the progress but there is a lot of work being done, in many ways, to improve the ecosystem.

[1] http://www.cl.cam.ac.uk/projects/ocamllabs/news/#Dec%202013

Re:OCaml 4.02: Everything else by jgg on Monday May 19, 2014 @10:30AM (#7767562)
Whoa, that's cool. I had no idea people were still working on it at that level. The last thing I saw was a version of OPAM that didn't seem to work that well...I'll have to go look around.
Re:OCaml 4.02: Everything else by yminsky on Monday May 19, 2014 @03:04AM (#7766073)
I think we're pretty clearly the most intense user (most code, most developers using it), but not technically the biggest company using it. Bloomberg and Facebook are examples of bigger companies using it in serious ways.
Re:OCaml 4.02: Everything else by jgg on Monday May 19, 2014 @10:30AM (#7767560)
Yep, that's what I was trying to convey.

Thanks for your work.

Re:OCaml 4.02: Everything else by mjambon on Monday May 19, 2014 @01:56AM (#7765906)
We use it in our backend to tie everything together. It serves an http/json api to our client apps (Web/JavaScript, Android/Java; iOS/Objective-C coming soon). We're handling the same data types in JavaScript, Java and OCaml.

What is clear is that we spend a lot of time fixing type errors in JavaScript due to the lack of basic type checking. Java does not have this problem and for Android programming it is a breeze since really the mobile app is just a GUI which doesn't have to do anything clever with the data.

Now the backend is in charge of serving correct data to the client apps. I could explain that OCaml is fast and lets us implement any CPU-intensive algorithm without having to switch to C, but the truth is most of our code is not much about algorithms but very much about data modeling and data management. Anything we store needs to be stored correctly if we don't want to accumulate broken data resulting in bugs that are costly to fix. Untyped languages such as JavaScript let you store anything without checking their conformance to a type definition, this is awful. Java for example would be perfectly acceptable if it wasn't so verbose. We want to write JSON-like records and arrays like in JSON or JavaScript. OCaml provides this, Java doesn't.

Now, we don't want half of our code to consist in annotating each variable with a type. The compiler should infer that 123 is an int. How hard is that? You tell me. JavaScript doesn't check anything. Java or C++ force you to declare that 123 is an int. How clever is that? I don't know. OCaml, Haskell just figure out that 123 is an int. That's called type inference. That makes code readable like JavaScript or Python, with the safety of Java and the performance of C++.

Re:OCaml 4.02: Everything else by lambda_foo on Monday May 19, 2014 @02:07AM (#7765931)
It's not clear to me why you'd choose OCaml over Haskell. I understand that OCaml isn't lazily evaluated like Haskell and has a simpler to understand compiler which gives a better understanding how the code will perform at runtime. But why as someone new why would I choose OCaml over Haskell?

From my perspective it seems like there is more activity and research going on in Haskell.

Re:OCaml 4.02: Everything else by andreypopp on Monday May 19, 2014 @02:56AM (#7766046)
> I understand that OCaml isn't lazily evaluated like Haskell and has a simpler to understand compiler which gives a better understanding how the code will perform at runtime. But why as someone new why would I choose OCaml over Haskell?

Isn't that enough to choose OCaml over Haskell?

Re:OCaml 4.02: Everything else by sanityinc on Monday May 19, 2014 @07:51AM (#7766964)
Why would that be enough on its own? If that alone is sufficient, he should choose C over both OCaml and Haskell.
Re:OCaml 4.02: Everything else by jstoja on Tuesday May 20, 2014 @04:56AM (#7771718)
Haskell comes with a very big community, and a lot of ways to start with the languages. I think about the http://learnyouahaskell.com/ and others.

Real World OCaml is that, without totally being it. The authors wrote it with the idea in mind that only people with a good background about functionnal world can read it.

I'd add that lazyness can be a good thing and that the type-system of Haskell is better than the OCaml one.

Re:OCaml 4.02: Everything else by zerr on Monday May 19, 2014 @02:19AM (#7765965)
As I'm aware, finance industry now prefers F#. Regarding Haskell - one of its biggest user (Standard Chartered I think) uses in-house dialect of it, miu, which is strict. Basically, it just syntactically resembles Haskell... i.e. you can't just use some random Haskell library with it.
Re:OCaml 4.02: Everything else by thinkpad20 on Monday May 19, 2014 @11:49AM (#7768015)
Where did you hear about this? Googling around for "miu", "miu haskell", "miu haskell standard chartered", "miu haskell standard chartered strict", etc hasn't given me anything.
Re:OCaml 4.02: Everything else by lpw25 on Monday May 19, 2014 @01:19PM (#7768576)
It's "mu" not "miu". I think they gave a talk on it at CUFP one year.
Re:OCaml 4.02: Everything else by mjambon on Monday May 19, 2014 @02:36AM (#7766003)
Pure Haskell is slow, that is why.
Re:OCaml 4.02: Everything else by dons on Monday May 19, 2014 @03:28AM (#7766154)
[citation needed]
Re:OCaml 4.02: Everything else by steshaw on Monday May 19, 2014 @02:16AM (#7765960)
Are you just using OCaml as an altjs then? And/or on the backend?

Any reason to try OCaml for Android development? Looked at Ocaml-Java?

Re:OCaml 4.02: Everything else by mjambon on Monday May 19, 2014 @12:55PM (#7768435)
For our web app we've been sticking with JavaScript so far. It's a conservative choice with a lot of problems due primarily to the absence of typing. The absence of typechecking is a problem for our moderately complex app (> 10K lines).

Alternatives that we've been considering include js_of_ocaml and TypeScript.

Re:OCaml 4.02: Everything else by mjambon on Monday May 19, 2014 @12:51PM (#7768417)
For the kind of Android app we're developing we wanted a native look-and-feel. That means using the Android SDK, and I don't know how going through OCaml would make that any easier.
Re:OCaml 4.02: Everything else by emmelaich on Monday May 19, 2014 @12:11AM (#7765666)
Have a look at Thomas Leonards blog, where he chooses Ocaml to replace Python over many others for his 0install project.

http://roscidus.com/blog/blog/archives/

It has been previously discussed on HN and Reddit.

Re:OCaml 4.02: Everything else by pjmlp on Monday May 19, 2014 @02:44AM (#7766014)
Languages in the ML family are getting into the industry via data modeling.

From what I can understand in the SkillsThatMatter sessions, the finance and insurance sector in some European countries are big users.

The applications aren't full ML stacks, just the algorithms are done with them, with the UIs using a more traditional one.

Might not seem much, but it already a foot in the door.

Re:OCaml 4.02: Everything else by zem on Sunday May 18, 2014 @10:58PM (#7765482)
apart from the more objective criteria, it's simply a very pleasant language to use. i usually evaluate new application programming languages by what they offer me that ocaml does not.
Re:OCaml 4.02: Everything else by andrewflnr on Monday May 19, 2014 @03:38PM (#7769327)
Algebraic data types and pattern matching are bliss. It's almost a cliche, but you don't know what you're missing without them and once you know them you'll wish every other language had them.
Re:OCaml 4.02: Everything else by zerr on Monday May 19, 2014 @02:13AM (#7765954)
I suspect the main reason why Jane Street uses OCaml is Yaron Minsky.