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.
Why People Should Learn Python
261–270 of 329 posts
Re: Why People Should Learn Python
#262Earlier 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…
Re: Why People Should Learn Python
#263Earlier 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.
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
#264For 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.
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
#265Earlier 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.)
Re: Why People Should Learn Python
#266For 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…
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
#267In PowerShell, PS> Import-Csv .\names.txt -Header name | group name | select name, count Name Count ---- ----- cat 3 dog 2 mouse 1 bird 1
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 CountRe: Why People Should Learn Python
#268For 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?
[1] http://stackoverflow.com/questions/8097408/why-python-is-so-...
Re: Why People Should Learn Python
#269I 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.
Re: Why People Should Learn Python
#270Earlier 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.
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.