Blog
The OCaml Planet RSS
Articles and videos contributed by both experts, companies and passionate developers from the OCaml community. From in-depth technical articles, project highlights, community news, or insights into Open Source projects, the OCaml Planet RSS feed aggregator has something for everyone.
Source
Keyword
Year
Author
Want your Blog Posts or Videos to Show Here?
To contribute a blog post, or add your RSS feed, check out the Contributing Guide on GitHub.
I wasn’t an early adopter of TreeSitter in Emacs, as usually such big transitions are not smooth and the initial support for TreeSitter in Emacs left much to be desired. Recently, however, Emacs 30 was released with many improvements on that front, and I felt the time was right for me to (try to) embrace TreeSitter.
A couple of days ago I noticed on OCaml’s Discord server that someone was confused by OCaml function applications (invocations) like these:
I’ve noticed that some newcomers to OCaml are a bit confused by code like the following:
When people think of OCaml they are usually thinking of compiling code to a binary before they are able to run it. While most OCaml code is indeed compiled to binaries, you don’t really need to do this, especially while you’re learning the language and are mostly playing with small exercises.
One of my small issues with OCaml is that the standard library is quite spartan. Sometimes it misses functions that are quite common in other (similar) languages. One such example are functions like drop, drop_while, take and take_while in the List module.1 What’s weird is that the similar Seq module features all those functions since OCaml 4.14. I believe it was Haskell that popularized them.
How can you be sure that an OCaml function you wrote is actually tail-recursive? You can certainly compile the code and look at the generated assembly code, but that’d be quite the overkill, given there is a much simpler way to do this.
While learning OCaml I’ve noticed one curious feature - it has two types of string literals. The first type are the common and quite familiar “double-quoted string literals” (or perhaps simply “string literals”?):
Ruby programmers are commonly called Rubyists. Python programmers are often called Pythonistas. Lisp programmers are widely known as Lispers. Clojure programmers are sometimes called Clojurians.
One thing I’ve noticed on my journey to learn OCaml was that reading (text) files wasn’t as straightforward as with many other programming languages. To give you some point of reference - here’s how easy it is to do this in Ruby:
Lots of programming languages have some built-in range functionality, that’s typically used to generate a list/array of integer numbers. Here are a couple of examples from Ruby and Clojure: