Live data from Hacker News

Clojure & Python, Side by Side

tin.nu

51–60 of 67 posts

Re: Clojure & Python, Side by Side

#51

Python looks like a lot less typing.

And much more readable, without the parenthesis balancing dance.

I've started using Clojure after many years of Ruby and I have to say the parentheses are a non-issue. Emacs and many IDEs automatically balance the parens for you (see e.g. paredit). Once your eyes learn to ignore the bracket soup, the code starts looking an awful lot like Python (cmp. Emacs Lisp indention with Python semantic indention).

Re: Clojure & Python, Side by Side

#53
post #52

LISP is the coolest language ever and maybe forever, in theory. In practice, it also works phenomenal, but just for 1%.

Meh, I am an amateur when it comes to programming and still I am loving clojure over python. Truth is that when you are using lists all the time, lisp seems just more natural. All those for and if in object oriented languages feel pretty awkward when you manipulate lists and hashes.

Just an amateur opinion although.

Re: Clojure & Python, Side by Side

#54
I can only admire the persistance (free time) of someone coding in Clojure. Everytime someone says to me "I hate Objective-C syntax" I show them Clojure...

If I want fast performance I code in C or other low level language. Sorry Clojure community, I'm not drinking the kool aid this time.

Re: Clojure & Python, Side by Side

#55

I can only admire the persistance (free time) of someone coding in Clojure. Everytime someone says to me "I hate Objective-C syntax" I show them Clojure... If I want fast performance I code in C or other low level language. Sorry Clojure community, I'm not drinking the kool aid this time.

What makes you specifically mention fast performance? I wasn't aware that this was the most important selling point of Clojure. What kool aid is it that you won't drink this time?

For me, Clojure is great because it allows you to build powerful abstractions and has some interesting concurrency constructs, while running on the JVM and making it easy to interoperate with Java code. Of course, being a Lisp, it uses Lisp syntax.

Re: Clojure & Python, Side by Side

#56

I can only admire the persistance (free time) of someone coding in Clojure. Everytime someone says to me "I hate Objective-C syntax" I show them Clojure... If I want fast performance I code in C or other low level language. Sorry Clojure community, I'm not drinking the kool aid this time.

What's really unique about the Clojure community is that (as opposed to many other language communities) we don't respond to vague handwaving-type flamebaits such as this one.

Most of us just get stuff done using Clojure, quickly, getting concise and most importantly — correct code, even in massively multithreaded applications.

Re: Clojure & Python, Side by Side

#57
post #29
post #17

Would love to see this in Ruby

Very much agreed. Although clojure might be faster, it is so so difficult to read, and from a rubyist's POV, looks like a disaster compared to python. Maybe that's just a result of being spoiled by super clean syntax and almost human readable methods... but that's gotta count for something

I'm a rubyist and now Clojure convert. The code does not look difficult to me, but i'm sure you can make it much more concise if you were to add some mutation in the Clojure code. As my career progressed i found that I don't care almost at all about syntax but semantics. Clojure offers far better semantics for almost everything including Data Structures, concurrency and meta-programming. That's were the true power of the language is on its semantics.

Re: Clojure & Python, Side by Side

#58
post #12
post #6

Earlier quoted context omitted.

cough http://www.jython.org/ cough

How does Clojure's Java interop compare to Jython's?

In some ways it's nicer (clojure fns are java Callables), in some ways it's less nice (harder to extend a class).

Re: Clojure & Python, Side by Side

#59

This is really neat. Although, one thing that makes it easier to map this program from Python to Clojure is that the original program was written in a pretty functional style. It would be interesting to see if a more imperative sample program, or one using more object-oriented features, would map similarly.

I agree. For some things, like more mathy things that only perform one function, it seems like functional programming is the way to go. However, for HUGE programs based on data and complex interactions between and extensions of objects, it seems like a more object-oriented style would be better... all about the right tool for the job, I guess.

I think you're absolutely right that functional programming is particularly suited for things like mathematics. But you can also enjoy many of the benefits of a functional approach by moving most of the complexity into purely functional, well, functions and leaving the state-modifying code fairly simple. For a good pragmatic example of this approach, check out the snake game in Programming Clojure v2 from Pragmatic Programmers.

Coming from Ruby this approach was a bit mind-boggling at first, but even with my fairly limited Clojure exposure (or should that be expojure?) I've come to appreciate how easy pure functions are to test and to reason about.

Post reply on HN