Live data from Hacker News

Why People Should Learn Python

iluxonchik.github.io

221–230 of 329 posts

Re: Why People Should Learn Python

#221

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.

Kinda. Many things you can do with a map can also be done with a list comprehension or generator, so that seems to be the way to go.

Moving from Scala to Python it was annoying at first.. but honestly the code is easier to read in most cases, so no complaints here.

Re: Why People Should Learn Python

#222
post #30
post #2

Now that I have a chance to ask: I've always found the def __init__ method with 4 (!) underscores one of the ugliest things I've seen in a programming language. Don't get me wrong: I like Python and know it's truly good, but __why__??

Agreed. That, the explicit self argument (which no other major OO language needed) and the : at the end of lines where you would need a { in other languages. If you google you find that there are good reasons for all of those choices but IMHO they are wrong solutions to the problem they solve and make Python look ugly. At least in 2016 they could make the colon optional. The colon is so ironic for a language that tak…

The explicit self, while clunky at first, is clear and easy to understand. Contrast this with the fun of 'this' for bound and unbound methods in Javascript, and the mysterious extra arguments like 'arguments' that plenty of people don't even know exist.

Re: Why People Should Learn Python

#223
post #38

Is it just my feeling or are there languages which are preferred on HN? Indicators for languages which are liked by the HN community: - Positive stories get many upvotes and are instantly at the top of HN - Most comments are positive - Frequent coverage on HN about the language Indicators for languages which are not liked by the HN community: - Rants get many upvotes and are instantly at the top of HN - Most comments…

What I find interesting is that we are so quick to follow new trends.

While I generally agree with you, I'm not sure Python is a new trend.

Re: Why People Should Learn Python

#224

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.

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

Re: Why People Should Learn Python

#225
post #38

Earlier quoted context omitted.

What I find interesting is that we are so quick to follow new trends.

Isn't there a psychological aspect to this - that if you are on the cutting edge of languages/frameworks, that you believe you will have an edge over everyone else and a chance to be better for a period of time at least? This is of course typically ignores whether the cutting edge can actually solve problems better than mature languages/frameworks.

Psychology or survival? How much demand is there for someone who's maintained an MFC app for the past 20 years?

This person could ROCK at C++, but who's going to look at his resume and give him an interview?

Re: Why People Should Learn Python

#226

Earlier quoted context omitted.

Wordpress is horrible. Never going to touch that again (Senior PHP Dev myself) or anything else like it (Magento, Drupal,...). And yes there is a lot of horrible PHP code out there, writting by bad developers. I guess newer or not as accessible languages don't have as many bad devs as PHP/JS. But if you have good devs, I prefer a good PHP codebase to any other language that I have come across (I tried a lot of them).

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…

Since when did something need to have novel features or ideas in order to be productive?

I'll counter that one of the main reasons PHP became such a used language (other than ease of deploy) is exactly the reasons you dislike it. There are multiple ways to do things - that coincide with the ways you do things in many other languages (which it steals from).

You dont have to learn anything radically new to use it, and that makes it very easy to do things quickly.

Re: Why People Should Learn Python

#227
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 really prefer the one line way. It reads closer to regular English I think.

Re: Why People Should Learn Python

#228

Earlier quoted context omitted.

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.)

> This isn't an issue with the language, it's an issue with the common implementation of the language. There is no formal definition of the language. It is defined by the C implementation. So I'm not sure how meaningful that distinction is. > If neither happens, then I guess it isn't really a problem. Or people give up on Python and use another language.

Python is not defined by its C implementation. For example, Python-the-language does not require reference counting even though CPython uses that.

The real-world distinction between the Python specification and its implementation started in the late 1990s, with JPython (now Jython).

Re: Why People Should Learn Python

#230

Earlier quoted context omitted.

Wordpress is horrible. Never going to touch that again (Senior PHP Dev myself) or anything else like it (Magento, Drupal,...). And yes there is a lot of horrible PHP code out there, writting by bad developers. I guess newer or not as accessible languages don't have as many bad devs as PHP/JS. But if you have good devs, I prefer a good PHP codebase to any other language that I have come across (I tried a lot of them).

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…

> I have never felt so uninspired by a language.

I agree with this sentiment very strongly. I understand that there's a lot of hate, flamebait, etc etc about the language, with which from my own experience I agree with or disagree with in fairly equal parts. At this stage, I have written more large web projects in PHP than any other language (for varying reasons). I don't proselytize on why it is (or is not) a good language. But for me, personally, a huge chunk of whether I'm happy or not comes from whether I feel inspired while I'm working. Quite separate from the excitement of solving problems: while working with Rust or Python, I get excited, and am generally happy (even when fighting with Rust's compiler); while working with PHP, I tend to feel vaguely annoyed. Take from that what you will.

I'm of the opinion that the best tool for the job is the one you know how to use, and in the real world of deadlines and opportunity cost, if you get a great PHP dev to write your application in Python it's going to be far more expensive and far worse than if it had been written in PHP. But it's also going to be far less fun to both write and maintain. I think you have to make your language decision depending on your priorities.

> the egregious security issues in PHP have been fixed

This I strongly disagree with. And I don't think it's possible. It's not that the existence of the language includes vulnerabilities, it just makes it extremely difficult to write applications securely. I actually teach an upper-division university class on Network and Application Security, I am writing my PhD dissertation on the topic. I have worked on the internal security team of a very large company, and I have worked as a penetration tester / security auditor. I am very familiar with the vulnerabilities that plague web applications. And I still occasionally find the odd XSS vulnerability, timing concurrency attack, etc. in PHP code that I myself have written. And most PHP applications are not written by people with my background.

Post reply on HN