Wednesday, July 22, 2015

Crack 0.11 Released

I am pleased to announce the release of Crack 0.11.  Enhancements include:

  • Allow importing crack.compiler outside of an annotation.
  • Fixed casting so we can now correctly cast from secondary bases and even cast across bases.
  • Added crack.protobuf.ann, which provides an annotation to allow you to expand inline protobuf messages into generated code.
  • Streamline generic serialization (only serialize file name and line number when they change).
  • Enhancements to jack and alsa modules, made alsa extension more OO.
  • Lots of smaller fixes and enhancements.


Thursday, July 16, 2015

Moving to github

Sadly, googlecode is shutting down and we needed to find a new home for Crack.

I've been a long time fan of Mercurial (I think I was using it before git existed) but I seem to be in the minority in that.  Most Crack contributors appear to prefer git.  There's also a huge community that's developed around github.  So, given that our current project hosting is going away, this seemed to be a good time to convert entirely to git and relocate to github.

In truth, I've been running the project out of git for over two months now.  I migrate changes to the mercurial repo on googlecode whenever I push, and I expect I will continue to do so for the foreseeable future, but the repository in github (crack-lang/crack) should now be regarded as canonical.  Patches to the codebase should be sent as pull requests or as git patches generated by "format-patch".  We will no longer accept requests to pull from a mercurial repository.

Hopefully we'll get around to replacing our home page before googlecode disappears entirely.

Friday, July 10, 2015

Protobuf Annotations

We've had a module to deal with protobuf wire protocols for a while now (crack.protobuf), but you've always had to code your message serialization by hand.  Not any more!

I've just checked in crack.protobuf.ann, which is an annotation that allows you to define protobuf message definitions inline and generates the appropriate code.  So, for example, this:

 @protobuf {
    # Uncomment "debug" to emit the generated code to standard output with
    # line numbers.

    message Bar {
        repeated string name = 1;

Generates this:

class Bar @impl Message {
     Array[String] name = {};
     oper init() {}
     void serialize(ProtoWriter dst) {
         for (item :in
             dst.write(1, item);
     void addField(Field field) {    
         if ( == 1) {
     int cmp(Bar other) {    
         int rc;
         ((rc = cmp(,
         return rc;
     int cmp(Object other) {
         if (o := Bar.cast(other))
             return cmp(o);
             return Object.cmp(other);
     uint makeHashVal() {    
         return makeHashVal(;
     @static Bar makeFromField(Field field) {
         Bar inst = {};
         return inst;


As protobuf generation goes, this isn't all that great.  For one thing, it would be much better if we could just generate crack code from the proto compiler like everything else and then we could use the same .proto files as everything else.  The implementation is also very incomplete.  It only supports the int32, int64, string and bytes types (and int64 is currently broken) and it doesn't support any protobuf syntax that is even slightly advanced.  That said, it still beats coding the serialization by hand.