3 ms·
There is a work-in-progress second edition of "Real World OCaml" book [1], which has many small but vital updates corresponding to the modern state of OCaml and
by xvilka 8y ago
There is a work-in-progress second edition of "Real World OCaml" book [1], which has many small but vital updates corresponding to the modern state of OCaml and its infrastructure. Moreover, I recommend checking the Lwt [2] from the beginning for working with multithreading. OCaml Ctypes [3] library for creating FFI stubs without a single line of C and Cstruct [4] for working with C structures. If you want to interact with some Python code or script your OCaml program with Python - you can use Pyml [5] library. OCaml universe also has a good library for numbers crunching and scientific computing (including primitive Machine Learning) - Owl [6]. For writing OCaml instead of JavaScript, it is possible to use BuckleScript [7]. And if you are starting a new project in OCaml - I recommend using the most modern buildsystem - dune [8]. It is very simple to use and with a less overhead than others. I found also Angrstrom [9] is very useful for implementing binary and text format parsers.
Utop [10] and ocaml-jupyter [11] are the best choice for experimenting, browsing the API and testing some small things.
[1] https://dev.realworldocaml.org/toc.html https://dev.realworldocaml.org/toc.html
[2] https://ocsigen.org/lwt/manual/ https://ocsigen.org/lwt/manual/
[3] https://github.com/ocamllabs/ocaml-ctypes https://github.com/ocamllabs/ocaml-ctypes
[4] https://github.com/mirage/ocaml-cstruct https://github.com/mirage/ocaml-cstruct
[5] https://github.com/thierry-martinez/pyml https://github.com/thierry-martinez/pyml
[6] https://github.com/owlbarn/owl https://github.com/owlbarn/owl
[7] https://bucklescript.github.io/ https://bucklescript.github.io/
[8] https://dune.readthedocs.io/en/latest/quick-start.html https://dune.readthedocs.io/en/latest/quick-start.html
[9] https://github.com/inhabitedtype/angstrom https://github.com/inhabitedtype/angstrom
[10] http://github.com/ocaml-community/utop http://github.com/ocaml-community/utop
[11] https://github.com/akabe/ocaml-jupyter https://github.com/akabe/ocaml-jupyter
- devmunchies 8y agoYou recommend LWT, but the book you recommended teaches Async instead. The split between with libraries to use (e.g. stdlib vs Base) has been frustrating as I’ve been learning and needing to look up documentation.
- xvilka 8y agoI use Core/Base library but rarely use Async. In my opinion and experience (though a short one), Lwt has more features and better maintained by the community.
- anuragsoni 8y agoIf you are following the Real world OCaml book but want to see the exercises in LWT, you can refer to: https://github.com/dkim/rwo-lwt https://github.com/dkim/rwo-lwt
- xvilka 8y agoSpeaking of problems, in my opinions the three biggest are: - Lack of automatic multicore scheduling, this is going to be solved with OCaml multicore project [1] - Lack of updated GUI libraries. There is LablGTK [2], but it stuck to GTK+ 2 version. The main developer started [3] to work on GTK+ 3 version support, but it is still at the very beginning. - Bad Windows platform support [4] (grep for "Windows" word at this page) and [5]. With upcoming opam-2.0 [6] release the support will be slightly better though. [1] https://github.com/ocamllabs/ocaml-multicore https://github.com/ocamllabs/ocaml-multicore [2] https://github.com/garrigue/lablgtk https://github.com/garrigue/lablgtk [3] https://github.com/garrigue/lablgtk/issues/2 https://github.com/garrigue/lablgtk/issues/2 [4] https://caml.inria.fr/mantis/roadmap_page.php https://caml.inria.fr/mantis/roadmap_page.php [5] https://github.com/ocaml/opam/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+Windows https://github.com/ocaml/opam/issues?utf8=%E2%9C%93&q=is%3Ai... [6] http://opam.ocaml.org/blog/opam-2-0-0-repo-upgrade-roadmap/ http://opam.ocaml.org/blog/opam-2-0-0-repo-upgrade-roadmap/
- shikoba 8y agoWe use OCaml on windows everyday and have no problems with it. Since the support of foreign encoding (recent) there is no major issues with OCaml. The support is not perfect, but you can't say that it's bad.
- nraynaud 8y agoCareful before using LWT, it produces unhelpful stacktraces that just show the thread starting point instead of the actual running code. I have some production stacktraces where I have to guess where the error lie while the customer's backup are in danger.
- Drup 8y agoThis probably means your code is wrong. You should not raise and catch exceptions normally in Lwt promises. You should use `Lwt.fail` and `Lwt.catch`. This is described rather precisely in the documentation: https://ocsigen.org/lwt/3.2.1/api/Lwt https://ocsigen.org/lwt/3.2.1/api/Lwt Another popular solution in the OCaml community is to stop using exceptions and use Result instead: https://ocsigen.org/lwt/3.2.1/api/Lwt_result https://ocsigen.org/lwt/3.2.1/api/Lwt_result
- sgrove 8y agoLots of libraries we depend on throw exceptions, e.g. yojson, postgresql, or even just the stdlib (`Invalid_argument`, anyone?). Because the exceptions aren't statically shown at each usage point, it's hard to know what failure modes you should be watching for.
- nraynaud 8y agoit's not my code, it's there, I can only send PR and hope.