News for hackers. Stuff that matters.
Re:Pixie: A sweet Clojure-ish language by afandian on Monday March 09, 2015 @06:08AM (#9170108)
There aren't many languages that have radically fewer parentheses than Clojure / LISP.

Clojure:

    (defn blub-extra [a b]
        (blub (inc a) (inc b))) 
8 parens + 2 brackets

Scala:

    def blubExtra(a: Int, b: Int): Int {
       blub(inc(a), inc(b))
    }
8 parens + 2 braces

Java:

    Integer blubExtra(Integer a, Integer b) {
        return blub(inc(a), inc(b));
    }
8 parens + 2 braces

Ruby:

    def blubExtra(a, b)
        blub(inc(a), inc(b))
    end
8 parens

Python:

    def blubExtra(a, b):
        return blub(inc(a), inc(b))
8 parens, one colon

C:

    int blubExtra(int a, int b) {
        return blub(inc(a), inc(b));
    }
8 parens + 2 braces

It's roughly the same numbers of brackets (or equivalent) in Clojure, Scala, C and Java. A bit less in Python and Ruby.

Re:Pixie: A sweet Clojure-ish language by virtualwhys on Monday March 09, 2015 @08:48AM (#9170568)
Scala example is wrong, wouldn't even compile; should be:

    def blubExtra(a: Int, b: Int): Int = blub(inc(a), inc(b))
The original would need an equals thrown in there, otherwise it's procedural syntax (IIRC, has been deprecated or will be in the next release) which has a return type of Unit, thus not compiling when specifying a return type of Int.

    def blubExtra(a: Int, b: Int): Int = {
      blub(inc(a), inc(b))
    }
Re:Pixie: A sweet Clojure-ish language by afandian on Monday March 09, 2015 @08:52AM (#9170581)
Thanks for the typo spot. I've not written Scala for about 5 years. Unfortunately I can't go back and edit my post.
Re:Pixie: A sweet Clojure-ish language by gleenn on Monday March 09, 2015 @07:51AM (#9170384)
You can do it in Ruby with 4 parens, or even 0 if inc is really just +1. I wouldn't ever write it with so few but if we're really going down this rabbit hole then we ahould get it right.
Re:Pixie: A sweet Clojure-ish language by afandian on Monday March 09, 2015 @08:50AM (#9170576)
Please feel free to contribute a Ruby example (as long as it's normal and idiomatic, this isn't a competition)! I've not written Ruby for years.

(inc was just a random function for the sake of showing invocation so it's not really fair to use operators)

Re:Pixie: A sweet Clojure-ish language by bjz_ on Monday March 09, 2015 @06:29AM (#9170167)
I think it's the positioning of them that makes them stand out to people, plus the fact that they tend to bunch up at the end of things.
Re:Pixie: A sweet Clojure-ish language by afandian on Monday March 09, 2015 @06:32AM (#9170178)
Of course, I know. But most people express it as 'too many parens', without (I believe) actually thinking too hard. I was just trying to provoke a few thoughts!

The position of parens is something to get used to, but then again so is Python's indentation, Scala's type system, etc etc. Every language has something unique to get used to.

Re:Pixie: A sweet Clojure-ish language by forki23 on Monday March 09, 2015 @07:45AM (#9170364)
as someone already pointed out on twitter:

F#:

let blubExtra a b = blub (inc a) (inc b)

4 parens.

Re:Pixie: A sweet Clojure-ish language by forki23 on Monday March 09, 2015 @07:56AM (#9170413)
Usually we would write it as:

let blubExtra a b = inc b |> blub (inc a)

which 2 parens less, but at the cost of using the (very idiomatic) pipe operator.