Announcing Clasp

Hello, everyone!

Click here for up to date build instructions

Today I am happy to make the first release of the Common Lisp implementation “Clasp”. Clasp uses LLVM as its back-end and generates native code. Clasp is a super-set of Common Lisp that interoperates smoothly with C++. The goal is to integrate these two very different languages together as seamlessly as possible to provide the best of both worlds. The C++ interoperation allows Common Lisp programmers to easily expose powerful C++ libraries to Common Lisp and solve complex programming challenges using the expressive power of Common Lisp.  Clasp is licensed under the LGPL.

Common Lisp is considered by many to be one of the most expressive programming languages in existence. Individuals and small teams of programmers have created fantastic applications and operating systems within Common Lisp that require much larger effort when written in other languages. Common Lisp has many language features that have not yet made it into the C++ standard. Common Lisp has first-class functions, dynamic variables, true macros for meta-programming, generic functions, multiple return values, first-class symbols, exact arithmetic, conditions and restarts, optional type declarations, a programmable reader, a programmable printer and a configurable compiler. Common Lisp is the ultimate programmable programming language.

Clasp has several features that make it unique and of interest to the wider programming community.

  • Clasp uses the LLVM library and has a built-in “just-in-time” compiler that generates native code that takes advantage of the fantastic LLVM toolchain.
  • Clasp exposes the LLVM C++ library within Common Lisp providing a rich, dynamic, programming environment for exploring the LLVM library and for writing new compilers that generate LLVM-IR.
  • Clasp exposes the Clang AST library and the Clang ASTMatcher library. This allows programmers to write tools in Common Lisp that automatically analyze and refactor C++ programs. Clasp can be used to automatically clean-up and refactor large C++ codebases!
  • Clasp has a built in C++ template library that makes it easy to expose other C++ (and C) libraries and make them fully available to programs written in Clasp-Common Lisp. Programmers can expose C++ classes as well as functions and class methods with a single line of code that provides the Clasp name and a pointer to the function/method. The “clbind” C++ template library works like “boost::python” and “luabind” and builds efficient wrapper functions at compile time to convert arguments and return types between Clasp and C++/C.
  • Clasp uses the Memory Pool System (MPS) a fast, compacting garbage collector by Ravenbrook. The MPS garbage collector guarantees efficient reuse of memory and provides near pause-less operation. Clasp also supports the Boehm garbage collector which is used for bootstrapping.
  • Clasp contains a static analyzer written in Clasp-CL that uses the Clang AST/ASTMatcher library to automatically write its garbage collector interface with the MPS (~15,000 LOC). This static analyzer serves as a prototype and a demonstration of the power of Clasp to analyze C++ code using the Clang C++ compiler front end.
  • Because Clasp is written in C++ from the ground up, common problems of interfacing C++ with other languages that arise from C++ name mangling, and C++ exception handling disappear.
  • Clasp builds on the excellent Common Lisp implementation: ECL “Embeddable Common Lisp”. Clasp borrows 31,500 lines of Common Lisp source code from ECL.

This is a “very alpha” release — it’s not fully tested. Clasp compiles and runs itself and its garbage collection static-analyzer. Clasp is not yet a complete Common Lisp – about 10% of the standard 978 Common Lisp symbols are not yet implemented. A faster Clasp compiler is coming soon – the current Clasp compiler generates slow native code that is about 100x slower than highly tuned Common Lisp compilers like Steel Bank Common Lisp. Currently Clasp builds on OS X 10.9 and Linux.

The Clasp project is actively looking for developers who want to contribute to this exciting open-source project. Future enhancements include – achieving full Common Lisp standard compliance, direct incorporation of C++ code within Common Lisp, a port to Windows, multi-threading (Clasp is single threaded at the moment) and incorporation of a new compiler (under development) that makes many language level optimizations. Our goal is to make Clasp the fastest and most capable dynamic scripting language for C++ libraries.

with best regards, Christian Schafmeister.

Links:

Link to Clasp github repository

Link to llvm.org

Link to ECL – Embedded Common Lisp

Link to Ravenbrook (MPS compacting garbage collector)

A Youtube video that I made that shows of Clasp C++ AST searching/refactoring

Advertisements

