Live data from Hacker News

Why People Should Learn Python

iluxonchik.github.io

261–270 of 329 posts

Re: Why People Should Learn Python

#261
post #177
post #43

I switched to writing python as my main backend/scripting language with my new job. Previously I was using Ruby for most of this stuff with some Go. I must say that so far Python has been a vastly inferior experience for me. The languages are fairly similar all though I prefer the more talkative/english style of ruby and the use of functions over list and dict comprehension. The thing that really stands out to me tho…

Amazing that Python 2 vs. Python 3 has still not yet been sorted out. I dipped my toe into Python a couple years ago when looking for a general-purpose scripting language and quickly gave up in frustration—Python 3 was by far the preferable flavor, but many libraries simply didn't work. I picked up Ruby and haven't looked back.

A lot has improved since a couple years ago. A majority of major libraries have both Python 2 and 3 support these days. I've since started all new projects in Python 3.

Re: Why People Should Learn Python

#262

Earlier quoted context omitted.

Around 2001 I felt jaded with the industry and determined to do whatever was expedient to earn money. That meant using PHP, because that was purportedly the place to be at the time. I have never felt so uninspired by a language. My overwhelming feeling from the get-go was that it was a collection of libraries, which would be fine -- but why create a new language? PHP has the rare distinction among languages of not co…

2001 was 15 years ago. PHP looks completely different now. It looks very much like Java with -> instead of dots and a few differences. Nobody sanes mixes HTML and PHP code anymore these days. Most people are using Twig for templating or at least something similar. Everything (decent) is object oriented these days. So your views were correct 15 years ago, but have a look with fresh eyes and you will see something comp…

Not disagreeing with you, the "javafication" of PHP has been going on for a while now (for better or for worse), but pluck your average person using PHP out from a crowd and they are still writing code like it's 2001.

Re: Why People Should Learn Python

#263

Earlier quoted context omitted.

Weird, I thought that Python was trying to discourage functional programming with its extremely limited lambdas and the proposal to move map and reduce out of the core language.

IIRC, the limitations on lambdas has to do with the way whitespace is parsed rather than being an explicitly conscious decision.

Guido also maintains that by the time you need multiline lambda's, the extra cost of giving the function a name is more than outweighed by the improved readability.

I kinda agree. Certainly it guards against some of the code you see in overly nested javascript.

The downside is that the code is slightly removed from it's call site - but rarely by much.

Overall the increased complexity it would bring to the language has not been justified by anyone arguing for it's benefits. Giving the function a name isn't the worst thing in the world.

Re: Why People Should Learn Python

#264

For all its virtues, I feel introductions to Python tiptoe around a very important topic: yes, Python is nice and easy, but you'll have to program the Python way too . Try running a nested loop on a non-trivial example, and you can end up spending minutes in what would take milliseconds in any other language. If you want to program in Python, you must get used to the functional paradigm. Not "should", "must". Now, I'…

Weird, I thought that Python was trying to discourage functional programming with its extremely limited lambdas and the proposal to move map and reduce out of the core language.

The important thing is to fully support first class functions - not the fact that they are anonymous - so I find it difficult to see how the lack of multiline anonymous functions is really a blow to functional Python

I think the argument against map and reduce was that there was better and more Pythonic ways to do both - not because they were 'too functional'.

Re: Why People Should Learn Python

#265

Earlier quoted context omitted.

8. Global Interpreter Lock in CPython

