News for hackers. Stuff that matters.
Re:No-GIL mode coming for Python by neilv on Friday July 28, 2023 @08:49PM (#36915542)
I remember scouring those C runtime docs, for every non-reentrant function. It might be what got me in the habit of checking docs when using some API that I know moderately well, just in case there's some important detail I missed before, or something had changed.

Around that time, doing cross-platform C++, I got an early look at Java, with concurrency built in from the start, along with GC and various other nice features that were easier to use than C++, and I "knew" it was going to be huge. (But who knew that the MIS people would take over Java, when it seemed clearly targeted at non-MIS programmers, and now MIS people are stuck with the C++ syntax and verbosity, after coming from 4GLs, etc.)

Then mainstream programmers picked up Python, which, IIRC, originally was an embeddable extension language, which was why it was simple. And for which the GIL made more sense.

Re:No-GIL mode coming for Python by eru on Friday July 28, 2023 @09:28PM (#36915809)
> I got an early look at Java, with concurrency built in from the start, [...] and I "knew" it was going to be huge.

And Java doesn't even have good (conceptual) support for concurrency. Compared with eg Erlang, Rust or even Haskell.

But Java was still better at it than C or C++ at the time.

Re:No-GIL mode coming for Python by dboreham on Friday July 28, 2023 @11:08PM (#36916468)
In your opinion. Some of us believe the exact opposite.
Re:No-GIL mode coming for Python by eru on Friday July 28, 2023 @11:35PM (#36916607)
By exact opposite you mean that when Java just came out ('I got an early look at Java, [...]') had good concurrency support?

One can make a solid argument that modern Java is adequate. But I don't buy you believe that of early Java?

Re:No-GIL mode coming for Python by soulbadguy on Friday July 28, 2023 @11:19PM (#36916527)
There are a lot of good things about java (and the jvm by some extend), but good concurency is not one of them.
Re:No-GIL mode coming for Python by bitcharmer on Saturday July 29, 2023 @03:35AM (#36917821)
This is not true. JSR-133 was one of the first and most prominent implementation of memory model among general purpose languages. You don't seem to know enough about the platform and it's history to make definite statements like that, imo.
Re:No-GIL mode coming for Python by grumpyprole on Saturday July 29, 2023 @05:27AM (#36918433)
JSR-133 was quite a few years after Java's release. But even after these changes, many problems remained. For example, standard library classes were often not thread safe out-of-the-box, even something seemingly innocuous like a date formatter class would malfunction in a threaded context. The rules around thread safety were also very complex, especially with regard to constructing objects. IMHO, it did not compare well with other languages around the time built with concurrency in mind, for example Erlang. I was once very fortunate to meet Joe Armstrong and we briefly discussed Java, suffice to say he was not impressed by it.
Re:No-GIL mode coming for Python by soulbadguy on Saturday July 29, 2023 @10:19AM (#36920574)
+1
Re:No-GIL mode coming for Python by ungamedplayer on Saturday July 29, 2023 @12:31AM (#36916946)
Old mate isn't alone.
Re:No-GIL mode coming for Python by pseudocomposer on Saturday July 29, 2023 @12:58AM (#36917103)
I agree that Rust handles concurrency about as well as Java (in addition to its memory safety). But could you provide docs on Erlang or Haskell concurrent data structures that were better than Java’s, say, 10-20 years ago? Java’s support for concurrent data structures was pretty unprecedented in its heyday.
Re:No-GIL mode coming for Python by quickthrower2 on Saturday July 29, 2023 @02:17AM (#36917447)
STM, 2006? https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.67...

Still way after Java was released I guess

Re:No-GIL mode coming for Python by grumpyprole on Saturday July 29, 2023 @03:57AM (#36917949)
Java didn't initially ship with lock-free data structures, those came later thanks to Doug Lea.
Re:No-GIL mode coming for Python by seanhunter on Saturday July 29, 2023 @03:25AM (#36917777)
The best example of this is probably the “Beautiful Concurrency” paper from Simon Peyton-Jones in 2007 https://www.microsoft.com/en-us/research/wp-content/uploads/...
Re:No-GIL mode coming for Python by SkiFire13 on Saturday July 29, 2023 @03:47AM (#36917891)
Compared to those other languages, Java has no mechanism to enfore the use of concurrent data structures, it's entirely up to the programmer to use them.
Re:No-GIL mode coming for Python by grumpyprole on Saturday July 29, 2023 @03:48AM (#36917905)
Java still doesn't provide persistent data structures out-of-the-box. IMHO these are more important than lock-free mutable data structures.

When one really does need shared mutable state. Haskell supports transactional updates to mutable state (STM), with optimistic locking and rollbacks. It's awesome, but unfortunately just not practically possible in any language with rampant uncontrolled side-effects.

Re:No-GIL mode coming for Python by Arch-TK on Saturday July 29, 2023 @06:48AM (#36918896)
Erlang processes are a first class object. Data is immutable. There's a special syntax for sending and receiving messages between processes.

I would say that in some ways this is simply incomparable to java but I think this concurrency model is probably the easiest and simplest to work with of any concurrency model.

There are obviously drawbacks like with anything but for a lot of situations it's an excellent choice.

Re:No-GIL mode coming for Python by almostnormal on Saturday July 29, 2023 @02:38AM (#36917547)
* * *
Re:No-GIL mode coming for Python by PaulDavisThe1st on Saturday July 29, 2023 @12:11AM (#36916821)
> I remember scouring those C runtime docs, for every non-reentrant function.

hint:

  % cd /usr/include
  % ag --no-color '[^A-Z]_REENTRANT'
Re:No-GIL mode coming for Python by cjfd on Saturday July 29, 2023 @01:46AM (#36917305)
What are 'MIS people'?
Re:No-GIL mode coming for Python by vore on Saturday July 29, 2023 @02:03AM (#36917386)
Management Information Systems, I think.
Re:No-GIL mode coming for Python by andybak on Saturday July 29, 2023 @06:33AM (#36918781)
I do so love playing guessing games for every comment I read.
Re:No-GIL mode coming for Python by bigbillheck on Saturday July 29, 2023 @10:27AM (#36920645)
I don't think it's reasonable to expect people here to cater to a least common denominator of comprehension.
Re:No-GIL mode coming for Python by paganel on Saturday July 29, 2023 @10:40AM (#36920769)
Nothing “least common denominator of comprehension” about not knowing what that acronym means. I also didn’t know.
Re:No-GIL mode coming for Python by nirvdrum on Saturday July 29, 2023 @10:42AM (#36920787)
That's fine. But, communication is a skill and like all skills, can be improved. For my part, this is the first time I can remember seeing MIS used in the wild (i.e., not in university). Given the tech industry's propensity for overloading initialisms and redefining terms, I have to go by context to work out the meaning. In this case, the context was insufficient.

I suppose I could just dismiss the comment, but curiosity got the better part of me. I'm glad someone asked. I also had to search what "4GL" means. I'm assuming this top Wikipedia hit [1] is what the OP meant.

I don't know if it's reasonable to expect people to know these terms. But, the concise text is not saving anyone beyond the OP any appreciable amount of time, so what's its value?

[1] https://en.m.wikipedia.org/wiki/Fourth-generation_programmin...

Re:No-GIL mode coming for Python by KolenCh on Tuesday August 01, 2023 @07:30PM (#36964740)
Speaking of which I never fully understand the meaning of OP. It seems there’s a few semantic ranges there and people sometimes use OP standing for slightly different things.
Re:No-GIL mode coming for Python by andybak on Saturday July 29, 2023 @10:57AM (#36920902)
Yes but unless I'm a extreme outlier "MIS" is not part of the common denominator.
Re:No-GIL mode coming for Python by otabdeveloper4 on Saturday July 29, 2023 @03:43AM (#36917869)
> originally was an embeddable extension language

Python was originally a teaching language, to replace BASIC and Pascal for kids and beginners.

(Yes, there once was a time when people took teaching programming seriously.)

Re:No-GIL mode coming for Python by tromp on Saturday July 29, 2023 @04:05AM (#36918005)
Quoting from [1], section "The ABC Project"

> The letter “B” was chosen because it is the first letter of the word “beginner” and because the project was meant to become a language for teaching programming to absolute beginners.

[1] https://inference-review.com/article/the-origins-of-python

Re:No-GIL mode coming for Python by eesmith on Saturday July 29, 2023 @06:59AM (#36918959)
Python was not originally a teaching language.

Yes, van Rossum was an implementer of ABC, which was a teaching language. Python drew on that experience, but also from Modula-2 and Modula-3, and the needs for writing an extension language for the Amoeba operating system.

From the initial release notes at https://www.tuhs.org/Usenet/alt.sources/1991-February/001749... :

  [Python is] an extensible interpreted programming language that
  combines remarkable power with very clear syntax.
  
  This is version 0.9 (the first beta release), patchlevel 1.
  
  Python can be used instead of shell, Awk or Perl scripts, to write
  prototypes of real applications, or as an extension language of large
  systems, you name it.
No mention of it being a teaching language.
Re:No-GIL mode coming for Python by weinzierl on Saturday July 29, 2023 @04:13AM (#36918053)
That Java had concurrency built in from the start is a blessing mostly, but also a bit of a curse. Most of the Java ecosystem is still in the mindset that threads are cheap and firing up a couple more cannot hurt. So we end up with apps that run thousands of threads and this disease is hard to contain.
Re:No-GIL mode coming for Python by pjmlp on Saturday July 29, 2023 @04:41AM (#36918215)
Like not everyone toy app isn't going to be the next FAANG, there are plenty of workloads where it hardly matters, while 30 years later it is still a mess in C and C++.

And between C++ and Rust coroutines, still not sure which one I like less.

Re:No-GIL mode coming for Python by doliveira on Saturday July 29, 2023 @11:15AM (#36921072)
I thought so too until I got to interact with databases and Big Data tools written in Java. God, what a mess that requires so much upkeeping, more dependency problems than I remember from C++ and probably some orders of magnitude more resources than they should.
Re:No-GIL mode coming for Python by pjmlp on Saturday July 29, 2023 @11:30AM (#36921218)
Doing code review for C++ code delivered by most well know offshoring companies, versus what they deliver in Java, will help get another point of view.
Re:No-GIL mode coming for Python by intelVISA on Saturday July 29, 2023 @02:20PM (#36922992)
Thankfully LLMs are becoming a viable, cost-effective, option for stuffing your favorite offshored codebase with even more unmaintainable spaghetti. What a time to be alive.
Re:No-GIL mode coming for Python by weinzierl on Saturday July 29, 2023 @06:03PM (#36925158)
"And between C++ and Rust coroutines, still not sure which one I like less."

I, myself, am not a Go guy, but I feel it has to be mentioned here. Go's approach might not be as universal as C++'s or Rust's but I think for a large number of use cases it makes sense.

Re:No-GIL mode coming for Python by pjmlp on Monday July 31, 2023 @02:58AM (#36939555)
Many that praise async/await in C#, kind of forget it took about 10 years to spread across all the layer of the language and runtime, since it was done via IL rewriting, it caused several issues with F# async tasks, due to the age of the ecosystem plenty of code isn't async/await friendly and needs to be wrapped into Task.Run() or similar.

There is a best practices guideline from one of the ASP.NET architects, https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/b...

During last year they researched adding Go/Java's approach to .NET, but now it is too late. See the ASP.NET Q&A session at BUILD 2023.

Re:No-GIL mode coming for Python by ptx on Monday July 31, 2023 @09:43AM (#36942338)
This seems to be the relevant part of the Q&A: https://youtu.be/H5jI76Fq420?t=2396

Aside from being to late (already having two models and not wanting to add a third) they also mention that the Go/Java approach adds a performance penalty when calling native APIs.

Re:No-GIL mode coming for Python by samus on Saturday July 29, 2023 @04:50AM (#36918262)
Fortunately Virtual Threads have landed, so when the ecosystem finally comes around to adopt it, many things might become faster.
Re:No-GIL mode coming for Python by the8472 on Saturday July 29, 2023 @06:27AM (#36918742)
Threads are cheap compared to the process-per-request model that came before. And they're easy to code for, you don't have to worry about blocking code or awaiting your futures in the correct way or things like that. They're not optimal if you want to squeeze lots of concurrent requests into some memory-limited box. But on the other hand even dumb threading offers more throughput than python or node.
Re:No-GIL mode coming for Python by cutler on Saturday July 29, 2023 @01:32PM (#36922511)
Green threads are coming to Java this September so all this will be moot.
Re:No-GIL mode coming for Python by weinzierl on Saturday July 29, 2023 @06:00PM (#36925131)
I wish, but I'm skeptical. It's not that we don't already have the means to be reasonable with threads. The issue in my opinion is more a mixture of path dependency and a mindset that changes too slowly.
Re:No-GIL mode coming for Python by formerly_proven on Saturday July 29, 2023 @06:05AM (#36918630)
Python has many similar restrictions even in the language itself, they just tend to be exceptionally poorly documented.

For example, you can't safely use print in a Python signal handler, because the entire I/O system is not reentrant [1], yet the documentation shows doing this in a "how to do it properly" example [2] while explaining that it's horribly unsafe to throw from a signal handler, which is the default for SIGINT. (And also the reason why the threading module doesn't expose PyThreadState_SetAsyncExc). So despite appearances to the contrary (since the Python signal handler is invoked by the VM, it doesn't actually run in a signal handler context; the signal module registers a C handler which simply sets a flag that is checked by the VM every instruction), you should probably only do in a Python signal handler what you would do in C, which is very little. Set a flag or write to a pipe. Don't go around and call library functions.

[1] E.g. https://bugs.python.org/issue24283 [2] https://docs.python.org/3/library/signal.html#note-on-signal...