n2liquid's sandbox

Drafts of a language that will never be – The Chii Programming Language

Posted on: June 28, 2011


I blamed C++ (and pretty much all of the most famous languages too) on my previous post, and I left everything pretty much unjustified. That bothered me, but I didn’t feel great energies with the idea of going in-depth as to why everything sucks, in my most not humble opinion, bear in mind.

So it occurred me that instead of blaming everything I hate (and boy, that’s a lot), it’d be easier to describe what I’d love to have (that’s also a lot, but still fewer than what I hate).

Chii (from Chobits) on the Water TowerI love helpless cuties. I also love persocons and, obviously, I love Japan.

So, it’s only natural, if I were to name my programming language, it’d gotta be Chii!

Since programming languages have many aspects to them, it’s hard to “explain everything in a single go”. Doing that would make this blog post become a book, but I want to go slowly and in small steps, so I’ll create a category “Chii Language / Chii’s Design”.

You can see how’s the progress by navigating the Chii Language / Chii’s Design category.

I’m gonna use this first post to talk a little about one of the first things I thought about Chii:


I imagine something quite complex when it comes to enumerations. It’s not my fault the current definition of an enumeration is so oversimplified, though.

An enumeration should create a data type capable of… well, enumerating a discrete set of values that carry special meanings. Enumerations are a very basic language construct, so they certainly get used a lot; but in my experience, most cases that call for an enumeration are simply too much for this language construct, and I end up avoiding them.

For Chii I would like an enumeration solution that really solved the problem of enumerating things. The first feature I’m interested in is called sparse enumerations.

I also gave a bit of thought to some other important aspects of enumerations, like inheritance, but they’re not well consolidated in my head yet, so I’ll have to post them later.

On to what matters…

Sparse Enumerations

Sometimes the elements of an enumeration are dictated by possibilities scattered throughout many files. If such an enum has to be defined all in a single place, you end up having to make changes to it. This doesn’t feel much like you’re plugging files together, but more like you’re gluing them.

Sparse enums allow you to define an enum in many different places and use it just like a regular enum.

Suppose you have an image resizer component that supports many different filtering algorithms. You write the resizer, declare an enum FilterType, and let the many different filtering algorithm modules “extend” this enum.

Another example in pseudo-code:

// File A
enum InputPackage.Button { CROSS, SQUARE, TRIANGLE, CIRCLE };

// File B
enum InputPackage.Button { DOWN, LEFT, UP, RIGHT };

// File C
// naturally use those sparsely defined
// enumerations as one would expect to be able to
InputPackage.Button pressed = DOWN | LEFT | CIRCLE;

An enum can be marked final, in which case it cannot be sparsely defined:

// File A
final enum MyPackage.StrictState { STATE_A, STATE_B, STATE_C };

// File B
enum MyPackage.StrictState { STATE_D }; // error; MyPackage.StrictState
                                        // is marked final elsewhere

Keep in mind that I’ve only quickly skimmed through those ideas. They certainly must be properly studied and improved before making real sense and actually solving problems and not just being another fallacious dream of mine.

Yet, I’d love to hear early constructive opinions, if you cared to leave a part of you in this blog; thanks. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Cute bouncing pixels


Twitter (technical)

Error: Please make sure the Twitter account is public.

Twitter (personal)

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Get messaged when I post something new!
Just enter your e-mail and hit Follow:

Join 171 other followers

%d bloggers like this: