Coding in Montreal near Lachine Canal
Envoyé de mon iPhone
C³designer's blog |
Yes, I'm C³wife's husband ;) |
Not much happened on this blog and c3wife's blog lately because I was back at work at Beenox for 3 months. They urgently needed someone for a specific task and I was happy to get back to work for a short time, giving me time to think about the next steps for C3. My sabbatical will be extended to December 2011, making it a complete year as scheduled.
Since my return at home, I worked on IPG and I decided that I would complete this project before continuing work on C3. I think the best thing to do now is to get things rolling as soon as possible. I hope to get experience with the dynamics of releasing open source software and hopefully accepting patches and interacting with users and collaborators.
IPG stands for "Incremental Parser Generator". The basic idea is to create a parser generator (such as Yacc or Bison) but with a few twists:
IPG was created to implement the following design choices for C3:
The current implementation generates C++ code. One interesting property is that the interface to traverse the parse tree is an STL-style iterator, making the client code very clean and terse. I will continue to work improving the interface and implementation but I will soon make a real first release.
Aims
C³ makes programming more enjoyable for serious programmers.
C³ is a general-purpose programming language that supports
– low-level programming
– data abstraction
– object-oriented programming
– generic programming
– functional programming
– metaprogramming
General rules
C³’s evolution must be driven by real experience.
Do the simplest thing that makes C³ better at fulfilling its aims.
C³ must be useful now.
Provide the best available implementation as a default for every feature.
Always provide a transition path.
C³ is a language, not a runtime system.
Provide comprehensive and customizable support for each supported style.
Don’t try to force people to use a specific programming style.
Design support rules
Support sound design notions.
Provide facilities for program organization.
Say what you mean.
Don't set policy.
Provide a mean to set policy.
Unleash large-scale collaboration.
Language-Technical Rules
No implicit violations of the static type system
Provide as good support for user-defined types as for built-in types.
Locality is good.
Avoid order dependencies.
Each individual feature must be easy to teach.
Syntax matters.
External tools usage should be eliminated.
All facilities have an interface in C³.
All facilities not directly supported by the environment are implemented in C³.
Low-level programming support rules
Leave no room for a lower-level language below C³ (including assembler).
What you don’t use, you don’t pay for (zero-overhead rule).
All implementation choices can be made by the user.
C³ allows mapping to any native environment.
I have been working on C³ for more than 5 months now. It was hard and slow in the beginning. Some people asked a lot about my progress and I did not have anything to show. It can be explained in part because I was focused on some other things in my life. It was a little difficult adapting to my new life but I now have a great pacing. I can separate what I did month by month:
In the last installment of my "husband's notes" series on my wife's blog (c3wife.com), I talked about new languages that add “just a little bit” of overhead and that have garbage collection and built-in types like strings and maps. It was a voluntarily general statement. Such languages include the D programming language (digitalmars.com/d) but of course I was thinking in particular about the recently released language Go (golang.org). Somebody asked me some questions about my opinion on Go, so here are my answers.
I was reading Paul Graham's RAQs and found this interesting paragraph:
Couldn't you add something equivalent to Lisp macros to languages like Perl or Python?Not without turning them into dialects of Lisp. Real macros need to operate on the parse tree of the program. To allow that in a language with syntax, you have to (a) make public the translation from source code to parse trees, and (b) give the programmer the opportunity to run programs on parse trees before they go on to the compiler.But it would be hard to do that without creating a notation for parse trees; and once you do, your language has become a skin on Lisp, in much the same way that in OS X, the Mac OS became a skin on Unix.
The way he explains the problem is great but the answer is, in my humble opinion, wrong. Why? Because it understates the importance of a good interface:
Do I want to use raw Unix on a daily basis? No.
Do I want to use Mac OS X on a daily basis? Yes.
The same goes for programming languages. As a great visual interface makes an OS easier to use, a great and expressive syntax makes a programming language easier to use.
A programming language that requires me to state operation priority for every single computation is wasting my time.
A programming language that considers the simple concept of sequential instructions a special case that needs special syntax is an abstraction barrier that I want out of the way.
If C3 is one day described as a skin on Lisp, I would probably take this as a compliment because I think Lisp needs a skin to be usable. But I also think that Lisp base abstractions are to high for an all-prupose programming language. I have great ideas for making meta-programming in C3 as powerful as Lisp macros but I will talk about it "when it's done".
.
About flexible vs fixed width for blog layout:
http://www.456bereastreet.com/archive/200504/about_fluid_and_fixed_width_layouts/
About little details that make a layout higher quality:
Michel Fortin posted an answer to this post about "values" in C3 from my wife. I was aware of most of the points made by Michel before his post but I guess I could say some words to clarify.
Is C3 vaporware? Yes, right now, it is. I was aware that C3 would be labeled like that when we decided to talk about it before writing a single line of compiler code (I did make a prototype parser in 2003 but nothing I can use in a real compiler). This is a great departure from the way I'm used to do things. I usually make sure that I show only finished and tested work. My wife and I decided that it was better to start a conversation with the developer community to have feedback as soon as possible. I'm still worried that the "vaporware" label will stick but I hope you will understand the dilemma.
I am a slow writer in english and I don't have much time. I decided it was better to spend my time actually coding the compiler (and necessary utilities) and refining the language specification. When my wife decided she wanted to help me in this project, her enthusiasm to document our experiment in an online journal was very welcome. Please keep in mind that she is trying to vulgarize this stuff. I could probably explain some details more thoroughly but that's not the point of her own blog posts. I will do from time to time (very rarely) in "husband's notes". The recurring pattern of these articles will be that they all contain C3 code (if the grammar change, I will go back and revise these examples). If I just want to talk about me or express opinions, I will do it here.
About RAII and garbage collection, optimizations that use garbage collection algorithms when we can afford delays in the release of resources will be possible in C3. However, the basic constructs of the language won't be dependant on garbage collection like Java, C# and D. I want to thank Michel for the explanation about the leaks in garbage collected programs and about the garbage collection techniques used in different languages. C3 is a meta-language which aim to ultimately support all these strategies and learning the details help me build the right abstractions in the language.
C3 will have the widest possible range of levels of abstraction. It will be both very low-level and high-level. That means that raw pointers that can point anywhere (including heap and stack objects) will exist in C3. They will be used as an implementation detail of other types of pointers but their usage won't appear more "integrated in the language" than smarter pointers. Their use in application-level software will be limited and not recommended but C3 will do as C do: trust the programmer.
To answer the last Michel question, I think that a non-managing weak pointer that becomes NULL when the object goes out of scope would be a good idea and would fit the requirement for a stack object pointer.
Thanks a lot to Michel for the feedback!