News for hackers. Stuff that matters.
Re:Not Lisp again (2009) by c3534l on Tuesday May 02, 2017 @12:48PM (#14248034)
Yeah, but it's goddamned ugly and unreadable. It considers repetition to be a design feature. If you're going to sell people on the benefits of functional programming, I think you should really be pushing more for SML or Haskell or something like that.
Re:Not Lisp again (2009) by BoiledCabbage on Tuesday May 02, 2017 @01:07PM (#14248232)
It's been stated a number of times, but

x.f(y, z) has just as many parens as (f x y z). And Haskell particularly comes with so many syntax quirks. There is a lot of cruft you need to learn to get to the underlying functional core of haskell. Lips you can get 100% of the cruft out within a few days / 1 week. And the rest is just understanding programming concepts.

I don't use any LISP on a regular basis, but it still amazes me how often people are willing to dismiss a language based on parens.

It reminds me of a friend who would never try food from any other country because: Look at all the weird colors and ingredients. I'm not trying that.

In the end, no one will ever force anyone to try something - but my view in life is if everyone raves about something, and my main concern with it is by (my own admission) superficial. I still go and give it a try.

SICP gives you a new view on programming regardless of whether you ever touch lisp again or not.

Re:Not Lisp again (2009) by dualogy on Tuesday May 02, 2017 @03:04PM (#14249534)
> And Haskell particularly comes with so many syntax quirks

Wouldn't agree per se, I'd rather formulate "it gives the user-land a lot of freedom & powers for introducing syntax quirks". You can code super-clean Haskell, or you can roll in 2 dozen language extensions and libraries with a 100+ custom operators, and use TemplateHaskell --- then yeah the syntax will begin to look horribly "quirky". Many practitioners end up limiting themselves in this regard after a while, or insist on "going back to basics" as much as feasible

Re:Not Lisp again (2009) by BoiledCabbage on Thursday May 04, 2017 @03:38AM (#14263211)
> super-clean Haskell

The super-cleanest Haskell still has a ton of syntax to learn compared to Scheme. If your goal is to teach concepts of programming, almost any time spent on the syntax of a particular language is time wasted. Particularly so during a semester in university.

Similarly, if you won't be using FP for your day job, and would be using it for the insight gained (and have never used it), a language where you can begin learning concepts without needing to internals a bunch of syntax or infix operator precedence rules is also the better choice.

Re:Not Lisp again (2009) by dualogy on Thursday May 04, 2017 @06:49PM (#14269566)
> a ton of syntax to learn

A handful of keywords (same as any language), fewer (mandatory) parens & braces than any other language, no (mandatory) semicolons, the same sort of indentation one tends to apply in any language anyway --- Essential-Haskell's "ton of syntax" in a nutshell.

Precedence rules for the built-in `Num` and `Bool` operators are equivalent to all languages. Other operators are either custom-defined (outside the scope of language's "syntax") or entirely inessential convenience-vehicles such as for composition (unnecessary, just handy in practice) or avoiding even more parens (dito) --- of which there are 2. Any tutorials or text-books that rely on such or other operators as part of "syntax" are, in that respect, simply a bit flawed.

Re:Not Lisp again (2009) by mnarayan01 on Tuesday May 02, 2017 @02:20PM (#14249067)

  x + y * z
has way fewer than

  (+ x (* y z))
though. I'm not arguing for one or the other, but e.g. infix operators do have upsides.
Re:Not Lisp again (2009) by thoth on Tuesday May 02, 2017 @03:55PM (#14249983)
>infix operators do have upsides

What you are also glossing over are the precedence rules for operators. In this case it works in favor of your point and LISP indeed needs more parens.

However in other situations, you might need to re-parenthesize (language with flat precedence like APL) or consult your favorite chart[0] in order to figure out what is going on.

[0] http://en.cppreference.com/w/c/language/operator_precedence

Re:Not Lisp again (2009) by Jach on Tuesday May 02, 2017 @03:01PM (#14249495)
Fortunately with Lisp this isn't an unsolvable problem. https://github.com/rigetticomputing/cmu-infix
Re:Not Lisp again (2009) by simplify on Tuesday May 02, 2017 @01:05PM (#14248217)
I find lisp to be the most beautiful and readable language. Lisp has practically zero syntax; all code can be written equally. You can even create your own "syntax" / language features without waiting years for the approval of a committee (I'm looking at you, JavaScript).

What repetition are you referring to?

Re:Not Lisp again (2009) by karmajunkie on Tuesday May 02, 2017 @12:53PM (#14248092)
That's a pretty subjective opinion... I don't have much trouble with lisp but Haskell makes my eyes bleed. Of course I'm not a Haskell programmer, so it stands to reason that those who are find its syntax enjoyable.

To each their own...

Re:Not Lisp again (2009) by Tarean on Tuesday May 02, 2017 @01:34PM (#14248536)
I think haskell's syntax is extremely beautiful. However code that uses two dozen operators in half as many lines is incredibly ugly in any language and doing that can be quite tempting in haskell.

For code that non-haskellers have to work with I would just write everything out which is what lisp does and probably results in better code. Otherwise there still is a balance, I think. Like

Lispy:

    n <- textInput (set textInputConfig_inputType "number"
                    (set textInputConfig_initialValue "0" def))
Operators for precedence:

    n <- textInput $ def & set textInputConfig_inputType "number"
                         & set textInputConfig_initialValue "0"
Alias for function:

    n <- textInput $ def & textInputConfig_inputType .~ "number"
                         & textInputConfig_initialValue .~ "0"
Re:Not Lisp again (2009) by c3534l on Tuesday May 02, 2017 @01:52PM (#14248741)
> That's a pretty subjective opinion

Only on hacker news do people think there are objective opinions! The syntax is, let's say, "divisive" which is enough of a reason to think that if you want functional programming to grow, something needs to change about it.

Re:Not Lisp again (2009) by karmajunkie on Tuesday May 02, 2017 @03:18PM (#14249650)
yeah, I don't think that's true. Neither Clojure nor Haskell seem to have any problems finding adherents, nor does the functional paradigm itself seem to be in danger of... anything. Your personal distaste for parens isn't much evidence to support the idea that they are antithetical to the growth of functional programming, nor my own distaste for Haskell evidence of the same.
Re:Not Lisp again (2009) by golergka on Tuesday May 02, 2017 @12:53PM (#14248090)
Unreadable? Personally, I think that Lisp has the clearest possible syntax - because it basically doesn't have any. It's just straight ASTs - something that I have to visualize myself in other languages wich have more syntax sugar.
Re:Not Lisp again (2009) by tromp on Tuesday May 02, 2017 @01:04PM (#14248196)
Lisp has the minimal syntax for lists:

    (a b c d)
where other languages require separating commas, but Haskell has minimal syntax for function application:

     f x y z
with no parenthesis needed. (Technically, this is a triple application ((f x) y) z, masked by the convention of application being a left-associative binary operator.)
Re:Not Lisp again (2009) by wtetzner on Tuesday May 02, 2017 @01:37PM (#14248568)
Right, Haskell's function application syntax is more "minimal" that Lisp's, at least in the simple case.

But golergka said that Lisp's syntax is the clearest, not the smallest. And while that's probably something that depends on one's knowledge and past experience, I think there's something to it. The parens mean that it's unambiguous, and there is very little work on the reader's part to figure out where an expression begins and ends.

There's no operator precedence to keep in mind, no special whitespace rules, etc. It's about as minimal as you can get while still being completely explicit about syntactic constructs.

Re:Not Lisp again (2009) by kazinator on Tuesday May 02, 2017 @01:28PM (#14248463)
That is "minimally punctuated syntax". What we want is a "minimal correspondence between written syntax and the AST"; that is what is really meant by "Lisp has minimal syntax".

What you have there is loaded with ambiguity that has to be resolved by semantics. And after the dust settles, you're left without variadic functions.

Partial evaluation and currying are very valuable techniques. They are still succinct if there is a visible, explicit partial application operator to denote a function that is constructed by binding arguments around an expression.

Re:Not Lisp again (2009) by golergka on Wednesday May 03, 2017 @07:39AM (#14254829)
> but Haskell has minimal syntax for function application: > f x y z

The question is, is it the _only_ syntax that Haskell offers and that the full language is built upon?

Re:Not Lisp again (2009) by chirau on Tuesday May 02, 2017 @01:15PM (#14248321)
How would you write f((x y)z) in Haskell?
Re:Not Lisp again (2009) by scriptdevil on Tuesday May 02, 2017 @01:47PM (#14248697)
f $ x y $ z

Basically, f $ x = f x and is applied with lowest operator precedence (0) and is right associative. Therefore, f $ x y $ z = f (x y $ z) = f((x y) z)

Re:Not Lisp again (2009) by vq on Tuesday May 02, 2017 @02:26PM (#14249115)
If by (x y) you mean x(y) then I would write it like this:

f (x y) z

Re:Not Lisp again (2009) by tromp on Tuesday May 02, 2017 @02:24PM (#14249099)
f (x y z)
Re:Not Lisp again (2009) by lmm on Tuesday May 02, 2017 @01:50PM (#14248718)
It makes e.g. arithmetic expressions look rather awkward.
Re:Not Lisp again (2009) by golergka on Wednesday May 03, 2017 @12:45AM (#14253100)
That's if you choose to think abiut them as arithmetic expressions and not function applications. If you work with arithmetic expressions a lot, you should probably use appropriate domain language - in fact, you can build it in Lisp itself.
Re:Not Lisp again (2009) by lmm on Wednesday May 03, 2017 @04:15AM (#14253899)
You can write a reader macro (in lisps that permit them, otherwise you've got no hope) but that's just lisp-speak for "program that parses strings". A language where you can use infix notation within the language is much nicer.
Re:Not Lisp again (2009) by agumonkey on Tuesday May 02, 2017 @01:20PM (#14248362)
sml is uber cute, probably the only syntax I enjoy more than sexps. I never got the people with problems regarding lisp thin syntax.

- there's no universal syntax for everything [1]

- lisp entice you to make tiny dsl as sets of correlated functions on some domain for which there's no syntax .. [related to 1]

- close to zero magic

- parsing complexity removed and built-in, jump straight into problem solving [3]

- some advanced academics don't see classic math as the ultimate notation (one sicp author made SICM for langrangian mechanics) he likes the consistency and smallness of sexps [related to :3

[1] I know, people like infix math

[2] I failed an ADA exam because I couldnt find how to typecase a 1-char string to a char type.. try to guess

[3] instead of how cute is my <incompatible-and-not-more-powerful-lang-of-the-day> looking.. Also Brown Uni. had a chapter on not wasting time on syntax in education. Although they made pyret lang since .. but syntax is not the only reason.

Re:Not Lisp again (2009) by sedachv on Tuesday May 02, 2017 @01:24PM (#14248415)
> I think you should really be pushing more for SML or Haskell or something like that.

There are two clues in this sentence (mentioning SML and not OCAML, "something like that") that suggest you do not regularly program in a "something like that" language. I wrote my first Haskell program over a decade ago. I find Haskell very hard to read. The grammar is very complicated[1] and is actually context-sensitive[2].

[1] https://www.haskell.org/onlinereport/haskell2010/haskellch10... [2] http://trevorjim.com/haskell-is-not-context-free/

Re:Not Lisp again (2009) by c3534l on Tuesday May 02, 2017 @01:50PM (#14248721)
I do like OCaml, but have never had the opportunity to write more than a few toy programs for fun. I put SML in there just to be like "and other ML-family functional programming languages." Haskell is complicated, but some complication is needed and that's more of a learning-curve problem. If humans were capable of simple, we'd all be typing 1s and 0s. We do better with grouping, context, similar things being similar and dissimilar things being dissimilar. I don't think Lisp is the way forward for functional programming.
Re:Not Lisp again (2009) by sedachv on Tuesday May 02, 2017 @04:41PM (#14250362)
> Haskell is complicated, but some complication is needed and that's more of a learning-curve problem.

That is a junk argument. No one needs context-sensitive grammars. I think designing a language that cannot be parsed with an LL(1) or LALR parser is just dumb. It guarantees that your compiler will be slow right from the start. In addition that applies to all the tooling - syntax highlighting and navigation in the editor, linters, pretty-printers, etc. And in practice the tooling is not just slow but also has a ton of bugs around corner cases.

Re:Not Lisp again (2009) by siscia on Tuesday May 02, 2017 @12:53PM (#14248086)
Repetition of what? I don't see any repetition on those snippets... What are you referring to?
Re:Not Lisp again (2009) by jasonkostempski on Tuesday May 02, 2017 @01:04PM (#14248200)
Maybe they had mistaken the breakdowns for user input? I did for a second.
Re:Not Lisp again (2009) by c3534l on Tuesday May 02, 2017 @01:43PM (#14248645)
Everything is nested in the form of (fn arg arg) and relies solely on indentation to create some modicum of differentiation.
Re:Not Lisp again (2009) by davexunit on Tuesday May 02, 2017 @01:36PM (#14248555)
Lisp is not a functional programming language.
Re:Not Lisp again (2009) by drdre2001 on Tuesday May 02, 2017 @02:36PM (#14249217)
How? Functions are first class in lisp.
Re:Not Lisp again (2009) by davexunit on Tuesday May 02, 2017 @02:53PM (#14249413)
Functional programming is but one of the many paradigms that you can use in Lisp, along with imperative, object-oriented, relational, etc. When you say a language is a functional language, you are saying that it is the paradigm supported, which is not the case here.
Re:Not Lisp again (2009) by concede_pluto on Tuesday May 02, 2017 @04:00PM (#14250030)
Lisp has lots of mutable types and lots of ways to smuggle them into and out of a procedure. I'd say pure functions are tolerated but not supported.

Still hard to beat for creating domain-specific languages, though, and a carefully designed DSL can rule out nondeterminism and side effects.

Re:Not Lisp again (2009) by davexunit on Tuesday May 02, 2017 @04:27PM (#14250254)
A language need not force purity to allow for purely functional programs. Besides, purely functional languages all need a way to cheat to actually do anything useful. Any nontrivial program needs a mix of paradigms.
Re:Not Lisp again (2009) by crimsonalucard on Tuesday May 02, 2017 @02:52PM (#14249396)
First class functions do not make a programming language functional.