Functional Programming in OCaml
Since there are a lot of questions regarding language choice for functional languages here, I think I&#x27;d be good to share my experience here.<p>I&#x27;ve learned from the ground up (since college) in a functional style through HtDP [1] and have used Racket (not just the teaching languages) and OCaml a good deal at this point. Some notes on my experiences with functional languages:<p>OCaml<p>The Good:<p>- Incredibly powerful data matching&#x2F;construction<p>- Typing gives good runtime guarantees<p>The Bad:<p>- The actual type checking messages from the compiler aren&#x27;t very fun to wrangle with<p>- Parens being optional but then sometimes being needed for data constructions adds to confusion along with types<p>- There are a lot of other quirks that I only see occasionally but pull me out of ever thinking &quot;this is the language I want to code in mainly&quot;. Things like being required to define mutually recursive functions in the same define clause, chained together with &quot;and&quot;. The ambiguity of the need for semicolons, similar to parens. I won&#x27;t detail them all here, but the quirks sum to something just large enough to be quite annoying to use.<p>Summary:
It can be beautiful to work with until it snaps you right out of it. At this point I&#x27;m not thrilled to work in it, but I&#x27;m not mad either and will probably see the day I write more of it.<p>Racket<p>The Good:<p>- For me, the most readable. I&#x27;m not sure if this is a reflection of learning it first, but there&#x27;s something so clean about it. While you can always drop into the more complex, the core basics read very well.<p>- Incredibly powerful macros. They are much more syntactically complex and resources for learning the ins and outs are hard to find, but once you get them, the world is your oyster.<p>The Bad:<p>For whatever reason, all of the practical packages you want simply don&#x27;t exist yet, or if they do, break the cleanness bare Racket gives you in ways you probably shiver looking at. It&#x27;s my only real negative, but the implication basically is that for any serious project, unless I want to write the tooling I want myself from the ground up, it&#x27;s basically not an option.<p>What really sucks about this the most to me is that of all the languages, writing good libraries for Racket is the easiest given the powerful macro tooling. All the bare bones are there, they just need to be composed together ands abstracted the right amount while keeping the simplicity that makes Racket beautiful. When said aloud, it&#x27;s a big ask. But IMO Python has done so well accomplishing this with things like requests, flask, etc - what&#x27;s stopping Racket?<p>Oh, and the IDE (DrRacket), while deceptively powerful, still needs a competitor badly. I&#x27;d love to see a Jetbrains IDE for Racket, though of course I know that&#x27;s not happening anytime soon.<p>Summary:<p>I wish I could write everything in it, but the tooling and IDE just aren&#x27;t there. Currently my focus is actually now on that tooling itself [2].<p>Functional languages I&#x27;ve looked at but have not written anything serious in:<p>Haskell: I get the appeal from a theory perspective, but the readability for me is absolutely terrible. Things are more verbose where they shouldn&#x27;t be and too terse in the reverse. I haven&#x27;t spent enough time to comment any further, but that alone was enough to steer me to explore other functional language options.<p>Clojure: The community seems great and I am excited it&#x27;s gaining traction (and building out that tooling that Racket is sorely missing), but I wonder why these two have to be separated from each other. At the core of the language, it seems to me on cursory glance that clojure&#x27;s syntax is just ever so slightly worse than Rackets, though less annoying than the quirks of OCaml. I can&#x27;t help but wonder what would be if the clojure community instead wrote tooling for Racket (and some do!). For everyone involved closely with Clojure, I&#x27;d love to hear more about why it needed its own language. I know being on the JVM was big, but beyond that I&#x27;m pretty fuzzy.<p>Functional Programming in general:<p>While there are cases where imperative and object oriented programming make sense, I truly wish a day comes where the word mutation is taboo, imperative style is used sparingly when needed, and code readability and library design is valued above all else in industry. And there are good developments with things like Clojure, Redux, and the big languages embracing functional style more. Still, the difference of how I program in each style is truly incredible, and while my code is objectively better in the functional style, I currently rarely get to use it for projects, professional or personal.<p>To anyone who hasn&#x27;t tried functional programming, I couldn&#x27;t recommend it enough. HtDP or this book both seem like good places to start.<p>[1] <a href="https:&#x2F;&#x2F;www.htdp.org&#x2F;2019-02-24&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;www.htdp.org&#x2F;2019-02-24&#x2F;index.html</a><p>[2] In an attempt to improve the tooling to Racket itself, I am working on two libraries: A web framework and a basic ORM for structures. Both are in highly unstable condition at the moment so it is not recommended to try and contribute to them at this point, but I am targeting May to have stable 1.0 releases. hopefully expect to see a Show HN :) They are loosely inspired by Flask &#x2F; SQLAlchemy, meant to address similar things in Racket. Links at [3] and [4]<p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;adjkant&#x2F;web-sourcery" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;adjkant&#x2F;web-sourcery</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;adjkant&#x2F;sql-sourcery" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;adjkant&#x2F;sql-sourcery</a><p>[5] Syntax Example for [3] and [4] together: <a href="https:&#x2F;&#x2F;github.com&#x2F;adjkant&#x2F;web-sourcery&#x2F;blob&#x2F;master&#x2F;examples&#x2F;0-0-1-example.rkt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;adjkant&#x2F;web-sourcery&#x2F;blob&#x2F;master&#x2F;examples...</a>