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