
Why Lisp is now an acceptable scripting language - wtbob
http://fare.tunes.org/files/asdf3/asdf3-2014.html
======
davexunit
Lisp is an acceptable language for a variety of things, not just "scripting".
I work on many projects written in Guile Scheme that range from game engines
to static site generators to dynamic web applications to package managers, and
I write one-off scripting tasks with it, too. There's a lot of mystique around
Lisp and Scheme, and people tend to write it off as a relic of academia, but I
use it for practical needs every day. Lisps enable a type of development via
live coding that I have yet to see a non-Lisp match. I've used the REPL for
doing everyday calculator tasks to live coding video games, and I've used it
for customizing an X11 window manager in the past, too.

But rather than read about me confess my love for Lisp, I recommend that
people just pick a Lisp that looks fun and take it for a spin. You might find
a lot to like.

~~~
petra
>> Lisps enable a type of development via live coding that I have yet to see a
non-Lisp match.

How does it compare to using python for live coding?

~~~
preek
If you want to compare Lisp Live Coding and you know Python, then let me
compare it like this: How much faster can you get things done using something
like ipython vs. a compiled static language like C(++/#) or Java? I don't want
to go into a flamewar against the other languages, of course. Yet, if you
favor an ipython repl against the compile/build/test cycle, then Lisp gives
you just about the same order of magnitude more power.

I've done professional Python coding for 2.5 years, Ruby and JS for 7. I
always believed that the REPL combined with those languages being dynamically
typed can yield big advantages.

With a Lisp you can evaluate your code in real time in your editor. Also your
app will re-load your code live without losing it's state. I've done that with
Backends, Web Frontends and Mobile Apps. It's pretty awesome, not just
compared to everything else^^

Take it for a spin and enjoy the ride(;

~~~
RegEx
What are the bread-and-butter (aka not sexy and cutting edge, but mature and
stable) lisps used for web development?

~~~
preek
Well, I run my own companies, so I like the cutting edge - and we are using
Clojure.

A good friend of mine works for one of those big consultancies, however, and
they are currently rewriting the backend of the second biggest online retailer
of the world and they are using Clojure, too^^

So either I'm getting too old for the sexy Startup business or Clojure is at
the same time stable and fancy(;

------
dheera
Well, you can use LISP/Scheme as a procedural language with a little "code
obfuscation" ...

    
    
      (define (return x) x)
      (define (! a b c) (not (b a c)))
      (define (-- a) (- a 1))
      (define (cout junk thing) (display thing))
      (define << 'nothing)
      
      ;ignore this   look at this
      ;...........   ...............................................
      (
                      define (__I_AM_HAPPY happiness) (
                        if(! happiness <= 0) (
      begin (             cout << "happy happy joy joy";                   
      ) (                 __I_AM_HAPPY (-- happiness);
      )                 ) 
      ;                 else (
      (                   return "yay! i'm done with 6.001 project";
                        )
                      )
      )
      
      ; got that? now we can do this:
      
      (__I_AM_HAPPY 10)

~~~
catnaroek
Wait, so now what determines whether a language is “procedural” is its surface
syntax rather than its semantics?

~~~
betenoire
What other kind of syntax is there? But yes, I've seen a lot of procedural
code in every paradigm I can think of. Lots of cargo-cult programming results
in it.

~~~
jonathankoren
Sit down dear child and hear of languages long ago...

Back I. The days of vacuum tube and electromechanical switches, when punch
tape rules the world p, there were two languages: The Algorithmic Language,
and the List Processor. The List Process, or LISP, to its friends was built
around s-expressions. The other, also known as ALGOL, was built around a
strange and unholy hybrid of text and formulae that only an insane
mathematician would love, for almost every statement was a special case.

ALGOL syntax went on to rule the world.

Seriously kid. There are only two syntaxes, and procedural, structural, object
oriented, aspect, imperative, and all the rest are immaterial to the syntax,
for they refer to how programs are organized, not what keys you press on the
keyboard. Don't they teach programming languages anymore?

~~~
catnaroek
Have you heard of Prolog? (Just to mention a single language whose syntax
doesn't fall in either category you mentioned. Not that there aren't others.)

Also, as someone who studies mathematics for fun, I disagree with your
statement that a mathematician would love a system with lots of special cases.
If anything, mathematicians are willing to pay a higher abstraction tax than
most other people, just to unify special cases.

~~~
groovy2shoes
I've noticed that the kinds of things a mathematician might pride an elegant
proof over are the same kinds of things a programmer might recognize as
elegance in code as well.

I think the Curry-Howard Correspondence is actually an intuitive result rather
than a surprising one, and that any experienced programmer who understands
formal proofs as well as they understand computer programming would eventually
arrive at the Correspondence on their own, or at least a suspicion of it.

------
EuAndreh
François-René Rideau has done a lot to evolve ASDF, the Common Lisp build
system, and lots have been done since, also, like an implementation
manager[0], an assets downloader[1] and compiler[2].

[0]: [https://github.com/roswell/roswell](https://github.com/roswell/roswell)

[1]: [https://github.com/eudoxia0/rock](https://github.com/eudoxia0/rock)

[2]: [https://github.com/eudoxia0/asdf-
linguist](https://github.com/eudoxia0/asdf-linguist)

------
gkya
Archived version from 11th of March:

[https://web.archive.org/web/20160311062403/http://fare.tunes...](https://web.archive.org/web/20160311062403/http://fare.tunes.org/files/asdf3/asdf3-2014.html)

~~~
clishem
1\. Doesn't work either for me.

2\.
[http://webcache.googleusercontent.com/search?q=cache:LWgWzFI...](http://webcache.googleusercontent.com/search?q=cache:LWgWzFIG_0wJ:fare.tunes.org/files/asdf3/asdf3-els2014.pdf+&cd=2&hl=nl&ct=clnk&gl=nl)

------
616c
People who agree with the overall philosophy of this will be interested in
avesh, an attempt to write a full shell in CL.

[https://gitlab.com/ralt/avesh](https://gitlab.com/ralt/avesh)

I am also very interested in xonsh. I am increasingly of the opinion that as
useful as a package manager would be like {bash,zsh} compliant shells written
in host languages that allow you to merge bashisms/Unixisms into your host
lang and vice versa.

I started looking into this, specificaly with Haskell. I founde chrisdone's
Hell and tangentially turtle. Combining those would be insane!

~~~
vram22
There is/was also scsh, a Scheme shell for Unix.

~~~
616c
Well, yes, I am aware of it. I had trouble getting scsh to work well. Outside
of Guile, I am not even sure what Scheme implementations are viable. I have
played with Chicken and Gambit very minimally.

IIRC, schs uses the MIT48 or a classic Scheme variant specific to it, and I do
not know if there is anything "built" on top of that. Where as least other
esoteric schemes (Chicken, Gambit, Gauche, etc.) are full environments people
can code in, in theory.

Guile is fascinating to me because this concept, subsumed into Emacs (a la the
guile->elisp super project), means a very interesting idea that I think moves
beyond the IDE. Some people here will poo poo that, but I find it very
interesting as I have moved away from tmux and screen and into Emacs as my
combined editor AND terminal manager. I know I know, where's the Unix
philosophy.

But, I like this. Soon I will play with this stack on top of Guix, and well,
that is more Lisp Machine that I should be allowed to have.

~~~
vram22
Have you considered Racket? I believe its a sort of Scheme (experts, feel free
to correct me) and a friend told me it has a small but good community. Also,
an IDE, many libraries, etc.

------
amelius
Can anybody explain the advantages of switching to a functional language when
it is not a pure one? For example, how is it better than Javascript? Is the
uniformity of the syntax (and perhaps implicit currying) the main benefit?

~~~
kazinator
Lisp isn't a functional language. It's a family of languages, most of which
support more than one programming paradigm.

Most languages that are identified as some kind of Lisp are strictly
evaluated, do _not_ support partial evaluation (explicit currying only), and
support mutable variables and mutable aggregate objects.

~~~
technomancy
Minor nit-pick; the terms here are backwards. Nearly all lisps support
explicit partial evaluation, but not many support currying, which is implicit.

------
sdegutis
Back in 2012 when I was sure I wanted to master some dialect of Lisp but
wasn't sure which one yet, I read about 80% of Practical Common Lisp before I
noped the heck out of there. The whole reason I was drawn to Lisp was for its
semantic and syntactic purity, simplicity, and consistency, and out of the
three popular Lisps at the time, CL felt like it had these the least.
Ultimately I ended up going with Clojure after a year of flirting with various
Schemes.

~~~
duncanawoods
I have tried lisps looking for the famed syntactic purity but I didn't really
find it.

For example, following the little schemer books, they don't print scheme as
the actual ascii you need to type, instead they use typography like bold,
italic and greek symbols that you have to replace with the uglier reality to
distinguish between things like s-expr from lists. It feels like they are
embarrassed by the cludgy real syntax, so they hide it and push the difficulty
on to the reader.

To give clojure a whirl, I was prepared for lispy paren extravagance but when
translating a small program to my best guess at idiomatic clojure (I'm sure I
failed) there were so many non-s-expr syntactic special cases for things like
list comprehensions and common macros that the result felt like it was jealous
of non-s-expr languages and didn't actually want to be a lisp.

In truth, I believe a strong contrast between different syntactic elements
helps readability, so I don't think the s-expr regularity I expected is
something I actually want.

~~~
undershirt
> ... they use typography like bold, italic and greek symbols that you have to
> replace with the uglier reality to distinguish between things like s-expr
> from lists.

My main complaint with Scheme is that it's hard to distinguish a "call" from a
plain list. For example, in `(let ((foo 1) (bar 2)))`, `let` is a call, but
`foo` and `bar` are just being assigned, not called. Clojure uses `(let [foo 1
bar 2])`, so you can tell that `let` is a call, but `foo` and `bar` are now
unwrapped and placed inside square brackets to signify plain data, not a call.

> To give clojure a whirl, ... there were so many non-s-expr syntactic special
> cases for things like list comprehensions and common macros

Everything is still an s-expr. The square and curly braces still follow the
same rules, but they just mean they are not "calls" like parens would normally
signify.

For a list comprehension example: `(for [m messages] (str m))`, `for` and
`str` are calls and `[m messages]` is just data. It could be unwrapped like
`(for m messages (str m))`, but it's wrapped in square brackets as a visual
indicator for what's important. But if it was wrapped in parens like in
Scheme, it could be confused as a "call".

Clojure is very well-designed to solve visual problems of Scheme and other
Lisps. I recommend looking at it again :D

~~~
jwdunne
From what I can tell, Scheme (or it may be a Racket thing) allows the use of
square brackets - this aids in readability greatly. There is no type
difference as there is in Clojure.

~~~
goldfeld
With the downside being inconsistent style across the community, making for
more overhead when reading code (see also macro abuse). Scheme has bigger
fragmentation problems anyhow.

------
corragon
If someone wanted to get started into Lisp programming, what REPL and
resources would you recommend? I began working through SICP a while back, but
found it difficult to know what dialect of Lisp to use. As a complete newbie
to Lisp, it was near impossible to debug why the code I wrote from SICP didn't
work at all.

~~~
arh68
SICP is written for Scheme, not Common Lisp, so that might've been your issue.
They're not at all the same, despite both being Lisps.

Just use Common Lisp. I use SBCL. Read Practical Common Lisp [1] &/ ANSI
Common Lisp [2]. Skim the CLQR [3].

If you're just starting out, you can get away with just using the REPL. You
might get that ^]]A crap when you up-arrow to previous expressions, so install
rlwrap and run 'rlwrap sbcl' instead of just 'sbcl'.

Once you get tired of that and want to use an editor, get Emacs (on OS X: see
[4], on Ubuntu: apt-get install emacs24). Install SLIME [5] through package-
install to send expressions down from a .lisp file to the REPL (with C-x C-e).

If you get stuck, try looking for youtube videos (or add an email to your HN
about).

[1] [http://www.gigamonkeys.com/book/](http://www.gigamonkeys.com/book/)

[2] [http://www.paulgraham.com/acl.html](http://www.paulgraham.com/acl.html)

[3]
[http://clqr.boundp.org/download.html](http://clqr.boundp.org/download.html)

[4] [https://emacsformacosx.com/](https://emacsformacosx.com/)

[5] [https://github.com/slime/slime](https://github.com/slime/slime)

------
superskierpat
I recently rewrote many of my shell scripts in guile, a really fun experience.
And tail call recursion makes it pretty easy to reason about the code, no more
looking up bash cheat sheets every time I write a script

------
stewbrew
Now that scripting languages are almost dead?

~~~
weatherlight
[http://www.tiobe.com/tiobe_index](http://www.tiobe.com/tiobe_index) 4/10 top
languages are scripting languages. Not bad for something that's almost dead.

~~~
stewbrew
What does that tell us? That there is a lot of legacy perl & php code around
that has to be maintained? I personally used to like lisp (scheme actually)
and ruby but I would never use them (or another dynamically typed language)
again. Never! I'll take another look at common lisp as a (scripting) language
when optional static typing is available, standardized, and commonly used. And
no, typed clojure and (unfortunately also) typed racket aren't viable
alternatives.

