Monthly Archives: February 2009

Why the name C3

My husband told me last night the meaning of the name C3. He surprised himself not having already told me about this a long time ago. Of course, the notion of a third C comes to the mind, the first and second ones being C and C++. That’s all right and my husband think that it’s a worthy successor, one that keeps the spirit of its predecessors, at least more than other pretenders like C# and D.c3wifewhatisc3

You can call it “C three” if you want, but in fact the real pronunciation is “C cubed”. This notion of volume expresses the orthogonality of the language, the fact that all paradigms can be used in conjunction with the others. In fact Cn would have suited the language better, but still, the notion of volume says something very important: what is drawn inside simple axis is bigger than the sum of its basic elements.

For some times he thought about changing the language name, maybe break out with the C legacy. But when you called something by a name for that many year, it’s hard to get rid of it. I put an ultimatum on this when I bought my domain name. There is no intention to change it now.

Compiled or interpreted

Will C3 be compiled of interpreted? This is the question c3friend asked us a few days ago. As the answer is not trivial, I think it’s worthy of its own post.

The short answer: both. But this is not very satisfying isn’t it? The priority is for a compiled version, mostly because this is the way to get the most performance out of it. Of course multiple targets will be available, Windows and Mac OS X being our two platform at home, I suppose they will get priority.

Some advanced metaprogramming features however will need an interpreter at compile time. Once this is done, there will be no reason not to release this for others that would need it as a scripting language for their application.

My husband really enjoys answering questions on which he had already though for a while, I asked a lot already, and you just did too! As of myself, I enjoy beach, maya ruins, snorkeling and piña colada a lot more than the long walk up to the wifi spot. This is why I’m going to post many articles at the same time. You should have time to read them all before I get back and post some more, hi hi!

Husband’s notes: Multiparadigm

C3 is a multi-paradigm language. It means that, like in C++, you can mix and match various programming styles. Here is the classical multi-paradigm example combining object-oriented, generic and functional programming and given by Bjarne Stroustrup himself:

for_each(shapes.begin(), shapes.end(), mem_fun(&Shape::Draw));

where Shape is a base class with a Draw virtual function and shapes is a container of pointers to different kinds of shape. The object-oriented part is the polymorphic call to Draw that will automatically dispatch to the appropriate Draw function depending on the actual type of the shapes. The generic part is the for_each algorithm that can be applied to any container of any type.

c3wifehusband1The mem_fun function is just an adapter that convert the member function pointer into a functor that accept a single argument: an object pointer. This last part constitutes the “functional” part of the example but as you can see, C++ does not handle this paradigm is an elegant way. The mem_fun function is a necessary evil because the object-oriented syntax is not directly compatible with function object as first-class citizen.

Please compare this last example with the same thing, written in C3:

