Comments on: Why Reddit uses Python http://brainsik.theory.org/.:./2009/why-reddit-uses-python .:. brainsik Sun, 08 May 2011 13:29:26 +0000 hourly 1 By: Nick http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-15348 Nick Sun, 08 May 2011 13:29:26 +0000 http://brainsik.theory.org/.:./?p=188#comment-15348 def get_pairs(list1, list2): zip(list1, list2) * In c# list1.zip(list2) * In lisp (zip list1 list2) * In haskell (forgot but the same) * In Ruby (forgot but the same) * Java, 20 lines of code:) The two biggest features that pyhton has over c# are multiple inheritence and native support for aspect oriented programming. I like the forced indentation aswel, but this is only a notational question. Its a shame these features are not in c#, but I don't seen any technical reason that they can't be introduced. Of all languages I currently like c# the most because it has closures, generics are implemented reasonably, it is reasonably fast, it integrates well with c++, has very nice api's and has a very user friendly IDE. def get_pairs(list1, list2):
zip(list1, list2)

* In c# list1.zip(list2)
* In lisp (zip list1 list2)
* In haskell (forgot but the same)
* In Ruby (forgot but the same)
* Java, 20 lines of code:)

The two biggest features that pyhton has over c# are multiple inheritence and native support for aspect oriented programming.
I like the forced indentation aswel, but this is only a notational question. Its a shame these features are not in c#, but I don’t seen any technical reason that they can’t be introduced.

Of all languages I currently like c# the most because it has closures, generics are implemented reasonably, it is reasonably fast, it integrates well with c++, has very nice api’s and has a very user friendly IDE.

]]>
By: Jatniel http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-6845 Jatniel Sun, 01 Aug 2010 03:41:04 +0000 http://brainsik.theory.org/.:./?p=188#comment-6845 BTW the self in a class funtion can be named anything you want it to be, I for one find it way less confusing and less distracting if I don't have to proclaim the variables beforehand. Thogh it is true that python may be slow on some places ,those weaknesses are easy to overcome, easier than using C++ or those low level program languages. BTW the self in a class funtion can be named anything you want it to be, I for one find it way less confusing and less distracting if I don’t have to proclaim the variables beforehand.

Thogh it is true that python may be slow on some places ,those weaknesses are easy to overcome, easier than using C++ or those low level program languages.

]]>
By: Xiong Chiamiov http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-1692 Xiong Chiamiov Mon, 17 Aug 2009 16:03:21 +0000 http://brainsik.theory.org/.:./?p=188#comment-1692 <blockquote>Tracking down bugs and figuring out what type of an object thing is supposed to be can be a nightmare.</blockquote> You're not _supposed_ to know (or care) what type something is. What you have to keep track of is what you expect it to be able to do, and that only to a certain extent. With "easier to ask forgiveness than permission" and duck typing such an integral part of the language, you're not going to be happy if you don't learn to love and use those.

Tracking down bugs and figuring out what type of an object thing is supposed to be can be a nightmare.

You’re not _supposed_ to know (or care) what type something is. What you have to keep track of is what you expect it to be able to do, and that only to a certain extent.

With “easier to ask forgiveness than permission” and duck typing such an integral part of the language, you’re not going to be happy if you don’t learn to love and use those.

]]>
By: blick black http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-698 blick black Fri, 10 Apr 2009 19:02:56 +0000 http://brainsik.theory.org/.:./?p=188#comment-698 As much as I like Python, its really a love/hate relationship. My biggest problem with it is the lack of type definitions and the lack of structure. Tracking down bugs and figuring out what type of an object thing is supposed to be can be a nightmare. The fact that any object can have a new member added to it at anytime, isn't fun to track down. Yes this all smells like bad coding styles to begin with, but when you have to modify someone elses code and figure out what is going on (mainly workin with alot of objects and classes) it can be a pain. Personally it would have been nice for python to allow for type declarations if the coder wanted to use them. Code is much easier to scan and bugs much easier to track down. As much as I like Python, its really a love/hate relationship. My biggest problem with it is the lack of type definitions and the lack of structure. Tracking down bugs and figuring out what type of an object thing is supposed to be can be a nightmare. The fact that any object can have a new member added to it at anytime, isn’t fun to track down. Yes this all smells like bad coding styles to begin with, but when you have to modify someone elses code and figure out what is going on (mainly workin with alot of objects and classes) it can be a pain.

