96 points · by e_d_g_a_r · 10y ago · 110 comments
The situation improved drastically over the last years with opam which allows easy installation of most packages.
What's still missing, however is
- decent multi core
- resource management for things other than memory. For example, bigarrays don't cause enough gc pressure, and can therefore leak space. Thus people tend to manage that manually (acquire, release) which is even worse than what a C++ dev can use (unique_ptr)
- decent profiling (yes I can leverage strace and callgrind, but they don't understand lwt)
- decent runtime inspection. (what are all theses values in my heap?)
https://github.com/openvstorage/alba https://github.com/openvstorage/arakoon/
But what's interesting is that I was being upvoted until I've rephrased the comment. It used to be "That's an unfortunate comparison you've made". In the same time it sounded more moderate and more personal. I've edited it because moderation came at the cost of authenticity/honesty, and I thought addressing the comment risked automatic rejection of the underlying message on the OC's part. I did think that the actual sentiment could sound worse to others, but it would be hypocritical of me not to have gone with it. The underlying message is precisely "don't conform on account of genuineness".
Hope this cleared something up after all
In particular, while the one used in RWO (Core) seems very nice, it looks like its use of named parameters is via some kind of syntax extension (edit: not the case; see LeonidasXIV's reply). This seems to be a pretty large difference in approach, and while I can appreciate the reasons behind using named parameters in Core, it makes me worried about writing code that might have to interact across different stdlibs.
As such, I've decided to hold off on learning OCaml for now until resolutions to these community issues can be made more clear. But perhaps I just prefer the Python approach, and that may not be the same objective as those in OCaml.
Edit: Actually, the nail in the coffin was probably when I found a web framework that I wanted to use, but then the author explained why he was removing support for both of the async frameworks and going with only one of them (the one that RWO doesn't use). And then the other main web framework I found also used non-RWO async... :(
No worries, OCaml natively supports named (and optional) parameters. What Core does, though, is reshuffle many function signatures to be more useful when using those parameters.
I suppose you're talking about this[0] blog post, his reasons are pretty clear: hardly anybody uses Async apart from Jane Street, whereas Lwt is much more popular, used by standalone projects, many bindings, as well as Mirage.
The reason RWO used Async is that it is basically a companion to Core and one of the authors of the book is also the author of both Core and Async.
The problem with Async is that what seems to be the best resource for learning OCaml in 2016 teaches Async, not Lwt. I was excited to use it until I discovered that many things I was interested in use Lwt instead. It's not hard to learn Lwt, but this discovery made me think about the problems I've had as a professional Perl programmer in dealing with Perl 5's multiple competing event loops.
The upside is that with the hopefully soon upcoming algebraic effects that are supposed to appear in OCaml sooner or later, Lwt and Async might end up being obsoleted or subsumed into a compatible set of Async primitives.
I'd rather have a system to generate composable queries (hopefully in a typesafe manner) and able to use modern SQL syntax (eg, window functions), without the stuff you typically find in an ORM (identity map, magic setters, etc)
Technically there is SQLProvider, but it's ugly as sin (I also don't care for type providers in general, I don't need automatic code generation, I have no problem specifying my schema and not needing access to a database server just to compile my code).
Yes they lack composability and type safety. You could easily add composibility in the guise of something line various existing JsonQL libraries. Type safety, at some point (crossing process/network boundaries) you just have to be pragmatic and let go.
I still hold out hope for a datalog-to-sql layer, someday.
i love ocaml, i love ml languages, and i think ocaml is a very good ml
but, i think its kinda too late for it, i think people who want to program with types today most likely will go to rust, scala or f#
ocaml is very niche
I think the biggest issue with OCaml for mainstream adoption is the syntax, honestly.
Didn't think of it that way. Well-put and I totally agree. So odd that one hits that sweet spot in design yet gets almost no uptake. Whatever problems like OP posted need to get solved because interesting and useful things are sure to come from mainstream attention to it. Useful even outside Ocaml given its influences on other languages.
Another thing is the compiler. It's reportedly easy to understand and robust compared to most. I recall reading Esterel's report on DO-178B certifying their code generator written in Ocaml. They had to do source-to-object-code equivalence. They said that, very unusually, the Ocaml toolchain was well-structured to the point they only need minor tweaks to get the job done.
So, great language design plus great implementation equals great opportunity for robust, app development. The concurrency situation is ridiculous, though. Even C-like languages and Haskell have safe concurrency techniques. They need to get on that shit cuz nobody uses single-core boxes anymore unless they're a small shop licensing Oracle. ;)
Indeed, a barrier in itself, after working through RWO I was impressed with the language, clearly very powerful, but some aspects of the language are syntactically unpleasant.
Yes, yes, semantics, not syntax, but new comers will come in all forms, including those who will just say no based on the general "look" of the language. IMO, if OCaml had the same power but looked more like SML it would have much greater adoption.
Anyway, modular implicits and multi-core will certainly help OCaml to grain traction, syntax notwithstanding.
The closest I've been able to get is Oasis+OPAM, but it's just not the same.
I'm a Scala dev. I'm playing with Rust for lower level stuff, don't know much about F#, but FWIW I would rather code in Ocaml than Scala.
At my previous job I tried to introduce some functional languages without much success. The stack was C++/Java and a lot of Python. I learned Scala because it runs on the JVM and I thought that may help.
Later I moved to another city and when looking at job offers I saw a few Scala offers (and no Ocaml in sight) so I settled on Scala.
IMHO Scala gained traction because it runs on the JVM. It's easier to train Java devs because you can start by writing Java-in-Scala and incorporate specific features as you go. The web ecosystem is nice (at work we're using Play.) There's also a few killer apps, like Spark.
I'm currently trying to become as proficient in Ocaml as I am with Scala, but I'm already working with Scala 8+ hours a day so it's not that easy.
The key difference for me is "is there a polished development environment where I can get from zero to debugging within minutes".
From my perspective Mirage is OCaml's 'killer app' (I'm sure others would disagree). Where I could see it excelling is as an open-source home server platform. I'm not sure what the current progress is but I know some of the Mirage developers were working on this particular use case, I'll see if I can find the link.
Could something like Mirage exist for F#? It could, though the Mirage team have a considerable head start.
EDIT: The project I was referring to before is Nymote: http://nymote.org/
Haskell has higher-kinded type parameters and Idris has dependent types. But SML and OCaml don't even have typeclasses at all, much less higher kinds.
Furthermore, what makes Rust's type system interesting isn't just its use of regions (which the ML Kit used); it's regions combined with inherited mutability plus the borrow check to maintain soundness.
OCaml has a powerful module system, labeled and optional function parameters, row polymorphism, equirecursive types, and GADTs. Most of these features would be fairly difficult to add to Rust.
OCaml also has a better track record with soundness issues than Rust, and more interesting fragments of the language have been formalized.
There is a fun library[0] with a pretty good paper[1] on how to do that in OCaml :-)
[0]: https://github.com/ocamllabs/higher
[1]: https://ocamllabs.github.io/higher/lightweight-higher-kinded...
GHC 8.0 almost has dependent types and the expectation is feature completeness in 8.2, thought what's in 8.0 is already useful.
I like and use Rust and the design decisions that led to a very capable region system that allows one to write data race free and memory correct code is excellent. Haskell doesn't have such a thing because it doesn't try avoid GC.
I didn't do a point by point comparison of Rust expressiveness vs Haskell recently, but I don't remember it being close. Rafael might need to write a Rust for for Haskellers as an update of his "for OCamlers" post a while back.
1. Really good unicode support
2. A dead simple high quality package manager i.e. bundler, mix, cargo.
I'd also add built-in concurrency primitives i.e. (Channels in Go, Processes in Erlang), though this probably isn't a must have currently, but will surely only become more important as time progresses into the multicore future.
Yes, but I just think unicode support is so pervasive its not something you should really leave up to a library in 2016. Still this is just my biased opinion as a developer who needs it on virtually every project.
"2. opam."
see: https://opam.ocaml.org/doc/Packaging.html#Publishing, - basically, I think requiring a PR on github to get a package published is not "dead simple".
Finally, the title contains "widespread adoption". There is no modern language on the Tiobe Index top 20 without those two characteristics except for possibly MATLAB and C# which both don't have good package managers as far as I know, but I could be wrong since I've never used either one of them.
The List: (http://www.tiobe.com/tiobe_index)
Anyway, I'd like to see ML get more adoption. I think fixing these things are more fundamentally important than some others such as web frameworks, etc...
On #2, I disagree. The effort required to make the pull request is a small fraction of the effort required to make a library worth adding to Opam. At the same time, it's enough effort that it should prevent the NPM problem of a million stupid "libraries" for 2 line functions.
I'm in the same boat as a lot of people here, in that I think OCaml looks great except for a few big shortcomings that they've ignored for a long time (unicode, multi-threading, etc.) that end up being deal killers for me. As I put it in another thread a while back, it's not even that I need the missing functionality all the time, it's that they refuse to add any of it for as long as possible.
It got a lot of attention on Tim Bray's widefinder benchmark:
https://www.tbray.org/ongoing/When/200x/2007/10/30/WF-Result...
Overall I'd say that OCaml is more pragmatic.
Logging is another popular example of a "benign" effect, but I personally don't think is: I mean, your logging library could be doing all kinds of weird things like shipping logs over TCP to a remote syslog daemon... and I don't want that to be hidden under the rug (using unsafePerformIO or similar) only to blow up later when the network happens to be down.
Anyway, having programmed in O'Caml for 3-4 years, I was won over to Haskell by the compiler-supported (side) effect tracking. I think it's also important to note the distinction between side effects and plain (desired) effects. Not enough people do this in these sorts of discussions.
I am on the fence with ORMs. Yes, they make 80% of cases possible, remaining 19% difficult and last 1% sometime impossible.
Having Slick (Scala) and JOOQ (Java) makes code much more transparent, explicit and easy to maintain. Debugging nasty stateful session bugs (oh JPA) can be nightmare.
I, certainly, do not remember one for JS or Node.