This isn't an issue with the language, it's an issue with the common implementation of the language. It will be remedied by either fixing CPython, or by switching to a different implementation. (If neither happens, then I guess it isn't really a problem.)

I wrote explicitly that this is a problem with CPython. I totally agree that this is not the problem of the language itself. Neither are the most of the points from the parent post(tooling, community, performance, error messages). Yet all that still greatly affects your experience with the language. Same applies to the default implementation. I think you would agree if I said that Sun(Oracle) JVM played an important role in Java adoption, wouldn't you? Unfortunately, it's not so easy to just switch to some other implementation of Python: PyPy uses GIL as well, IronPython and Jython don't but they are years behind the current version of the language. GIL is not a problem when you use libraries that handle concurrency natively(e.g. NumPy) but when you try to parallelize some computationally intensive algorithm written in Python you're probably going to hit the wall. I love Python but it's really not a one-size-fits-all tool.

Re: Why People Should Learn Python

#266
post #54

For all its virtues, I feel introductions to Python tiptoe around a very important topic: yes, Python is nice and easy, but you'll have to program the Python way too . Try running a nested loop on a non-trivial example, and you can end up spending minutes in what would take milliseconds in any other language. If you want to program in Python, you must get used to the functional paradigm. Not "should", "must". Now, I'…

> Try running a nested loop on a non-trivial example, and you can end up spending minutes in what would take milliseconds in any other language. Huh? Can you provide an example? There's nothing about writing nested loops in Python that is qualitatively different from other languages. > If you want to program in Python, you must get used to the functional paradigm. Not "should", "must". This is incorrect, much to my c…

> Can you provide an example?

Gladly. Check the nested loop in [1]. That's exactly what I fought against (although that's not me asking that question). No other language AFAIK suffers from that issue.

[1] http://stackoverflow.com/questions/8097408/why-python-is-so-...

Re: Why People Should Learn Python

#267
post #40

In PowerShell, PS> Import-Csv .\names.txt -Header name | group name | select name, count Name Count ---- ----- cat 3 dog 2 mouse 1 bird 1

Seriously, the author seems to have fairly limited knowledge of powershell.

A 13-line python script is presented, followed by a smug "you can almost hear the UNIX folks complain about how verbose the PowerShell version is".

First off, the provided Unix commands _don't work_ (should have used `sort -rn -k 2`), while the provided powershell, as verbose as it is, does work.

Second, the entire python script along with the wrapping unix commands is encapsulated with a powershell 1-liner:

    cat ./names.txt | group | sort -d Count

Re: Why People Should Learn Python

#268
post #76

For all its virtues, I feel introductions to Python tiptoe around a very important topic: yes, Python is nice and easy, but you'll have to program the Python way too . Try running a nested loop on a non-trivial example, and you can end up spending minutes in what would take milliseconds in any other language. If you want to program in Python, you must get used to the functional paradigm. Not "should", "must". Now, I'…

Curious what you mean about nested loops? Do you specifically mean nested list comprehensions? If nested they can sometime be less readable than explicit for loops so my advice to a struggling newbie would be "if it hurts stop doing it" Or did you mean something else?

I don't mean it as "readable", but as in "thanks to type inference, it will take forever". I linked to this question [1] somewhere else, which is something that AFAIK happens only in Python.

[1] http://stackoverflow.com/questions/8097408/why-python-is-so-...

Re: Why People Should Learn Python

#269
post #255

I just wanted to point out a bit of syntax from the article. I'm a huge fan of compact variable declaration if statements. The code from the article: if name in names: names[name] += 1 else: names[name] = 1 That can actually be written as just one neat, readable line: names[name] = names[name] + 1 if name in names else 1 It may not be as readable to some who are used to spelling it out as an if/else block, but I real…

Or just `names[name] += 1` if you're using a Counter.

Which would of course be the optimal solution. I always forget about that object.

Re: Why People Should Learn Python

#270

Earlier quoted context omitted.

2001 was 15 years ago. PHP looks completely different now. It looks very much like Java with -> instead of dots and a few differences. Nobody sanes mixes HTML and PHP code anymore these days. Most people are using Twig for templating or at least something similar. Everything (decent) is object oriented these days. So your views were correct 15 years ago, but have a look with fresh eyes and you will see something comp…

Not disagreeing with you, the "javafication" of PHP has been going on for a while now (for better or for worse), but pluck your average person using PHP out from a crowd and they are still writing code like it's 2001.

If you pick an average person, then yes maybe. But that's because it's so widely used by non-developers.

But if you narrow that down to actual developers who have a job working on a product, not someone hacking a wordpress template, then it will look much different.

Not saying the average PHP developer is great at OOP, but at least things are moving into that direction. And the code quality has come very far since 2001, just look at at current open source libraries (see packagist.org) and compare them to old PHP code.

Post reply on HN