This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-21
Channels
- # announcements (14)
- # aws (8)
- # babashka (3)
- # babashka-sci-dev (41)
- # beginners (78)
- # calva (15)
- # cider (9)
- # clj-commons (10)
- # clj-kondo (5)
- # cljs-dev (8)
- # clojure (47)
- # clojure-bay-area (3)
- # clojure-europe (13)
- # clojure-nl (2)
- # clojure-norway (15)
- # clojure-uk (13)
- # clojured (2)
- # clojurescript (20)
- # conjure (29)
- # cursive (4)
- # emacs (19)
- # events (3)
- # funcool (13)
- # hyperfiddle (16)
- # jobs (2)
- # lsp (4)
- # malli (13)
- # meander (1)
- # missionary (2)
- # nrepl (7)
- # off-topic (68)
- # other-languages (82)
- # polylith (1)
- # reagent (28)
- # reitit (12)
- # releases (3)
- # remote-jobs (5)
- # ring (27)
- # sci (6)
- # shadow-cljs (9)
- # spacemacs (2)
- # sql (10)
- # tools-deps (10)
- # vim (10)
immutable persistent data in js
structural sharing and everything
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.
I don't think performance improvements are a goal?
I'd expect it to be slower, even
I'm comparing it to plain mutation
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
I do wish there were things like assoc-in and friends
but as a selling point for integrating into current code that relies on mutation this setup is probably nice
and also modifying deep structures in clojure suuuuuucks where something like this would probably do a lot better job
it's all trade-offs. this seems like a step in a good direction for comprehensible apps, to me
sure, but you can operate on things directly. for clojure you have to chain update-ins
or use zippers
I love clojure but this is definitely one of the weaker parts
We've been using https://immutable-js.com/ at work for a while. I wonder how this compares?
I'll bet there's some similarity
immutable is faster and IMO more ergonomic if you stay in immutable world. immer can be used more in an ad-hoc fashion
Ah, good to know. Our front end team is big on immutability.
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”
we just use good ol discipline to keep from mutation
it takes a lot of discipline for sure
you get used to it
but I'm sure sisyphus said the same
I'm fairly certain my life is happier for not having JS in it...
did you know you can sort nodelists and the dom updates accordingly? it’s kind of wierd
neat! (and terrible)
that's the whole js story I think
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
some day i'll have my own programming language, i'm sure of it
it'll be terrible and full of hacks and dubious features and I'll love it
I mean that was the idea
another hosted language, probably
maybe something akin to hy
or fennel
and it's already all sexps!
it even supports hot reloading apparently: https://epiccastle.io/blog/hot-loading-wasm/
just a gc, nbd
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 🙂
why not write threading, too!
marks & sweeps & marks & sweeps
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.
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
(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!)
I never made it to a full language. that’s still on my bucket list. but it sounds very fun
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).
TIL from that job: the Microfocus COBOL compiler was written mostly in COBOL at the time.
I mean they warned you, it's just an extra-reduced instruction set
This would be a fun language to learn next: https://en.wikipedia.org/wiki/INTERCAL
seems appropriate it has more than one version
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 😄
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.
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.
I often do multiple transforms on data into different structures that are handy for different interfaces where something like this would be really helpful
but yeah, it might irk me that it's so magic, I'm not sure
@U02N27RK69K 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?
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 😄
have you seen specter and meander?
and supdate?
they're there for this purpose but it's hard to justify bringing them into a project in my experience