Announcing Type-C to the World!

6/12/2024

type-c

Hello, world!

You are probably here because you have clicked a link on reddit, or by chance. Welcome anyway!

I want this post to be a showcase of Type-C, its current state at the time of writing and a bit of future plans.

What is Type-C?

It's like Java, but with a cool hat.

Type-C is a high-level programming, primarily inspired by TypeScript. However Type-C takes a different shift from regular languages to focus more on performance, behavior driven programming, type safety and avoiding object oriented programming pitfalls.

These are strong promises and Type-C is still under development. Right now the ecosystem is very limited and the language is not yet stable. There are a couple of test cases to make sure the language is working as expected, a working VM with limited memory (GC not fully finished yet).

Now enough with words, we will just go through some code example to give you a taste of Type-C and get some feedback from you.

Show me some code!

The language provides basic arrays similar to Java, but you can't do much with them, hence the limited functionality and the need for a proper standard library. Let's have a look at that class:

Classes can only implement interfaces, and interfaces can only have functions. However Type-C type matching is based on structure, so even if we remove AbstractArray<T> from type Array<T> = class AbstractArray<T>, Array would still match an AbstractArray, since methods match.

Some of the issues with classes at the moment is that the compiler is unable to identify uninitialized attributes.

Classes also are allowed to reuse methods, provided they are defined within an implementation type.

An implementation type or impl for short, is a group of methods that a class can reuse. This is useful for defining methods that are shared between classes.

Immutability

Immutability is inverted in Type-C. By default, all variables are mutable, and function parameters are immutable by default. Immutability spreads to all fields of a class or an object.

Argument mutability is also part of the function signature.

Data Types

Oh boy, I will just over the fancy stuff.

Structs

Designed to behave similar to JavaScript objects, except they are not.

Variants

Joins

Only applicable to interfaces. Gets translated to an interface during compilation.

Closures

Pattern Matching

Probably already seen it

(almost) Everything is an expression

Almost everything can be written in an expression form.

Where to go from here

There is plenty of stuff that I didn't cover, so have a look at the documentation!

What is the future of Type-C

Still a lot of work ahead! The compiler produces cryptic error, and the VM still not fully implemented. Some benchmark of Type-C already looks promising (but then again I compared to python).

If you are interested in Type-C and would like to contribute, feel free to contact me! I would be happy to have some help. Most important areas of improvements right now are the language itself, unit testing the compiler, and the VM.

So a lot of code needs to be written in Type-C.

Thank you for reading! Cheers!

Written By

Author Avatar

Soulaymen Chouri

Software Engineer, author of Type-C, maintainer of the Type-C ecosystem