Personally it would have been nice for python to allow for type declarations if the coder wanted to use them. Code is much easier to scan and bugs much easier to track down.

]]>
By: Brian http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-697 Brian Fri, 10 Apr 2009 16:40:53 +0000 http://brainsik.theory.org/.:./?p=188#comment-697 <blockquote>And it’s awesome because I can see from across the room, looking at their screen, whether their code is good or bad. Because good Python code has a very obvious structure. And that makes my life so much easier.</blockquote> Your awesome code auditing methods explain why reddit has remained in a broken state for as long as I can remember.

And it’s awesome because I can see from across the room, looking at their screen, whether their code is good or bad. Because good Python code has a very obvious structure. And that makes my life so much easier.

Your awesome code auditing methods explain why reddit has remained in a broken state for as long as I can remember.

]]>
By: James Gordon http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-696 James Gordon Fri, 10 Apr 2009 00:26:10 +0000 http://brainsik.theory.org/.:./?p=188#comment-696 <blockquote><pre> def get_pairs(list1, list2): assert len(list1) == len(list2) return ((list1[i], list2[i]) for i in enumerate(list1)) </pre></blockquote> WHY? WHY? <pre> def get_pairs(list1, list2): zip(list1, list2) </pre> Python reads better because common collections are integrated directly into the language where they belong and because functions are first class. If Java had that, I would not have minded the static typing one bit. C# is heading in a more sane direction in this respect. I nevertheless tolerate, even enjoy static Java at times because of the strict adherence to idioms by its programmers and the wonderful IDEs that it is blessed with, which make navigating, modifying and examining the code easy. Java guys: Don't debate type inference and properties as if your language is the only programming language in the entire world and as if you have to figure all this out carefully, all by yourself. They have been implemented many times before and no one ever regretted them adopting them. Or lets just get a decent IDE for Scala and forget about Java. Without a decent IDE, Scala's higher constructs don't mean much for productivity when the Java libraries are verbose and low level.
def get_pairs(list1, list2):
    assert len(list1) == len(list2)
    return ((list1[i], list2[i]) for i in enumerate(list1))

WHY? WHY?

def get_pairs(list1, list2):
    zip(list1, list2)

Python reads better because common collections are integrated directly into the language where they belong and because functions are first class.

If Java had that, I would not have minded the static typing one bit. C# is heading in a more sane direction in this respect. I nevertheless tolerate, even enjoy static Java at times because of the strict adherence to idioms by its programmers and the wonderful IDEs that it is blessed with, which make navigating, modifying and examining the code easy.

Java guys: Don’t debate type inference and properties as if your language is the only programming language in the entire world and as if you have to figure all this out carefully, all by yourself. They have been implemented many times before and no one ever regretted them adopting them.

Or lets just get a decent IDE for Scala and forget about Java. Without a decent IDE, Scala’s higher constructs don’t mean much for productivity when the Java libraries are verbose and low level.

]]>
By: Tony http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-695 Tony Thu, 09 Apr 2009 23:13:48 +0000 http://brainsik.theory.org/.:./?p=188#comment-695 I also have experienced this "code shrinkage" piramida speaks of, although I find myself quite embarassed by it. I honestly think that it is just proof that I am evolving as a programmer, and that my code is never perfect...darn! In any event, I like Python because it allows one to propose quick solutions to computational Biology, Chemistry (et al) problems. It is easy to integrate with MATLAB. I once wrote an interface to MATLAB in 1 hour with Python. It is very friendly to folks in the hard sciences. I also have experienced this “code shrinkage” piramida speaks of, although I find myself quite embarassed by it. I honestly think that it is just proof that I am evolving as a programmer, and that my code is never perfect…darn!

