[HN Gopher] Lessons on Writing JavaScript and React from Clojure...
___________________________________________________________________
Lessons on Writing JavaScript and React from ClojureScript
Author : yogthos
Score : 34 points
Date : 2021-05-08 18:28 UTC (4 hours ago)
(HTM) web link (jerue.org)
(TXT) w3m dump (jerue.org)
| mikojan wrote:
| 1. Redux docs encourage you to use @redux/toolkit which
| drastically reduces boilerplate. And even if you do opt into
| using vanilla redux: Typescript for some time now has supported
| string literal types which render enums obsolete almost.
|
| 2. Mutability is not at all a problem. Those types of bugs are
| obvious. On the other hand, mutability allows for a type of fine-
| grained control you will absolutely need. It is Javascript after
| all.
|
| 3. Redux _does_ allow "users to create complicated compounded
| subscriptions in a performant way using materialized views" which
| is a rather convoluted way of saying "memoize derived values."
| You are looking for the createSelector-API you had been shunning
| in the opening statement.
|
| 4. What in the name of god almighty is this:
| function Component({ children }) { const { data,
| loading, error } = useGetMyData(); return (
| <div> {(function () { if
| (loading) { return (
| <div>loading...</div> ); }
| if (error) { console.error("Uh oh!");
| return ( <div style={{ color: "red"
| }}>{error.message}</div> );
| } return ( <>
| <div>Data:</div> <div style={{ color:
| "green" }}>{data}</div> </>
| ); })()} {children}
| </div> ); }
|
| We are encouraged to pour yet another layer of abstraction on top
| of Javascript pulling in clones of the very libraries we had
| already been using. Only now, our knowledge about performance
| testing and tuning in ReactJS/Javascript is basically useless.
|
| At this point, why not do away with all "boilerplate" and just
| use Elm?
| prezjordan wrote:
| I assumed (4) was the author's frustration that if-statements
| aren't expressions, and nesting ternaries is rough.
| swordbeta wrote:
| What is wrong with the component?
| agentbellnorm wrote:
| I just wish more people would adopt clojure and clojurescript.
| The world would be a better place.
| rchaves wrote:
| > ClojureScript has unlocked whole new levels of productivity
|
| I keep seeing this claim over and over again about Clojure and
| Clojurescript. I don't get it, at all. I tried it, multiple
| times, I don't get where the productivity boost could come from.
| I though maybe the so-called REPL-driven development (as if
| clojure is the only language ever with a REPL), I watched videos
| about REPL-driven development, developed a project that way,
| cool... not more productive than say TDD or hot-reloading
|
| > I enjoy it because there is little cognitive load in terms of
| understanding what the program is doing.
|
| Is there? I mentioned I was not more productive in clojure, in
| fact I was actually much slower in clojure. It's not lack of FP
| knowledge, because in fact I love how productive I am with Elm,
| so maybe it's the lisp style, or maybe my inexperience with the
| language, I can't memorize all thousands of functions to
| manipulate lists and hashs in clojure (get-in, map-vals, conj,
| dissoc, select-keys, sorted-map-by, do you know what all those
| do?) which do a lot, I felt clojure was dense, the opposite of
| little cognitive load
|
| After that, his following arguments about reagent vs useContext
| and Re-Frame vs redux is not about some real advantage of
| clojurescript over javascript, but rather conscious decisions
| that js community did to be explicit over implicit, it was an
| explicit trade-off, doesn't convince me that much as positive
| point for cljs
|
| I want to like Clojure and Clojurescript, I really do, I would
| like to brag about writing lisp like the rest of you too, please
| convince me, claiming productivity because of "repl" or "less
| symbols" is not working, I need deeper reasoning
| christophilus wrote:
| Fellow South Carolinian and former Charlestonian. I nearly
| applied to Reify for the same reasons. Clojure is one of my
| favorite languages. However, I suspect I'd dislike it in a large
| product / team setting. Having moved from C# to Rails to
| JavaScript and now to TypeScript, I think I'd miss static types
| too much.
|
| I'd be very interested in a follow up blogpost after you've been
| at Reify for a year or two.
___________________________________________________________________
(page generated 2021-05-08 23:00 UTC)