News for hackers. Stuff that matters.
Re:Not Lisp again (2009) by lisper on Tuesday May 02, 2017 @03:38PM (#14249826)
> 1 - All those parenthesis. (Still a top objection)

If you actually count parens fairly you will find that Lisp has no more than any other language, it's just that other languages use a mix of parens, square brackets and curly braces whereas Lisp only uses parens. Also, if you really don't like parens, you can get rid of a lot of them using macros. See e.g.:

https://github.com/rongarret/ergolib

and in particular the binding-block (BB) construct.

> 2 - Lisp doesn't look like or work like what I'm used to.

Neither does anything else until you get used to it.

> 3 - Lisp doesn't have as many libraries as the most popular mainstream programming languages.

That used to be one of my objections, but it's simply not true any more. And with Quicklisp accessing the (very large) collection of available libraries is incredibly convenient. (Thanks Zach!)

> 4 - There aren't nearly as many Lisp programmers, so it'll be hard to find more to join your project/company if you use Lisp.

That becomes a self-fulfilling prophecy. But it's no harder to create new Lisp programmers than it is to create new X programmers for any other value of X.

> 5 - There aren't nearly as many Lisp jobs, so why bother learning Lisp if you're going to have a hard time finding work using it?

Because knowing Lisp is a huge lever for learning other languages. Once you know Lisp everything else becomes a lot easier to learn (but a lot more frustrating too because now you will be aware of the shortcomings of other languages).

> 6 - Lisp is ancient, and anything that old is useless and primitive compared to new and shiny languages.

Chasing the shiny new thing is usually a mistake. Most old things suck simply because most things suck in general. But the things that don't suck continue to not suck even after they become old. In fact, standing the test of time is one of the defining characteristics of non-sucky things.

Re:Not Lisp again (2009) by ue_ on Tuesday May 02, 2017 @04:00PM (#14250028)
The part about lisp being primitive was rather silly. Many languages don't have anything close to what Lisp has in its macro system, not even other functional languages, even in those languages with temperating systems. Perhaps Perl 6 comes close (I haven't had the chance to use p6 macros yet) but to say that lisp is 'primitive' is rubbish, unless you're going to claim that case insensitivity is enough to declare a language primitive.
Re:Not Lisp again (2009) by brianberns on Tuesday May 02, 2017 @04:09PM (#14250107)
>> 1 - All those parenthesis. (Still a top objection)

> If you actually count parens fairly you will find that Lisp has no more than any other language

Bull. For example, compare the Lisp factorial function from the article:

    (define (fact x)
      (if (zero? x)
          1
          (* x (fact (- x 1)))))
with the corresponding F# implementation:

    let rec fact x =
        if x = 0 then 1
        else x * fact (x - 1)
That's 7 vs. 1 pair of parens.

Also, the problem isn't just that Lisp has so many parens, but that they nest so deeply and quickly. Five nested levels of parens for factorial alone.

Re:Not Lisp again (2009) by lisper on Tuesday May 02, 2017 @08:38PM (#14252103)
F# and all ML derivatives are an aberration because they use juxtaposition to denote function calls. That eliminates a lot of parens but personally I find the result less readable.

But compare to, say, C where no one complains about the parens:

    int fact(int n) {
      if (n==0) {
        return 1
      } else {
        return n*fact(n-1);
      }
    }
That's six pairs of parens. The only reason it's not more is because some function calls in C are disguised as operators, and those just happen to be the functions that factorial uses. If we wanted a semantically equivalent function that handled bignums you'd have to write:

    bignum fact(bignum n) {
      if (bignum_is_zero(n)) {
        return n;
      else {
        return bignum_multiply(n, fact(bignum_subtract_1(n)));
      }
    }
Now you've got nine parens. But still no one complains about C because of that.
Re:Not Lisp again (2009) by chriswarbo on Wednesday May 03, 2017 @08:28AM (#14255075)
> F# and all ML derivatives are an aberration because they use juxtaposition to denote function calls. That eliminates a lot of parens but personally I find the result less readable.

It makes a lot of sense when all functions are curried. Parenthesised function calls treat all of these as different things:

    f(a, b, c, d)
    f(a, b, c)(d)
    f(a, b)(c, d)
    f(a, b)(c)(d)
    f(a)(b, c, d)
    f(a)(b, c)(d)
    f(a)(b)(c, d)
    f(a)(b)(c)(d)
If functions aren't curried, then these all mean different things. When functions are curried, all of these have the same semantics (call `f` with `a`, call the result with `b`, call that result with `c` and call that result with `d`); ML's juxtaposition syntax makes these semantically-identical expressions syntactically-identical too:

    f a b c d
Re:Not Lisp again (2009) by lisper on Wednesday May 03, 2017 @11:41AM (#14256689)
You can curry in Lisp too, and if you do you can get rid of all but one of the unnecessary parens as well.

    (curry f a b c d)
Re:Not Lisp again (2009) by brianberns on Tuesday May 02, 2017 @09:18PM (#14252275)
Only if you assume that curly braces function as parens in C, which isn't true.
Re:Not Lisp again (2009) by lisper on Tuesday May 02, 2017 @10:14PM (#14252492)
It's not an assumption, it's a fact. Curly braces serve the same function in C as (some of the) parens do in Lisp.
Re:Not Lisp again (2009) by Frondo on Tuesday May 02, 2017 @07:33PM (#14251684)
Yeah, you know what else I'm realizing? All the different kinds of punctuation let my eyes skim over different parts of code so easily, and lisp doesn't give me that.

You know how, when you're reading natural language, you don't actually read individual letters, not once you have any reading fluency? That's how I read code, too, I'm realizing. When I see the parentheses in C#, my brain just goes "oh that's a method/function call" and I can either skip over the contents of the parens or read them if I need to. Reading comprehension is pretty quick.

Looking at all the parens of even that simple lisp factorial, and I realize that I'm feeling a lot of cognitive load that would simply never go away, because the punctuation doesn't let me filter any of it out. I'd have to read everything more carefully.

Re:Not Lisp again (2009) by shakna on Wednesday May 03, 2017 @03:36AM (#14253736)
> Looking at all the parens of even that simple lisp factorial, and I realize that I'm feeling a lot of cognitive load that would simply never go away, because the punctuation doesn't let me filter any of it out. I'd have to read everything more carefully.

Completely the opposite here.

Parens means function call or list. Lists usually denoted by a quote first.

I don't read the parens, I skim everything, reading words. And the punctuation is really simple.

For example:

    if (number? a)
      + a b
      error "Not A Number" a
I stripped most of the parens there, (like Wisp [0] does), because I don't really see them. I see function call and arguments, because there isn't anything else.

Scheme has the very least syntax out of just about any programming language I've used. It has a tiny cognitive load compared to most.

[0] http://dustycloud.org/blog/wisp-lisp-alternative/

Re:Not Lisp again (2009) by Volt on Tuesday May 02, 2017 @09:37PM (#14252355)
>You know how, when you're reading natural language, you don't actually read individual letters, not once you have any reading fluency?

As difficult as it is to imagine, you can indeed achieve fluency in reading Lisp code. Like with everything else, it takes time and practice.

Re:Not Lisp again (2009) by lisper on Tuesday May 02, 2017 @08:32PM (#14252071)
Focus on the words, not the punctuation, just like you do when reading natural language.
Re:Not Lisp again (2009) by spacemanmatt on Tuesday May 02, 2017 @10:08PM (#14252473)
You get used to reading lisp, the same as you get used to reading all that boilerplate syntax.
Re:Not Lisp again (2009) by Johnny_Brahms on Wednesday May 03, 2017 @03:59AM (#14253831)
You can replace parens with indentation, yes. There are lisps that do this, like WISP for guile,which provides "implicit parens through indentation".

Then you get the same amount of parens as fsharp. It is even standardised as an SRFI (although not widely.implemented)

Re:Not Lisp again (2009) by Roboprog on Tuesday May 02, 2017 @04:28PM (#14250266)
Try putting the closing parens on a line aligned with the opening one, as if they were K&R style closing braces (ignoring that open-paren goes before keyword/func-name, rather than after)

    (define (fact x)
        (if (zero? x)
            1
            (* x (fact (- x 1)))
        )
    ) 

Square brackets work in some dialects, as well:

    [define (fact x)
        (if (zero? x)
            1
            (* x (fact (- x 1 ]
Re:Not Lisp again (2009) by sigjuice on Tuesday May 02, 2017 @05:46PM (#14250932)
Almost all Lisp code will put the closing parens all together at the end. And the idea is to not care about how many there are by using an editor that provides the appropriate assistance.
Re:Not Lisp again (2009) by tomjakubowski on Tuesday May 02, 2017 @06:54PM (#14251421)
> by using an editor that provides the appropriate assistance.

To spell it out: this means Emacs with Paredit, or an imitation thereof.

Re:Not Lisp again (2009) by krapp on Tuesday May 02, 2017 @07:46PM (#14251788)
Having to depend on an editor to make your code legible seems like a bad thing.
Re:Not Lisp again (2009) by Roboprog on Friday May 05, 2017 @11:42AM (#14274247)
Especially since most IDE's seem to go out of their way to make sludge out of the text, unless you have hours to spend training each one, and can figure out how to do so...

... until your coworker edits the file in the out of the box IDE and munges it.

I guess now-a-days, our languages and frameworks are so ugly they need a "bag" over their [inter]face while you are doing them :-)

Re:Not Lisp again (2009) by lisper on Tuesday May 02, 2017 @08:30PM (#14252063)
Why? (And what language do you use where you don't have to rely on the editor to format your code?)
Re:Not Lisp again (2009) by krapp on Tuesday May 02, 2017 @09:13PM (#14252252)
To me, that's a sign that maybe a language has too little syntax.

I can read C++, Javascript and PHP just as well in plain text because the other non-paren elements provide necessary contextual cues, along with nesting. Syntax coloring is helpful, but it shouldn't be necessary.

I can at least understand nesting closing parens on their own lines, the way Roboprog did above, but throwing all of them on a single line just seems like needless noise.

Re:Not Lisp again (2009) by KingMob on Wednesday May 03, 2017 @10:27AM (#14255909)
It's not something we ever really think about. That list of closing parentheses just signals termination of the top-level S-expression.

And there's virtually nobody coding in a Lisp that doesn't use a structural editing mode (like Paredit or SmartParens). E.g., any time you type "(", you get "()", enforcing balance.

What we rely on is proper indentation to indicate the important groupings.

Re:Not Lisp again (2009) by sigjuice on Wednesday May 03, 2017 @11:28AM (#14256516)
Exactly. IMHO, this is quite similar to Python indentation rules, except it is up to writers of Lisp code to be disciplined enough to maintain the proper indentation.
Re:Not Lisp again (2009) by lispm on Wednesday May 03, 2017 @02:14PM (#14258507)
Hmm, my editor does it for me.

Wait, even Lisp does that for me, because it has a built-in source code pretty printer:

Call the pretty printer to format this mess:

    CL-USER 41 > (let ((*print-case* :downcase))
    (pprint '(defun add-text-padding
    (str &key padding newline)
    "Add padding to text STR. Every line except for the first one, will be
    prefixed with PADDING spaces. If NEWLINE is non-NIL, newline character will
    be prepended to the text making it start on the next line with padding
    applied to every single line."
    (let ((str (if newline (concatenate 'string (string #\Newline) str) str)))
    (with-output-to-string (s) (map 'string (lambda (x) (princ x s) (when (char= x #\Newline)
    (dotimes (i padding) (princ #\Space s)))) str))))
    ))

It prints wonderfully formatted and indented code:

    (defun add-text-padding (str &key padding newline)
      "Add padding to text STR. Every line except for the first one, will be
    prefixed with PADDING spaces. If NEWLINE is non-NIL, newline character will
    be prepended to the text making it start on the next line with padding
    applied to every single line."
      (let ((str
             (if newline
                 (concatenate 'string (string #\Newline) str)
               str)))
        (with-output-to-string (s)
          (map 'string
               (lambda (x)
                 (princ x s)
                 (when (char= x #\Newline)
                   (dotimes (i padding) (princ #\Space s))))
               str))))
Now one would only need to fix this beginner level code.
Re:Not Lisp again (2009) by lisper on Wednesday May 03, 2017 @01:00PM (#14257680)
No. Our editors auto-indent the code for us. This is one of the reasons Lisp syntax is better than python. Python syntax does not have enough information to auto-indent so it really is up to the programmer. Not so with Lisp.
Re:Not Lisp again (2009) by nitroll on Thursday May 04, 2017 @08:58PM (#14270341)
I hate when I code python and refactor stuff, moving stuff around and such, that I cant just copy/clip around and then do a final 'indent all my work correctly' like I can in a language like lisp.

I am kind of developing a grudge against whitespace sensitive languages. Not because it forces the programmer to indent properly, but because it disables my editors abilities to do it for me.

Re:Not Lisp again (2009) by lisper on Friday May 05, 2017 @12:55AM (#14271192)
Actually, Python has the equivalent of open-parens: the colon. What it doesn't have is close-parens, but if you use emacs then it will outdent on PASS and RETURN statements. In my personal coding style I always put PASS statements at the end of block so my code auto-indents properly. Hard-core Pythonistas hate this, but I really don't care what they think.
Re:Not Lisp again (2009) by lispm on Wednesday May 03, 2017 @02:23PM (#14258597)
Actually I write Lisp code, but I use neither Paredit nor SmartParens. I don't automatically balance my parentheses.
Re:Not Lisp again (2009) by Roboprog on Friday May 05, 2017 @11:35AM (#14274190)
Thanks. Almost nobody liked my comment (downvoted), but it sure kicked off a long discussion :-)

I haven't done any actual Lisp since the 80s on a CDC Cyber mainframe and a dedicated expansion card on an Apple II, so I'm "a wee bit" out of date.

I'm very visual / "geometric", so I like to see the "shape" of things. I can't stand looking at stuff "formatted" (?) in the typical enterprise java (8) "staircase of doom" with minimal whitespace, incredibly long lines, with a few arbitrary line wraps that indent to random spots way off on the right.

I swear, many programmers have never considered how newspapers and textbooks are formatted. They don't sprawl text endlessly across even if the paper is wide, they keep it reasonably narrow so your eye can follow it.

Re:Not Lisp again (2009) by Roboprog on Friday May 05, 2017 @12:14PM (#14274533)
Seriously, if you would have showed me the text of the code I'm working on now when I was a year into college in the early 80s, I think I would have changed my major.
Re:Not Lisp again (2009) by dTal on Wednesday May 03, 2017 @01:28PM (#14258004)
To any lisp enthusiasts who wonder why the language family isn't more popular: this is 99% of why. You have to use an editor where "copy" is called "Kill-ring-save" is invoked with "Meta-w". Any attempt to use any other tool will be met with incredulous responses to "just use Emacs".

It's such a shame because the development environment for Lisp could be so much better than other languages. It could be mindblowingly futuristic, instead of mindblowingly archaic.

Re:Not Lisp again (2009) by abustamam on Thursday May 04, 2017 @08:38PM (#14270241)
I've just started using Clojure (another Lisp) and I use IntelliJ IDEa with the Cursive plug-in, with par-infer to deal with the parens.

It works like a charm. I can have a REPL and my code right in front of me, I can cmd-down to go to a function definition, and it's overall a very pleasant developer experience.

Now, I did experiment with Emacs, so I do understand what you're talking about -- kill-ring-save and the related key bindings made zero sense to me, and I was having trouble doing things I'd do easily in IntelliJ.

Re:Not Lisp again (2009) by lispm on Wednesday May 03, 2017 @02:04PM (#14258403)
> You have to use an editor where "copy" is called "Kill-ring-save" is invoked with "Meta-w"

You are misinformed. I'm using a GNU Emacs (-> Aquamacs) on the Mac and cut/paste/copy are invoked with the usual command keys. But usually I use the LispWorks editor, which is also in the Emacs family, and even there cut/copy/paste is the usual command sequence... Both editors are built with excellent Lisp support. One is written in C + Emacs Lisp and the other one in Common Lisp.

> mindblowingly archaic

You haven't even understood the old part, how would you be able to deal with the futuristic part?

Re:Not Lisp again (2009) by fao_ on Wednesday May 10, 2017 @03:23PM (#14310872)
> You haven't even understood the old part, how would you be able to deal with the futuristic part?

"You haven't used a PDP-10, how would you be able to deal with a smartphone?"

Re:Not Lisp again (2009) by lispm on Wednesday May 10, 2017 @04:50PM (#14311589)
He didn't talk about old technology like 'smartphones', which existed as products (Nokia Communicator, ...) 20 years ago, but claimed that much better 'futuristic' IDEs for Lisp are possible, though what he claims may currently only exist in his imagination...
Re:Not Lisp again (2009) by sigjuice on Thursday May 04, 2017 @11:06AM (#14265330)
Any large piece of software will have its own terminology (car, cdr, frame, window, buffer, yank, kill, meta, ...). It is a shame that people would rather fixate on these superficial things instead of the minimal effort to get familiarized.
Re:Not Lisp again (2009) by kazinator on Wednesday May 03, 2017 @07:48PM (#14261271)
I've been programming in Lisp for 17 years now. I've always done it in Vim.
Re:Not Lisp again (2009) by lispm on Wednesday May 10, 2017 @04:52PM (#14311604)
my sincerest condolences
Re:Not Lisp again (2009) by mark_l_watson on Wednesday May 03, 2017 @09:47AM (#14255562)
+1, couldn't agree more. Especially about Quicklisp: Zach had an idea, implemented it, and made the lives of most CL programmers easier.