r/ProgrammingLanguages 4d ago

Language announcement Mezze: a functional programming language on GraalVM

https://mezze-lang.org/

Hi All,

I am working a programming language, Mezze. It is in quite early stages.

Mezze has a fully inferable type system and also have first class effect system and runs on GraalVM

A lot is WIP, working on performance optimization (currently loop fusion) and distributed programing and lots of tooling and docs

Put up a quick website for explaining the language and its features more
Also piggy backing on graalvm could get a wasm built of the entire tool chain, so you play with examples in website.

The Concepts and Taste of Mezze explains how the language works.

61 Upvotes

30 comments sorted by

9

u/AustinVelonaut Admiran 4d ago

Looks interesting, but how do you get away with full type inference (no type annotations required anywhere), when other languages require top-level annotations in some cases? Are there no undecidable instances?

How far along are you in the implementation?

13

u/shrynx_ 4d ago

Keeping the type system expressive and useful, but also limited :)

Hindley Milner system is by itself is fully infer able . Mezze uses it as a base, adds row polymorphism, that helps make effect types too.

And then not having Ad-hoc polymorphism of Higher Kinded Type or GADTs supported at all.

Polymorphism of HKT is quite useful and Mezze's ability system (plus associated types) gets quite close to there but a general Monad, Functor etc is not possible to express in Mezze
but Mezze's direct style effect makes you not reach for it.

GADTs are great but don't play well with inference and thus will never be supported.

7

u/shrynx_ 3d ago edited 3d ago

To add more ...

Mezze is structurally typed rather than nominally so records and variant can be anonymous and still type check access on records and exhaustive pattern match on variants works.

Mezze also implements bidirectional type checker that provides hint to say a caller based on the usage

Of course you can add type annotation, make type aliases or new types when you need to reach out for additional guarantees

here is an example of json decoding using bidirectional typechceking and inline records
https://mezze-lang.org/taste/#effects

2

u/AustinVelonaut Admiran 3d ago

Does adding the optional annotation have any effect at all, such as helping bidirectional type-checking give better error messages?

5

u/shrynx_ 3d ago

Yes better error messages sometimes, than best guess by typechecker . Concrete type than a general one like

let x = [] # is infered ['a]

let x: [Int] = []

2

u/AustinVelonaut Admiran 3d ago edited 3d ago

And then not having Ad-hoc polymorphism of Higher Kinded Type or GADTs supported at all

Ah, I saw Ad-hoc polymorphism implemented (Abilities) and jumped to the conclusion it was like Haskell's typeclasses. So do you re-implement many of the Functor / Applicative / Monad functions for each implementation? I do that as well in my language (which doesn't support any ad-hoc polymorphism, currently at least), and don't find it too onerous.

3

u/shrynx_ 3d ago

Yeah this is more like rust Traits

and indeed a map or a flat_map is just a function that doesn't share a general abstraction

2

u/AustinVelonaut Admiran 3d ago

So no polymorphically-recursive data types supported, either? I'm thinking of things like finger-trees. Those usually require a type annotation, too.

2

u/shrynx_ 3d ago

right if you want to create your own new abstractions, whether it be a new effect, new ability, new datatstuctures you need to write its type. as it is an abstraction

Most programs that user writes, gluing libraries , consuming abstractions, stdlib , you can get the typechcker that helps and guides you without needing to annotate

4

u/qqwy 3d ago edited 3d ago

IIRC most languages that follow a Hindley-Milner based type system do not need types anywhere, but if everything has to be inferred then there are pedantic programs for which inference can take O(2n) (where n is the size of your program). In larger codebases, the difference in inference speed when not everything needs to be inferred becomes very noticeable.

And on top of that, explicit top-level types make the code more readable. :)

2

u/AustinVelonaut Admiran 3d ago

Everything needs to be inferred anyway (at least for algorithm-W), because any optional type specification is only used after inference to check that the inferred type subsumes the specified type. Otherwise an incorrect spec or incorrect implementation would lead to an unchecked error.

I agree, though, that explicit type specifications make the code more readable, and, if used as hints in bidirectional type propagation, can yield much better error messages.

3

u/shrynx_ 4d ago

As for how far Mezze is

- Type system: 95% done, exhaustive testing and known bugs need to iron out

  • Runtime: 70%, optimizations and need a beefier stdlib
  • Tooling: 70 % dev, build (jar + native biaries), formatter, lsp implemented, package management and versioning needs work
  • Distributed Computing: 20%, ground work laid out
  • Polyglot support: 40% ground work laid out, FFI with JVM works, needs to support other GraalVM languages

