News for hackers. Stuff that matters.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by andrewstuart on Tuesday March 17, 2015 @08:38PM (#9222746)
So many brackets. Resolving mismatched brackets seems to be just about the most pointless developer activity possible.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by muraiki on Tuesday March 17, 2015 @09:31PM (#9223008)
If you edit s-expressions as text then yes, it's horrible.

If you edit s-expressions as data structures using something like paredit you'll actually code very quickly, and it'll also be impossible to have unbalanced parens.

Say you have this (| = cursor): (a b |c d)

If you type ( you get balanced parens: (a b ()| c d)

If you press Ctrl+Right twice you slurp in c and d: (a b (c| d))

If you then press Alt+Up you get back to: (a b c| d)

As you can see, you manipulate code on the level of data structures instead of manually placing parentheses, and you are actually prevented from making unbalanced parens in paredit. You can likewise move through code in ways similar to moving by word or paragraph in vim vs moving by character, but I only showed basic editing above.

I won't downvote you because I understand your complaint. But the problem is that you are unaware that you are using the wrong mode of editing for s-expressions. :) It's like editing photo using a hex editor: possible, but very much suboptimal.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by beeworker on Tuesday March 17, 2015 @08:45PM (#9222781)
I know right, I totally hate having to match Map<String, Map<String, Object>> foo = someMethod(withMethodArg1(), andTwo());

Let's all just use Forth, and implement washing machines as simply as:

    : WASHER  WASH SPIN RINSE SPIN ;
Re:John Carmack: “I just dumped the C++ server I wrote for a... by kenferry on Tuesday March 17, 2015 @09:09PM (#9222888)
Lisp uses the same number of parens as most languages per call – the only thing that's different is whether the paren goes before or after the first part of the call.

    (print "hello") 
vs

    print("hello")
So to the extent Lisp is paren-heavy, it's more a stylistic thing. Lisp programmers tend to chain up calls more.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by eru on Tuesday March 17, 2015 @11:28PM (#9223435)
> Lisp uses the same number of parens as most languages per call [...]

Indeed. If you want less parens, use Haskell or Forth.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by UnquietTinkerer on Tuesday March 17, 2015 @09:33PM (#9223019)

    (-b + sqrt(b*b - 4*a*c)) / (2*a)
    (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a))
It does depend on your use case.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by yogthos on Tuesday March 17, 2015 @10:27PM (#9223226)
Re:John Carmack: “I just dumped the C++ server I wrote for a... by kazinator on Wednesday March 18, 2015 @07:48PM (#9229390)
Lisp only has infix macros so that we can say "we have that".

Nobody in their right mind uses this stuff in production code.

It just overcomes objections. "Oh, if I start using Lisp, there is be a way to use infix, should I really need it". Ten years and six Lisp project later, you still haven't used the infix stuff; the situation never comes.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by jakub_h on Friday March 27, 2015 @06:43PM (#9279527)
> Nobody in their right mind uses this stuff in production code.

You sure about that? I thought the lispy approach was generally pragmatic - you use what you deem handy for your application. It this weren't the case, there would be little need for macros in the first place. I can very well imagine, say, a scientific or engineering application that would share a common infix parser for both user-provided expressions (in the UI, to be more friendly to non-lispers) and heavy math lifting in the source code.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by yogthos on Friday March 20, 2015 @02:11PM (#9239510)
Clearly you didn't even look at the links provided. :)
Re:John Carmack: “I just dumped the C++ server I wrote for a... by kazinator on Wednesday March 18, 2015 @07:35PM (#9229339)
But! Perfect splitting across lines according to a formatting algorithm which is simple, consistent, and incrementally applicable:

1.

   (/ (+ (- b) (sqrt (- (* b b) (* 4 a c))))
      (* 2 a))
2.

   (/ (+ (- b)
         (sqrt (- (* b b) (* 4 a c))))
      (* 2 a))
3.

   (/ (+ (- b)
         (sqrt (- (* b b)
                  (* 4 a c))))
      (* 2 a))
4.

   (/ (+ (- b)
         (sqrt (- (* b
                     b)
                  (* 4 
                     a 
                     c))))
      (* 2
         a))
Now you have a sideways tree, revealing the structure of the expression, where it is immediately apparent what the operands are of the / and the + and so on.

Infix turns into a mess breakfast when it's too long for one line.

For this particular expression, I'd probably go with variant (3) in production code. Compared to the beauty of (3), the original one-liner is basically a strawman. In terms of clarity of structure, it trumps the infix also.

This is actually a very important point that is overlooked by Lisp noobs. In real Lisp code, expressions are not written all out in one line, whereby the human reader must mentally match the parentheses. Even numeric expressions that might be one-liners in Fortran or C, are split across several lines to make at least the major constituents clear in relation to the major operator.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by ynniv on Tuesday March 17, 2015 @10:34PM (#9223256)
http://srfi.schemers.org/srfi-105/srfi-105.html

    {-(b) + {sqrt((b * b) - (4 * a * c)) / (2 * a)}}
Re:John Carmack: “I just dumped the C++ server I wrote for a... by thoth on Wednesday March 18, 2015 @10:20AM (#9225620)
>It does depend on your use case.

Yes, and the first line's use case depends on the language built-in operator precedence rules to reduce the number of parens.

If you are using math formulas as an example of minimal paren usage, go with APL and have even fewer since all operators are equal precedence and associate to the right.

If you really wanted to write the quadratic formula (or math formulas in general) you could use APL and use even fewer.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by evincarofautumn on Wednesday March 18, 2015 @07:27PM (#9229310)

    b fnegate b b f* 4 a c f* f* f- fsqrt f+ 2 a f* f/
Re:John Carmack: “I just dumped the C++ server I wrote for a... by andrewstuart on Wednesday March 18, 2015 @12:52AM (#9223690)
Executable line noise.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by ChristianBundy on Tuesday March 17, 2015 @09:43PM (#9223055)
Your second line hurts me inside.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by kazinator on Wednesday March 18, 2015 @07:45PM (#9229374)
> Lisp uses the same number of parens as most languages per call

Furthermore, Lisp uses zero parentheses for grouping in order to override precedence. These parentheses don't exist in Lisp.

In print(2/(2+4)), we actually have two kinds of parentheses, because two different grammar rules use the same token.

C has even more parentheses. The parentheses in for (;;) are not the same as those in 2/(2+4) which are not the same as those in (double) p, which are not the same as those in p(42).

Lisp has parentheses that do one darn thing in the read syntax---at least when they are not literal as in "(" or #\(.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by rtpg on Tuesday March 17, 2015 @09:31PM (#9223000)
What about a paren-less calling mechanism?

main = putStrLn "hello"

Re:John Carmack: “I just dumped the C++ server I wrote for a... by eru on Tuesday March 17, 2015 @11:29PM (#9223438)
Possible, and nice. But you lose the ability to easily specify a variable number of arguments.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by jakub_h on Friday March 27, 2015 @06:46PM (#9279539)
Well, there's always the Smalltalk approach.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by Sanddancer on Tuesday March 17, 2015 @11:45PM (#9223478)
Shell languages seem to do just fine using spaces to easily specify a variable number of arguments.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by eru on Wednesday March 18, 2015 @12:54AM (#9223697)
Yes. I forgot to mention that Haskell also supports partial application. Shell doesn't, so that's easier.

And that's just talking about syntax. The type system complicates matters further.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by dang on Tuesday March 17, 2015 @09:20PM (#9222946)
> So many brackets. Resolving mismatched brackets seems to be just about the most pointless developer activity possible.

It's precisely the other way around: finicky syntax issues consume far less time in Lisp. This isn't just a surface thing—when syntax occupies a block of resident memory in your head, you have that much less capacity to spend on the problem at hand.

It takes a while to adjust to a more regular notation, but that's true of anything unfamiliar. And what you get in return is astonishing.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by Crito on Tuesday March 17, 2015 @08:50PM (#9222800)
Unsurprisingly, working with balanced brackets is something computers are well suited for. Even in Vim, an editor not exactly built with Lisp development in mind, handing mismatched brackets is pretty trivial.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by orthecreedence on Tuesday March 17, 2015 @09:24PM (#9222965)
Agreed, I do all my lisping in vim and have for years. Mismatched parens has pretty much been the least of my worries from day one.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by wyager on Tuesday March 17, 2015 @08:50PM (#9222798)
While that's a bit of an acerbic way to put it, I agree. The human brain has a very short stack depth, so we're no good at nested pattern matching.

Indentation or delimiter based languages are much easier for me to parse than lisps.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by l4mbda on Tuesday March 17, 2015 @09:46PM (#9223065)
As they say, “If you think paredit is not for you then you need to become the kind of person that paredit is for.”
Re:John Carmack: “I just dumped the C++ server I wrote for a... by Zelphyr on Tuesday March 17, 2015 @09:19PM (#9222942)
One of the reasons I'm falling in love with Rebol and Red. Very Lispy but with out the hassle of the parens.

Brackets, yes, but not nearly as bad.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by pjscott on Tuesday March 17, 2015 @09:05PM (#9222875)
The usual solution is to indent your lisp code.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by lmm on Wednesday March 18, 2015 @04:26AM (#9224226)
Why repeat myself? If the indentation contains the information, why can't I just use that?
Re:John Carmack: “I just dumped the C++ server I wrote for a... by nialo on Thursday March 19, 2015 @12:48PM (#9233144)
The parens are the single point of truth, the indentation is just for display and is (almost entirely) mechanically generated.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by current_call on Wednesday March 18, 2015 @08:09PM (#9229485)
Because then you end up with thinks like Python's one expression lambda.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by iopq on Tuesday March 17, 2015 @09:08PM (#9222884)
What I hate is when my delimiters are unmatched and I can't tell where. I haven't used Lisps, but it bothers me a lot even in C-like languages.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by andrewchambers on Tuesday March 17, 2015 @08:52PM (#9222812)
Generally things like paredit force brackets to never go unmatched. There is also rainbow colored parens.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by krylon on Wednesday March 18, 2015 @04:01PM (#9228273)
There are good text editors and IDEs for LISP-like languages that will help you matching braces. It stops being a problems very quickly. Also, like in other languages, you can make the structure of your code clear by indentation (good editors/IDEs will help you with that, too, of course).

Also, in C/C++/Java/C#/whatever code, you can run into the same kind of problem on a smaller scale when editing deeply nested blocks and expressions, especially when dealing with complex arithmetic/logic expressions.

(I basically only use Lisp when messing with Emacs, so I would not call myself a Lisp hacker, but when learning Lisp, the braces cease to be a problem after a month at most.)

Re:John Carmack: “I just dumped the C++ server I wrote for a... by davexunit on Tuesday March 17, 2015 @08:53PM (#9222815)
M-x paredit-mode
Re:John Carmack: “I just dumped the C++ server I wrote for a... by e12e on Tuesday March 17, 2015 @09:36PM (#9223028)
Re:John Carmack: “I just dumped the C++ server I wrote for a... by frozenport on Tuesday March 17, 2015 @09:34PM (#9223021)
As opposed to checking the indent level? (Python)
Re:John Carmack: “I just dumped the C++ server I wrote for a... by andrewstuart on Tuesday March 17, 2015 @10:06PM (#9223154)
I'm guessing you mean with Python? I have to say I've never once had a bug related to number of spaces.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by jquast on Thursday March 19, 2015 @01:46AM (#9230383)
I billed 8 hours work to a company to fix a python bug that was exactly this problem.

After a lot of refactoring by someone inexperienced in python, something was indented inside of a loop that should have been outside it.

8 hours work for de-denting one line of code.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by fixxer on Tuesday March 17, 2015 @09:13PM (#9222915)
Nothing raises the ire of HN devotees like the most mild criticism of Lisp aesthetics... Such a sensitive lot.
Re:John Carmack: “I just dumped the C++ server I wrote for a... by orthecreedence on Tuesday March 17, 2015 @09:20PM (#9222947)
I'm sure if lispers started going into python threads and whining about "argg all the whitespace makes me want to gauge my eyes out!!!11" the response would be similar. Don't like parens? That's fine, really. Want to write off an entire class of languages because the syntax isn't plastered with curly braces? Go ahead!

Just don't expect anyone to all that interested when you start blubbering about it.

Re:John Carmack: “I just dumped the C++ server I wrote for a... by Semiapies on Wednesday March 18, 2015 @11:38AM (#9226227)
If a post on Python has more than a handful of comments, the whitespace discussion almost inevitably comes up, in my experience.