Feb 6 2010

How much can we tell about an unreleased project?

We are closing in on our one year wedding anniversary, or paper anniversary as they call it. For this big event, I was planning to write a full description of the C³ experience. I asked a lot of questions, draw diagrams, wrote a very long article. I was very excited because when I start reading myself, I felt that we had a very innovative concept, something that would improve the experience of programming for all. But then I started to have doubts, how can I be clear enough that this is an intention, a dream, and without creating expectations?

Marketing

We cannot deny the importance of marketing. In video games, statistics show that marketing influence sales three times more than ratings. These numbers probably vary depending if you are aiming at mass market or a niche of specialized people, but the first impression you do is always important, no matter who you are targeting.

I worked on many projects that had huge marketing budgets. For all those, we had to keep quiet on what we were working on until the marketing reveal. This moment usually happens quite close to the launch which means most of the job is already done when the world learn about the project. The team usually have a hard time about this, you are very proud about this very amazing project you are working on, and yet you cannot talk about it to anyone. “The only thing I can say about what I am working on, is that it is incredibly fantastic!” We do show our work to selected people in order to get feedback, focus tests, but this is rigidly controlled not to interfere with the marketing reveal.

Reality is, this is necessary, you want your project to be hyped as much as possible. You start with a big reveal, then you maintain, and attempt to rise the hype until the product is truly available. If you cannot maintain the interest in your product, you start falling. Apple have been a very good example of this in the last few years, launching their products with a big boom, creating as much hype as they possibly can. Well timed hype translates into sales.

“A (…) problem: The company sells the visionary project before it has the product. This is a version of the famous vaporware problem, based on preannouncing and premarketing a product that still has the significant development hurdles to overcome.” -Crossing the Chasm, Geoffrey A. Moore

I have seen many project trying to create a hype too soon and missing the wave. Some games that were presented at my first GDC in 2006 have a hard time getting credibility when they aren’t completed four years later. My personal reaction is that their game got to be amazing because my team got a fraction of this for our own work, and we still manage to make great stuff. I imagine that the general customer simply forgot about it, and is mislead into thinking that it is an old thing that he just missed when it came out.

Even worst are the projects that are hipped but never see the light of day. In life, many projects get cancelled. Believe me, it happens all the time. People starts working on something, but things change, the project becomes something else, or the team simply starts over on a new concept. If nobody knows about it, you waste some time, but if you are already public with it, you also add shame on your name. You end up spending a lot of energy to justify yourself to a lot a people that don’t matter that much, and your reputation goes down. Easier to crash down a credibility than it is to raise one. Even if you have very strong creations in you port-folio, you aren’t protected from this.

Talking about a personal project

So I imagined that C³ would be different. It is a personal project, not some block buster anyway. Following the creative adventure of my husband helped me renewing my love for programming, and push myself learning new stuff. I love writing, why not write about it? Most comments, from friends or on the blog, have pushed us forward in our reflection, shaping the project into something better.

When I started, I never anticipated any problem writing about anything. My husband didn’t agree with me. Many of the concepts we were talking together were early into development, and subject to change. “Won’t people judge us if they see we are changing our mind all the time?” Not only do I think it is normal for ideas to change, I believe it is in the nature of great project to iterate on them. I am fascinated by the creative process. This is exactly what I wanted to talk about: how a project evolve, how the vision refine itself, ideas that shape themselves with the various challenges, new discoveries that add themselves to the big picture.

I was seeing myself as some kind of journalist, I though it would be obvious that I was following a creative process. But my enthusiasm led me to write a lot about C³ in a descriptive and somewhat “selling” way. I cannot claim neutrality, I care for my husband, I care for his project. No matter how I try, my words become some kind of marketing involuntarily.

I first become aware of this when my former schoolmate Michel talked about C³ as vaporware. I was disappointed at first, I though I had failed to make it clear that this was the documentation of the process, and not an actual reveal. Now I realize that this is impossible, as soon as you start talking about something, it is a reveal.

