3 ms·
Python vs Clojure 2: Reloaded
Many Python users submitted better code than what was posted in the last article - This time I've dug up exemplary code from Rosetta.
- icey 17y agoSince I know Lau reads comments here: The way to advocacy is to start with an excellent example in language X and then tell us how it can be done better with an example in language Y. Cherry-picking examples isn't going to win you many converts.
- jacquesm 17y agoEven worse, it makes you look after two tries at it like you have an agenda to push. I've flagged this because I thought the first time around that that was the case, now I'm sure. Python and clojure both have their strengths, and their weaknesses. Contrasting languages to show how one solves something vs how the other does it is education, keeping 'score' is a childish attempt at proving 'your' language to be the better one. key quote: "But like I also told one disgruntled Scala user, it's not always fun being compared to Clojure and I think a few Python users felt that they got more competition than they hoped for." And the picture at the end speaks volumes. What I really don't get is if you're that much of a clojure fan why you don't get that these stupid articles are doing clojure more bad than good. It reminds me of the damage done to Erlang by flooding HN with all those articles. If a language is good then there must be other ways of showing that. Show me not how you implement some trivial benchmark in 16 vs 12 lines of code, show me how you made a serious production system capable of handling a couple of hundred thousand uniques in a real-world application. And I'm sure that can be done, but that would be 'real work (tm)', whereas sniping is so much easier. And for extra points, then find an expert programmer in the language that you wish to compare with and have them do the exact same thing. That would impress me. This just annoys me.
- lbj 17y agojacques, calm down, please. This is a fun comparison showing off some features of both languages. Notice in example 2 where Python is actually the most concise, cleanly written example where my code comes out looking a bit cramped? It's not a hatchet job, it's a comparison which will tell you something about both languages. Sure I like the real world examples too, but for a simple outline of a few of their respective qualities this should tell you enough. If you have a larger project you'd want to tag-team on, showing the capabilities of both languages on a much larger scale I'm definitely up for it, that would also be educational.
- jacquesm 17y agoI'm pretty calm, thank you. I don't have a dog in this fight, I like both languages for pushing the envelope, but I wouldn't consider myself qualified to do a comparison that is meaningful. The only language where I think I could make any statements is C, and that's only because of decades of using it. I've used PHP for business reasons for 10 years and I still wouldn't think I'm qualified to write a benchmark comparing PHP to something else. The other day, there was a discussion here about 'the hundred year language' (that essay by PG), and I wrote that if there is a candidate for that spot it's either Clojure or Erlang, and my money would be on clojure fwiw. The python guys ripping in to perl with cherry picked examples, the clojure guys ripping in to python it gets us exactly nowhere. You don't need to compare to anything to show excellence. But if you're going to do it, Rosetta is the right way to do it. If you want to do runtime comparisons then I think you should get a person that has at least your skills in python to have a look at what's going on, and you should not just show one example where you come out ahead. You should show many examples along the lines of the great programming language shootout. Again, that's real work. Who knows how many were tried where clojure was terribly slow that were not shown for that reason and so on. Hand-picked, biased, a waste of time.
- lbj 17y agojacques, I don't quite agree with your sentiment that excellence stands on it's own, but time will tell. I'd just like to correct two mistakes you made. 1) I didn't pick examples where Clojure runs circles around Python - Like I've stated before, Example #2 is a lot cleaner in Python than what I wrote. The fact that my implementation is 9.4x faster than the Python teams is not subjective and tells you something important about parallelized sequence consumption. 2) I didn't hand pick anything, I picked Lehman because it was on the front page, followed another link to something which didn't have a Python solution, another to the 'Count examples' and so on. I didn't set Python up for sniping, which I why I think the comparison is interesting. And for the record: I think Python came out looking pretty good.
- lbj 17y agoicey - I'm not trying to win any converts, simply display some qualities of both languages.
- icey 17y agoI think you're missing an opportunity. Every language can benefit from more users, especially fledgling ones like Clojure. The problem is that Python, Ruby and Lisp developers are likely Clojure's target market... and they know enough to know when things are getting slanted. Like I've said before, I don't think you've got bad intentions, I'm just trying to give you some advice. It's very tough to create a comparison without the illusion of advocacy, so it can't hurt to make sure that you're comparing fairly.
- jacquesm 17y agoamen. Also, the comparison is really flawed, see above.
- lbj 17y agoHi, I just signed up for the single purpose of posting this, since quite a few Python users felt that the examples in the last post were poor - This time I've selected prime examples from Rosetta and despite jacques comment, the point wasn't to make Python look bad - it was exactly the opposite. Lau out, hope you take something away from it.