News for hackers. Stuff that matters.
Re:Python Is Easy. Go Is Simple. Simple != Easy by lambda_garden on Monday November 27, 2023 @12:40PM (#38435370)
Python is valuable due to the ecosystem of libraries it offers. The language itself is extremely poor. I think this is not something most Python users are aware of since if you are doing ML, data-science or simple scripting there is little reason to step outside of the ecosystem.

- Weird scoping rules

- Very limited list-comprehensions

- Ability to monkey patch things is a liability

- Mutability by default

- Lack of support for functional programming

- Deployment story remains extremely painful

- Tacked on type-system

- Slow execution of pure Python code

If this sounds like a rant... it sort of is. I find it really sad that so much programmer effort is being put into something with poor fundamentals. Many of these issues cannot be fixed with breaking changes.

Re:Python Is Easy. Go Is Simple. Simple != Easy by whalesalad on Monday November 27, 2023 @02:24PM (#38436934)
I really cannot agree with most of this.

Weird scoping rules? This will rarely if-ever impact you in the real world.

The list comprehensions in Python are incredible, in fact people over-use them all the time in really gnarly ways. Like [x for x in [y for y in [z... and the consistency with the same system supporting all datastructures (sets, dictionaries, tuples, etc) is very intuitive.

Monkey patching is a liability? This is like saying a car is a liability because I am free to drive it off a cliff. You're technically correct, but you are the one in the drivers seat. The ecosystem does not do or encourage this behavior, with the exception of things like gevent where it is required.

Mutability by default is common in virtually every language. You can't say it is good or bad, it's just a fact of life. There is a cost to immutable datastructures unless the language is designed from the get-go to utilize them efficiently.

Lack of support for functional programming? Functions are first class in Python. You can pass them around all over the place, as args, put them in datastructures, etc. When you combine this with comprehensions and generators it is very powerful and lets you do lazy evaluation of complex transformations. There are lots of built-in tools in the stdlib to do functional programming. This is just straight up false.

Deployment story remains extremely painful - again false, I do not know why people say stuff like this. Create a virtualenv (built into the standard library), and pip install your requirements. If you are using conda and all the other noise you are going to have problems.

Slow execution of pure python code - this is the ONLY area where you are perhaps correct... but compared to what? For a lot of use cases, the speed of Python is not a problem. When it becomes a problem, you off-load that responsibility to something else. There is also something to be said for writing software quickly, which is a perk of Python for sure.

Re:Python Is Easy. Go Is Simple. Simple != Easy by tyree731 on Monday November 27, 2023 @04:32PM (#38438672)
> Slow execution of pure python code - this is the ONLY area where you are perhaps correct... but compared to what?

Compared to… basically everything? Python’s performance is unacceptable, especially given that single threaded processor performance isn’t really improving any longer.

Re:Python Is Easy. Go Is Simple. Simple != Easy by whalesalad on Monday November 27, 2023 @05:08PM (#38439115)
asyncio is quite fast, especially with libuv/uvloop

- https://github.com/libuv/libuv

- https://github.com/MagicStack/uvloop

Re:Python Is Easy. Go Is Simple. Simple != Easy by durable_queue on Monday November 27, 2023 @04:31PM (#38438658)
> Weird scoping rules? This will rarely if-ever impact you in the real world.

It can be a problem if you have nested loops. Things would have been less error-prone if Python introduced a let keyword.

> The list comprehensions in Python are incredible, in fact people over-use them all the time in really gnarly ways. Like [x for x in [y for y in [z... and the consistency with the same system supporting all datastructures (sets, dictionaries, tuples, etc) is very intuitive.

They have been completely surpassed by those in other languages. For example, you can't do this in Python list-comprehensions:

    xs = [
      if some_flag:
        yield 1
      
      for y in ys:
        yield y * 2
    ]
> Monkey patching is a liability? This is like saying a car is a liability because I am free to drive it off a cliff. You're technically correct, but you are the one in the drivers seat. The ecosystem does not do or encourage this behavior, with the exception of things like gevent where it is required.

Only if you are a solo developer. Unfortunately the Python ecosystem is built around things that compose poorly like annotations and exceptions.

> Mutability by default is common in virtually every language. You can't say it is good or bad, it's just a fact of life. There is a cost to immutable datastructures unless the language is designed from the get-go to utilize them efficiently.

It's a mistake, even though it is common. The cost is low in true FP langauges, because they can be optimized away.

> Lack of support for functional programming? Functions are first class in Python. You can pass them around all over the place, as args, put them in datastructures, etc. When you combine this with comprehensions and generators it is very powerful and lets you do lazy evaluation of complex transformations. There are lots of built-in tools in the stdlib to do functional programming. This is just straight up false.

Python lacks do-notation. It doesn't give you tail-call optimization. Function calls are slow. Immutability is very much opt-in. Lambdas can only be one line. If you do lots of FP in Python, you're in for a bad time.

> Deployment story remains extremely painful - again false, I do not know why people say stuff like this. Create a virtualenv (built into the standard library), and pip install your requirements. If you are using conda and all the other noise you are going to have problems.

In other language stacks it's pretty trivial to cross-compile from e.g. MacOS to Linux and things just work. In Python this basically requires Docker. Note that Pip install doesn't give reproducible builds. There's nothing like Go static binaries out-of-the-box, either.

> Slow execution of pure python code - this is the ONLY area where you are perhaps correct... but compared to what? For a lot of use cases, the speed of Python is not a problem. When it becomes a problem, you off-load that responsibility to something else. There is also something to be said for writing software quickly, which is a perk of Python for sure.

Python is about 100x slower than mainstream GC languages such as Java and C#. Having to drop into native code is not always possible and it's extra work besides.

Re:Python Is Easy. Go Is Simple. Simple != Easy by somat on Monday November 27, 2023 @01:53PM (#38436510)
Python always felt well designed to me. Slow yes but it felt the the author really thought about how the language would go together. This is mainly a comparison to the other scripting languages available.

Pick your poison

  shell  #expand all the strings, but those pipes are nice, why can't more languages have pipes.
  awk    #not a bad language, but very very small, and an AWKward(see what I did there) implied data loop
  perl   #can do anything but the syntax is, well it is a real frankenstein monster of a syntax
  python #well designed syntax, has a strange block structure but at least it is always nicely formatted
  tcl    #all the strings! but other than that not half bad
  ruby   #pretty, but wow, that is a lot of magic
  php    #just graft on whatever to the language as you need it, don't worry about how it all fits together.
Re:Python Is Easy. Go Is Simple. Simple != Easy by grumpyprole on Monday November 27, 2023 @02:06PM (#38436694)
Yes it's certainly better, but it definitely slithered out from under the same rock. There are even better languages, designed by folks whose minds where presumably never corrupted by anything on that list.
Re:Python Is Easy. Go Is Simple. Simple != Easy by chpmrc on Monday November 27, 2023 @02:58PM (#38437361)
I could address each of these "issues" but I'd rather focus on the following:

> The language itself is extremely poor

> I think this is not something most Python users are aware of

These two statements are contradictory. If it was indeed so "poor", people would notice :) If they instead increasingly adopt it (out of appreciation, not because they are lobbied into doing it) it becomes really difficult to logically demonstrate that it's a poor choice. Software development is a very efficient market. Everyone is (or can be) aware of (almost) everything. So if most people (including experienced devs) gravitate towards a certain technology, the only acceptable explanation is that the technology, as a whole, is good.

Deconstructing and pointing out the flaws of the individual components is a common flawed thought process IMHO. Python is great despite all the issues you point out. To me this is equivalent to comparing individual components when shopping for a product, missing the fact that it's the ensemble of all those (flawed) components that make the product (or the language, in this case) work. The easy syntax, the packages, the community, those are all things that make "weird scoping rules" pretty much irrelevant.

Re:Python Is Easy. Go Is Simple. Simple != Easy by chlorion on Monday November 27, 2023 @03:41PM (#38437936)
You could claim the same thing about JavaScript. It's very possibly more popular than Python, but it's definitely not better designed than Python or most of the other languages in current use.
Re:Python Is Easy. Go Is Simple. Simple != Easy by chpmrc on Monday November 27, 2023 @10:01PM (#38441773)
Yes and that would be a correct claim. Unless one assumes that a language is objectively "good" or "bad", in which case, rationally speaking, we would only be using "good" languages, which is clearly not the case. Ironically the same happens with natural language. In theory we should all be using Esperanto by now, in practice English as the de facto international language is totally fine.

The main difference with JS is that we don't know whether it would be so commonly used if it wasn't for browsers. Still, it seems that the majority of efforts are towards augmenting JS' capabilities rather than finding ways to use alternative languages on the web (yes, I'm aware of WASM and maybe in the long run this statement will be proven false).

Re:Python Is Easy. Go Is Simple. Simple != Easy by lambda_garden on Tuesday November 28, 2023 @04:59AM (#38444185)
> These two statements are contradictory. If it was indeed so "poor", people would notice :)

Would they? The history of programming is full of great ideas that took a very long time to reach mainstream adoption. We also did some things that in hindsight were bad ideas, but for a time were very popular.

This is because the programming language "market" is not rational. It moves at the speed of education, not the speed of innovation. People learn a language and they make useful things with it. Why would they stray into niche languages and PL research?

Re:Python Is Easy. Go Is Simple. Simple != Easy by chpmrc on Saturday December 02, 2023 @04:01PM (#38502002)
I don't claim that Python is the perfect language and it will never be replaced, in popularity, by something that is better.

What I'm saying is that considering Python a bad language, just because there are some languages that improve on some of its shortcomings, is just wrong.

As of today, Python is the most popular, hence (as a corollary) the best choice for most people. One day that might change, sure. These aren't mutually exclusive.

I don't agree with the claim about the market not being "rational". Someone who adopts Python even when given requirements that are clearly beyond the language's capabilities isn't going to last long in such market (and neither will their choices).

On the other hand there are plenty of people (myself included) who prefer using Python whenever possible, even though they have been "educated" in the use of other languages (I'd say I'm fairly comfortable with Typescript or even C building non trivial systems). I guess I'm not innovative enough :)

Re:Python Is Easy. Go Is Simple. Simple != Easy by alsodumb on Monday November 27, 2023 @12:50PM (#38435524)
I mean it's not like MATLAB where a company put in millions of dollars to make these libraries - the entire ecosystem was developed by open source contributors because they liked something about Python - sure, it's probably not as sophisticated as some of the other languages, but it has a low barrier of entry, it has users, and people developed libraries - in some cases because that's where users are and in many cases because it's the language they know!

You're thinking about the programmer effort put into making certain libraries efficient, but think about the users who are reaping the benefits of low barrier to entry! More people are coding, getting comfortable with the idea of programming, and we should welcome them!

Re:Python Is Easy. Go Is Simple. Simple != Easy by lambda_garden on Monday November 27, 2023 @12:59PM (#38435664)
> they liked something about Python

I think it's simply what they already knew. Very few programmers learn multiple languages to any kind of depth.

Is there any evidence that Python is an easy language to learn? I think we've reached a situation where beginners learn Python because it's seen as beginner friendly... because beginners learn Python!

Re:Python Is Easy. Go Is Simple. Simple != Easy by EnergyAmy on Monday November 27, 2023 @01:19PM (#38435970)
It's definitely easier than many other languages to start learning. Absolute beginners don't want to worry about overflow, signedness, or anything like that. They just want to add some numbers and have it work. Python isn't perfect by any stretch, but having syntax like "for x in y:" goes a long way towards helping beginners not have to care about stuff they're not ready for yet.

Admittedly, that's just an opinion. I don't know of any relevant studies, but Python wasn't always the preferred language for beginners, and it changed at some point. It feels like there must be a reason for that.

Re:Python Is Easy. Go Is Simple. Simple != Easy by grumpyprole on Monday November 27, 2023 @01:21PM (#38436001)
I once read that "Python" came from Monty Python's Flying Circus. And that's how I've always viewed the language, i.e. something akin to a Terry Gilliam animation.