News for hackers. Stuff that matters.
Re:Is Clojure dying, and what has Ruby got to do with it? by graphememes on Thursday May 25, 2017 @03:17PM (#14419407)
I'm still left with the question of "why all the parenthesis?"

While it might sound silly and reductionist, it is ostensibly the single hurdle I could never overcome when it came to lisp languages. The majority resides with the fact that it could work without them, so I see it as an ancient artifact.

Re:Is Clojure dying, and what has Ruby got to do with it? by flavio81 on Thursday May 25, 2017 @04:16PM (#14419811)
For Lisp, parentheses are a big plus. They allow the following advantages:

TL;DR: Once you start programming in Lisp for long enough, you end up loving and embracing the parentheses.

0. They allow for an extremely simple syntax, which in turn allows the source code to easily manipulate source code. No simple syntax, no really easy way to write macros. And macros are one of the most essential keys to Lisp's power. You can argue that, without extremely simple syntax, a Lisp language is not possible.

1. Syntax, being so simple, is extremely easy to learn. Yesterday i explained Lisp's syntax to a friend, in 3 minutes.

2. No need to care for special operator precedence rules. The precedence of operators is obvious by looking at the code.

3. IDEs, like SLIME, can easily traverse the code in many powerful ways. Due to this syntax, the IDEs can "understand" expressions and expressions within expressions. This means that the IDE can 'understand' any part of your code, not just big constructs like functions, methods or classes.

4. IDEs will also easily complete the parentheses for you, and will warn you of a missing parenthesis.

5. It is also dead simple to understand which parenthesis closes which one. It can be done with most source code editors -- Even a simple program like Notepad++ can do it, Visual Studio Code can do it, etc.

6. Parentheses also enable IDEs to automatically apply "pretty" format to the code rather easily.

7. As anything, you get used to it. Many people, for example, think that, in Python, whitespace as a block delimiter is a bad idea, however I never had any problem with that, it was just fine. Unless you are using Windows Notepad to edit code...

Re:Is Clojure dying, and what has Ruby got to do with it? by graphememes on Thursday May 25, 2017 @07:49PM (#14420993)
This is more an emotional response to me than it is functional or logical one since you can apply all of these points to any other language.
Re:Is Clojure dying, and what has Ruby got to do with it? by iLemming on Saturday May 27, 2017 @03:34PM (#14431586)
It's not emotional, no. After just a few months of using Lisps it feels like parentheses bring some structure and order. In non-lispy languages things feel "all over the places" - there you do have to deal with punctuation - not just parens but: semicolons, dots, commas, brackets, curlies, indentation.

Programming in a Lisp is like writing a prose. Your brain is occupied with ideas, you just need to type them down. You don't need to think about structure (until later), it's a flow - you're looking for right words (functions), you can immediately try them out in the REPL, pretty much like a writer would review usage of a word in a thesaurus or a dictionary.

But to be fair I met a few people who claimed that even after months of using a Lisp, they just couldn't get the parentheses. I dunno, guess some people's brains maybe just not suited. You can call it dyslisplexia or whatever.

Re:Is Clojure dying, and what has Ruby got to do with it? by coolmitch on Thursday May 25, 2017 @03:55PM (#14419699)
I'll plug Parinfer as the best tool I've found for removing the pain of editing s-expressions. It's done wonders for my own workflow, and there's almost nothing to learn before you can use it effectively (compare to Paredit which requires you to know quite a few shortcuts before becoming productive)

I almost never have to think about the parentheses while editing, any more than I would braces in a c-like language. It's really freeing. It's also fully integrated into Cursive so there isn't even a setup step if you're using that already.

https://shaunlebron.github.io/parinfer/

Re:Is Clojure dying, and what has Ruby got to do with it? by ledgerdev on Thursday May 25, 2017 @04:35PM (#14419950)
I feel most syntax themes are designed for syntax based languages and make the parenthesis far too dark/prominent and it's visually overwhelming.

If you dial back the color of parenthesis and brackets to a lighter grey, the experience is almost like writing python with parinfer.

Re:Is Clojure dying, and what has Ruby got to do with it? by dangerbird2 on Thursday May 25, 2017 @03:36PM (#14419555)
Parentheses exist because it is the easiest way to represent the raw AST in text form. S-Expressions were originally an intermediate form for a more algol-like syntax[0], but became the primary form of representing Lisp because allowing the programmer to manipulate the AST is extremely useful, arguably what makes Lisp Lisp. There are homoiconic languages like Prolog and Julia that have more familiar syntax styles, but S-Expression Lisps are unmatched in making homiconicity readily apparent.

Another reason Lisp programmers tolerate parentheses hell is that Lisp development has often paralleled that of emacs and emacs-like editors that make manipulating s-expressions extremely intuitive.

[0] https://en.wikipedia.org/wiki/M-expression

Re:Is Clojure dying, and what has Ruby got to do with it? by peterhadlaw on Thursday May 25, 2017 @03:22PM (#14419449)
The parentheses end up serving as a tool to speed up the development process with tool like paredit. You end up manipulating the "tree" of code vs the characters on a line. Check this out: https://www.youtube.com/watch?v=D6h5dFyyUX0
Re:Is Clojure dying, and what has Ruby got to do with it? by bryanlarsen on Thursday May 25, 2017 @03:26PM (#14419476)
paredit doesn't require parentheses to do it's magic.
Re:Is Clojure dying, and what has Ruby got to do with it? by falcolas on Thursday May 25, 2017 @05:42PM (#14420342)
Contrast, for a moment:

    var x = fib(a, b);
with

    (let x (fib a b))
And count the delimiting symbols. I count 5 in the first example. In the second, I see 4.

Let's try something a bit harder.

    function(a, b) {
        return a * b;
    }(6, 4);
vs.

    ((fn (a b) 
        (* a b)
    ) 6 4)
10 first, 8 second.

Yes, "why all the [symbols]" indeed.

Re:Is Clojure dying, and what has Ruby got to do with it? by city41 on Thursday May 25, 2017 @07:10PM (#14420829)
Quantity is only one aspect. Structure and ability to mentally parse out patterns matters too. I don't mind Lisps and use Clojure regularly, yet I'd still argue your JS examples are easier to read than the Lisp ones.

Heck even Clojure seems to agree, just the simple act of using vectors for various things (ie function parameters) helps with the readability

    ((fn [a b]
        (* a b)
    ) 6 4)
Re:Is Clojure dying, and what has Ruby got to do with it? by falcolas on Friday May 26, 2017 @09:22AM (#14423796)
Well, vectors are a workaround for the challenges in creating homeoiconic lists that the JVM understands.

And if I'm frank, the JS examples are easy to read because you're familiar with the syntax. When you first started to learn C style syntax, it was likely just as confusing. I've spent a fair bit of time with lisp now, and the parenthesis are no more or less confusing than any of the symbols used in other languages. They're just scope delimiters.

Re:Is Clojure dying, and what has Ruby got to do with it? by city41 on Friday May 26, 2017 @12:12PM (#14425062)
I disagree. The JS is easier to read because it has an easier to parse structure. I've been coding in clojure for several years now.
Re:Is Clojure dying, and what has Ruby got to do with it? by bshimmin on Thursday May 25, 2017 @06:09PM (#14420549)
For your second example, your JavaScript is wrong. Let's compare the ES2015 JavaScript:

  ((a, b) => a * b)(6, 4);
...against the Clojure:

  ((fn [a b] (* a b)) 6 4)
Not a lot in it, really, is there?
Re:Is Clojure dying, and what has Ruby got to do with it? by dragandj on Thursday May 25, 2017 @06:43PM (#14420725)
The clojure example is really (* 6 4) since * is already a function, not an operator as in most languages.

On the other hand, you can trivially create a macro that would implement the exact es2015 syntax (or at least a very close match), but why would anyone do this?

Re:Is Clojure dying, and what has Ruby got to do with it? by lilactown on Thursday May 25, 2017 @06:37PM (#14420698)
If we're golfing...

  (#(* %1 %2) 6 4)
Re:Is Clojure dying, and what has Ruby got to do with it? by smnplk on Thursday May 25, 2017 @09:13PM (#14421421)
And a bit shorter version...

24

;)

Re:Is Clojure dying, and what has Ruby got to do with it? by mrkgnao on Thursday May 25, 2017 @11:42PM (#14421839)
I wonder, does #(* %1) do anything sensible?
Re:Is Clojure dying, and what has Ruby got to do with it? by latte on Friday May 26, 2017 @07:31AM (#14423310)
Clojure's * can accept any number of arguments, including zero (returns 1 in this case), one (acts as identity function on numbers) or more than two (returns the product of all arguments). This helps to simplify arithmetic expressions in some cases (e. g. polynominals) and allows to calculate a sum or product of any sequence, including empty one, using (reduce * xs)
Re:Is Clojure dying, and what has Ruby got to do with it? by kbp on Thursday May 25, 2017 @11:50PM (#14421871)
> I wonder, does #(* %1) do anything sensible?

It's a 1-argument function, so applying it to 2 arguments would give an error. Minus the arity error, 1-argument * is an identity.

Re:Is Clojure dying, and what has Ruby got to do with it? by dragandj on Thursday May 25, 2017 @03:43PM (#14419602)
It took me an afternoon to get used to the prefix notation (not to parentheses; those are used even in python), and after that afternoon I would refuse to program without it. Makes the code way more regular.
Re:Is Clojure dying, and what has Ruby got to do with it? by bitwize on Thursday May 25, 2017 @03:44PM (#14419614)
Use Emacs and optionally avail yourself of a structural editing mode like paredit. Then, at a minimum, the editor will help you match parens and you barely even have to think about them. Seriously, get over your Emacs hate (if you have any) because Emacs is to Lisp family languages what IntelliJ is to Java.
Re:Is Clojure dying, and what has Ruby got to do with it? by flavio81 on Thursday May 25, 2017 @07:36PM (#14420938)
SLIME (for Emacs) is wonderful. I like Emacs, what i don't like is the key combinations, which are horrible.

Fortunately, you can redefine them. Emacs can be customized at will, and using Lisp :)

Re:Is Clojure dying, and what has Ruby got to do with it? by graphememes on Thursday May 25, 2017 @04:04PM (#14419753)
I don't hate emacs, I have however invested a lot more time and work into vim than emacs so that is why I do not use it.
Re:Is Clojure dying, and what has Ruby got to do with it? by indigo0086 on Thursday May 25, 2017 @04:20PM (#14419841)
I use spacemacs. before I had to have a vim plugin in every ide. But seeing the incredible power of emacs and the ease of integrating vim with it (pretty much a "pick your style" at the beginning of spacemacs installation) I'll never go back.
Re:Is Clojure dying, and what has Ruby got to do with it? by smnplk on Thursday May 25, 2017 @07:06PM (#14420807)
the only reason i didn't like spacemacs was the 3 keystroke combos for everything that I do with 2 strokes in vim.
Re:Is Clojure dying, and what has Ruby got to do with it? by throwaway7645 on Thursday May 25, 2017 @09:17PM (#14421438)
Yea...I like the theory of emacs, but the reality of vim usage.
Re:Is Clojure dying, and what has Ruby got to do with it? by bryanlarsen on Thursday May 25, 2017 @03:24PM (#14419465)
There seems to be a very nice solution to the parenthesis problem: https://sourceforge.net/p/readable/wiki/Home/

I have no idea why it hasn't caught on. As far as I'm aware, there's no Clojure implementation. Lispers like their parentheses.

Re:Is Clojure dying, and what has Ruby got to do with it? by gnaritas on Thursday May 25, 2017 @08:57PM (#14421354)
> I have no idea why it hasn't caught on.

Because there is no parenthesis problem; there's a newb problem. The people who complain about parenthesis haven't used a Lisp long enough, that's all. Parens are a feature, not a problem, and everyone eventually figures that out and stops complaining or they move on to a language more suited to them.

Re:Is Clojure dying, and what has Ruby got to do with it? by dragonwriter on Thursday May 25, 2017 @03:36PM (#14419554)
It hasn't caught on is because for all the talk about parens, they aren't really a decisive barrier, just an easy thing to latch on to, and because S-expressions are more clear (note that more algol-inspired M-expressions were the original proposed programming syntax for Lisp, with S-expressions as an behind-the-scenes representation, but programmers preferred using S-expressions directly.)
Re:Is Clojure dying, and what has Ruby got to do with it? by flavio81 on Thursday May 25, 2017 @04:29PM (#14419924)
(we) lispers LOVE our parentheses.

"Elegant weapons... for a more civilized age."

Ref: https://xkcd.com/297/

Re:Is Clojure dying, and what has Ruby got to do with it? by bbcbasic on Thursday May 25, 2017 @06:21PM (#14420610)
I love that particular xkcd

I'm not even a lisper.

Re:Is Clojure dying, and what has Ruby got to do with it? by protomyth on Thursday May 25, 2017 @03:28PM (#14419493)
Perhaps because significant white space (e.g. Python) has quite a lot of detractors of its own.
Re:Is Clojure dying, and what has Ruby got to do with it? by weaksauce on Thursday May 25, 2017 @03:33PM (#14419531)
I absolutely cannot stand significant whitespace... it is a step back in almost every area of usability.
Re:Is Clojure dying, and what has Ruby got to do with it? by flavio81 on Thursday June 01, 2017 @06:47PM (#14465627)
Why?

I have done two major (commercial) software projects in Python, with a good amount of code, several months of work, and I've never had ANY kind of problem with the indentation/whitespace.

Any Python IDE (like Pycharm) will easily highlight you where each section of code sits relative to the indentation level, so it's really pretty simple. Really, really simple.

Re:Is Clojure dying, and what has Ruby got to do with it? by goatlover on Friday May 26, 2017 @03:03AM (#14422433)
In your opinion. For you it's a step back. For some of us it's very easy to read and write.
Re:Is Clojure dying, and what has Ruby got to do with it? by weaksauce on Friday May 26, 2017 @02:53PM (#14426312)
I don't really get this line of thought... are curly braces really that hard to read and get in the way of things to you?
Re:Is Clojure dying, and what has Ruby got to do with it? by throwaway7645 on Thursday May 25, 2017 @09:15PM (#14421433)
I love both Lisp & Python. I'm not sure about large projects, but to me, nothing is easier to read than Python and a lot of people agree. It is so strict and authoritarian that nearly everyone ends up writing similar code. Good for sharing scripts on my team. If I write Perl, only I can understand it...and even that is temporary lol (I joke, but you get the point).
Re:Is Clojure dying, and what has Ruby got to do with it? by cutler on Friday May 26, 2017 @12:39AM (#14422029)
If you love Lisp & Python try Hy (hylang.org).
Re:Is Clojure dying, and what has Ruby got to do with it? by graphememes on Thursday May 25, 2017 @03:31PM (#14419515)
This is a much more approachable syntax, reads much like a mix of Ruby and Python