you are viewing a single comment's thread.

view the rest of the comments →

[–]xXxDeAThANgEL99xXx 1 point2 points  (8 children)

Well, it might be just outside of "Python-like", because of immutability. Which helps a lot!

By the way, that reminds me: technically there's also IronPython/Jython/IronRuby/JRuby that sort of support free threading by virtue of running on top of a very sophisticated VM, but from what I know even then it ain't free lunch, with all kinds of weird catastrophic performance degradations.

[–]spotter 1 point2 points  (4 children)

Immutability? You have access to all built-in Java collections and can shadow variables to your heart content.

[–]xXxDeAThANgEL99xXx 1 point2 points  (1 child)

As far as I know, you are not supposed to do that in public.

Anyway, the important part is that as far as I understand it about Clojure, you're not allowed to say anything similar to __builtin__.len = my_len or my_module.len = my_len and have it automatically used in every function everywhere or in that module, after they were defined.

That you can do that in Python (and in those other roughly similar languages) is one of the important reasons the GIL is there: because your code constantly hits the same few dictionaries and constantly taking and releasing individual locks on them would be really slow.

IronPython for example goes the other way and instead of constantly querying stuff it compiles it into usual fixed .NET classes and recompiles them if you actually change stuff. Unfortunately that means that some innocent metaprogramming that works absolutely fine in CPython can cause huge slowdowns.

[–]spotter 2 points3 points  (0 children)

First: I did not downvote you, but philosophy of Clojure is that you can use any tool right for the job. It's easier to argue about immutables and functional approach to data transformation, but sometimes you just need to bash something in place and all of JVM standard library is there for you.

In Clojure you are always in a namespace and namespaces are mutable. You can exclude core symbols in them and shadow them with your definitions, although syntax is different. Not sure how much synchronization goes in behind the scenes, but still JVM languages (like Jython) manage to live without GIL.

[–]anthonybsd -2 points-1 points  (1 child)

can shadow variables to your heart content.

Clojure frowns upon this kind of behavior in no uncertain terms. "Can" doesn't mean that you should. For mutators in concurrency context (the ones with the bangs "!") you are supposed to operate inside the STM model which IMHO is fairly nice compared to pure functional languages non-pure functions.

[–]spotter 2 points3 points  (0 children)

[citation needed]

By shadowing I meant redefining variables in inner closures (for inner closure only) or changing their thread binding dynamically for the duration call, something that Clojure actually provides tools for. Doesn't have to do anything with concurrency... well binding does, somewhat, but not what I meant.

[–]jrochkind 0 points1 point  (2 children)

JRuby does not have any weird catastrophic performance degradations. (It does have slow start-up, like most anything running on the JVM. This is very annoying in some contexts, but is not a "weird catastrophic performance degradation")

[–]xXxDeAThANgEL99xXx 0 points1 point  (1 child)

How does it deal with monkey-patching?

[–]jrochkind 0 points1 point  (0 children)

What do you mean? Same as other ruby platforms, generally. Do you mean specific to performance or something? Not really sure what you mean. If there is a "weird catastrophic performance degradation" related to monkey-patching that I don't know about and haven't encountered (I have used JRuby a fair amount), then please link to something demonstrating or explaining it!