4 ms·
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 th
by andrewstuart 13y ago
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?
- avsm 13y agoThe overview of Real World OCaml might help answer that: https://realworldocaml.org/v1/en/html/prologue.html#why-ocaml 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."
- andrewstuart 13y agoThe 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.
- zem 13y agoapart 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.
- emmelaich 13y agoHave 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/ http://roscidus.com/blog/blog/archives/ It has been previously discussed on HN and Reddit.
- jgg 13y agoIt'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
- yminsky 13y agoI 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.
- jgg 13y agoYep, that's what I was trying to convey. Thanks for your work.
- amirmc 13y ago> "... 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 http://www.cl.cam.ac.uk/projects/ocamllabs/news/#Dec%202013
- jgg 13y ago
- mjambon 13y agoWe 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++.
- lambda_foo 13y agoIt'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.
- zerr 13y agoAs 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.
- zerr 13y agoI suspect the main reason why Jane Street uses OCaml is Yaron Minsky.
- pjmlp 13y agoLanguages 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.
- andrewflnr 13y agoAlgebraic 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.