Live data from Hacker News

Why Python is Important for You

blaag.haard.se

161–170 of 231 posts

Re: Why Python is Important for You

#161

Earlier quoted context omitted.

I used Python for a really long time and switched to Ruby several months ago. Benefits of Ruby are: -no distinction between expression and statement (everything has a value) -lambdas can thus contain any expression -much bigger range of built-in methods and classes (all permutations of a list, removing duplicates from a list, Rational class, Regexp class, Range class, etc.) -more flexible syntax and "control operator…

> -lambdas can thus contain any expression why would you want to use lambdas if you have generator expressions? eg: map(lambda c: c.strip(), countries.split(',')) vs [c.strip() for c in countries.split(',')] IMHO the latter one is way more readable and generators cover almost all the use cases for lambdas. If you could not do it with a generator expression and choose to use a anonymous function it should have been a…

>Range class: [i for i in range(10)]

How does this differ from list(range(10)) (besides being highly suggestive of the power of list comprehensions)?

>IMHO the latter one is way more readable and generators cover almost all the use cases for lambdas. If you could not do it with a generator expression and choose to use a anonymous function it should have been a method anyway.

This is actually why Guido van Rossum wanted to remove lambda from the core language: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 (He didn't, thankfully. I still want reduce back in 3.x, though.)

Re: Why Python is Important for You

#162

Python is great in every way except one -- it isn't Javascript. (to clarify: I'm not saying JS is a superior language. I'm just saying it's going to win out in the end because of the history of its implementation. There is a serious benefit to having one language everywhere, and JS is the only viable candidate because of the investment in client-side sandboxing and performance -- two features which turn out to matter…

I wasn't aware that Python and JavaScript were in competition. Or for that matter, that JS is by any stretch of the imagination "invested in performance".

People don't use Python because of its merits as a programming language. They use it because of the excellent standard library, Scipy, Sage, etc. While it may be that in a decade JavaScript has built an ecosystem to match, I frankly don't see why anybody would bother. We already have Python, why would we invest such effort into a less suitable language?

JavaScript is tolerated by web developers, because they're forced to use it on the client, and so there's a benefit to also using it on the server to prevent duplication of effort. But there is absolutely no reason why non-web developers would or will ever use it outside of that niche.

Re: Why Python is Important for You

#163

Earlier quoted context omitted.

Syntactically, JS is funny in a lot of ways. I highly encourage you to investigate CoffeeScript.

As someone with lots of Python experience, having used CoffeeScript/JS for ~three months makes Python looks somewhat old fashioned when I switch back. If Coffee/JS had some way of overloading array access operations, and maybe a numpy equivalent, I don't think I would have any reason to go back to Python. It's also just so much faster than CPython...

Sounds like Apples to Oranges...

Re: Why Python is Important for You

#164

Earlier quoted context omitted.

Some many years ago I decided I should learn a new scripting language because PHP wasn't general-purpose enough. I decided it would be either Python, Ruby or Perl. For some reason Perl was dropped early, I forget why (don't worry I learned some Perl later). So I started Googling for Python vs Ruby. After checking some language basics tutorials, I decided that really, for my purposes they were about equivalent in powe…

Also, just a little disclaimer: This was a couple of years back (I forget how many, 5 or so) maybe the Ruby community changed, and it's also totally possible that I just happened to land on a rather "particular" region of the Ruby blogosphere, so take this cum grano salis. I had to make a choice and was about this close to just flipping a coin over it :) ruby-talk used to have, as one of a number of perma-threads, th…

Call me a cynic, but I'm weirded out by the idea that the only reason for civility is to emulate an idol who is civil.

Re: Why Python is Important for You

#165
I could not agree more. After learning the python idioms, I realized how much time I have wasted doing similar things in PHP. Python has gotten lot of things right. I don't feel cramped by a language as I have with Java.

Python idioms : http://python.net/~goodger/projects/pycon/2007/idiomatic/han...

