Live data from Hacker News

Why People Should Learn Python

iluxonchik.github.io

271–280 of 329 posts

Re: Why People Should Learn Python

#271

Earlier quoted context omitted.

I kind of wonder how these points are true today vs. 10 years ago ... * It also compiles to Scala.js (it's actually the independent best compile-to-JS language out there in terms of libraries, tooling and IDE support). Support for compiling directly to native is coming around nicely. * Scala is quite far away from the kitchen sink, and many of the questionable parts have been deprecated and/or removed. * I have never…

Hmm I guess they have been actively shrinking the jar (it isn't 4 megs but ~5.5... still a massive improvement [1]). As far as kitchen sink I'm still not sure what idiomatic Scala is especially with the likes of Scalaz. Maybe modern Scala is finally abandoning the OOP fusion. Of course my biggest reason of not liking Scala is completely arbitrary and almost illogical (of course most reasons to (dis)favor things are a…

Maven Central says it's around 4.4MB (with some things still pending to be dropped before the release of the final version)[1].

[1] https://mvnrepository.com/artifact/org.scala-lang/scala-libr...

I would disagree with the comment on verbosity compared to Java 8/Haskell/Ocaml. Most of the things I do regularly in Scala would require a magnitude of more code. Ocaml doesn't even have higher-kinded types or implicits, so I don't think it can win much on that front (except of saving a line where Scala's curly brace might be). With Haskell it really depends. There are certainly ways to write much more succinct code, but what I see in practice is that it's not that much different from Scala. Haskell has it's own unsolved issues though: broken typeclasses, lacking module system, poor tooling, and a weekly-changing, terrible dependency management.

Re: Why People Should Learn Python

#272

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…

NO. That is not more readable, and is warned against in most style guides and code-quality books. In the original, at a glance I know exactly what is going on. In your version, I have to read the whole sentence carefully to notice that it's even a conditional and not a normal assignment, and then I have to mentally unpack it to understand the logic that you're trying to implement. If/else should never be a one-liner.…

Yup, but the right way to do it would be a defaultdict, or a Counter anyway.

    from collections import defaultdict

    def count_names():
        names = defaultdict(int)
        for name in sys.stdin.readlines():
            name = name.strip()
            names[name] += 1
            ...

Re: Why People Should Learn Python

#273

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…

    Julia *****
(or maybe that's just my opinion :-)

Re: Why People Should Learn Python

#274
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.

i started with python when 3 dropped in ~2008.917

ignorant of any prior ecosystem i just thought i was getting into the most current

i came for the prebaked arbitrary precision floating point arithmetic and now i use it for prototyping all of my projects, and all the other stuff that i would call general scripting

this 2to3 complaint made sense to me from an employed standpoint:i work as X and use 2.7's Y library; but you said general scripting

i wonder what libraries were you hoping to use but were unable, and for what general scripting purpose?

Re: Why People Should Learn Python

#275

Earlier quoted context omitted.

Yeah mainly due to that. If you don't have a VERY strict approach to writing code, one wrong decision could turn into a few days of debugging..

Where 'strict' == 'unit tested', then I agree with you. You don't need strong typing to make good code.

I would agree that complete and meaningful unit and integration tests are definitely a necessity for a large Python projects. Or really for any software project meant to be maintained.

Re: Why People Should Learn Python

#276
post #205
post #128

Earlier quoted context omitted.

Reasons to learn Python: Sklearn, tensorflow, pandas, Sqlalchemy, requests, Beautifulsoup, numpy, scipy, pulp. If you have a language that had equivalent libraries that cover all these domains I'd love to hear it. Until then I can build really cool stuff in Python very easily thanks to the amazing hardwork and generosity of these library creators.

If you have a language that had equivalent libraries that cover all these domains I'd love to hear it. R[1]. [1] https://cran.r-project.org/

The problems people have with Python are magnified at least 10x on R.

Re: Why People Should Learn Python

#277

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…

With PHP, I'll agree, though with JS I think it's the reverse. At least my personal dislike for the language and the ecosystem grows with every new hot framework, build system, or other weird "must-have" link for the toolchain that Node people seem to create almost daily.

The JS community is considerably larger than all other programming communities, and better at promoting (and documenting) its tools/libraries/frameworks (a lot of these tools come with beautiful landing pages, docs and demos).

That shouldn't be seen as a mark against the technology. Nobody is forcing you to switch tools.

Re: Why People Should Learn Python

#278
post #125
post #52

I use python on daily basis for 5 years now. It's a really cool language, but: * Packaging is horrible * Releasing python code is a non-standarised nightmare. Every solution has it's own flaws * Big and complex projects in python are really hard to reason about * Poor support for concurrency (fixed in py3) Don't get me wrong, python is really cool as a proof-of-concept scripting language. But for mature and complex s…

I've programmed in a few other languages than Python. I'm curious to know which languages you think have an easier time managing mature and complex stuff?

Statically typed languages. Personally, java or C#.

Re: Why People Should Learn Python

#279
post #125

Earlier quoted context omitted.

I've programmed in a few other languages than Python. I'm curious to know which languages you think have an easier time managing mature and complex stuff?

Statically typed languages. Personally, java or C#.

I've worked with large C++ projects and large C# projects (both at large software corporations) and the code was not particularly less unwieldy than an equivalent Python projects I've worked on.

I think static typing alone doesn't make managing complexity easier.

I'd like to know what other features people think Python is lacking that make it much worse than C# or Java when handling large projects.

Re: Why People Should Learn Python

#280
post #54

Earlier quoted context omitted.

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

1) That particular example is 10 or 20 seconds on CPython, depending on CPython version, machine, etc.

2) With the exception of Luajit and JS, any dynamic interpreted language will take in the range of 5-20 secs to run equivalent code. I'm pretty sure Ruby and PHP are in the same range, no time to benchmark it now. Besides, if you use the Pythonic version of this loop (using list comprehensions), it will take more like 5 or 10 seconds and not 20. Run the same code on Pypy, and it takes under a second.

3) In any case, if performance is really an issue, the correct answer (as the parent discovered) is to use Numpy or Cython or C extensions for that part of the code. This is not uncommon knowledge.

4) I've been using Python in production for a decade and have never thought of this (~0.2 vs ~10 secs) as a problem because I never used pure Python for critical numeric code (or Ruby, or even JS). I did that in C or Cython, or Numpy (or OCaml, on one occasion). If I had to do something like that now, I'd probably use Rust and call it from Python (assuming I was writing the app in Python).

5) Any language has edge cases like this that can surprise you if you're not familiar with the ecosystem. The higher the level of abstraction, the more edge cases. Look at even the Julia thread directly below this one. It's a massive difference between the naive, Julia beginner version (no offense, I would have written it the same way, probably) and the experienced Julia programmer version. Even a language like Go has performance gotchas.

Python certainly has it's problems (like building large, robust programs, although that's being actively addressed with MyPy types), but I honestly don't agree that this is one of them.

Post reply on HN