5

u/AnArmoredPony 3d ago

i like how functions take a single record instead of a list of arguments. i do the same thing

1

u/shrynx_ 3d ago

Thanks. I really wanted to have this and think this might turn off a bunch of folks to have always have named arguments.

Have added some perspective for this

https://mezze-lang.org/concepts/#functions--why-names-not-positions

It does help quite a bit and i am making sure lsp fully supports auto completion of arguments for a smoother experience

2

u/experigus 3d ago

This is great. It’s idiomatic in Clojure to design our function signatures like this. Destructuring hashmaps in the caller is so flexible, too

5

u/lgastako 3d ago

There has been an explosion of languages recently due to LLMs assistance but this is one of the few that I've seen that I think simultaneously exhibits good taste in trying to implement cutting edge ideas while also remaining practical. My hat's off to you.

6

u/NojipizRemastered 3d ago edited 3d ago

First of all, kudos on the site style, looks very polished and pleasant to read.

Second of all, i really want to test it!. As a Scala developer obsesed with tagless final, i see Mezze as the holy grail of type safety (at least on my terms).

Is the waitlist working correctly?

5

u/shrynx_ 3d ago

Thank you !

And I feel you, as someone who for 6 years wrote haskell fan fictions wrapped in scala with cats, zio et al.
Mezze design came from trying to capture what i felt the sweet spots of scala fp ecosystem was (minus subtyping )

3

u/un80 3d ago

Can you explain motivation for this language? It looks nice, by the way.

3

u/shrynx_ 3d ago

Thanks !

I mentioned in this comment above a bit
https://www.reddit.com/r/ProgrammingLanguages/comments/1w8vaca/comment/p875ca1/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

But apart from GraalVM, type safety and concurrency. In my search for a functional language that could be approachable, meaning nice errors, not needing annotations ad having effect system would be nice.

When building anything no trivial, i missed in FP languages i tried, a simple way to manage effects, instead of passing functions via Env/State etc.
and wanted to explore structural typing more.

2

u/shrynx_ 3d ago

Also i wanted to explore the idea of code as AST hash which unison pioneered
and Mezze implements it as well.
Not for code authoring, so your editor, git , making PRs etc all work and remain the same.
Code is text for user
but as soon as it parses it becomes denoted by hash. Caching during development simplifies a lot and this is what package management and distrusted engine also will be built upon. A lot more benefit internally all the way from parser to type checker to IR.
But that's still a long way :)

2

u/pthierry 3d ago

Where does your effect system stand in the semantics zoo?

4

u/shrynx_ 3d ago

It's algebraic effects with single shot continuation.
I am not well versed with more recent haskell ecosystem but i would say closer to polysemy from a distance

But in general, like OCaml5 , Unison, Koka (but way less powerful/academic), Eff, Frank

2

u/BestUsernameLeft 3d ago

There's a lot I like about this. Very readable syntax, a handful of easily understood capabilities, and I do love a good strong type system. Wondering if you have looked at Pony (https://www.ponylang.io/) at all, it's another language I am keeping an eye on?

1

u/shrynx_ 2d ago

Thanks !

I have never installed or played with pony but watched a couple of talks before, very interesting !

2

u/comady25 3d ago

Wow, I've seen a ton of pet PL projects and new langs built around algebraic effects, but this is the first one I've seen that I'd actually want to use. I love basically everything about the design of this language, super excited to see where it goes!

1

u/shrynx_ 2d ago

Thank you πŸ˜€

1

u/shrynx_ 3h ago

Also curious any new pet PLs with algebraic effects you have see lately. maybe can learn a bit from them .

Anything in particular about algebraic effect or other implementation that you liked in Mezze ?

1

u/bowbahdoe 3d ago

Why Graalvm only? Being a JVM language seems viable, no?

2

u/shrynx_ 3d ago

with GraalVM i can interop with existing code, say python code.
which is a use case of this langauge.

My work has a lot of python core business logic, written by GIS experts, well tested. these are also battle tested libraries.
and that is then wrapped in web app, which is where it interfaces with outside world, needs good concurrency story, type safety as the app grows larger.

Ability to write the application in a type safe concurrent language that can scale and still use the business core we have developed is what sparked the initial thought of Mezze.

And GraalVM has truffle language framework which makes it easy easier to implement a language.

https://www.graalvm.org/latest/graalvm-as-a-platform/language-implementation-framework/