Compromise for the best of both world

So comes the dilemma, either I just don’t care about it and continue talking about it. Too bad for those who think we don’t have credibility because we don’t publish anything. They should know that creating a programming language takes time. Or I start writing behind closed door, showing my stuff only to chosen people. Closing ourselves from potential feedback and suggestions.

All this may seems obvious from the outside, but it wasn’t for me. But now that I am aware of all this, I cannot unseen, and have to take a decision. C³ is an ambitious project and we will need all the credibility, and hype we can get when the time comes. How can I keep from creating unnecessary expectation, raise my credibility while getting maximum feedback at the same time? I also want to keep on writing and drawing for the fun of it!

I don’t have a simple answer for this, but I do think of a few approaches on the subject that I feel wouldn’t interfere with the project while attracting constructive feedback.

First thing, I should go back to my primary idea of documenting the creative process. As a manager, I develop a strong knowledge of this in my day job, and I choose that way because I have a passion for it. Talking about challenges, how we overcome them, methodology and tips are interesting things to share. By nature they apply to various types of projects, thus it can reach a wider audience. This is also a nice way to get feedback on how to face certain situations. All this without really talking about the nature of the project itself.

I also realized that when we get challenged, it is more about our view on a certain topic, than how it really translates in the C³ design. Our opinions are shaped by our experience, I find it interesting to challenge my conclusions and seek advice from people that have a different background than me. I am very confident in my beliefs, but there is nothing like a good fight to improve them and make them stronger. I feel I should continue talking about our opinions, without going deeper on how it translates into the project.

As we will approach release, I will want to be as transparent as possible, describe with great details how things work, and why so, but only when the design on those aspects are complete. This is necessary to build a relationship based on trust, especially if we go open source and and want people to contribute. For now, things are evolving too quickly to spend energy on describing publicly something that is destined to change.

And then I cannot turn my back on this long article, exhaustive description of the project, a first draft documentation. I think it is necessary to write this in order for the project to go forward at an optimum pace. But now I realize I don’t have to publish these, they have to be written for ourselves, to clarify our vision into words. Maybe we can use them in focus tests. So no pressure to publish everything I write as soon as it is complete, leave space for iteration in the writing as well. The world can wait.


Dec 10 2009

Ancestors of C³

c3wifepyramidWe had a very slow week-end. Some friends came home saturday evening, and we went to sleep after too much food, wine, beer and video games. No wonder why it was so hard to get out of bed Sunday morning. So instead of getting things done, we spent some time together, talking about C³ on the pillow. Alex was telling me how existing programming languages were inspiring him and making things possible for him. He suggested I wrote something about it. I thought it was a very good idea.

C³ doesn’t intend to change everything, on the contrary, my husband want to take what is best in the already existing languages and bring that to the next level. Reinventing the wheel is not about starting from scratch, it’s about learning from the past, taking advantage of the tools you have, that your ancestors didn’t, and innovating at the same time.

Low-level inspirations

An inspiration I didn’t expect was LLVM. We have coded in C and C++ for so many years, those languages infused themselves into our mind. But LLVM has been in our live since so little time, and we haven’t really coded with it, and yet it seems to be an important source of solutions for problems he had earlier this year. Almost too good to be true.

The first thing that came to mind was that LLVM makes a perfect back-end. It fits the requirements: low-level enough to provide performance and control, and a special attention to performance as well. The C³ compiler code is planned to be flexible to support different back-ends, but it seems very likely that LLVM will be the first one.

But LLVM is not only a tool, its implementation contains some nice things too. The analysis and optimizations that LLVM makes on the SSA form (Static Single Assignment) is very inspiring. The algorithms behind this are very powerful and my husband want to adapt them for his own optimization system, or in short, apply them for high-level types. The list is very long, but to name a few:  ”Dead-code elimination”, “Constant propagation”, and “Combine redundant instructions”.

