CL21

CL21 is an experimental project redesigning Common Lisp.

Features

  • More object oriented.
  • Add more functional programming facilities.
  • Organize symbols into several packages.
  • Include MOP.
  • Syntax for regular expression.
  • Written in pure Common Lisp.

Comparison

CL21 Common Lisp

(let ((name "John"))
  (princ #"Hello, ${name}\n"))
                

(let ((name "John"))
  (format t "Hello, ~A~%" name))
                

(defvar *hash* #H(:name "Eitarow Fukamachi"))

(getf *hash* :name)

(coerce *hash* 'plist)
                

(defvar *hash* (make-hash-table))
(setf (gethash :name *hash*) "Eitarow Fukamachi")

(gethash :name *hash*)

(let ((plist nil))
    (maphash (lambda (k v)
               (setf plist (list* k v plist)))
             *hash*)
    plist)
                

(doeach ((key val) *hash*)
  (when (< (length key) 2)
    (princ #"${x}\n")))
                

(loop for key being each hash-key of *hash*
      using (hash-value val)
      when (< (length key) 2)
        do (format t "~A~%" val))
                

(let ((query (dbi:execute
               (dbi:prepare *db*
                            "SELECT * FROM table"))))
  (while-let (row (dbi:fetch query))
    (princ row)))
                

(loop with query = (dbi:execute
                     (dbi:prepare *db*
                                  "SELECT * FROM table"))
      for row = (dbi:fetch query)
      while row
        do (princ row))
                

(use-package :cl21.re)

(#/^(\d{4})-(\d{2})-(\d{2})$/ "2014-01-23")

(re-replace #/a/ig "Eitarow Fukamachi" "α")
                

(ql:quickload :cl-ppcre)
(use-package :cl-ppcre)

(scan-to-strings "^(\\d{4})-(\\d{2})-(\\d{2})$"
                 "2014-01-23")

(regex-replace-all "a" "Eitarow Fukamachi" "α"
                   :preserve-case nil)
                

Motivation

Common Lisp has succeeded.

Dear Common Lispers,

Common Lisp has the most expressive power of any modern language. It has first class functions with lexical closures, an object system with multiple-dispatch and a metaobject protocol, true macros, and more. It is ANSI standardized and has numerous high-performance implementations, many of which are free software.

In spite of this, it has not had much success (at least in Japan). Its community is very small compared to languages like Ruby and most young Lispers are hacking with Clojure.

Why? Common Lisp is much faster than them. Ruby has no macros and even Clojure doesn't have reader macros. Why then?

Because these languges are well-designed and work for most people for most purposes. These languages are easy to use and the speed isn't an issue.

Is Common Lisp sufficiently well-designed? I don't think so. You use different functions to do the same thing to different data types (elt, aref, nth). You have long names for commonly used macros (destructuring-bind, multiple-value-bind). There is no consistency in argument order (getf and gethash). To put it simply, the language is time-consuming to learn.

Given this, how can programmers coming from other languages believe Common Lisp is the most expressive one?

Fortunately in Common Lisp we can improve the interface with abstractions such as functions, macros, and reader macros. If you believe our language is the most expressive and powerful language, then let's justify that belief.

We should consider the future of the language, not only for ourselves but for the next generation.

Written on January 26, 2014 by Eitarow Fukamachi.

Discuss about this

Have some ideas which make CL21 look good? Do you know more efficient way to implement those facilities?

Comments are always welcome. Join discussion at reddit or GitHub Issues.

Requirements

  • Common Lisp Implementation (SBCL, Clozure CL, GNU CLISP or Allegro CL)
  • Quicklisp

Installation


(ql-dist:install-dist "http://qldists.8arrow.org/cl21.txt")
(ql:quickload :cl21)
        

Updating


(ql:update-dist "cl21")