Fork me on GitHub
#off-topic
<
2023-09-05
>
teodorlu17:09:33

https://m.youtube.com/watch?v=a3VRwz4zbdw Value Objects in Project Valhalla (from the JVM language summit) . They talk about identity and state, and how being able to compare values is a good thing. What especially excited me is what they say about performance. Value Objects can be implemented without allocation and pointer dereferencing. I imagine this might be good news for languages relying on immutability and the JVM! 😊

🎉 8
🆒 2
👀 2
phronmophobic17:09:44

Yea, seems great. There are some really impressive projects for the JVM: • graalvm's native-image: compile to native • panama: flexible, fast native interop • valhalla: value objects • loom: virtual threads

5
Ben Sless17:09:41

Gripe about loom: give us continuations, Ron

💯 4
2
2
Ben Sless17:09:23

Calling it now: Next Big Thing for JVM is lifetimes

hiredman17:09:42

it is complicated though, things like clojure maps rely on being trees of pointers to make path copying work, which is what makes updating cheap even though they are immutable maps

yes 2
hiredman17:09:00

if you watch the loom presentation from the jvm language summit, the presenter mentions people running into basically unrealistic expectations

hiredman17:09:54

people just wanting to sprinkle virtual threads on everything and have it go better, without understanding the limitations of virtual threads and the expected use cases for them

🪄 4
hiredman17:09:59

value objects look great, and some of the more recent stuff I've seen where they talk about not having to introduce new byte codes for it sounds fantastic, and man it would be great to get rid of the primitive/object distinction

hiredman17:09:07

but we'll see what we get

teodorlu19:09:52

Yeah - perhaps this can do more for things like tech.ml.dataset (which relies on packed data) than the built in clojure data structures.

👍 4
Ben Sless19:09:59

Aren't value classes in Clojure a good fit for • defrecord • enjoying the benefits for primitives - longs, doubles, booleans?

hiredman20:09:55

I think the semantics of value classes are a good fit, the question is will the improved communication of intent to the jvm result in running faster / using less memory, it likely will, but there maybe be caveats, and it may take time to how best to use them

hiredman20:09:57

and, depending on how they are implemented, if they require additional compiler support, etc it might be a while before we see that land in clojure

isak20:09:33

.NET has had them forever, I think usually most business apps usually don't have a strong need for them

👍 2
hiredman20:09:18

there was a lot of speculation about improvements from invoke dynamic, but that has been available for sometime and clojure doesn't use it (deciding where and when in the clojure compiler to use it, would certain things in clojure need a redesign, would that be backwards compatible, etc, etc)

hiredman20:09:12

java got functional interfaces and some notion of lambdas a while back and maybe the next clojure release will have features to make interop with that more seamless

emccue20:09:49

I think its safe to be in "wait and see" mode

2
emccue20:09:07

at least in terms of language features on the clojure side

emccue20:09:50

though no reason the wider us can't mess around with macros+bytecode generation day -100

clojure-spin 2
hiredman20:09:01

the loom presentation mentioned that because so much of the continuations implementation in the jvm is actually written in java, to reach peak performance of virtualthreads you have to wait until the continuation implementation has been jitted

emccue20:09:07

Ron Pressler replied to a reddit thread where i shared some snippets for using Continutations pointing out that they are unsafe to use right now

emccue20:09:11

or at least the API is

hiredman20:09:34

sure, but the continuations are what underpin loom virtual threads

emccue20:09:59

i guess i was more replying to @UK0810AQ2 wanting continuations to be exposed

emccue21:09:46

it depends on how the nullness side channels are exposed i guess?

emccue21:09:06

if i'm thinking about how someone could make a maximally flattened array from clojure

emccue00:09:15

Okay so random thoughts • Defrecord probably can't be made value-like because clojure maps probably can't. Structural sharing requires identity • If we made a def-jvm-record we could piggyback on whatever construction/reconstruction optimizations the JVM will do for records with those operations • A JVM record can be made value-based, so that might be the interop path • Assoc in a "value based JVM record" might not be able to support adding arbitrary keys like clojure records, so crash or promote would be a choice. • If we choose promote then maybe generating a sealed interface with a JVM record and clojure record implementations would make sense? • If we choose crash then that problem goes away • If there are no special optimizations given to JVM records, then generating a "different" impl of clojure lang Record might be okayI'm stuck in bold now okay I'm free • The elephant in the room is metadata. To support metadata I think we want identity semantics even if we don't need it. == shouldn't really compare metadata • Tags, as implemented, probably won't be enough to represent arrays which contain non-null elements since [L the descriptor is unchanged • Array creation would need to be somehow expanded to allow for cramming in nullness/specification information • The benefit of Valhalla for us on this side would the same as for java, but it would be much more for high perf JVM specific stuff, not altering the programming model (unlike Java where I expect to have to explain the knob a lot more)

👍 2
emccue00:09:58

Considering how much startup time is a problem, ComputedConstant might be the most interesting thing coming down the pipe for me right now

phronmophobic00:09:03

I don't remember ever running into an issue where startup time is a problem. What are people doing where startup time is an issue?

emccue00:09:15

Lambdas, shell scripts, etc

emccue00:09:25

Babashka has claimed that niche as of now

Ben Sless06:09:24

@U3JH98J4R re defrecord, can't value classes' members be references? I think the extmap won't be a problem, if anything metadata will but just use equals() like the presenter said

hiredman07:09:18

You couldn't do lazy hashcode calculating

hiredman07:09:38

(which defrecords do)

hiredman07:09:13

Not lazy, deferred until first use I guess?

Martynas Maciulevičius07:09:41

Why not implement metadata as Object<struct>? I think this should work. Then the Object bit won't be copied around but the struct bit would be copied :thinking_face: But then this Object will be located in the heap and cloned a lot of times :thinking_face: Basically int vs Integer... so object and Object :thinking_face: Edit: probably this doesn't sound too good

ghadi21:09:35

exposing continuations is super gross and I don’t know why people moan for it except for academic reasons or feature envy

ghadi21:09:11

it would be incompatible with pretty much every extant java lib

hiredman21:09:38

democratization of control flow

hiredman21:09:43

without continuations the runtime/language determines what control flow is available, with continuations users can build their own

hiredman21:09:19

(should they? do you trust them to? do you want to rely on code doing that?)