Good old C is also an inspiration. To be more specific, he really likes the way the abstractions of the language directly map on the different modern computer architectures. As he mentioned in his latest notes: the flexibility of a set of native abstractions (that may change between target machines!) may be the core element that will allow C³ to be the bridge toward the next generation of computers.

Syntax and types

I talked a lot about C++ as an inspiration. One feature of C++ that he wants to push beyond its current boundary is the ability for the user to create his own types. What he wants is to make user-defined types first-class citizens of the language. Int, float, long and double don’t have to be special cases. The language architecture is done in a way that allows every type to be used without additional limitations, optimized as much as intrinsic types would have been.

The C++ syntax is a familiar one but flawed in so many ways, especially the type declaration syntax. Bjarne Stroustrup admit himself that he kept it this way only for backward compatibility with C. It is a mess to parse and some contradictions have led to many debates: do I put my * with the pointee type or with the pointer name? But yet many languages like Java and D continue to use it as an inspiration for syntax, C³ as well. The reality is that the C++ syntax contains everything necessary for a good syntax and people love it! It just need a good clean-up. My husband describes the C³ syntax as a “naive” version of the C++ syntax, which means what you would think the syntax is intuitively instead of the one you discover in the field.

Multiple paradigms

Having multiple paradigms is a major aspect that my husband want to push farther. Being able to mix and match different programming styles with the same language is a rare quality that we love in C++. Some believe in purity of style, we believe that the right toolbox has a variety of tools that cover most situations, and even allows you to build your own!

One of these tools is generic programming. In C++, it is a powerful but complex style. Templates have allowed for this to be possible by decoupling the algorithms from the data structures they are processing. Inspired by the writings of Alex Stepanov and his work on STL, my husband intends to make generic programming something more intuitive, for example with the unification of static and dynamic polymorphism.

My husband often says that functional programming is an important part of C³ with the use of functions and closures. In C³ it is done with a “function” type that allows functions to be assigned to variable (that means support for closures as well). When I think about LISP, I think about parenthesis. But reading the essays of Paul Graham, I have to admit that functional programming can often be the best tool for the job, especially if the syntax is made convivial. An unexpected inspiration that has lots of potential.

Not only does he plan the unification of static and dynamic polymorphism, he is planning the unification of imperative and functional programming as well, isn’t it interesting…

So many…

Each of these elements would be worthy of a post by themselves, and there are so many other inspirations, aside from those we are not even conscious about! Great languages already exist and we have so much to learn from them. I find it very exciting to delve in this complex but so fascinating field that is programming language design. And just in case you worry about the impact of all this in our couple, we do talk about C³ often but we still try to get some things done, we are almost over with the wedding thanks cards. I know we are very late on this… Better late than never!


Nov 27 2009

The excitement of anticipation

c3wifeelevatorIsn’t it exciting when you know you are one step away from something amazing? Like tracking a precious package in the mail, or waiting for your plane to land in some exotic location. I feel just the same way about C³, especially recently. My husband has been working like crazy each night and his plan is becoming clearer every day. Each morning we walk together toward our day job office and we talk about programming, most of the time about language design. I learn a lot from those conversations but I also get a connection to the grandiose project growing in his mind. But you would be right to ask yourself when you will be able to see anything at all.

Being a big fan of Scrum, and using it for the team I manage daily, I consider important to ship early and often. C³ should be no exception to this mantra, but a programming language is quite more complex than the common web application. Getting to the point of a small basic subset of features will still take time, especially as this is done part time by a single human. For this reason, I cannot give a calendar based answer, but I can tell you about the plan.

To decide how many features is enough for a first release, and which ones have priority, you have to know your “client”. We believe that the base design of C³ gives it the potential to please “everyone”, but a first release can hardly reach that goal with just a subset of the language. So what’s the best thing to do then? I think: “Start by filling you own needs, chances are you will please others that have similar goals.” And as he defines what he wants, we see other programmers that crave for the same things everywhere, on forums, on blogs, in books, among our friends. People asking how to solve a problem where the best answer would be “switch to C³”.