Re: Why Python is Important for You

#166
post #11

As a commenter on the article wrote: what about Ruby? I say this as a happy Python user. Ruby seems very similar but I'm reminded of a pg essay on language power: looking up the power curve, you see '$Language plus a bit of weird stuff that is probably irrelevant.' So I don't trust myself. As someone who loves Python and doesn't know any Ruby beyond a few bits of syntax and the obvious bits that are common to most la…

A key difference is that Ruby picks one paradigm (object oriented programming) and sticks with it (to a fault, potentially) whereas Python takes a multiple paradigm approach and various styles tend to be mixed together even in the best of conditions (consider len(str) vs str.length). You can attempt to ignore OO in Ruby but it's not recommended and under the hood, everything you're doing is forced into an OO paradigm anyway.

Re: Why Python is Important for You

#167
post #62

I do love Python, but I often wish there was more rigor for some things. I currently work on a large project (>500K LOC) and have started to see it fall apart with a bigger team. Lack of enforced typing in function arguments, inability to create strict interfaces, inconsistency in standard library conventions, and package management would probably be my biggest gripes.

On most projects I have seen where python was seen as problematic, I think that having types ala C++/Java would not have improved much. The real problem is that the function is not documented, nor is the function expectations. Typing in C++/java does not replace that (more advanced typing systems do much better, though). Package management and generally deployment is certainly a pain in python. I think it is one of t…

This, this, and this. We document our stuff using ReST and Sphinx. You can optionally specify data types in the docstrings, which does a ton to help with this. It isn't time-consuming, and it makes your team not hate reading your stuff.

Re: Why Python is Important for You

#168
post #152

Earlier quoted context omitted.

As a Python user, I'll give my personal reason for using Python over Ruby. Upfront: I think Ruby is absolutely fantastic. It's a very elegant language. In a lot of ways I think it's cleaner than python. I'd love to use it. Except... Every interpreter I've tried is just too slow. I recently ported over a networking library I wrote in python to ruby, and the requests per second (CPU limited in this case, since it was t…

Did you give JRuby a try?

I didn't. Perhaps I should, but it seemed like it would have to be at least 10x faster than YARV to be worth it, which looking at the benchmarks seemed unlikely (but who knows? maybe I was hitting some sort of interpreter specific bottleneck)

Re: Why Python is Important for You

#169

Python is great in every way except one -- it isn't Javascript. (to clarify: I'm not saying JS is a superior language. I'm just saying it's going to win out in the end because of the history of its implementation. There is a serious benefit to having one language everywhere, and JS is the only viable candidate because of the investment in client-side sandboxing and performance -- two features which turn out to matter…

I wasn't aware that Python and JavaScript were in competition. Or for that matter, that JS is by any stretch of the imagination "invested in performance". People don't use Python because of its merits as a programming language. They use it because of the excellent standard library, Scipy, Sage, etc. While it may be that in a decade JavaScript has built an ecosystem to match, I frankly don't see why anybody would both…

> non-web developers

Sorry, not sure what that means

OK maybe not everything will be a web app, but pretty much everything that isn't some deep driver-level boot code or embedded firmware is already almost always part of some sort of web app, and the stuff that isn't is pretty much all written in C/C++.

When is the last time you wrote a Python program that didn't interact over TCP or equivalent with some other process? And how often was that other process not something at least nominally webby?

Re: Why Python is Important for You

#170

My biggest problem with Python is that projects larger than a given size tend to become unmaintainable rather quickly. This is in large part because of the lack of strong typing and type annotations; if you aren't the only author or can't keep the codebase in your head, it takes real effort to figure out what a function does. Even the type annotations provided in a language like Java or C++ make this task much easier…

Working on big legacy code base without proper unit testing and strong style checks is probably hard in any case. With Python the idea is that e are grownups. If someone accesses private methods or changes the type of an argument without proper checking, it's his problem.
Post reply on HN