849 karma · joined September 2, 2015
The biggest value-add of using React on the server is being able to share our design library and business logic with our front- and back-end. We can develop the structure, style and behavior of our website as React components and deploy them server side or client-side. In general, our team has found that the component model is far more composable than templates like pug, PHP, etc.
I'm actually in the process of wiping it to give to a friend and feeling a bit of sadness. I use a 2017 MBP now - the screen is what finally got me - but you're right, todays hardware just doesn't compare to how it felt back then.
> First, it's possible that different elements of an array or different properties of an object has different shapes
I can't imagine how this would introduce any sort of difficulties w.r.t. lenses that aren't already present with normal getting and setting of nested structures (aka probably not much).
> Second, it's just difficult to get things right without a compiler's help
This has nothing to do with lenses and everything to do with you preferring the feel of static types. You go on to talk about a bunch of issues with complex constructs that really only exist in static typing.
Sometimes you write a wrong thing and get a runtime error. This happens in all dynamically typed languages (and many statically typed as well).
> Furthermore, without types... this rather elegant unification of getter and setter seems to be lost.
Like ya do. I don't see how this has any impact at all on developing applications.
(defn my-component []
(let [user-data (data/pull! :user "{ user { firstName } }")]
(fn []
(if (:loading @user-data)
[:div "Loading..."]
[:div "Hello, "
(get-in @user-data [:data :user firstName]) "!"])))
I'm a bit surprised this pattern isn't more popular; having side-effectful functions return ratoms in a form-2 component seems almost as flexible as Hooks. It seems that most CLJS people try and keep their views more pure, which I think is honestly to their overall detriment. You miss out on the encapsulation and composition that React is espousing.That being said, I intend to replace reagent soon with just raw React + a few helpers :P
Maybe 80 isn't the right one, but letting code stretch out to ad-infinitum (either with awkward line breaks or having to scroll) is a big ergonomic loss for me personally.
I literally haven't sat in an office chair for longer than 20 mins for the last 12 weeks and my back is so much for the better.
1. How well does it compose?
2. How simple are the tools?
Both re-frame and Cycle have their issues with composition.
Cycle has inherent complexity and difficulty with composing dynamic child-states and circular dependencies as outlined above. It sounds like there have been tools developed since I last used Cycle.js to ameliorate the difficulties in handling these cases.
Re-frame has complexity with composition because it uses an absolute global namespace, which makes multi-tenant scenarios very awkward and potentially insecure. This problem mainly exists in use cases like having a developer environment with multiple states of the application on the same page, consuming components developed by external teams, and server-side rendering. At the moment these are either worked around or avoided completely.
The simplicity of the tools is something that I am very passionate about. As someone infected by the Clojure virus, I am pretty excited about the ability to use regular functions that return data to build my applications. It has been several years since I went down the rabbit hole of "everything as a stream/observable." At the time I found it to be very intellectually exciting, but also very confusing. Functions and data are much more familiar tools to most developers and the ergonomics of designing, developing, and debugging functions and data are much more understood.
So in closing, I would choose re-frame over Cycle for a project that I was working with a team of developers on. For extremely large applications that needed to be developed cross-team and/or have a strong use-case for server-side rendering... I would probably pick something new- similar to re-frame, but which fixes it's issues with composition. I maaayyyyy be working on something like that. ;)
Events in re-frame (and reagent and React.js in general) are "push"-based. You must be explicit in your UI tree which events we care about and when they are emitted.
I actually wrote a library a long time ago[0] to invert this in React and expose a more pull-based event API, but in practice it wasn't very ergonomic.
Cycle.js and re-frame, in some ways, are on opposite sides of various spectrums.
Cycle.js favors local reasoning and composability through modeling your application as a pure function that takes in streams (sources) and returns streams (sinks). All of your event handling, external data, DOM changes, etc. are explicitly tied together in your "main" function.
Cycle.js requires you to reason about, write and read your application code in terms of reactive "streams" of values. This means that a big part of your app's development is expressing it in terms of operations on reactive streams and using the language of whichever stream library you choose.
Re-frame favors separating your UI code (which you can compose) from state and other side effects (which are global) through it's use of named reactive subscriptions and dispatching of named events.
You register your app's events as functions that take in "coeffects" (e.g. the current state of your app) and returns "effects" as data, e.g. the new state of your application. You can also return other "effects" like the parameters for doing an HTTP request and what event to dispatch when it completes/fails. Your UI code is then written to dispatch the names of these events (e.g. on click) that will trigger the registered function and cause re-frame to run the returned effects.
You register your app's subscriptions as functions that take in the application state and return a materialized view of it. Your UI code is then written as functions that subscribe to the names of these subscriptions, take the materialized view of your app state and return the UI tree that should be shown.
The majority of your re-frame app code is written as regular functions which return data. This means that a big part of your app's development is expressing it in the terms of functions that return data so that the UI framework (React/reagent) can render it and re-frame can do the appropriate side effects.
Cycle.js is a very "pure" framework, in that it's approach is to start from first principles - pure functions, application-as-a-stream - and to layer on tools and abstractions to make it effective. The work that the core of Cycle.js actually does for you is quite minimal, and the skeleton and muscles of your application is not at all hidden from you.
Re-frame is much less "pure"; it has a guiding concept of separating your UI code from the side effects it produces. For instance, many UI functions are not pure because they subscribe to the global app state. And in fact you don't have to use re-frame for everything at all; you can opt to use local component state and direct mutation instead of that fits your use case better.
Btw, really great write up - I think you did a great job explaining the process of solving problems in Clojure.
https://github.com/Lokeh/lilac.town/blob/master/src/lilactow...
Source: am a millennial and experienced the huge pressure to go to college, especially an expensive one.
In general, I am much more confident in the React team supporting these concerns - simply because there's WAYYY more time, money and mindshare involved - than the CLJS ecosystem shouldering the burden.
This seems similar-ish, but with a self-hosted option - which I prefer after my experience when 900dpi shuttered ;)
Seems useful!
Of course, I'm a brown belt in Brazilian Jiu Jitsu, so I'm slightly biased.
It certainly can be a positive thing to remove people's megaphones who are not acting in good faith, who are spreading violence and vitriol. There's almost no room for "understanding and exchange of ideas" on twitter, and definitely not what Alex Jones et. al. is seeking from the platform.
I also think that one of the biggest issues facing "understanding and exchange of ideas" in general is the idea that no one can be earnest or genuine in their outrage. Your original post used the term "virtue signaling," but even saying that the person is "throwing a tantrum" is purposefully trying to diminish the idea that the OP might be rationally upset about the events that have unfolded.