So what is that “kind of programmer” exactly? We work in an industry where performance is the key, on projects with large code bases. Many programmers continue to work with old languages like C, even with all the problems and limitations that we know from those languages, because the more recent languages have made compromise in areas where they cannot afford to loose. Those programmers prefer performance, flexibility and control over ease of use and embedded feature. We believe that the early versions of C³ can satisfy this public with something simple, but well executed. “Simple” is probably an understatement, he wants to release a compiler that can do as much as C does, no less. Support for all the basics of a programming language, with an implementation that provide performance at run-time. We have to keep in mind that this stereotype of programmer is an autonomous quick learner but is also very intolerant toward instability and slowness.

The support for more high-level concepts will come afterward, but their development is already being anticipated, so they will be integrated naturally in the language. In which order, this has yet to be defined, but having a complex project to try it on seems like the best idea. We have yet to decide on a specific project, many are in the air: from obvious like creating a benchmark, to very audacious like porting Linux. He often jokes about that last part, but I feel he thinks it would actually be possible (but would require a C converter to make the task manageable).

One thing is certain, the first step is the biggest to make, the anticipation of this moment is a mix of excitement and fear. He is driven by his passion, but also hope. Recent announcement of the Go language could have broken a dream, but on the contrary, it confirms that there is a need for new languages, that there is still place for improvement in this field. Go can be use as an inspiration but is also very different from C³. My husband’s project have so many genuine ideas and concepts that I continue to anticipate a revolution.


Apr 23 2009

Tough love: the programmer love-hate relationship with her languages

the-design-and-evolution-of-cFor the first time since the wedding I was away from my husband, we were both visiting our family for Easter. He wasn’t there to “brainwash” me about his project, but convinced me a few days before leaving to read The Design and Evolution of C++ by Bjarne Stroustrup.

The motivations behind C++

I’m just starting chapter 2 (which is the third one, the first being chapter 0 of course). I found out that the motivations to create C++ were founded on this love-hate relationship he had with Simula, BCPL and others. Even though he doesn’t want to compare his creation to other modern languages, he doesn’t hesitate to criticize vigorously those he used before. Here are some excerpts: Pascal gets no love, but it isn’t clear about the others.

“I had found Pascal’s type system to be worse than useless – a straitjacket that caused more problems than it solve by forcing me to warp my design to suit an implementation-oriented artifact.
(…)
The feature of Simula were almost ideal for the purpose, and I was particularly impressed by the way the concepts of the language helped me think about the problems in my application
(…)
The implementation of Simula, however, did not scale the same way. As a result, the project came close to a disaster. My conclusion at that time was that the Simula implementation (…) was inherently unsuitable for larger programs. Link time for seperatly compiled classes was abysmal (…).

BCPL makes C look like a very high-level language and provide absolutely no type checking or run-type support.
(….)
I swore never again to attack a problem with tools as unsuitable as those I had suffered (…).”

Different state of mind, different languages

Some languages, like lisp, are creation of design and purity. These are interesting for the intellectual stimulation, but rare are the people that use them in real life (or happy to do so). Like a nice, but small, canvas in which you can only express a part of yourself. After all, lisp was design to express mathematical concepts and not to communicate with a machine.

There are also the “design by comity” languages. Composed by a team of designer, based on compromise, the result is a hybrid between different style. Having keyword for mostly anything is a big sign of design by comity because it is easy solution for a group of people to agree on. Usually the result can do a wide range of things but doesn’t perform well in any of it. COBOL and ADA are two examples, I don’t know anyone who have a really positive opinion about those.

I have the feeling that real life experiences forge language design oriented toward well… real life. When you have to face a wide variety of problems, went to the limits of your favorite languages, you develop a devoted love for the good things, and a growing frustration for those itches, especially if you have an idea on how to fix them. Programming language designers that falls in this category tend to create stuff people are more inclined to use (or love using).toughlove

