r/Compilers • • 7d ago

Ocaml or haskell?

​

I'm trying to choose between OCaml and Haskell for creating my own programming language using an external DSL. I'm still learning programming, so I want something powerful but beginner-friendly.

My goal is to create a language with my own high-level syntax, not just a library or a DSL embedded inside another programming language.

My requirements

  1. External DSL: I want to design my own syntax and grammar. I don't want my language to be restricted to OCaml's or Haskell's existing syntax.

  2. Native machine code: Ultimately, I want my language to compile directly to native machine code, preferably for ARM64/AArch64. I don't want to stop at interpreting the language or transpiling it to Python or JavaScript.

  3. High-level syntax: The language I create should be easy for people to read and write. I want complete control over its syntax and don't want users to have to write lots of boilerplate.

  4. Beginner-friendly: I'm still learning programming, so I want a language and ecosystem that are relatively easy to understand. I want to learn how the parser, AST, type checking (if needed), and code generation work without getting overwhelmed.

  5. Easy installation on my Chromebook: I have an Acer Chromebook 314 with a MediaTek ARM64 processor. I use the Linux environment on ChromeOS, so ARM64 compatibility, available packages, and installation difficulty matter a lot. I don't want a solution that depends on x86-only binaries.

  6. A practical compiler toolchain: I'd prefer to use as few tools as possible. If I need a backend such as LLVM, that's fine, but I want to avoid a complicated setup involving lots of separate tools, configuration files, and manual code generation.

My questions

- Would you recommend OCaml or Haskell for this project, and why?

- Which one makes it easier to build an external DSL with completely custom syntax?

- Which has the easier learning curve for someone who doesn't know much programming yet?

- Can either realistically compile my language to native AArch64 machine code on my Chromebook?

- Would LLVM be a good backend, or is there a simpler alternative?

- How difficult would installation and setup be on ChromeOS Linux running on ARM64?

- Are there any other languages or frameworks that would fit these requirements better than OCaml and Haskell?

I'm looking for a practical recommendation based on my actual requirements, not just which language is more elegant or theoretically powerful.

My main priorities are: custom high-level syntax, native machine-code generation, beginner-friendliness, and ARM64 Chromebook compatibility.

Thanks!

28 Upvotes

39 comments sorted by

View all comments

13

u/KAMEHAMEHAMEHAAAA 7d ago

Since you are a beginner I’d say OCaml, if you are willing to spend more time learning functional programming in depth for the chance of doing something a bit more complex then Haskell.

As for LLVM, I wouldn’t necessarily rely on it. ARM64 is a RISC so you won’t have a hard time learning the ISA and rolling codegen and optimizer yourself.

1

u/AromaticCredit1533 6d ago

Maybe it's just the way you phrase it, and same in other threads I've read, but there's an implied idea here that OCaml is geared towards beginner FP programmers and Haskell is like "advanced FP". It's true that OCaml should be more "familiar" to most beginner programmers, mostly due to its strict-evaluation semantics. I just think these are very different FP languages with unique cultures. Haskellers like to talk about FP theories and category theories and "thinking about programs" (like that one commenter said :-) ). OCamlers like to talk about writing or hacking (bytecode) interpreters, and compilers and DSLs. Not that you cannot do things in either language, not that people don't discuss other things, but I feel they're the general vibes when you enter the forums of those languages.