166 points · by qwertyuiop924 · 10y ago · 64 comments
Work has been done to run it on bare metal too - a sort of LISP Machine in PicoLisp!
I think it should make it clearer whether you can actually use this and how. It seems to be run inside a VM and call C and Java functions. They advertise this prominently, but having to run both Picolisp and JVM does not seem very attractive to me. Can we use it reasonably without Java? Is it production ready? How fast is it? How old is it?
I think a programming language is hard to sell, so they should work on that a bit (if that's there goal, of course).
PicoLisp is written in C, or the 64-bit version in assembler. It is Posix-dependent, so you need to run it in Cygwin for Windows, although somebody is working on a platform independent version based upon Midipix to eliminate the Posix dependency [2].
The creator of PicoLisp, Alex Burger, created it for his own use decades ago. It has a built-in database and Prolog interpreter. It is very fast for an interpreted Lisp, and there are lots of examples on rosettacode.org.
It is fexprs-based instead of sexprs as far as I know.
I like it a lot, but since I am on Windows for my livecoding / game dev hobby, I have not gone too far with it. I am hoping the Midipix work takes off. I also run Linux on my notebook, but all of my work nowadays is on Windows. .NET Core might change that.
Most games still run on Windows, and the ones on Linux have compatibility issues across the various Linux distros.
There may be a glowing white Apple on most web-dev's notebooks, but my 3 year old Alienware plays games with a Technicolor LED show that would put the F&F film franchise to shame ;)
...I don't think that was what you meant.
Picolisp has fexprs, and it uses them quite a lot, but they replace macros, not sexprs.
I had been reading John Shutt's paper a day before this post, on what he calls vau calculus vs lambda calculus, where the Kernel programming language is used as an example implementation [1]. Very interesting take on fexprs given the arguments raised around them.
I mainly use Lisps for livecoding. I am currently trying to learn Extempore for livecoding. It has two languages: xtlang, a Lisp language that is strongly typed and compiled for close to C speed via LLVM, and a scheme for doing more high-level scripting stuff in the Extempore environment [1]. There are binaries available for all platforms. I run it in Spacemacs on Windows 8.1. It's very snappy, and powerful, for coding music/sound at the signal or note level, and it has OpenGL and Nanovg for graphics. Watch Andrew Sorensen rock it on YouTube or Vimeo - just search for Extempore and/or Andrew Sorensen. I hope there will be a way to distribute things created with it someday. Then it would be a kick ass game dev platform.
I tried Racket and SBCL briefly specifically for games. Both are very capable. I will probably go back to SBCL, since it worked well with SDL2, OpenGL and was fast on both my Windows and Linux boxes. CEPL is great for working with OpenGL in Lisp [2].
I would love to use PicoLisp. I almost did use it for a game jam, but you would need to create the game framework from the pieces it has, and again, the Posix / Windows issue. I'm really hoping for the Midipix solution. You can learn PicoLisp fast in a week or so by following along with the two great books - PicoLisp Examples, and PicoLisp Works. The PDFs are freely available on Scribd and the source code is available online [3][4].
Even Erlang is available as a Lisp - LFE, or Lisp Flavored Erlang, created by one of the original designers of Erlang, Robert Virding. Would be great for a game server with many connections. Elixir is becoming very popular but LFE has true macros, and why not, it's a Lisp! [5]
[1] http://extempore.moso.com.au/
[2] https://github.com/cbaggers/cepl
[3] https://github.com/tj64/picolisp-by-example
[4] https://github.com/tj64/picolisp-works
[5] http://lfe.io/
So how does evaluation work here? Why isn't (1 2 3) evaluated? Or is it not evaluated because 1 is not a function? In which case, is it not possible to create a literal list where the first element is a function?
> [...] as a special case - if the CAR of the list is a number, the whole list is returned as it is [...] This is not really a function call but just a convenience to avoid having to quote simple data lists.
Picolisp has a special rule for (literal) lists starting with a (literal) number, they're implicitly quoted instead of the CAR being interpreted as a function:
> if the CAR of the list is a number, the whole list is returned as it is
This makes more sense considering a second quirk of Picolisp: numbers can be used as functions, in which case they're interpreted as a pointer to the executable code to run.
And from what I understand Picolisp's execution model doesn't have special forms as such, rather function definition specifies whether they receive their arguments evaluated or not.
Its also not very performant, BUT you can call C functions quite easily, and you can embed Racket programs into your existing C/C++ programs.
(list? '(1 2 3))
;;; => true
(= '(1 2 3) (cons 1 '(2 3)))
;;; => true
(list? (cons 1 '(2 3)))
;;; => false
That's actually psychotic: if your lists aren't lists, than don't call them lists!Anyways, Scheme is the part of the lisp family tree that actually evolves, albeit slowly. The spec is minimal, so compatability between implementations is low. I'd reccomend either Chicken or Guile scheme to most people, as both have pretty good FFI, decent performance (Chicken's is better), and good libraries (for a scheme).
Racket isn't a Scheme, although it started as one. The official implementation of Arc runs on an old version of Racket, from when it was closer to Scheme (we should probably port it to another scheme at some point...). It's not really my thing, but you might like it, and it has some of the best library support of any lisp outside Common Lisp.
OTOH, you may like Common Lisp. Bits of it are idiosyncratic, and it's huge and inelegant, but it's a tremendously powerful language, and very well supported and documented. There are actively developed implementations, and the most popular is probably SBCL.
(list? '(1 2 3))
;;; => true
'(1 2 3) is, in fact, a list of 3 elements (= '(1 2 3) (cons 1 '(2 3)))
;;; => true
= is closer to equal? in scheme. The doc string for clojure.core/= explains this pretty well:
Equality. Returns true if x equals y, false if not. Same as
Java x.equals(y) except it also works for nil, and compares
numbers and collections in a type-independent manner. Clojure's immutable data
structures define equals() (and thus =) as a value, not an identity,
comparison.
Finally, (list? (cons 1 '(2 3)))
;;; => false
`cons` is defined over a sequence in Clojure, not a list. The doc string actually says this upfront "Returns a new seq ..." and the type of this happens to be a `clojure.lang.Cons`. To get add a value to a list, you would actually use `conj`, which conjoins a value onto a collection or sequence in a way that is specific to that collection or sequence. (list? (conj '(2 3) 1))
;;; => true
If you are dead-set on using lists for some reason (you probably want a different datatype in Clojure), you could always define: (defn cons?
[x]
(instance? clojure.lang.Cons x))
(defn list-cons
[v l]
(cond
(cons? l) (list-cons v (into '() (reverse l)))
(list? l) (conj l v)
:else (throw (AssertionError. "Assert failed: list-cons requires a PersistentList or a Cons."))))
If you really want a Lisp-style cons with pairs and such, you'll need to define that yourself. It's not hard, or particularly useful, but if you really feel you must... user=> (type (cons 1 '(2 3)))
#<Class@bc57b40 clojure.lang.Cons>
user=> (type (conj '(2 3) 1))
#<Class@6137cf6e clojure.lang.PersistentList>
user=> (seq? (cons 1 '(2 3)))
true
user=> (seq? (conj '(2 3) 1))
trueBut seriously, Clojure is designed from scratch to work well with the JVM, so if the JVM's where you live then Clojure is the obvious choice.
Wut? I understood as shorthand for 'What?' ;)