25 thoughts on “Announcing Clasp

  1. Hi Chris,
    it’s great your project is finally nearing release. I’ve been following it for some time now, and it sounds like the best thing since sliced bread to me.

    As you asked for comments about your announcement on irc, here are some:
    [WHAT TO SAY HERE? – I wouldn’t say anything here, the important part is in the second sentence. Or else say “…release of Clasp, a super-set of Common Lisp that interoperates smoothly with C++”, and mention the LGPL later, because, well, the license is the least innovative thing about this project.
    I would even say “Clasp, an implementation of Common Lisp …”, because some people might not understand “super-set”, and AFAIK, almost all implementations of CL are super-sets.

    “Future enhancements include […] integration of C++ code within Common Lisp,” – this might be misunderstood. Although I know what you mean, some people will trip over this, reading an announcement that promises C++ and CL interoperability and then in the end reading this as a future enhancement. The distinction between library interoperability and code integration might not be clear to some.

    Anyway, good luck with your release. I hope I’ll be able to contribute a little (what did I major in compilers for?), but time will be very short.

  2. Hi Chris,
    [Apologies if this is a repost – I don’t know whether this blog has a moderation queue or my comment was lost in nirvana]

    congratulations on the impending release of Clasp. I’ve been silently following it for some time now, and it sounds like the best thing since sliced bread to me.

    As you asked for comments about the announcements, here are some observations:

    [WHAT TO SAY HERE? – I wouldn’t say anything. What clasp is, is explained in the second sentence. I’d probably go for “[…]release of the Clasp, a super-set of Common Lisp that interoperates smoothly with C++” and mentioned the LGPL later. The license is not the most important or most innovative thing about this release.
    I’d probably also go for “Clasp, and Implementation of Common Lisp”, as not everybody might understand “super-set” in the context of programming languages, and AFAIK almost all implementations of CL are super-sets anyway.

    Near the end: “Future enhancements include […] integration of C++ code within Common Lisp”. This might be confusing to some. It should be clear what you mean, but the first part of this release talks about the great interoperability between Clasp and C++, and this might make it sound like this interoperability is a planned, but not yet achieved feature. I don’t know if something like “direct integration of C++ source code in Common Lisp files” might be better.

    Anyway, good luck with the release. I’d really like to contribute (what did I major in Compilers for?), but time is very short at the moment.

    • Bernhard,
      Thank you for these comments. I am new to WordPress and I just saw them. I’ll incorporate many of these suggestions.
      I’d love to get help with Clasp if/when you have the time. Keep me in mind.

      Cheers,

      .Chris.

  3. Can we have a binary distribution please? The build process looks a bit involved. This looks cool but doesn’t seem like it will be usable with iOS which is a bummer for me.

    • Jean,

      No, I haven’t considered it. My focus is on developing software for my research (organic nanotechnology). As I was writing Clasp I realized that it could be really useful for a lot of things. If someone wants to make that happen I’d be happy to work with them. Send me an email.

  4. I am a bit surprised by the factor of hundred (100x) slowdown when compared to other Lisp implementations (e.g. SBCL). Do you have an explanation? I would have guessed a factor of ten (10x) slowdown (which is often the slowdown of many Lisp *interpreters* w.r.t. compiled implementations. Also, many Ocaml programs have a factor of 3 or 5 between the interpreted (ocamlc + ocamlrun on the bytecode) thing and the native compiled thing).

    Or is that 100x just a typo?

    Thanks!

    • It all comes down to that the current compiler in Clasp doesn’t do any Common Lisp language optimizations like escape analysis. I was focused on just getting it working. The current compiler in Clasp is used to bootstrap almost all of the Common Lisp language within Clasp. Now that it is a pretty full featured Common Lisp and has CLOS we can incorporate a much more intelligent compiler. I didn’t bench mark Clasp extensively, but when I do things like load compiled/linked ASDF it takes 30 seconds when on ECL or SBCL it takes a fraction of a second. I put the 100x slower in the announcement because I wanted to be clear about what Clasp currently is. What it’s going to be when we get the new compiler is awesome!

  5. “Common Lisp is considered by many to be one of the most expressive programming languages in existence. [..] Common Lisp is the ultimate programmable programming language.”
    and
    “Clasp is written in C++ from the ground up”
    makes me wonder.

    • It’s written in C++ from the ground up, but at about eye level (where you usually find a brain) it is written in Common Lisp which generates LLVM-IR that is lowered to native code. There’s even some Python in there to scrape the C++ code.

  6. ” the current Clasp compiler generates slow native code that is about 100x slower than highly tuned Common Lisp compilers like Steel Bank Common Lisp.”

    begs the question, why not work on a C++ interface to SBCL rather then extending a not-so-highly tuned Common Lisp compiler like ECL.

    • I don’t use the Common Lisp compiler in ECL – not one bit of it. I wrote an interpreter to bootstrap and a compiler to bootstrap farther. I’m now integrating a very modern and sophisticated Common Lisp compiler that I think will beat the pants off of every other Common Lisp compiler out there. Stay tuned.

  7. […] By coder – April 11, 2016 11 5 Share on Facebook Tweet on Twitter (adsbygoogle = window.adsbygoogle || []).push({}); (adsbygoogle = window.adsbygoogle || []).push({}); Video is ready, Click Here to View × — Update Sep 29, 2014 — I released Clasp – a Common Lisp that interoperates with C++ and uses LLVM as the back end! Announcing Clasp […]

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