Live data from Hacker News

Python Is Eating the World

zdnet.com

731–740 of 993 posts

Re: Python Is Eating the World

#731

Earlier quoted context omitted.

okay, so use type annotations and mypy --strict

It's not my project; I'm just a collaborator. My experience has been that a very tiny minority of Python code out there is written in this style, so unless you're only starting projects from scratch, you can't benefit from it.

you can gradually type (probably don't use --strict in that case). It might not be a ton of benefit if you aren't actually writing new code though.

There's a good document on this:

https://mypy.readthedocs.io/en/latest/existing_code.html

Re: Python Is Eating the World

#732
post #301

Earlier quoted context omitted.

Right, but when you're at that point in performance considerations you already have a team of specialists working on multiple angles in performance. And precisely, for ML code all python libraries run extremely optimized natively compiled code. The language overhead is a minimal consideration. And for business domain code language performance is rarely the limiting factor.

In some companies that team size is a very tiny number of 1.

If your team size is 1 then you're not doing yourself any favor thinking about performance beyond basic usability when dev productivity is a far higher priority.

Re: Python Is Eating the World

#733
post #712

Earlier quoted context omitted.

I still don't think you quite understand what's going on here. Python wouldn't create a new variable in this case. I It would re-assign the value represented by the variable you already assigned once. I agree that it would have been better if Python had explicit variable declarations (this is one of the few things I think Perl got right.). On the other hand, Ruby made this same mistake. If you wrote this code in Java…

I don't understand why you're accusing me of being irrational. These seem like very rational problems to have with Python. They literally caused me bugs that cost me time to deal with that I wouldn't have faced in other languages. You're also assuming that I don't have the same problems with Ruby or JavaScript. I do. The exact same critique could be made of them as well, but they're not the subject of this thread; Py…

You can't argue with someone who has chosen to overlook your viewpoint.

I've ran into the same issues while writing python code. People who are newly picking up python are especially prone to these kind of bugs. Also, with python I have to spend lot of time to figure out what went wrong in my code as compared to other languages.

People who have been using python for long have wired there brain to avoid such pitfalls and now they happily defend it.

Re: Python Is Eating the World

#734

Earlier quoted context omitted.

>Oh nice, you have two frameworks. Well, whatever suits your fixed mindset. Let me see, you've got Django, DRF, Flask, Flask-Restful, Flask-Restplus, Flask-API, sanic, pyramid, Cornice, hug, falcon, eve, bottle, tornado, aiohttp, vibora, weppy, starlette... Those are just some that I've picked out of my head.

Most of those enumerations are Flask, and the others are basically useless.

And what exactly are Flask and Django missing to merit more packages doing the same thing?

Routing requests and managing HTTP fundamentals is a solved problem. There is literally zero value in adding another framework when the real complexity is in business logic.

Re: Python Is Eating the World

#735

Earlier quoted context omitted.

Your 2nd error isn't possible in Python, so I'm not sure what you did there. Regarding the first, sure, it is a bug that was annoying to catch. But, having an `Iterable` interface in Python is also really neat and useful if used responsibly. If you're programming regularly in Python, you are accustomed to the tradeoffs that come with a dynamic programming language and no static types, and you can still avoid issues l…

Maybe they could write unit tests to make sure what's being passed is lists and strings. But that's probably crazy.

You can write a unit test for anything you can think of, of course.

But a strongly-typed language will catch such errors automatically (and for free) at compile time, even if you didn't anticipate the failure case.

Re: Python Is Eating the World

#736

Earlier quoted context omitted.

You need to test anyway. So, is it the case that type systems provide much value beyond what a proper set of tests, which are necessary, are going to provide anyway? If you skimp on testing your system will be crap, but at least the type system can fool you into thinking otherwise because it still compiles.

> You need to test anyway. Actually, if your type system is powerful enough, you don't need to test. That's the source of the "if it compiles, 99% of the time it works right" people mention about Haskell (and even more so languages like Idris etc). Type systems are tests -- just formal and compiler-enforced, not ad-hoc "whatever I felt like testing" tests, like unit tests are. From there on it's up to the power of th…

> Actually, if your type system is powerful enough, you don't need to test. That's the source of the "if it compiles, 99% of the time it works right" people mention about Haskell (and even more so languages like Idris etc).

Types only eliminate certain tests. You will always have system tests, acceptance tests and unit tests. One should use types to augment their system reliability.

Types will not catch logical errors in your code.

Re: Python Is Eating the World

#737

Holy Crap! What a lot of irrational, hyperbolic hate for Python. I think everybody should spend their first couple of years working in Fortran IV on IBM TSO/ISPF. No dependency management because you had to write everything yourself. Or maybe [edit: early 90's] C or C++ development where dependency management meant getting packages off a Usenet archive, uudecoding and compiling them yourself after tweaking the config…

Here's some rational "hate" for Python then. I just returned to Python for the first time in a little while to collaborate on a side project and ran into a few tricky-to-debug errors that caused a fair bit of lost time. Know what the errors were? In one case, I was iterating over the contents of what was supposed to be a list, but in some rare circumstances could instead be a string. Instead of throwing a type error,…

The first problem is a valid problem in Python: it essentially don't have a "char" type, instead it only have strings with size 1.

This actually ruined type annotation in Python: you can't properly annotate a function to accept anything iterable except string.

https://github.com/python/mypy/issues/4334 is a FR to at least check it with mypy.

Re: Python Is Eating the World

#738

Earlier quoted context omitted.

Your 2nd error isn't possible in Python, so I'm not sure what you did there. Regarding the first, sure, it is a bug that was annoying to catch. But, having an `Iterable` interface in Python is also really neat and useful if used responsibly. If you're programming regularly in Python, you are accustomed to the tradeoffs that come with a dynamic programming language and no static types, and you can still avoid issues l…

I didn't explain the second one well. Here's some exact code. group_keys = ... if not isinstance(group_keys, list): groups_keys = [ group_keys ] So rather than listifying the non-list variable, it was creating a new variable. The cause of this bug is that Python doesn't distinguish between declaring new variables and overwriting existing ones.

I see this often and it is a bad pattern that people do.

Typically type checked languages wouldn't even allow you to do. If you would use mypy for type checking it wouldn't like it because you're redefining the type of a variable. Best practices would suggest you use a different variable for the conversion if you must, but ideally you should just make the function accept list as an argument. If you're really worried about passing something else than a list, you should use type annotations to tell type checker what it is. If you want to add extra runtime check then do:

assert isinstance(group_keys, list)

You can complain that Python allowed you to something dangerous, but you have tools to help you avoid it and this flexibility is what makes tools like SQLAlchemy so powerful.

Re: Python Is Eating the World

#739

Earlier quoted context omitted.

I don't understand why you're accusing me of being irrational. These seem like very rational problems to have with Python. They literally caused me bugs that cost me time to deal with that I wouldn't have faced in other languages. You're also assuming that I don't have the same problems with Ruby or JavaScript. I do. The exact same critique could be made of them as well, but they're not the subject of this thread; Py…

You can't argue with someone who has chosen to overlook your viewpoint. I've ran into the same issues while writing python code. People who are newly picking up python are especially prone to these kind of bugs. Also, with python I have to spend lot of time to figure out what went wrong in my code as compared to other languages. People who have been using python for long have wired there brain to avoid such pitfalls…

I don't think what you're saying is true. I already said I think it would have been better if Python and Ruby had explicit variable declarations. But, if this is your biggest issue with a language and it's ecosystem, then IMO that language is doing pretty well. I would rather, for instance, have to deal with implicit variable declarations in Python that the gigantic mess of Java frameworks that have been invented to "reduce boilerplate", such as Spring/Guice, AspectJ, Hibernate, etc.

Re: Python Is Eating the World

#740

Earlier quoted context omitted.

The best, brightest and most informed/experienced people who do not think it is a good idea for significant whitepace to be the determiner of syntactic nesting do not hold that position because they would like to inflict badly formatted code on their maintainers. You've invented a stupendously silly strawman.

That's a stupendously anonymous appeal to authority you've made there, and it's unclear what argument you're actually saying without some explicit parenthesis around all those deeply nested phrases, or some kind of grammatical diagram. Can you please restate how we disagree in a few simple sentences? Are there any names or links or citations or concrete examples you could add to support your argument and help us resp…

[deleted]
Post reply on HN