News for hackers. Stuff that matters.
Re:How to write Common Lisp in 2017 – an initiation manual by hydandata on Tuesday March 28, 2017 @05:49PM (#13981037)
I started a big project at work using Common Lisp in 2017 and could not be happier. Sure, most nice features have trickled down to other languages, but they are rarely as nicely integrated. And Lisp still has many advantages that are not found elsewhere: Unmatched stability, on-demand performance, tunable compiler, CLOS, condition system, and Macros to name a few. It has its warts too but which language does not?

I found lack of high quality library documentation a bit annoying, but a non-issue, there were tests and/or examples included in practically all of the libraries I have used so far.

Lastly, this rarely gets brought up, but I think Common Lisp has some of the best books available out of any programming language. The fact that it is so stable means that most of material, and code, from the end of 80's and 90's is quite relevant today, and new stuff is being written.

The biggest downside is that it makes JavaScript and Python revolting to work with. But I can still enjoy SML for example.

Re:How to write Common Lisp in 2017 – an initiation manual by shady-lady on Tuesday March 28, 2017 @06:14PM (#13981261)
Curious over why CL vs Clojure? Any comments.
Re:How to write Common Lisp in 2017 – an initiation manual by Guthur on Tuesday March 28, 2017 @07:54PM (#13982014)
I have used both in production setting and can say that the tooling for most CL implementations is just plain light years ahead of Clojure, and there is no sign of it really improving.

For Clojure the interactive debugging experience is just plain dreadful and for a dynamic language this is pants on head crazy imo. For me a dynamic language has to have a good interactive debugging experience because you have foregone the support of a static compilation and instead wish to reason about your program at runtime. But with the JVM stack traces and lack of interactive debugger Clojure just does not support you in this regard. And as a side note the lack of an identity print is annoying as well e.g. (+ (print 4) (print 4)) "4" "4" 8 (yes, it's easy to add...)

Clojure's decision to use persistent data structures is good but it's really the only standout thing for me other than some syntax sugar like hash maps.

Re:How to write Common Lisp in 2017 – an initiation manual by cdegroot on Wednesday March 29, 2017 @07:58AM (#13985199)
The JVM indeed quickly got me disinterested in Clojure. However, I have similar issues with other (free) Lisps, with probably only Emacs Lisp being the exception.

As a Smalltalker ("the other heroin of the programming world") I'm used to a highly integrated and responsive development environment; from what I heard from other Lispers, the quick feedback and gradual building up of your program is a shared aspect, but the thing that Smalltalkers always bring up and Lispers less so is also that your program and your IDE are basically indistinguishable, which is quite powerful because it makes it trivial to adapt your IDE to your project as you go. In the Lisp environments I've tried - latest being Emacs+SBLC - the split between editor and REPL seems unnatural to me, more so because in the standard case you work with two different dialects of the language. It seems that only ACL and LW have more unification.

Am I wrong and are the $$$$ versions not better in that respect and should I just drop my Smalltalk habits/arguments when learning CL?

Re:How to write Common Lisp in 2017 – an initiation manual by lispm on Wednesday March 29, 2017 @08:27AM (#13985356)
> also that your program and your IDE are basically indistinguishable

Lisp provides that,too. But you can also deliver programs with the IDE and much of the development tools removed.

Examples for integrated IDEs:

Allegro CL on Windows/Unix+Gtk, Clozure CL (free) on Macs, LispWorks on Windows/Macs/Unix+GTK/Unix+Motif. There the IDE and the user code runs in one Lisp. Other examples: Lisp Machines, CMUCL on X11, ... there is also the McCLIM project where some ideas from the Symbolics GUI are used.

There are also countless other implementations from the past, which are now mostly forgotten, which had an integrated IDE (Golden Common Lisp for Windows, Corman Lisp for Windows, Macintosh Common Lisp, Medley, Open Genera for X11...),

Re:How to write Common Lisp in 2017 – an initiation manual by iheartmemcache on Thursday March 30, 2017 @01:57PM (#13997469)
You should really write an analysis contrasting the functionality of these IDEs, especially those 'mostly forgotten' ones so they aren't lost into the abyss.

I've used Squeak Smalltalk and DrRacket in the past. As someone who finds slime/swank/sbcl in Emacs a pleasure, I can only imagine how great some of those other environments can be.

Re:How to write Common Lisp in 2017 – an initiation manual by vram22 on Friday March 31, 2017 @11:46AM (#14004959)
Hi,

I read this article on your site:

http://lispm.de/why-lisp-is-different

Quote from it:

[ When in doubt design software to be introspective.

when in doubt design software to be reflective. ]

What is the difference between introspective and reflective? I've used introspection in Python and know about and used (a bit) reflection in Java earlier, but thought they were roughly the same sort of thing. Please explain the difference if possible.

Re:How to write Common Lisp in 2017 – an initiation manual by lispm on Friday March 31, 2017 @12:43PM (#14005560)
Introspection means that the program's structures and procedures are discoverable and we can query about them. Typical questions we might want to have answers for:

* find me the class, typically by name or by some relationship

* what are the fields of that class?

* find me a function

* what are the arguments of the function? does it have documentation? Who wrote it? Where is its source? What values does it return?

* where is the function used? what functions does it call?

* what are the values of a field of some object? What class does it have?

This and more for example enables you to inspect a program at runtime and find out what it does, how it does it and what its state currently is.

Reflection means that elements of the programming language are itself exposed and we can change/extend them.

Two examples of the Lisp world. Very unusual is the reflective tower, where a Lisp program is run by some kind of machine, which for example is a Lisp interpreter. This Lisp interpreter is itself a Lisp program. Thus you can not only write the program, but you can change/extend the interpreter running the program. A certain Lisp dialect allowed also to look at the interpreter running the interpreter running the interpreter running the interpreter ...

In Common Lisp a typical form of reflection is the Meta-Object Protocol of CLOS. It allows you to program the object system to implement new variants: persistent objects, transactions over objects, different inheritance mechanisms, classes which record their instances, ... Thus the MOP exposes classes, methods, generic functions, slot descriptors, ... as CLOS classes and methods - and protocols about them. Thus CLOS can be programmed in itself. Even at runtime.

More primitive reflection would allow you to create/change/remove things like user classes and user methods. Task: create a new subclass of an existing class at runtime.

Re:How to write Common Lisp in 2017 – an initiation manual by vram22 on Friday March 31, 2017 @05:38PM (#14008545)
Interesting, and thanks for the answer. It's a while ago, but when I used reflection in Java (in v1.4, IIRC), what it did seemed like some of the capabilities you describe under introspection above. Maybe they just used a different term for it than you do. Example: Finding the methods of a class and calling them dynamically at runtime, finding the number and types of the arguments of a method, etc. These capabilities were part of the java.reflect* package, IIRC.
Re:How to write Common Lisp in 2017 – an initiation manual by lispm on Friday March 31, 2017 @06:18PM (#14008844)
https://en.wikipedia.org/wiki/Type_introspection

> Introspection should not be confused with reflection, which goes a step further and is the ability for a program to manipulate the values, meta-data, properties and/or functions of an object at runtime.

Re:How to write Common Lisp in 2017 – an initiation manual by vram22 on Friday March 31, 2017 @07:07PM (#14009209)
Thanks.
Re:How to write Common Lisp in 2017 – an initiation manual by db48x on Wednesday March 29, 2017 @03:36PM (#13989822)
You might find MIT Scheme interesting, because it has a built-in Emacs clone. Just call (edit) and you're in.

I think what it really comes down to is that writing and maintaining an editor (especially a good one) is a very large task. A language that lets you use an editor you already like thus has a double advantage, with the possible downside that the integration won't be as good as possible. SLIME is pretty nice though.

Re:How to write Common Lisp in 2017 – an initiation manual by boogiewoogie on Tuesday March 28, 2017 @11:16PM (#13983062)
For debugging try https://cursive-ide.com it uses intellij and has improved nicely in the past year.
Re:How to write Common Lisp in 2017 – an initiation manual by Royalaid on Tuesday March 28, 2017 @08:15PM (#13982142)
Have you tried out recent versions of CIDER? I find it works good for that I need. But I have to say that the big problem I have is Emacs and its inability to handle long strings.
Re:How to write Common Lisp in 2017 – an initiation manual by Guthur on Tuesday March 28, 2017 @08:32PM (#13982227)
I may be missing some massive leap but until it does this http://malisper.me/2015/07/07/debugging-lisp-part-1-recompil...
Re:How to write Common Lisp in 2017 – an initiation manual by Royalaid on Tuesday March 28, 2017 @08:42PM (#13982279)
AHHH, not quite the same, nor as good but sayid(https://github.com/bpiel/sayid) is a step in the right direction
Re:How to write Common Lisp in 2017 – an initiation manual by ane on Wednesday March 29, 2017 @04:01AM (#13984248)
CIDER has had debugging abilities like this for a year, there's a sexp based interactive debugger that allows injection, evaluation, stepping etc.

Here's a 39 second video about it https://www.youtube.com/watch?v=A3JAlWM8qRM

Re:How to write Common Lisp in 2017 – an initiation manual by lispm on Wednesday March 29, 2017 @04:11AM (#13984288)
The debugger needs to 'instrument' the code with breakpoints...?

That's something different.

In a Lisp system I would have an arbitrary amount of code and can halt and inspect/debug any code without any prior need to 'instrument' code.

Re:How to write Common Lisp in 2017 – an initiation manual by ane on Wednesday March 29, 2017 @05:59AM (#13984682)
To debug a function, yes, you need to eval the form using instrumentation. Then the debugger starts when this form is evaluated. This is the the only major difference to what SLIME provides. Adding breakpoints is somewhat easier with cider, you don't need to call break but you can just add a breakpoint to any sexp by pressing b.
Re:How to write Common Lisp in 2017 – an initiation manual by lispm on Wednesday March 29, 2017 @06:12AM (#13984743)
> Then the debugger starts when this form is evaluated.

You mean the stepper using break-instrumented code? That's just a part of what one would call 'debugger' in Lisp.

What CIDER calls 'debugger' would be mostly called 'stepper' in Lisp.

http://franz.com/products/allegro-common-lisp/stepper_dialog...

http://www.lispworks.com/documentation/lw70/IDE-M/html/ide-m...

> Adding breakpoints is somewhat easier with cider, you don't need to call break but you can just add a breakpoint to any sexp by pressing b.

LispWorks does that, too. Usually via a break icon in the window toolbar or the context menu.

Re:How to write Common Lisp in 2017 – an initiation manual by zehemer on Wednesday March 29, 2017 @06:05AM (#13984720)
Toggling pretty printing via `cider-repl-toggle-pretty-printing` may provide a workaround there. Courtesy of: https://github.com/clojure-emacs/cider/issues/1115
Re:How to write Common Lisp in 2017 – an initiation manual by SolarNet on Tuesday March 28, 2017 @07:25PM (#13981827)
I'm not OP, but there are a few I could see some mentioned in the OP's post in passing.

* The common lisp condition system [3, 0] is a way better way to do errors.

* Tune-able compilers [1] allow you to make better trade offs than even gcc allows for c, let alone Clojure's very opaque compiler.

* CLOS [2] is a very powerful object system which clojure does not replicate (they have multi methods, and java classes, but not a meta class system; think python's meta class features but better (because of macros and compiler access) and with multi methods designed in).

* Nice native interoperability (Clojure generally being on the JVM, and common lisp capable of direct calls and memory manipulation).

That being said. Clojure's unparalleled concurrency features are amazing. I would compare them as: if Clojure is the Java of lisps, then Common Lisp is the C++ of lisps.

[0] http://www.gigamonkeys.com/book/beyond-exception-handling-co...

[1] http://franz.com/support/documentation/current/doc/compiling...

[2] http://www.laputan.org/pub/papers/MOP.pdf

[3] http://axisofeval.blogspot.com/2011/04/whats-condition-syste...

Re:How to write Common Lisp in 2017 – an initiation manual by 0xcde4c3db on Tuesday March 28, 2017 @10:49PM (#13982936)
Not speaking for hydandata, a few key points of CL as opposed to Clojure (which might be advantages or disadvantages depending on context and preference) include:

- Defined by a standard (the text of the standard is available for free online as the Common Lisp HyperSpec [1]), not by a reference implementation led by a BDFL

- Multiple mature implementations, both free and proprietary

- Wholeheartedly multi-paradigm; has FP features, but also provides plenty of tools for imperative (notably including a powerful macro for loops) and (meta)object-oriented approaches

- "Lisp-2" rather than "Lisp-1"; functions and variables are in different namespaces, which reduces name clashes but requires disambiguation in some places

- Designed for implementation in a wide variety of environments, including being embedded as an extension/scripting language in C or C++ applications (see ECL [2])

[1] http://www.lispworks.com/documentation/HyperSpec/Front/index...

[2] https://common-lisp.net/project/ecl/

Re:How to write Common Lisp in 2017 – an initiation manual by kakapupu on Wednesday March 29, 2017 @01:55AM (#13983780)
> Defined by a standard

How does this help, compared to Clojure?

> Multiple mature implementations

Why wouldn't one free mature implementation be good enough?

> Wholeheartedly multi-paradigm

Exactly like Clojure.

> "Lisp-2" rather than "Lisp-1"

I can't remember which one Clojure is :) But I haven't had any problems with namespaces and the like.

> Designed for implementation in a wide variety of environments

So is Clojure, right? There's the CLR version, and ClojureScript too.

Re:How to write Common Lisp in 2017 – an initiation manual by lispm on Wednesday March 29, 2017 @02:57AM (#13984011)
Clojure variants are incompatible in various basic ways, since they use the host language for various things. The underlying platform also restricts what the implementation provides. No TCO in JVM -> no TCO in Clojure. Numbers are internally floats in Javascript -> Numbers are internally floats in ClojureScript and use Javascript semantics, not Clojure-Semantics.

Clojure:

  Clojure 1.8.0
  user=> (/ 3 4)
  3/4
ClojureScript

  cljs.user=> (/ 3 4)
  0.75
Looks like these are different languages...

Common Lisp implementations OTOH implement most of the standard. There is also more choice in implementations:

* native implementations AND hosted implementations

* actual Lisp interpreters or a mix of interpreters and compilers, interactive compilers, batch compiler

* compilers written in Lisp itself with good error messages, forms of compile-time type checking/inference, and advanced error handling (like SBCL, CMUCL)

* compilation to C, full embedding into C programs (ECL and others)

* full embedding in C++ (CLASP)

* compilation to shared libraries, embeddable into other applications

* whole program compilers for delivery of compact applications (like mocl)

The main Clojure compiler is written in Java and it shows...

https://github.com/clojure/clojure/blob/master/src/jvm/cloju...

If one targets a certain host environment (JVM, Javascript, ...) then this range of options and choice might not matter, even hinder - besides getting a poorer version of interactivity.

If we see a Lisp as a language on its own, then it matters a lot.

Re:How to write Common Lisp in 2017 – an initiation manual by azrazalea on Wednesday March 29, 2017 @11:17AM (#13987073)
> > Wholeheartedly multi-paradigm

> Exactly like Clojure.

Clojure is definitively not multi-paradigm. The only blessed by the developers/community paradigm is functional.

Re:How to write Common Lisp in 2017 – an initiation manual by hydandata on Tuesday March 28, 2017 @09:11PM (#13982425)
Obviously highly opinionated and personal statement coming, but Common Lisp is to Clojure what Meccano is to LEGO, and I have never been a LEGO person.

If I work on a project where functional programming with emphasis on purity is required I will much rather go to ML family, which I think offers more natural way to express ideas in functional paradigm with beauty and integrity not even Lisp can match.

Re:How to write Common Lisp in 2017 – an initiation manual by Jach on Tuesday March 28, 2017 @06:58PM (#13981652)
Why Clojure vs CL? The parent already mentioned some features that Clojure lacks, so if you don't care about features, what do you care about?
Re:How to write Common Lisp in 2017 – an initiation manual by platz on Tuesday March 28, 2017 @11:45PM (#13983210)
SBCL compiles to native code.
Re:How to write Common Lisp in 2017 – an initiation manual by kazinator on Tuesday March 28, 2017 @11:19PM (#13983090)
Clojure is tied to the Java environment. Someone who has no use for or interest in that environment has no use for Clojure.
Re:How to write Common Lisp in 2017 – an initiation manual by ethagnawl on Wednesday March 29, 2017 @12:12AM (#13983333)
> Clojure is tied to the Java environment.

I guess you're not familiar with ClojureScript and/or Clojure CLR?

Re:How to write Common Lisp in 2017 – an initiation manual by mathw on Wednesday March 29, 2017 @04:00AM (#13984246)
Last time I tried to use Clojure CLR, all the useful libraries were JVM-only because they called out to JVM libs underneath.
Re:How to write Common Lisp in 2017 – an initiation manual by 59nadir on Wednesday March 29, 2017 @03:25AM (#13984121)
That's sort of like the following:

- I don't want a door here.

- Ok, you don't like the wooden door here. You can have a plastic one or a steel door.

With CL you're not tied to _any_ platform.

Re:How to write Common Lisp in 2017 – an initiation manual by kazinator on Wednesday March 29, 2017 @12:34PM (#13987942)
"Clojure" is being used as a family name for similar, but incompatible dialects. If I were Hickey, I'd trademark it and enforce against these projects.

Look at lispm's comment: https://news.ycombinator.com/item?id=13984011

It's not just the platform libs, but the semantics of things that really should be portable.

Re:How to write Common Lisp in 2017 – an initiation manual by sheepmullet on Wednesday March 29, 2017 @06:31AM (#13984828)
Clojure makes certain language sacrifices to ensure great integration with its host platforms.

Easy access to the tens of thousands of person years worth of effort put into the Java/JavaScript ecosystems in return for dealing with a bit of ugliness is a win in my books.

Re:How to write Common Lisp in 2017 – an initiation manual by cdegroot on Wednesday March 29, 2017 @08:01AM (#13985217)
It's a loss in my books. I like Clojure but pretty much the only thing that's been putting me off is how the JVM "shines" through in lots of aspects.
Re:How to write Common Lisp in 2017 – an initiation manual by edem on Tuesday March 28, 2017 @06:32PM (#13981433)
I'm also interested in an insightful answer.
Re:How to write Common Lisp in 2017 – an initiation manual by Johnny_Brahms on Wednesday March 29, 2017 @07:41AM (#13985120)
Which lisp implementation are you using? I had the pleasureof using AllegroCL at a gig I did recently. The environment has a bit of a learning curve, but once everything clicks it is like heroin.

I ended that job a couple of months ago, but I still have wet dreams about it.

Re:How to write Common Lisp in 2017 – an initiation manual by netmask on Tuesday March 28, 2017 @06:16PM (#13981279)
which lisp interpreter did you use ?
Re:How to write Common Lisp in 2017 – an initiation manual by hydandata on Tuesday March 28, 2017 @08:37PM (#13982256)
No interpreters used, mostly SBCL and CCL. Folks over at Grammarly have a blog post which mentions few reasons for the combo http://tech.grammarly.com/blog/posts/Running-Lisp-in-Product...

I write portable code and use libraries which abstract away implementation specific stuff so it will be easy to run on any other conforming implementation should the need arise.

The community is quite responsible when it comes to portability and utility libraries which help with it, but on top of that Quicklisp maintainer tests library compilation on most major implementations and reports bugs.

Re:How to write Common Lisp in 2017 – an initiation manual by Guthur on Tuesday March 28, 2017 @07:43PM (#13981940)
It baffles me that this notion of Lisp as an interpreted language still persists. Common Lisp is a compiled language for all non toy implementations, and in general Lisps have had compilers for decades.
Re:How to write Common Lisp in 2017 – an initiation manual by PuercoPop on Wednesday March 29, 2017 @12:39AM (#13983446)
It baffles me that people refer to languages as interpreted or compiled. That is a property of the implementation of the not the language.
Re:How to write Common Lisp in 2017 – an initiation manual by nine_k on Tuesday March 28, 2017 @10:19PM (#13982773)
Having a good REPL is important, though.
Re:How to write Common Lisp in 2017 – an initiation manual by hydandata on Tuesday March 28, 2017 @10:39PM (#13982887)
Having a REPL does not necessitate interpreting http://www.sbcl.org/manual/#Compiler_002donly-Implementation
Re:How to write Common Lisp in 2017 – an initiation manual by nabla9 on Tuesday March 28, 2017 @10:39PM (#13982888)
REPL and interpretation are orthogonal concepts.

SBCL (most common CL implementation) don't have interpreter at all. It complies into machine code before execution even in REPL.

Re:How to write Common Lisp in 2017 – an initiation manual by juki on Wednesday March 29, 2017 @12:00AM (#13983285)
SBCL actually does have an interpreter, but doesn't use it by default. You can set

    sb-ext:*evaluator-mode*
to :INTERPRET to enable it.

http://www.sbcl.org/manual/#Interpreter

Re:How to write Common Lisp in 2017 – an initiation manual by lispm on Wednesday March 29, 2017 @01:02AM (#13983550)
Though, to be fair, a 'real' Lisp interpreter often provides more interactive features. The Lisp interpreter sees the code as Lisp data and interprets that. This enables a few things.
Re:How to write Common Lisp in 2017 – an initiation manual by lokedhs on Wednesday March 29, 2017 @05:11AM (#13984509)
You don't need an interpreter for that. SBCL (as does other compilers) always compiles an expression prior to executing it, even when it's code as data passed to EVAL.
Re:How to write Common Lisp in 2017 – an initiation manual by lispm on Wednesday March 29, 2017 @05:25AM (#13984556)
> You don't need an interpreter for that.

For what?

> You don't need an interpreter for that. SBCL (as does other compilers) always compiles an expression prior to executing it, even when it's code as data passed to EVAL.

True, but that's not what a Lisp interpreter does and provides.

I was talking about the difference between an interpreter and a (possibly interactive) compiler. The interpreter works over source code as Lisp data. The compiler does not - it does not matter that the compiler compiles individual forms. At runtime the code is machine code. With an interpreter the code is Lisp data.

Think about it: What difference could that make, if the code gets actually executed by a real Lisp interpreter?

Re:How to write Common Lisp in 2017 – an initiation manual by nameless912 on Tuesday March 28, 2017 @06:40PM (#13981496)
Common Lisp would imply SBCL, that's my guess at least.
Re:How to write Common Lisp in 2017 – an initiation manual by fiddlerwoaroof on Tuesday March 28, 2017 @07:05PM (#13981702)
There are half a dozen CL implementations, for various purposes:

sbcl, ccl and open source implementations with built in compilers.

ecl is similar, but designed to be easily embeddable in C applications

clasp is a newer one that's built on top of llvm (still unstable, as far as I can tell, but actively developed)

abcl targets the jvm platform and, consequently, can gives you access to all the libraries in the Java ecosystem.

And then there are commercial implementations like LispWorks and Allegro that have their own benefits: Lispworks has, I here, a very nice cross-platform GUI library and, although I don't know much about it, I suspect Allegro has it's own perks.

And, because of the community's emphasis on avoiding implementation-specific behaviors, which implementation you choose isn't that big a deal: I regularly develop a project under multiple implementations, and seldom have major issues doing so.

Re:How to write Common Lisp in 2017 – an initiation manual by fny on Wednesday March 29, 2017 @11:40AM (#13987326)
Can you elaborate on your use case?
Re:How to write Common Lisp in 2017 – an initiation manual by lafytahoe on Tuesday March 28, 2017 @10:19PM (#13982774)
How do you sneak something like lisp in to work?
Re:How to write Common Lisp in 2017 – an initiation manual by hydandata on Tuesday March 28, 2017 @10:59PM (#13982978)
You build trust with stakeholders, usually by solving important problems until you reach a point at which having you solve a new problem is more important to them than what you solve it with. It helps if whatever tech you are introducing actually helps you in the task of solving more problems, increasing quality of solutions or reducing cost, in that particular order.
Re:How to write Common Lisp in 2017 – an initiation manual by kruhft on Wednesday March 29, 2017 @03:54AM (#13984218)
Good advice and similar to the strategy I use at work to use Common Lisp and Parenscript. They are yet to be completely accepted, but I'm working in it.