My own love story

Under my last post, my friend Michel‘s comment was right. I am very harsh against garbage collection, and virtually everything counter performing. This is probably a professional deformation. After a few years coding with performance as a priority, it’s hard to quit. In fact I don’t want to quit, this has made me a better programmer.

My first serious experience with code was with C++. It wasn’t an easy gal, took a while to master the basic concepts. What really hook me up was the wide range of possibilities. I had frustration with the sometime non-intuitive ambiguous syntax, with the compiler’s bugs and performance, with ugly Microsoft stuff like MFC or COM; but I never felt limited in anyway. Controls, physic simulation, graphic, AI, photo processing; I went deep down many of those and the only limitation was the time I had to code. Would it have been easier to use, I would probably spend more time thinking, less time coding. But I still prefer flexibility and control over ease of use.

I loved my experience with Java when I was at university, easy to learn, quick to make simple stuff. But when I got into more serious programming, it couldn’t match my needs. I had outgrown the language. Mostly the problem was performance and control. But I also had some design interrogation, for example: why do I have to make a class even when it’s not the right design?

I always had a passion for assembly and down to the metal languages. You totally have the right to judge me crazy on this. I’m not sure why I love them so much. I agree with their reputation, hard to master and it takes a lot of time to do something with it, no matter how simple. They are extremely non-portable, hence I learned a few: x86, Motorola 680×0, but my favourite was VHDL. Programming directly the controller behaviour, managing directly the electric current, how much closer can a programmer get to the machine? You know you are low level when you have to manage the impact of the laws of physics on your program. While doing this slow pace programming, I developed an unconditionals love for the machine and its complexity. I now must reassure you, my husband is not as crazy as I am!

Impact on the C3 design

My huband programmer love story with C++ went a lot farther than me, metaprogramming with templates and stuff like that. The C3 design doesn’t compromise on performance for the exact same reasons that Stroustrup had when building C++. Similar background, similar conclusions.

Having multiple paradigms is probably the only way to allow programmers to fully express themselves. Like he said, each paradigm has its part to play, but it is their combination that really make thing lift off. Supporting a wide range of styles doesn’t have to make programming difficult. Nice design, behavior that default the correct way (that can get overridden should you need), simple and clean syntax: many elements that can give birth to something as easy as java to use (even easier), but as powerful as C++. Although, easy on the user side doesn’t mean easy in the compiler implementation.

Easy for me to say all this, nothing of this truly exists yet. But when we talk about it (everyday, even in bed before sleeping), I feel he thought of everything, now polishing on aspects I wouldn’t have imagined. I’m not usually easy to impress, I challenge him on every aspect I learn about. I hope this will help improve things. Unlimited passion… all this because we love and hate our programming languages. I feel my relation with C3 is going to be a wild one!


Apr 7 2009

The value of values

or Why value-based programming is not a bad thing!

Working on values was implemented in C++ to maintain compatibility with C. Bjarne Stroupstrup also invented RAII, a method that ensure that resources are acquired correctly, and also properly released. This is more intuitive to beginners, and honestly, this is what we want to do most of the time; keeping pointers for when we really need them. c3wifegarbage

Values and references both have their uses and patching the nonexistence of value-based variables with a garbage collector makes your programs slow and less predictable. Even with the optimization made to garbage collection algorithms and the increase of computer performance, many applications need to minimize overhead and cannot afford to lose on something that can be done at compile time. There is also the predictability of a garbage collector. The ones I worked with had a non-deterministic nature, the memory gets cleaned up, but it’s hard to know the exact moment. Sometimes life depends on a program, some applications in space or health care cannot afford randomness. Serious programming often requires performance and predictability. It will be possible for someone to add the possibility to use a garbage collector, but it shall not be a necessity in C3.

