Live data from Hacker News

Why People Should Learn Python

iluxonchik.github.io

131–140 of 329 posts

Re: Why People Should Learn Python

#131
post #121
post #117

Earlier quoted context omitted.

Could you post the Julia code? Unfortunately, you do have to make sure that the types are correctly inferred by the compiler in high-performance loops. Or maybe you used a global. http://docs.julialang.org/en/release-0.4/manual/performance-...

I'll admit I don't really know that much Julia and basically wrote naive MATLAB code (and I wanted to make it as close as possible to my python code): s=10000; a=ones(s,s); b=ones(s,s); c=zeros(s,s); tic(); for i in 1:s for j in 1:s c[i,j]=a[i,j]*b[i,j] end end toc(); Obviously in real code I'd simple write c=a.*b and get basically the same performance as numpy

Tarrosion is right, on my machine, putting the code inside a function is 10X faster, and then swapping the order of the loops gives another 10X improvement:

    function f(s)
      a=ones(s,s);
      b=ones(s,s);
      c=zeros(s,s);

      tic();
      for j in 1:s
         for i in 1:s
          c[i,j]=a[i,j]*b[i,j]
         end
      end
      toc();
      return c
    end
Note that you also might have to run the function twice, because the first time JIT-compilation kicks in.

Julia 0.5 also now automatically devectorizes some code (eg. x = a .* b .+ c) so that you don't have to write explicit loops to get performance benefits.

Re: Why People Should Learn Python

#132
post #49

Earlier quoted context omitted.

Yes, I've seen Python described as "everybody's second-favourite language". It's not the best at anything, but if your main requirement is a bunch of different people all need to be able to read and edit the same code then it's a good choice.

Couldn't we say the same thing about Ruby?

Not really. Ruby isn't anywhere near as widespread or well supported in fields like finance, math, various scientific fields and GIS. Python on the other hand has at least has pretty good support in just about any domain you happen to stumble into.

Re: Why People Should Learn Python

#133

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…

Elixir is exciting because it's making the amazing world of Erlang accessible to mere mortals with a developer experience on par with Ruby.

Re: Why People Should Learn Python

#134
post #34

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. Significant whitespace. Not only is it a constant minor inconvenience when editing the program, it makes it very hard to cut-and-paste code fragments on the web.

I've never understood this complaint. Whitespace is included when you copy something. What's the problem?

Admittedly it is mildly annoying when someone decides to use some random number of spaces for indentation, and you have to fix it to make it match the rest of your code (my preferred editor, Geany, has a feature for this). We should all just use tabs. But "very hard"?

Re: Why People Should Learn Python

#135

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…

Weird, I actually consider Pythons consistency in syntax to be a positive. And it's continually becoming more so.

Re: Why People Should Learn Python

#136
post #82
post #73

Earlier quoted context omitted.

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.

> Half the stories here are about Node.js. I think that might be a slight exaggeration. At present, zero of the stories on the HN front page appear to be about Node.js.

My last ten coin flips were heads, but overall, heads is roughly half.

Re: Why People Should Learn Python

#137
The long history of Python support in the scientific community has produced a rich catalog of domain-specific analysis libraries. Warts and all, it's simply not possible, in most languages, to achieve the analytical productivity you get when working in Python.

Re: Why People Should Learn Python

#138
post #74

Earlier quoted context omitted.

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)

My understanding is that the majority of PHP jobs out there are maintaining old, outdated, and bad codebases using an old version of PHP so a lot of people just don't bother.

Re: Why People Should Learn Python

#139
post #134
post #34

Earlier quoted context omitted.

8. Significant whitespace. Not only is it a constant minor inconvenience when editing the program, it makes it very hard to cut-and-paste code fragments on the web.

I've never understood this complaint. Whitespace is included when you copy something. What's the problem? Admittedly it is mildly annoying when someone decides to use some random number of spaces for indentation, and you have to fix it to make it match the rest of your code (my preferred editor, Geany, has a feature for this). We should all just use tabs. But "very hard"?

The web collapses whitespace so if the code is not in
 tags you are stuck. This is quite often a case where comment systems were not intended to share code.

Re: Why People Should Learn Python

#140

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…

And in /r/programming, anything that isn't Python, C, C++, C#, Java, Rust, and sometimes Haskell gets hated on and labeled as "hipster" and terrible.
Post reply on HN