What do you think of a new language as better OCaml?

I always dream of a beautiful perfect language. Now I start working on it, and call it the Hi programming language. Its name captures the spirit of the language: as simple as saying “hi.”

What do you think?

Nice, I’m glad you put a “why not …” section in the readme, but i think it’s missing the language closest to what you’re trying to do: ReasonML. It also has a more “modern” syntax, while keeping compatibility with OCaml. I’m interested in what you plan to do differently from ReasonML.

ReasonML is not a new language but just a syntax that is more C-like. Its semantics are just the same as OCaml. For example, its labeled function arguments is not any modern language feature, but just rooted from OCaml, which IMO is very ugly compared to the equivalent feature in Scala. In summary, ReasonML not bring any improvement or innovation other than syntax.

On the other hand, the Hi language is a fresh new language with modern features, including default arguments, extension methods etc.

The most related concept in OCaml that resembles Hi is modular implicits. I am really excited to it, but 10 years passed it’s still not in the roadmap. I understand it’s hard to bring ambitious features to a mature language like OCaml. Thus I think creating a new language is better, since no tech debt, nothing hold you back.

Also cross reference a discussion in 2018 about modular implicits.

Back then, some community users call for a new language.

Thanks for doing this! For someone who is not convinced the bullet list of shortcomings in the README – in fact not seeing shortcomings on that list – could you provide an intro about what are the value-adding departures from OCaml? For example, how the labelled arguments differ, how is extensibility easier. Personally, I am excited about modular implicits but not sure how I would use them, and turns out I want modular explicits in my recently written code. It’s encouraging that unlike implicits, explicits (module-dependent functions) are on a path to landing in the language soon.

Edited to add: I overstated the part about not seeing shortcomings: not a big shortcoming, but I like the more consistent syntax for types, where type constructors are capitalized and their arguments follow them.

Did you know MoonBit(moonbitlang.com)? It’s influenced by OCaml but with a much better tooling(IMHO) and ad-hoc polymorphism.

Yes, I knew moonbit and also did a research of it.

  1. It targets at WASM, so it’s actually in a different market place competing with other languages that compile to WASM. Its looks much like Rust but mixed some OCaml’s syntax like labeled argument. I don’t see why WASM programmers would prefer Moonbit over Rust given Rust already kind of dominating the wasm world. In addition, moonbit also needs to build an ecosystem from scratch, like what I explained in the ReadMe about Kotlin/Native or alike.
  2. Hi targets at native programming (with GC, but not VM dependent), just as OCaml. In this world, a top competitor is Golang. But Hi stands on the shoulders of giant (OCaml compiler), reusing all the parts from middle IR (lambda) to backend; so semantically it is binary compatible to OCaml. You can have one module written in OCaml, and another written in Hi.

I had dig into the source code of Go’s runtime and OCaml’s runtime, to compare how they implement coroutine (lightweight thread). IMO, OCaml’s effect (stack) support is very powerful and better than Go’s coroutine. OCaml’s power is really underestimated by the industry. Thus I want to leverage that, and let it shine. With a good language design, I believe Hi could beat Golang in backend programming.

MoonBit targets wasm first but comes with js and native backend now.

We believe we will beat Rust in all important metrics soon when targetting wasm.

You are correct that it takes time to build an ecosystem but great stuff takes time.

I expect a better ocaml to stem from 1ML.
When creating a new language you have to convince me it beats 1ML.
If you claim it just beats ocaml i will not even consider.

Another big motive would be better interoperability with coq/gallina.
So, ideallly, you have to design both a better 1ML and a better coq/gallina that would interoperate eachother. Anything less is not ambitious enough.

I do not try to belittle your innovations, i just try to maximize the benefits :wink:

1ML and coq are both good languages. But they sit at the other end of the spectrum, compared to Hi. At that end, there are a bunch more options, Agda, LEAN etc, mostly used by academia users.

Hi is designed to be an intuitive and practical functional programming language, trying to leverage the solid foundation of OCaml compiler and runtime, and bring it to mediocre programmers.

1 Like

If you haven’t already been there, you might find the old camlp4 alternative syntax interesting → The revised syntax

At a casual glance Hi seems to have accounted for some of the issues addressed there, but at any rate, whether you like their revisions or not, it’s a good critique.

@bobzhang I didn’t know of MoonBit, it looks interesting, thanks! Out of curiosity, where can I find the source of the type-checker and compiler? Browsing github I only found build tools and the core library.

Thanks for the interest! We plan to open source the compiler soon, stay tuned.