Anyway, garbage collection doesn’t make your program leak proof, if you make some complex cycles (a pointer pointing on something that is pointing to the original), chances are that it won’t be detected, leaving a nasty leak while the programmer have been used not to care about those things. There are so many things other than memory that has to be managed, memory doesn’t have to be a special case. Examples: network connections or OS resource handles . Why assume the programmer is an idiot that needs to be protected from herself? Good design doesn’t prevail by limiting control, especially in a creative tool like a programming language.

The solution is to make the use of objects, both as value or reference, easy for general application and leave the door open for a meticulous management. Using value-based programming is easy in C++ and will continue to be in C3, thanks to RAII. Using pointers in C++ have a reputation of being complex, but it becomes an easy thing if you are using smart pointers. Most of the time, there is two ways we want our pointers to behave: non-copyable pointers, and reference-counting pointers. Non-copyable pointers simply disallow multiple pointers to the same object. Reference-counting pointers keep track of the number of pointers to the same object. Both know when the pointed object is no longer necessary and deletes it at this moment. No need for complex manual management! Another example is a clone pointer that makes a copy instead of pointing to the same item when copied. Other more custom pointers could also be used. This is where the serious programmer is free to push thing down to the metal.

Having smart pointers being part of the language standards allows making other simplification for the user. In C++, not redefining constructor, destructor, copy constructor can be a dangerous thing if your class contains pointers. But in C3, the default behavior will most probably be the one you need because the type of pointer you use define its behavior in those situation. Basic language functions won’t return raw pointers (like C++’s new operator). Other operators could be generated automatically correctly, like operator==, which isn’t the case in C++. My husband recently answered this question after seeing it on stackoverflow.

Why don’t C++ compilers define operator== and operator!= ?

IMHO, there is no “good” reason. The reason there are so many people that agree with this design decision is because they did not learn to master the power of value-based semantics. People need to write a lot of custom copy constructor, comparison operators and destructors because they use raw pointers in their implementation.

When using appropriate smart pointers (like boost::shared_ptr), the default copy constructor is usually fine and the obvious implementation of the hypothetical default comparison operator would be as fine.

So this is how memory is never stack as a pile of garbage, waiting for another process to collect it. It just manages itself in a very easy way and the serious programmer continue to be free to invent new ways to manage his pointers. Memory recycling itself without more efforts. The simple programs continue to be easy of implementation, and the programmer gets flexibility, performance and control for all possible applications.

Husband ‘s note:
C++ “concrete type” facilities were only optimized for small objects that are cheap to copy.
C3 makes value-based semantics easy and efficient, even for more complicated objects.


Apr 2 2009

Is creating a programming language an extreme form of Not-Invented-Here Syndrome?

c3wifereinventingIn my last article, I posted a link to Joel Spolsky‘s “In Defense of Not-Invented-Here Syndrome“. To justify modifications to a compiler is something technical that can be demonstrated in a non-subjective way. Creating your own programming language, can hardly justified the same way since there are so many languages already existing. Still I’m coming in defense of the language creation, mostly by describing my husband motivations.

The first motivation to any write any code for which you aren’t paid is fun, including compilers. If design is fun to you, there is nothing wrong trying to design a programming language. In fact, the exercise will make you grow up. Trying is the better way to learn, programming language design and compilers are two of the best ways to get down to the metal, into the deepest layers of the machine. Understanding how things work will always gives you a heads up compare to learning workaround by memory. This is true for programming, but also when learning English or French, or when operating a microwave (you can learn what not to put in it, and maybe forget, or you can learn how it works, and deduce naturally what is a bad idea to put into it.)

Still there is more about C3 than having fun. It sure began that way, but my husband has outgrown the educational purpose. It all starts with a dream of making the perfect language. Off course reality catches up, the more you program, the more you realize the complexity of the task. But the more you program, the more you see space for improvement. There is an amazing amount of programming languages out there, some are really good and we have a lot of respect for them, especially C++. But they all have a bunch little something annoying (sometimes big) which leave the door open for improvement and new discoveries. Closing the door would be a very sad thing for the sake of creativity, but pushing the limit farther: that’s an interesting challenge.