In any event, I like Python because it allows one to propose quick solutions to computational Biology, Chemistry (et al) problems. It is easy to integrate with MATLAB. I once wrote an interface to MATLAB in 1 hour with Python. It is very friendly to folks in the hard sciences.

]]>
By: piramida http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-694 piramida Thu, 09 Apr 2009 18:35:03 +0000 http://brainsik.theory.org/.:./?p=188#comment-694 It is really easy to see from comments who have and who have never tried writing python code :) I have done extensive coding in all of the languages mentioned here (bar Smalltalk) and I can say that I easily second the original opinion - in no other language can developer express his/her logic more clearly than in python. It's also one of the rare languages where the more you think about / refactor your code the smaller *and* clearer it becomes - which is an inherent magic property of that language, it seems :) It is really easy to see from comments who have and who have never tried writing python code :) I have done extensive coding in all of the languages mentioned here (bar Smalltalk) and I can say that I easily second the original opinion – in no other language can developer express his/her logic more clearly than in python.

It’s also one of the rare languages where the more you think about / refactor your code the smaller *and* clearer it becomes – which is an inherent magic property of that language, it seems :)

]]>
By: Jeff M. http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-693 Jeff M. Thu, 09 Apr 2009 16:05:07 +0000 http://brainsik.theory.org/.:./?p=188#comment-693 Just as people sometimes think that brief == readable, many programmers also confuse readable == maintainable. None of these things are the same. And very often, getting one means losing another. Sometimes getting very high-performance, multi-threaded, or ... code requires sacrificing one or more of the above. Also, it's silly to throw out trivial examples (like getPairs) where sometimes language syntax can be argued either way. I don't know Python. I can venture a guess as to what the get_pairs example code does above, but I wouldn't be sure. But it's _very_ clear what the Java code does (and I don't know Java either). Then again, what about any language with list comprehensions? <code>[ {A, B} || A <- List0, B <- List1 ]</code> Is that more readable because it's more terse? Show that to anyone who has never seen a list comprehension or doesn't know Erlang and I think you'd have a hard time arguing that it's more readable. But it's certainly more maintainable (imo). Then again, how about showing a non-programmer some Qt UI code in Python vs. say... Hypercard: <code>set the text of field "Name" to "Jeff"</code> That's a heluvalot more readable than the Python would be, but also more verbose. At the end of the day it. comes down to this simple fact: Working code is good code. Plain and simple. I know many of you will argue that. But you can spend forever iterating code trying to get it just right, and never actually ship anything. You can waste time debating whether to use Python or Lisp or C or Smalltalk, but that's just time you are wasting vs. getting the project to market. I've seen very "experienced" programmers who couldn't actually complete anything they were so stuck in the details, and I've seen novice programmers with BASIC turn out some pretty amazing things. Just as people sometimes think that brief == readable, many programmers also confuse readable == maintainable. None of these things are the same. And very often, getting one means losing another. Sometimes getting very high-performance, multi-threaded, or … code requires sacrificing one or more of the above.

Also, it’s silly to throw out trivial examples (like getPairs) where sometimes language syntax can be argued either way. I don’t know Python. I can venture a guess as to what the get_pairs example code does above, but I wouldn’t be sure. But it’s _very_ clear what the Java code does (and I don’t know Java either). Then again, what about any language with list comprehensions?

[ {A, B} || A <- List0, B <- List1 ]

Is that more readable because it’s more terse? Show that to anyone who has never seen a list comprehension or doesn’t know Erlang and I think you’d have a hard time arguing that it’s more readable. But it’s certainly more maintainable (imo). Then again, how about showing a non-programmer some Qt UI code in Python vs. say… Hypercard:

set the text of field "Name" to "Jeff"

That’s a heluvalot more readable than the Python would be, but also more verbose. At the end of the day it. comes down to this simple fact:

Working code is good code.

Plain and simple. I know many of you will argue that. But you can spend forever iterating code trying to get it just right, and never actually ship anything. You can waste time debating whether to use Python or Lisp or C or Smalltalk, but that’s just time you are wasting vs. getting the project to market. I’ve seen very “experienced” programmers who couldn’t actually complete anything they were so stuck in the details, and I’ve seen novice programmers with BASIC turn out some pretty amazing things.

]]>
By: dan http://brainsik.theory.org/.:./2009/why-reddit-uses-python/comment-page-1#comment-691 dan Thu, 09 Apr 2009 08:49:15 +0000 http://brainsik.theory.org/.:./?p=188#comment-691 <blockquote>What you guys are saying is that Java and C# are more readable because of static typing right?</blockquote> No. They're saying shorter and more readable are not the same thing.

What you guys are saying is that Java and C# are more readable because of static typing right?

No. They’re saying shorter and more readable are not the same thing.

]]>