other-languages

Cora (she/her) 2022-04-21T23:12:21.363019Z

https://immerjs.github.io/immer/

Cora (she/her) 2022-04-21T23:12:38.314969Z

immutable persistent data in js

Cora (she/her) 2022-04-21T23:12:58.290579Z

structural sharing and everything

dgb23 2022-04-21T23:25:15.272619Z

It’s a very clever library, but to me personally it feels incredibly clunky in comparison to a more expression based style. Also the performance improvements over just writing vanilla functional JS are flaky at best.

Cora (she/her) 2022-04-21T23:26:27.949949Z

I don't think performance improvements are a goal?

Cora (she/her) 2022-04-21T23:26:38.778829Z

I'd expect it to be slower, even

dgb23 2022-04-21T23:34:59.574449Z

slower than copy on write with object/array spreading?

dgb23 2022-04-21T23:35:09.314909Z

would expect it to be faster

Cora (she/her) 2022-04-21T23:38:05.387139Z

I'm comparing it to plain mutation

dgb23 2022-04-21T23:38:24.670819Z

but my bigger problem is it feels clunky to me and it breaks my flow and both reading and writing. when I see imperative code I expect it to be imperative

dgb23 2022-04-21T23:38:48.344329Z

> I’m comparing it to plain mutation ah that’s for sure

Cora (she/her) 2022-04-21T23:38:52.458079Z

I do wish there were things like assoc-in and friends

Cora (she/her) 2022-04-21T23:39:33.951099Z

but as a selling point for integrating into current code that relies on mutation this setup is probably nice

dgb23 2022-04-21T23:39:37.926379Z

ah yes, spreading is also not nearly as ergonomic as that

Cora (she/her) 2022-04-21T23:40:10.430669Z

and also modifying deep structures in clojure suuuuuucks where something like this would probably do a lot better job

Cora (she/her) 2022-04-21T23:40:51.137749Z

it's all trade-offs. this seems like a step in a good direction for comprehensible apps, to me

dgb23 2022-04-21T23:41:42.236909Z

you still write out the whole path and have to query with loops etc with this

Cora (she/her) 2022-04-21T23:42:51.993139Z

sure, but you can operate on things directly. for clojure you have to chain update-ins

Cora (she/her) 2022-04-21T23:42:56.932779Z

or use zippers

dgb23 2022-04-21T23:43:15.798619Z

in some cases normalizing is the way to go

Cora (she/her) 2022-04-21T23:43:16.299849Z

I love clojure but this is definitely one of the weaker parts

seancorfield 2022-04-21T23:43:24.524799Z

We've been using https://immutable-js.com/ at work for a while. I wonder how this compares?

Cora (she/her) 2022-04-21T23:44:06.886529Z

I'll bet there's some similarity

dgb23 2022-04-21T23:44:13.290889Z

this is “just” JS syntax and you don’t need to translate between normal objects/arrays

dgb23 2022-04-21T23:45:02.516249Z

immutable is faster and IMO more ergonomic if you stay in immutable world. immer can be used more in an ad-hoc fashion

seancorfield 2022-04-21T23:45:37.844039Z

Ah, good to know. Our front end team is big on immutability.

dgb23 2022-04-21T23:46:12.710889Z

but I tend to use neither now and just use the spreading operator all over the place. looks kind of ugly but it’s one less dependency and “weirdness”

Cora (she/her) 2022-04-21T23:46:42.977989Z

we just use good ol discipline to keep from mutation

dgb23 2022-04-21T23:46:52.398539Z

yes that

Cora (she/her) 2022-04-21T23:47:08.958179Z

occasionally i get bit. like when I forget that sort mutates

😭 1
dgb23 2022-04-21T23:47:10.830809Z

and when there is mutation it is meant as such

dgb23 2022-04-21T23:47:17.548299Z

i hate that 😄

Cora (she/her) 2022-04-21T23:47:30.719989Z

it takes a lot of discipline for sure

Cora (she/her) 2022-04-21T23:47:38.718769Z

you get used to it

Cora (she/her) 2022-04-21T23:47:54.076789Z

but I'm sure sisyphus said the same

seancorfield 2022-04-21T23:47:56.754379Z

I'm fairly certain my life is happier for not having JS in it...

dgb23 2022-04-21T23:47:58.784639Z

did you know you can sort nodelists and the dom updates accordingly? it’s kind of wierd

👀 1
Cora (she/her) 2022-04-21T23:48:35.354189Z

neat! (and terrible)

Cora (she/her) 2022-04-21T23:49:01.027739Z

that's the whole js story I think

seancorfield 2022-04-21T23:49:55.521789Z

My partner has a T shirt that says "That's a terrible idea! What time?"

😄 3
Cora (she/her) 2022-04-21T23:50:47.987499Z

I like using a variety of languages and platforms and tooling and such. so many things I want to learn even after 15 years as a pro

dgb23 2022-04-21T23:51:51.135009Z

I think that’s great! This is such a fun profession 🙂

➕ 1
Cora (she/her) 2022-04-21T23:52:06.316499Z

some day i'll have my own programming language, i'm sure of it

Cora (she/her) 2022-04-21T23:52:50.536679Z

it'll be terrible and full of hacks and dubious features and I'll love it

dgb23 2022-04-21T23:52:57.757219Z

make a lisp!

dgb23 2022-04-21T23:53:17.159089Z

there’s not enough of those

