Live data from Hacker News

Why People Should Learn Python

iluxonchik.github.io

71–80 of 329 posts

Re: Why People Should Learn Python

#71
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…

> how about an almost Erlang-like full stop?

This is just brackets/braces in disguise, at which point you might as well follow convention and use {}.

This is obviously a very personal issue, but for me, the whitespace has less cognitive load. E.g.: in languages with brackets, people usually still indent the code for readability.

I've also found that when teaching people to program, consistency works well. I think this is one of the reasons Python is easy to pick up, just because Python code consistently looks like Python.

Re: Why People Should Learn Python

#72
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…

Huh? Can you provide an example?

Well he did mention numpy and obviously doing something that can be done in numpy with nested loops will be much much slower. However that is as much a case of numpy being really fast as python being slow.

For example, just tested elementwise multiplication of two 10kX10k matrices and with numpy and numpy arrays it took ~350 ms vs ~15 seconds with a nested for loops and python lists. Still minutes vs. milliseconds seems like extreme hyperbole.

edit: Figured I'd test how long the naive nested loop approach would take in a 'fast' language like Julia, and much to my surprise it took over 50 seconds.

edit2: cleaned up all my code to try to make it as similar as possible across both languages:

Nested for loops python 2.7: ~30 seconds

Nested for loops Julia 4.6; ~50 seconds

Nested for loops PyPy 5.3.1 ~0.9 seconds

Make of these numbers what you will

Re: Why People Should Learn Python

#73

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…

I would say that node.js is very liked on HN. Half the stories here are about Node.js.

But I rarely see any positive mentioning on HN about c#, .NET, C++ or Java.

Re: Why People Should Learn Python

#74

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…

At a glance, it looks like all languages are reasonably well loved except PHP and Node.js (shouldn't this just be Javascript? Does having a different standard lib make it a different language?) I think that's due to people having flash backs to terribly written code in both languages. For example, PHP apps pre-2005 rarely if ever used frontend controllers, preferring instead to twine in configuration and helper funct…

just to chime in on this, modern PHP is nothing like what people remember from the pre ROR days, i still use it to this day and the major frameworks and libs are really well written to the point i feel some are even over engineered and almost looking like Java (just take a look at the latest Guzzle PHP Library)

Re: Why People Should Learn Python

#75

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…

Maybe all your C#/.NET/Java devs can't access HN because their big enterprise businesses have security policies which have blacklisted it? Hah.

Re: Why People Should Learn Python

#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?

Re: Why People Should Learn Python

#77
post #73

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…

I would say that node.js is very liked on HN. Half the stories here are about Node.js. But I rarely see any positive mentioning on HN about c#, .NET, C++ or Java.

Those are the unsexy, but get-shit-done languages. I would hazard a guess that most people are familiar with them, and either are currently, or have in the past, used them for their day jobs. But they are on the plateau of productivity, rather than the peak of inflated expectations or trough of disillusionment, to use the Gartner model.

Re: Why People Should Learn Python

#78
post #46

Why you shouldn't learn Python: 1. In-consistant syntax. 2. The language uses exceptions to control flow of logic. 3. Divided community, since Python 3+ included breaking changes to the standard. 4. Un-discoverable APIs. You better hope the documentation is bulletproof else the API could change in any which way during runtime. 5. Poor error messages. If an import goes wrong you are not told why, and so on. 6. Ultimat…

What do you mean by inconsistent syntax?

Collection library has:

  deque

  defaultdict

  Counter
After many years I often write DefaultDict myself.

Edit: formatting

Re: Why People Should Learn Python

#79

Why you shouldn't learn Python: 1. In-consistant syntax. 2. The language uses exceptions to control flow of logic. 3. Divided community, since Python 3+ included breaking changes to the standard. 4. Un-discoverable APIs. You better hope the documentation is bulletproof else the API could change in any which way during runtime. 5. Poor error messages. If an import goes wrong you are not told why, and so on. 6. Ultimat…

8. Global Interpreter Lock in CPython

Re: Why People Should Learn Python

#80
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…

I wish Ruby had the math and scientific library support of Python. Also, I've been using Jupyter lately to brush up on data structures and algorithms. It's been pretty sweet to write code in a web notebook and render output including digraphs beneath each block of code. Is there anything like that for Ruby?

You can run a Ruby kernel in Jupyter - https://github.com/SciRuby/iruby
Post reply on HN