In this guide, we will explore why you should use YOCaml. It is organized around three main axes:
- the (subjective) strengths of YOCaml
- educational reasons
- an ideological perspective
Of course, the first obvious reason to use YOCaml would be that you already know OCaml (and love the language), want to create a personal site, and don’t want to reinvent the wheel—and yes, building your own site generator is a canonical exercise for an OCaml developer.
Subjective strengths
All of the strengths listed here are derived from our experience using YOCaml over several months on different projects. Hence the highly subjective nature of this section.
Performance and efficiency
Even though we don’t have concrete benchmarks, as users we have had relatively few reasons to be frustrated by YOCaml’s page generation speed. Moreover, the YOCaml engine aims for minimality — meaning it only rebuilds pages that need to be updated from one modification to the next.
In addition, OCaml compiles extremely quickly and is very stable, making it possible to build a generator that remains reliable over time!
Flexibility and diversity without "hacks"
Since YOCaml only enforces a computation model, it doesn’t impose any limits on organization, or the types of data to consume and produce. This genericity allows YOCaml to be used in a fairly standard way whenever you want to read and generate files, enabling the creation of almost any type of statically generated site.
YOCaml emphasizes genericity, allowing users not to be locked into pre-designed page archetypes. This choice was made without sacrificing possible static guarantees and type safety by grounding the computation model in an expressive yet strict API.
As an educational tool
Although YOCaml is probably not the ideal library for discovering and learning OCaml, it offers opportunities to explore sometimes bewildering concepts of functional programming. Indeed, YOCaml attempts to make practical and meaningful use of Monads, Applicative Functors, User-Defined Effects, Profunctors, and Arrows. As such, using YOCaml provides a concrete way to engage directly with intimidating abstractions in functional programming.
Learn OCaml
If you’re not familiar with OCaml but find the arguments in this section convincing, here are some resources to learn OCaml and come back here when you’re ready to build your personal site, with YOCaml:
- OCaml Programming: Correct + Efficient + Beautiful
- Real World OCaml
- Using, Understanding, and Unraveling The OCaml Language
Against the "boring normalized web"
Although the web is an amazing tool, over time — often for legitimate reasons — it has become drastically standardized. Indeed, with the proliferation of devices, we have moved from a patchwork of chaotic personal sites to increasingly similar ones! Fortunately, there is a resurgence of fun in personal initiatives or more institutionalized projects. YOCaml fits right into this trend!
Behind the platforms
Platforms like Medium and Dev.to have marginalized the practice of maintaining your own websites. What a shame. We imagine the main reasons were community consolidation; however, many articles have been held hostage (at least by Medium), with pop-ins and other annoyances. One way to fight this terrible centralization of information is to maintain your own digital garden! And YOCaml is perfectly suited for that!
Templates and tools
Since YOCaml requires starting from a blank slate (in terms of architecture, templates, and organization), it may seem impractical. One of the main reasons behind this choice is to avoid pushing users into the same templates and architectures. Indeed, we want YOCaml to be an excuse to reinvent the wheel — at least for your own website! Having a CLI that bundles a specific usage and templates is therefore not on the agenda (or at least not in the form of an official YOCaml package).
Why Not Use YOCaml
There are several perfectly valid reasons why you might choose not to use YOCaml. To save you time, here’s a list:
-
You don’t like OCaml: that’s unfortunate! But since YOCaml is an OCaml DSL, disliking OCaml makes using YOCaml pretty much unthinkable.
-
You want something pre-bundled: YOCaml’s goal is not to restrict users’ creativity but to encourage them to build their own site, following the architecture and model of their choice. It is therefore not packaged with a generator that enforces a file structure or imposes templates.
-
You want to build a dynamic application: this, of course, applies to all static site generators. If you need heavy interaction between users and a server and are not inclined to use JamStack, we suggest looking into Ocsigen, Vif & Hurl, Dream, or Mirage (all OCaml frameworks).
If none of these reasons apply to you, you’re ready to start using YOCaml!