😅 1
Cora (she/her) 2022-04-21T23:54:05.663449Z

I mean that was the idea

Cora (she/her) 2022-04-21T23:54:13.540729Z

another hosted language, probably

Cora (she/her) 2022-04-21T23:54:20.612059Z

maybe something akin to hy

Cora (she/her) 2022-04-21T23:54:33.074249Z

or fennel

dgb23 2022-04-21T23:56:10.277389Z

WASM is a cool target, it’s pretty small and easy to learn

Cora (she/her) 2022-04-21T23:56:33.044069Z

and it's already all sexps!

dgb23 2022-04-21T23:56:36.208919Z

you’ll have to write some kind of GC though

dgb23 2022-04-21T23:56:47.829389Z

it even supports hot reloading apparently: https://epiccastle.io/blog/hot-loading-wasm/

Cora (she/her) 2022-04-21T23:56:48.997629Z

just a gc, nbd

seancorfield 2022-04-21T23:57:04.931239Z

I try to learn a new language every year or two (per Pragmatic Programmer) and I'm still enjoying learning new stuff after doing this professionally since the early '80s 🙂

Cora (she/her) 2022-04-21T23:57:16.020569Z

why not write threading, too!

dgb23 2022-04-21T23:58:29.469759Z

here: https://craftinginterpreters.com/garbage-collection.html

Cora (she/her) 2022-04-21T23:58:37.755479Z

fun!

Cora (she/her) 2022-04-21T23:59:16.178149Z

marks & sweeps & marks & sweeps

seancorfield 2022-04-21T23:59:39.177829Z

Writing new languages used to be so much easier when we had fewer expectations of them. When I was at uni, lots of postgrad students were writing their own languages, mostly FP, mostly in the mold of SML in some sense. GC was still somewhat in its infancy back then so folks were experimenting with that too.

Cora (she/her) 2022-04-22T00:00:55.763229Z

that's the big win in a hosted language that does straight compilation to the host language like hy or fennel, you don't have to meet the expectations yourself they're already there

seancorfield 2022-04-22T00:00:56.069469Z

(like everyone else at the time, I designed and implemented SURE -- Surrey University Recursive Evaluator -- and it had an interruptible GC intended for better interactivity... because we only had single-threaded systems back then!)

🆒 1
dgb23 2022-04-22T00:00:58.009159Z

I never made it to a full language. that’s still on my bucket list. but it sounds very fun

Cora (she/her) 2022-04-22T00:01:36.306149Z

SURE you did, Sean. SURE

🤣 1
Cora (she/her) 2022-04-22T00:01:44.690929Z

🤪

seancorfield 2022-04-22T00:03:22.539969Z

My first job out of uni was essentially a compiler company. That was fun. We got to play with prerelease silicon which often had missing instructions (an early version of what became Motorola's 88000 RISC chip had no divide instruction).

seancorfield 2022-04-22T00:04:48.362749Z

TIL from that job: the Microfocus COBOL compiler was written mostly in COBOL at the time.

Cora (she/her) 2022-04-22T00:05:11.642059Z

I mean they warned you, it's just an extra-reduced instruction set

Cora (she/her) 2022-04-22T00:07:54.774309Z

COBOL in COBOL? in the spirit of pypy I'm going to call that COBCOB

😄 1
dgb23 2022-04-22T00:08:07.020189Z

This would be a fun language to learn next: https://en.wikipedia.org/wiki/INTERCAL

Cora (she/her) 2022-04-22T00:10:28.984179Z

seems appropriate it has more than one version

mauricio.szabo 2022-04-22T13:32:37.526229Z

Not gonna lie, looking at documentation Immer sounds amazing. I think it's probably one of those things that I would think "wow, this is incredible", then when I start to use it I'll think "oh gosh, this is so bad it hurts" or something 😄

dgb23 2022-04-22T13:37:38.133249Z

That’s what happened to me to some degree. When I see mutation I expect mutation, not structural sharing. It would be somewhat equivalent to seeing set! or swap! in a function, but instead those are macros that turn imperative code into functional code. Just think about how a program flows and composes much better if it is expression based, has functional HoCs etc. versus a bunch of imperative loops, statements and mutations.

dgb23 2022-04-22T13:40:31.032309Z

on top of that inside of React/JSX for example you write functional expressions anyways. This basically only makes sense in reducer code (Redux or useReducer hook) if we’re in React world.

Cora (she/her) 2022-04-22T14:05:07.410839Z

I often do multiple transforms on data into different structures that are handy for different interfaces where something like this would be really helpful

Cora (she/her) 2022-04-22T14:05:39.942299Z

but yeah, it might irk me that it's so magic, I'm not sure

mauricio.szabo 2022-04-22T19:53:08.378999Z

@corasaurus-hex did you think about creating a function where you pass the original data, a map with keys/vals and transformations, and apply then all to produce a result? Something like (transform-all <my-data> {:person {:name str/upper-case :age inc}}), for example?

mauricio.szabo 2022-04-22T19:53:55.656539Z

That could be a good experiment to check how well this would make transformations work, and how easy (or hard, or horrible 😄) it would be to use something like this 😄

Cora (she/her) 2022-04-22T20:03:04.007289Z

have you seen specter and meander?

Cora (she/her) 2022-04-22T20:03:49.373609Z

and supdate?

Cora (she/her) 2022-04-22T20:05:25.489469Z

they're there for this purpose but it's hard to justify bringing them into a project in my experience