foreach(shapes) {

The following syntax is also valid and equivalent:

foreach(shapes, {1}->Draw());

The first syntax was valid because the last parameter of a function can be outside the parenthesis when it is itself a function. This allow us to define basic language constructs like for and foreach loops as functions.

The {1} refers to the first parameter of a lambda procedure that is implicitly defined. The following example makes more explicit use of a lambda procedure:

foreach(shapes) void(Shape* pShape) {

And, if we decide to name the procedure and make it global:

void DrawShape(Shape* pShape) {

foreach(shapes, DrawShape);

Since a method is automatically also a procedure with an additional “this” parameter, we can also skip the additional procedure and simply pass the Draw method as parameter:

foreach(shapes, Draw);

But the previous examples will be more common since we usually need to do a little more than call a single function inside the loop.

C3 algorithms act on ranges. Containers are interpreted as ranges for all their content but there are other ranges that can be passed. For example, there is a method in random access containers to get a reference to a subrange of their content. It is used here to get the first 5 elements:

foreach(shapes.subrange(0, 5), Draw);

As a bonus for those interested, without additional explanations, here is the definition of the foreach procedure:

template <type T>
void foreach(Range<T> _range, void _action(T)) {
    for(Iterator<T> i = GetIterator(_range); !AtEnd(_range, i); ++i) {

I will explain more details of the C3 algorithm library in another post. Meanwhile, make sure you know STL since my library will be mostly inspired by Alex Stepanov’s masterpiece.

Dreaming of a community

I briefly talked about a programming environment and community in my last two posts. Those are the core elements of what would make C3 lift off. A perfect language is nothing if nobody is fluent with it, or worse, if nobody ever hear about it. In the past, major languages have been pushed up front by major companies or a dedicated community, usually a combination of both. As we cannot force the first one to appear, we want to work on the second, convincing you to add your voice, but also your workmanship to this grand project.c3wifecommunity1

The big picture would be to have a very nice way to create, compile and manage your code. But the real innovation lie in the way my husband want you to share and find code between each other. What I liked from Java, when I started working with it, was this pleasant selection of classes and functionalities, basic stuff surely, but stuff I didn’t have to rewrite. I could concentrate of the specificities of my project. After a while, I found things that could be improved, I created generic code that could have been shared. As a university student I would have gladly shared my code for free. But the thing is: even if there are ways to do this, they are awkward to use, and chances are that even if there are people searching for what you did, nobody will actually stumble on it.

Now that I’m in “the real world”, I see some basic needs not been satisfied and everyone doing the same solution on their side. Company want their people to create functionalities in their software, stuff that they can write on the box or their website to sell more, not to write once again a set of basic containers, ordering algorithm and so on. Some will use STL, but for many, it won’t fill the exact requirement, and will prefer to rewrite everything. For some more specific things, they won’t even bother to look if it already exist, because even if they found something claiming to be what they want, they could never be sure of its stability.

I just wrote a lot about the problems, but what about the solution? All start with a nice comfortable interface for the basic needs, with the source control fully integrated into the coding interface. When starting with C3, a new personal branch is created for you so you can have fun and create your application in your own sandbox. You already benefit from the backup service from the source control without making more efforts. If you need a library, you can start searching with a powerful search engine, if your need is shared you will find something close to them, and import it into your branch and customize it if necessary. If your need is less casual, you will want to implement it. Using a promoting system, you will be able to tag your library as in progress and keep it to your personal space or spread the word identifying your library as ready to be released to the word. Beyond a certain point, the community becomes responsible to rate the code base and mark the buggy ones from the achieved ones.

For companies, the formula change a little. Should they choose not to divulge their code, they could buy a server that would serve as a proxy as well. You could even choose to sell support for your library, which would increase its rating.

Many aspect of this, like the rating system, the interface, or the integration with the source control, are worth to be talked in details and will make object of many posts to come. In the near future, I want to concentrate on the language itself because it needs to be a lot more complete in order to implement this system. What bigger test would it be for the language than to implement its own programming environment!

First impression

We finally found an wireless connection at the hotel, this should make update easier; and my mother-in-law more comfortable. I understand that she was worrying after a full week of silence.

I show this site for the first time to three programmer friends this morning, here is what they said:

  • Will it support web programming?
  • Can I write the first book about C3?
  • I’ll talk to you later, I’m late for class!

About web programming, the language itself is designed to support mostly everything we know of, including web-oriented programming. The real answer would be: when someone implement support for it, it will become available. Some basic web functionality may be developed early in the process or maybe a javascript backend, but we aren’t there yet. In fact, the web may have changed a lot by the time C3 becomes mature enough to make full support of it. If you are interested in implementing this for the C3 community, you should be able to do it soon!

The first book about C3 will be written by myself, or so I hope! My husband is already writing more technical things on the side but I won’t publish them for now as too much things are still changing. After a bit more discussion, my friend agreed to write the first “C3 for dummies” which is fine by me!

And finally, my student friend is clearly too satisfied with Java to be interested in C3, ah ah, I’m kidding. Still, we are aware that there is many thing to build before entering the competitive world of programming languages. While my husband is working on the core aspects, the main interest remains the creative process of designing a programming language.

Starting to write about C3 has been a powerful kick off for this project which had been standing by for too long. Each answer he gives me opens new doors for other questions. I haven’t been far in the language description so far but don’t hesitate if any question crosses your mind, I’ll be happy to ask my husband!

Last note: english is a second language to me, don’t hesitate to point me any mistakes I could have made.

Now with husband: What is C3?

Seems wifi in rooms is not a standard thing in mexican hotels, I brought my computer with me but you’ll be reading this with a small delay. We had an amazing wedding, our family and many friends helped us into making this day a perfect one. But let’s skip those romantic girly memories of mine and head straight to main course: what is C3?

There are two principal aspects to the C3 project, the language and its programming environment. On the first approach, the language itself is similar to C++ in the fact that the syntax is C inspired and that C3 allows multiparadigm programming. C3 would be the natural evolution of C++, my husband feels that it is a very good language, the best achievement so far, but still, some improvements could be done, major ones. Many concepts in C++ were patched up a long time after its first design, which makes their implementation mostly suboptimal and sometime awkward. Some features are not even implemented in some major compilers because of the complexity of integrating them while maintaining others. Redesigning the whole thing will allow us to keep all those things that made us love C++ in the first place, and make major improvements in that same direction: flexibility, performance, control.

The C3 syntax is mostly a clean-up from the C++ syntax. One major improvement is on the declaration side. Making a simple declaration in C++ is a very easy thing, but when complexity comes, things quickly becomes to feel less natural. Pointer, reference and table symbols; do I put them before? After? In between? So many opportunities to be wrong. This is something C++ inherited from C. The original idea was that it would be great to have a declaration identical to its use. On the other hand, this is a nightmare to parse, and in the end, the declaration doesn’t look that much like the way it’s used. Even the creators of C now acknowledge that this has brought more problem than it has solve any. But stepping away for this long legacy still have a major drawback, it will not allow syntactic retrocompatibility with C and C++.

The flexibility of a multiparadigm language is essential to my husband. The C++ have been the best so far in that way. Other languages often try to be a representative of the purity of one paradigm or another, and mostly fail. One size fits all isn’t the most comfortable of sizes, different problems need different types of solution, and when facing complex situations, the best solution is often a combination of methods. All four C++ paradigm will be supported in C3

  • Procedural programming
  • Data abstraction
  • Object-oriented programming
  • Generic programming

But why stop when you can do more! There are two other paradigms that he wants to support: metaprogramming and functional programming. But the true goal would be to support paradigms that are still unknown to us. This is what good design is: to be used in a way it wasn’t intended to be in the first place.

I haven’t cover half of it but it’s enough for today, we are leaving to see Chichen Itza very early tomorrow. Maybe this will add a bit of mayan inspiration to C3, who knows?