10 ms·
Reason/OCaml is truly a secret weapon, beating the averages and all. The reach this language has is incredible. Whether you work on React UIs, REST/GraphQL serv
by osener 7y ago
Reason/OCaml is truly a secret weapon, beating the averages and all. The reach this language has is incredible. Whether you work on React UIs, REST/GraphQL servers, desktop apps, Unix systems programming, or even unikernels, it never feels like the wrong tool for the job and is always fun all the way through.
- smabie 7y agoIt’s nice, but not that nice. The type system is primitive compared to modern alternatives and the use of functors for generics is clumsy. Also multicore still isn’t a thing, despite it being just around the corner for years. If the type system was as powerful as, say, Scala and multicore worked OCaml would be my go-to language. But at this point, I think F# would be a better choice for new projects. And you also get to use Akka.net with it, which could be a major value add.
- momentoftop 7y agoIf by "generics", you are referring to the sort of parametric polymorphism that you have in .NET and Java, then no, you don't use functors for that. # let foo x = x;; val foo : 'a -> 'a You need to use functors if you want higher-kinding, but they're generally useful beyond that, and I wish more typed languages had an SML style module system. F# doesn't have one, and has always had a punier type system.
- brmgb 7y agoNo offense but it's hard to take you seriously when you call OCaml type system primitive. Also OCaml obviously has generics independently of functors. Polymorphic functions and types are literally everywhere.
- tybit 7y agoI see functional languages with primitive type systems a pro not a con. We need simple languages like ReasonML more than something like Scala or Haskell if they are to be embraced more widely.
- k__ 7y agoLuckily, the only big competitor Reason has to mess with at the moment is TypeScript.
- dean177 7y agoWhat do you mean the type system is primitive? Compared to what?
- tomp 7y agoOCaml was my first serious language, and while I think it's a bit weak for "programming in the large" (cumbersome types, typeclasses, lack of type annotations sometimes hurts) I'm still incredibly fond of it. Unfortunately, I haven't had much experience using it recently, as most of my work is in Python / Scala etc. I'm assuming you're a current, up-to-date user, so I'd like to ask you: - what are the current reasonable options for a StdLib? Last I checked, the default lib was still very poor, while JaneStreet's I found barely documented. - Multicore I guess I can forgive, it's not like there are any other modern GC languages that make multi-threading particularly easy (with the possible exception of Java). - What's an example of a recent codebase written in "modern" OCaml / Reason?
- osener 7y agoI've been writing a lot for Reason and OCaml last few years, but the majority of it target BuckleScript and React. My front-end bias alone means it's a better stack than any other alternatives mentioned in this thread (and I even find it more productive than TypeScript), so take it with a grain of salt. I do use ocaml-graphql-server and such a lot to write small services, but I often don't interact with databases or build complex backends that would require a bigger back-end webdev ecosystem. Most of my native development happens far from the cloud, and mostly around CLI and GUI tools for which I adore OCaml and recently Reason (https://github.com/revery-ui/revery https://github.com/revery-ui/revery). > cumbersome types, typeclasses, lack of type annotations sometimes hurts I've grown to really like the explicitness of OCaml actually. Nothing implicit or circular, and I can just read a module from top to bottom. The lack of type annotations don't bother me as much with tools such as Merlin, and I find that the amazing type inference lets me prototype code as fast as dynamic languages. > - what are the current reasonable options for a StdLib? Last I checked, the default lib was still very poor, while JaneStreet's I found barely documented. I use Containers (https://github.com/c-cube/ocaml-containers/ https://github.com/c-cube/ocaml-containers/), Lwt, and a few other small libraries like Rresult and Bos pretty heavily. For a big application with many contributors I'd still suggest giving Core another try as it's very well thought out and extensive (compared to npm-style dozens of dependencies you need to introduce with different API designs). I must say that even though I'm pretty used to reading type signatures and jumping to interface files for documentation (and even prefer it to tutorial style docs in markdown), and wouldn't say Core's documentation is _poor_, I agree with you at some level. Because of how it's built and split up across different packages and modules, it gets pretty tiring having to power through many levels of indirection every time you want to look something up. > - Multicore I guess I can forgive, it's not like there are any other modern GC languages that make multi-threading particularly easy (with the possible exception of Java). I find that, compared to some other languages I've used, my naive and readable implementation in OCaml last much longer before I need to optimize it. I do use Lwt_preemptive threads that call C code and subprocesses often, but usually because of the nature of the problem I'm solving and not as a parallelization technique. > - What's an example of a recent codebase written in "modern" OCaml / Reason? Most open source projects I can think of are libraries and tools such as compilers, but here are some real-world applications off the top of my head: - https://github.com/onivim/oni2 https://github.com/onivim/oni2 (native, desktop) - https://github.com/SVdotCO/pupilfirst https://github.com/SVdotCO/pupilfirst (bucklescript, react) - https://github.com/Schniz/fnm https://github.com/Schniz/fnm (native, CLI) Some of the cool stuff I saw in the wild: https://github.com/osener?language=reason&tab=stars https://github.com/osener?language=reason&tab=stars https://github.com/osener?language=ocaml&tab=stars https://github.com/osener?language=ocaml&tab=stars Hope this helps! I think with the recent convergence around tools such as dune, opam, esy, it is a great time to start writing OCaml again.