Identifying what doesn’t work is one thing, but thinking about an elegant solution is very different. Over the years, he had been collecting problems in languages he was using, each time challenging his design. But the good designer also has an eye for good design, even when it’s not own work. Experience is what shaped this dream into the refined reality of C3.

So here we are, he doesn’t intend to reinvent the wheel, C++ is a big inspiration in his work and those familiar to it should feel totally comfortable with C3. But he’s making it evolve, mostly by making the syntax leaner. This doesn’t make the language more restrictive. On the contrary, simplifying the rules will leave more space for innovation. Alongside come ideas to make the programming more comfortable with better tools and a dream of a more unified community of programmer (and somewhat of a plan on how to make it happen).

Back to the question, is this a Not-Invented-Here syndrome? Probably… But this is how evolution works right? If everything was perfect, there would be no need to improve it. Only the most innovative persons challenge the very basics of things.

So mostly that’s it, a programmer should start designing his own programming language for fun and educational purpose. Some people, like my husband, discovers along the way that the world could benefit from their innovative ideas and want to push further. There is a long way ahead to make this actually happen. Hopefully he isn’t alone, a wife stands by him!


Mar 29 2009

Why would someone build its own compiler?

c3wifecompilerneed1Many programmers live in a very fluffy world, where there is an API for everything, where a nice compiler takes all that nice code into something that the machine will interpret correctly. Others will go further, and hack their way through uneasy code. Only a few will come to the end of the darkness, where no compiler fits their needs.

I admit this isn’t a feature that is often required, but when you faced it once, you never want to go back again. Having to choose between making your own compiler and a big, ugly massive hack that you will regret for a long time, telling yourself “if only I had access to the compiler sources, I could change this one little thing and everything would be perfect”.

It happened to me once in my short career as a programmer, back when I was working on porting someone else’s application to a new platform. We were working on a library that handled the generic part of most of our tasks, not an unusual strategy. For each project, we received frequent drops of the client’s code, hence we wanted to minimize the changes to their code. In one particular project, we had a nasty crash, hard to reproduce: it took a while to happen, it seemed random, no specific reproduction step could be identified. The stack trace didn’t give much information of what it was, but we finally identified the source: the memory management system in the client’s code.

The client’s code used a memory pool, which is very common in these kinds of program. They defined a global new and delete in order to wrap everything into their memory managing system. This means everything we created in our library that used global new and delete (int, long etc.) was also getting managed by the memory pool. The buffers being at their limit, linking with our library was making everything explode. Blindly increasing the size of the buffer solved this problem, but created others. A brief analysis of upcoming projects shown us that a similar problem could happen again. We had to made our library “global new and delete proof”.

The clean solution would have been to create a new and delete specific to a namespace, but this is impossible to do without modification to the compiler. We didn’t have the budget or task force to buy or create the compiler, so we resign to another solution. We replaced everything with malloc, add a mention to the training program that new and delete were banned, and quit on integrating other libraries in which we couldn’t make this ugly modification.

There are many other reasons to build your own compiler. The Excel team at Microsoft had its own C compiler, allowing them optimizations not possible otherwise and a total control on their software. You can read more about this in this very interesting article from Joel on Software.

My husband want to make the compiler code open (the license has yet to be defined). Once he’ll bootstrap it, he’ll make it available to the world. An important aspect of C3 is that you should not find yourself limited by the language itself. You may need to work hard for something unusual, but everything should be possible (code-wise).


Feb 22 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 “cubic C”. 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.


Feb 19 2009

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!


Feb 19 2009

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) {
    {1}->Draw();
}

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) {
    pShape->Draw();
}

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

void DrawShape(Shape* pShape) {
    pShape->Draw();
}

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) {
        _action(*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.