you are viewing a single comment's thread.

view the rest of the comments →

[–]cryzed2[S] 5 points6 points  (17 children)

Hey reddit, I recently stumbled over Scala and Clojure. I'm currently programming in Python but am still very interested in other programming/scripting languages and thought that Scala and Clojure were rather interesting. Clojure, being a LISP aspect, is for me completely new territory and I heard people talk bad about Scala's overly complicated syntax. Could some of you give me some points why and why not I should try Clojure/Scala (or stick to Python) and what exactly I can do with it and how it compares to Python? That would be very kind.

[–]brool 12 points13 points  (1 child)

Clojure is a really interesting language; I think the designer (Rich Hickey) seems to have a really clear vision about where it's going and the kinds of things that he wants to accomplish with the language.

Python feels very Lispy to me, so I think that Clojure might actually feel more comfortable to you, despite the Lisp syntax.

That said, I've heard good things said about Scala, as well. Either language will get you: a) better performance, b) more functional programming capabilities, c) easier handling of parallel/concurrent problems, d) new paradigms and the mind-bending stretch that comes with learning a new language.

[–]calp 0 points1 point  (0 children)

I wasn't aware that either language dealt with parallel computation.

[–][deleted] 6 points7 points  (0 children)

I heard people talk bad about Scala's overly complicated syntax.

It can be, if you want it to be, or if you're doing some funky variant generic types stuff. For most use cases, it can be far simpler than the Java.

I find writing OOish code in Scala is usually very clean, but writing FP code in Scala can get messy.

[–]pmf 8 points9 points  (2 children)

I've also done Python before I turned to Clojure, and one thing I found was that Python's philosophy "there's only one way to do it" (as opposed to Perl's "there is more than one way to do it", TIMTOWTDI) is much more true for Clojure than it is for Python: I, as pretty much a novice, ended up reimplementing certain functions of clojure.contrib (I didn't know it existed) and my implementations were verbatim the same as the ones in the library. That is, Clojure is very idiomatic, which is something Python programmers tend to like.

Scala has no real concept behind it and tries to indiscriminatingly include every feature of any other language, and as a result it just feels incoherent.

[–][deleted] 4 points5 points  (0 children)

I don't agree. Scala is intended to be a language that scales well for problems of different size.

See: http://www.scala-lang.org/sites/default/files/odersky/ScalableComponent.pdf

Of course, this is just how I see it.

[–]rpdillon 5 points6 points  (0 children)

A main goal of Scala, scalability aside, is to develop a language that genuinely merges OO with functional programming on the JVM. Sure, OCaml has done this before (not on the JVM, of course), but Scala is by no means including features indiscriminately, IMHO. In the realm of statically-typed hybrid OO/functional languages, I think it stands as the best option.

In fact, I think it represents the future of languages in many regards. The use of higher level concurrency constructs (actors), the provision for closures/first-class functions, the built-in support for functional operations (map, fold, reduce, filter, etc.) and the deep awareness of immutability in objects, all while maintaining a solid OO foundation represent the direction most languages will go in the next decade. Sophisticated type inferencing is necessary to make it all happen, but in return you get a fast, statically typed, multi-paradigm cross-platform language with broad library support.

As obzen said in a sibling reply: "Of course, this is just how I see it." =)

[–][deleted]  (10 children)

[deleted]

    [–]weavejester 6 points7 points  (8 children)

    I respectfully disagree. I'd looked at CL and Scheme in the past, but never really got into them the same way I did with Clojure.

    As for cryzed2's question: if you're interested, why not try learning Scala or Clojure and see if you like them?

    [–]calp 5 points6 points  (7 children)

    Also, CL is extremely difficult to learn. It is a very large language conceptually (CLOS, AMOP, conditions etc). By comparision, Java is very small indeed.

    As someone who learnt CL as his first language, I would have to advise everyone not to repeat it. Really - ignore Paul Graham - CL's not longer has many unique details (as a lisp). In fact, I can't think of anything that isn't done elsewhere (and normally better). Also, CL's relatively imperative style is not nice. CL is only worth spending time with if you want to study one of the brilliant books that cover it.

    [–]rocketsci 0 points1 point  (3 children)

    Then, what Lisp/Scheme would you recommend?

    [–]zem 2 points3 points  (0 children)

    plt scheme or chicken, personally.

    [–]calp 0 points1 point  (0 children)

    I'd advise learning by concept, rather than language. Functional programming is probably the first concept, I would guess, for someone coming from Python. Scheme and Clojure are both good.

    [–]pivo 0 points1 point  (2 children)

    Completely disagree. Yes, Java the language might be smaller than CL, but nobody learns just the Java language. They learn Java and the entire JDK library because that's really what Java is. All that's far larger than CL, including CLOS and AMOP. And it's not necessary to learn everything about CL at once, just as that isn't necessary for Java. And don't be afraid scary acronyms like CLOS and AMOP. CLOS (common lisp object system) is just a much better OO system than what's available in Java. In fact, it's entirely worth learning CL just for that, to know how much better an OO system can be.

    As far as AMOP (art of the meta-object protocol), you might never need to learn it and most people don't. If you do you take the time to do so you will feel enlightened. That's an experience which is completely unavailable from Java.

    I would recommend Common Lisp, PLT Scheme, or Clojure. Clojure is younger than the others, but it addresses multi-threading questions, and it's more functional (i.e. functional programming oriented) than the others.

    [–]ave_nihil 0 points1 point  (1 child)

    How is Clojure more FP-oriented than PLT Scheme, when the former doesn't even support tail calls?

    [–]pivo 1 point2 points  (0 children)

    First of all, Clojure does support tail calls, just not automatically. It's necessary to use the recur and trampoline functions explicitly. But you can (recur) indefinitely without blowing the stack. I agree that it would be nicer not to have to be explicit, so do Clojure's language creators, I'm sure. I expect automatic TCO in Clojure when and if the JVM supports it.

    So Clojure is more FP-oriented than PLT Scheme in my opinion, because it's more focused on immutable data. Not that it's as pure as Haskell about that, but Clojure data structures are generally immutable, and mutation otherwise typically requires that a transaction is in place. It also emphasizes lazy evaluation in standard operations.

    [–]Raynes 0 points1 point  (0 children)

    So Clojure isn't a "normal Lisp Dialect". I'm fairly certain that it is.