r/programming • • Jan 06 '24

A case for ClojureScript 2.0

https://tonsky.me/blog/clojurescript-2/
57 Upvotes

35 comments sorted by

29

u/Aetheus Jan 06 '24

How many people are there still actively writing new ClojureScript? I feel like it occupies a pretty small niche.

25

u/activeXray Jan 06 '24

There’s dozens of us!

8

u/brunogadaleta Jan 06 '24

And I'm considering adding my name to this list.

2

u/agumonkey Jan 07 '24

any space left on that bus ?

89

u/qq123q Jan 06 '24

Is there really a difference between, say, a 500k bundle and a 1M bundle? A practical one? One that users will definitely notice in a meaningful way?

No wonder applications and websites are so bloated when devs don't even care about a 2x difference.

31

u/Practical_Cattle_933 Jan 06 '24

I mean, absolute scale matters. 2x of 1k is not a problem. 2x of a GiB may well be, depending on what are we talking about. It’s a fallacy to assume that everything is linear.

14

u/qq123q Jan 06 '24

Sure but my comment is to be taken in context of the blog post and is aimed at the attitude of developers that leads to bloat.

From the blog post:

So we will only potentially lose a little bit in bundle sizes and (maybe) performance? But there are so many low-hanging performance fruits in ClojureScript anyways maybe nobody will notice.

Doesn't even check if there is any performance impact and hopes nobody will notice.

What’s important is what we’ll gain: The Simplicity. Ease of Mind. Happiness.

As long as the devs are happy, whatever happens to the end users doesn't matter apparently.

Well I'm both a dev and end user of quite a bit of software end I hate this stupid bloated shit everywhere. It's clearly not just managers and too short timelines to do things properly.

6

u/CitationNeededBadly Jan 07 '24

The main point of the post is that :advanced produces bad user experience (ie, buggy behavior) because the optimization transforms are too aggressive and not reliable. He is proposing to improve reliability at the cost of speed/bundle size. That is not just DX, that helps end users as well. As a user I dislike large downloads, but I really hate buggy crap, especially bugs that are hard to track down because they are a result of the optimizer doing something unsafe and weird.

25

u/IanisVasilev Jan 06 '24

You are correct, however the website bloat is mostly due to flashy high-resolution images and videos, and developers are usually not the ones who insist on that.

26

u/gwax Jan 06 '24

I just optimized or site for bandwidth recently and big libraries were an order of magnitude worse than images.

After preprocessing, our banner image is ~200k, which is still smaller than lodash. (I got rid of lodash)

17

u/IanisVasilev Jan 06 '24

As much as I like to bash on lodash, if you only use a function or two, this particular problem should be solvable by only loading the few modules of lodash that you need.

That being said, if somebody uses forEach, map, find and the like from lodash, he deserves his faith.

10

u/gwax Jan 06 '24

Lodash was an easy example because it was used in four places that were easily replaced with reduce.

Honestly, the biggest offender was an icon library that was eager loading everything.

5

u/Garethp Jan 06 '24

My go to example is momentjs. That library is huge and swapping to dayjs is easy enough for most use cases with massive benefit

1

u/Jump-Zero Jan 06 '24

Momentjs is deprecated so moving away from it is a win on that front too.

1

u/rpd9803 Jan 09 '24

Ugh my time library is huge. Stupid js jodatime clone.

1

u/rpd9803 Jan 09 '24

Yeah I could try and write some babashka scripts to tree shake the material design icon set.. but maybe someday I’ll need mdiCornOff.

0

u/[deleted] Jan 06 '24

[deleted]

1

u/gwax Jan 06 '24

lodash-es supports tree shaking and I considered swapping over but it was literally 4 places we used lodash and it was trivial to remove.

4

u/functionform Jan 06 '24

The bloat users feel are network response times and poor coding not wait of the application download. 1 mb has 0 impact on the end user.

8

u/Garethp Jan 06 '24

At 1mb the time for the JavaScript engine to load and parse the application absolutely has impact. It starts getting into the amount of time that's just long enough for the user to feel, even if it's not that long

1

u/rpd9803 Jan 09 '24

lol imagine fussing over 1 bit vs 2. B-b-b-but it’s TwO X!

1

u/Worth_Trust_3825 Jan 06 '24

We can reduce the size of it to 0, but apparently server side rendering is considered ancient and not wasteful enough.

21

u/gitgood Jan 06 '24

Abomination of a website.

50

u/IanisVasilev Jan 06 '24

The light toggle is a masterpiece.

10

u/n-of-one Jan 06 '24

I hate it and love it at the same time.

8

u/drakgremlin Jan 06 '24

I laughed then I was really sad this person obviously knows the horror they are bringing into this world.

6

u/chiefnoah Jan 06 '24

Tonsky is the guy behind... a lot of tools and libraries you'd probably come across or even use, most notably FiraCode and DataScript (if you're a clojurescript dev). He knows a thing or two about design and is at least partially trolling with his blog's design.

3

u/Bavoon Jan 06 '24

🤷 I love it

5

u/activeXray Jan 06 '24

The thing I worry more is about google abandoning closure. Because cljs relies on it to work, google practically controls it. I think something the likes of graal-ing clj to wasm might make more sense in the future.

1

u/agumonkey Jan 07 '24

I see borkdude is on it. It means the problem will disappear in a few minutes.

2

u/rpd9803 Jan 09 '24

All hail borkdude

-3

u/[deleted] Jan 06 '24

A nice reminder for me to avoid ClojureScrupt 😅

-1

u/redalastor Jan 06 '24

That makes no sense. If he doesn’t care about bundle size, he already has the option of not using optimizations. Why does he need that no one else can ?

If clojurescript moves away from closure, then why would that break semver ?

Also, the reason that he needs a more bloated clojurescript, is that he is already bloating his app by adding npm dependencies. If you only use clojurescript, then everything works in advance compilation without issues.

3

u/Alan_Shutko Jan 06 '24

He writes a library, therefore he has to support dependent projects that do and don't use optimizations.

2

u/CitationNeededBadly Jan 07 '24

He writes libraries. popular libraries. he gets bug reports from people complaining that his library is broken, when the root cause is not his library but something weird the optimizer did.