SBCL: The Ultimate Assembly Code Breadboard
pvk.ca
pvk.ca
Pure jealousy =]. People like to rag on lisp, but their language dujour just got what lisp's been packing for at least 20 years. Between the interactive programming model, compiling to machine code, real threading, macros, and many other features, it's the perfect secret weapon.
The threading APIs, however, are all different -- not necessarily in any deep way, but in incidental ways like function names and signatures. There's a package Bordeaux-Threads that provides a portable API layer on top of the various implementation-specific APIs.
Strong static typing? ;o)
core.typed - Type Clojure, but still not complete
Shen - despite its questionable licensing scheme, it is a derivative of Qi. Qi and Shen are very powerful types systems (not just Haskell, but think even more complex like Idris, Coq, Agda, etc). The original implementations, if you want irony, are Common Lisp. The caveat is Shen has been ported to other runtimes, namely, Python and Ruby. But SBCL is the preferred runtime layer for Shen's crazy type system.
Typed Racket - It is a Scheme, and people will throw things at me, but I think it safe to say static types for this subset prove Lisp family languages have the potential for robust static typing systems you hint at.
TL;DR: Strong static typing is not common (pun intended), but it is possible. I think what we want to see is Shen with a good license: a very robust type system with a Lisp, separate or library. Then, Lisp will be the one ring-language to rule them all.
Perhaps we can call this library or Lisp variant Precious, and its hipster vote can go through the charts.
* (defun foo (x) x)
FOO
* (declaim (ftype (function (fixnum)) foo))
* (defun bar (y) (declare (string y)) (foo y))
; in: DEFUN BAR
; (FOO Y)
;
; caught WARNING:
; Derived type of Y is
; (VALUES STRING &OPTIONAL),
; conflicting with its asserted type
; FIXNUM.
; See also:
; The SBCL Manual, Node "Handling of Types"
;
; compilation unit finished
; caught 1 WARNING condition
BAR
One could also declare the function signature first (perhaps in skeleton code generated by modelling tools). Then, if someone implements it incorrectly, the compiler will throw an error (again, SBCL): * (declaim (ftype (function (fixnum)) qux))
* (defun qux (z) (car z))
; in: DEFUN QUX
; (CAR Z)
;
; caught WARNING:
; Derived type of Z is
; (VALUES FIXNUM &OPTIONAL),
; conflicting with its asserted type
; LIST.
; See also:
; The SBCL Manual, Node "Handling of Types"
;
; compilation unit finished
; caught 1 WARNING condition
QUX
So, what else do you think Common Lisp lacks compare to more "modern" languages? ;)As for whether Common Lisp supports parametricity, I don't know. It might be one of those things that isn't difficult to implement on your own, like design-by-contract or AMOP.
For instance, I'd use C for embedded systems, tight control of memory, or building libraries I wanted to be used everywhere. I'd use Erlang for distributed programming. I'd use Haskel if I needed pure functional programming. I'd use Java if I had a team of 500 engineers working on an enterprise app.
For any other general-purpose programming, I'd probably pick lisp.
If possible, fire 490 of them, and switch to a saner language. Quintuple the salary of the remaining ten, and pocket the difference.
There are good reasons why hardware supports registers instead of a stack. However, given where x86 was at the time, the hardware designers of the time took the penalties because the gains to the software folks justified it.
Those choices no longer hold.
Are they any other usable compiled languages with a REPL?
I was part of the team that wrote the original Open Source implementation (under GPL terms) named OpenBIOS. The project now also hosts all kinds of other implementations that were later published under BSD terms by their owners (and had 10+ years of market experience under their belt at that time).
When FORTH started out, one of its differentiators was its live environment: you could test one step (part of an algorithm or similar) at the prompt, then define a "word" (= function) that implements it using the statements you tried, repeat until you finished your program using the words you defined earlier.
Erlang and Elixir, a new language for the Erlang VM with a different syntax, are compiled languages with REPLs. I also think about Scala and others for the JVM, but I have a feeling you do not think of those as examples because of the VM or the lack of native code compilation. I could be wrong.
http://www.insectnation.org/howto/problems-with-root
Really, IMHO, jumping back and forth between the editor and the REPL with constant reloading is a better approach than pasting things into the REPL. I remember when I was playing with Common Lisp, I would always have trouble keeping the code on disk and the code loaded into the REPL synced.
ghci Module.hs
*mess around*
:e *this opens Module.hs in vim, and reloads afterwords.*
*mess around some more*
It's the best programming work-flow I've found in any language.Then you're doing it wrong. Most people doesn't type directly into the REPL, they open up a separate buffer in Emacs and play in that. The REPL is just for small tests. There is no such thing as 'keeping the code synced'.
If you do things this way, the state of the running lisp interpreter depends on the entire history of the coding session. Each time you add a new definition, you mutate the interpreter's memory. There is no guarantee that the current state matches what you would have if you recompiled the entire system from scratch.
On the other hand, the usual style in Haskell development is that you write a function definition and then hit the "reload" key combination, and this makes the state of the repl exactly the match the contents of the file. It throws away the results of any commands you ran in the repl in the meantime.
(This seems like an interesting cultural difference, something like "Haskell/ML/Java/Scheme programmers think of a program as a text, Common Lisp/Smalltalk programmers think of a program as an OS process").
I haven't used either Distel or SLIME extensively enough to say if it's comparable, but it looks fairly similar.
What I think still sets Lisp and Smalltalk apart, is their environments at Xerox PARC.
We are still far from having back this type of live editing experience in more mainstream languages.
Plus, most don't implement Lisp's READ EVAL PRINT LOOP, but a simpler command line interface.
Take this simple example:
> (+ 1 "foo")
The value "foo" is not of the expected type NUMBER.
[Condition of type TYPE-ERROR]
Restarts:
0: [USE-VALUE] Use a new value of type NUMBER instead of "foo".
...
> 0<RET>41<RET>
=> 42
>- Create an interpreter library for language X
- Offer a GUI/CLI application using the said library
Not all repls need to work at function level like LISP does.
Google Cache seems to always try to load the images and hang for a while if the site is unreachable (not sure why, since if the site were reachable I wouldn't be on Google Cache in the first place). You can click "text-only version" in the top-right to stop that.
The blog is just a bunch of static files, so there shouldn't be any issue. This situation is really annoying; I'll figure something out soon.
Anyone get that old code to run today?
I have always thought think LISP/Scheme's "best" use is to write code generators (e.g., that output C or asm). I know there's at least one LISP/Scheme project that outputs C, so I know I'm not alone in thinking this can be useful.
FORTH has always seemed better suited to driving hardware than any LISP/Scheme.
This is some sort of bias perhaps. These are both very flexible languages.
What if historically programmers tried to use FORTH for "AI" and LISP as a "portable assembler"?
Then I guess the Burroughs B5000 and its ilk might have become a popular machine for AI research. We would have had Stack Machines instead of LISP Machines.
https://github.com/darius/tusl
P.S. If Dan Bernstein did write a Forth, I'd like to see it.
But there's also no shortage of big, slow, verbose languages designed for dummies.
Worse, these actually form the majority of the world's most popular computer languages.
When juxtaposed against that state of affairs, the small, terse, fast, flexible languages which do not insult one's intelligence could seem "exciting".
FORTH has that effect on me.
Check IOCC. And let me know if you do get it to compile.