4 ms·
Python has a GIL and is mutable, which makes concurrency impossible and error-prone, respectively. Elixir doesn't have a GIL and is immutable.
by innocentoldguy 1y ago
Python has a GIL and is mutable, which makes concurrency impossible and error-prone, respectively. Elixir doesn't have a GIL and is immutable.
- 15155 1y agoPython allows for memory sharing between threads - which is why a GIL is necessary. A high-level language with a strict shared-nothing concurrency model doesn't need a GIL... but you naturally can't practically share very large objects between BEAM processes.
- icedchai 1y agoIf you couldn’t share memory between threads, they’d be called something else. Many languages have threading without a GIL.
- innocentoldguy 1y agoHi, 15155. May I clarify a couple of things? 1. Regarding Python's GIL: The issue isn't memory sharing between threads. Java and Go allow you to do this, too, but they don't have GILs. The reason Python has a GIL is that it uses reference counting for memory management. If it didn't have a GIL, multiple threads could simultaneously manipulate reference counts, which would lead to memory corruption/leaks. 2. You can share massive "objects" between BEAM processes. For example, if you're running BEAM in a 64-bit environment, you can share maps, structs, and other data structures that are up to 2,305,843,009,213,693,951 bytes in size. I hope this information helps. I also hope it is correct. I think it is, but I've been wrong before.
- pjmlp 1y ago1. not really, you can do this with atomic operations, which is now what CPython does, since GIL removal got final.
- pjmlp 1y agoOnly on CPython, other implementations never had one, and it is finally gone on CPython 3.14.
- pjmlp 1y agoNot really. CPython used to have a GIL, it is no longer the case since the latest version, 3.14. Other Pythons, jPython, GrallPy, PyPy, never had a GIL. Languages and implementations aren't the same.
- int_19h 1y agoIt still has a GIL unless you're using the free-threaded build, which most people do not.
- pjmlp 1y agoWell most people aren't using version 3.14 yet, and it depends on the platform installer. However it is still a CPython issue, it is already available for those that install the right version, and no longer considered experiemental.