Earlier quoted context omitted.
Your counter points don’t check out too much though? > jQuery Just not possible to compose, which makes full applications difficult. No answers for state management or such either, completely a different scope than frameworks > Google more clout than FB In some domains sure, but I’ve never understood how people don’t think FB are masters of UI. There is probably no org with more UI clout than FB, they built their own…
Oddly, despite the immense resources that Facebook has available, Facebook in a browser is slow and glitchy, especially after the most recent redesign.
Comparing Svelte and React
301–310 of 338 posts
Re: Comparing Svelte and React
#302Earlier quoted context omitted.
What do you mean by "a certain event-sourcing something idea?" I really do mean "pure." That doesn't mean that Redux doesn't provide other facilities on top, such as React interop, error-handling, logging, etc. But if you don't need any of that and you use the core of Redux, it really is just a state machine representation. Let's write out the classic finite state machine representation of a locked/unlocked item. Sta…
If you think that's the simplest you could get, more power to you. I personally think your example is convoluted for such a simple example, but that's just me. However, I should point out something that is not actually trivial about your code, by proposing a refactor: your FSM adequately models a car lock button interface, but not the lock itself. If we are modeling the lock, you have two invalid transitions...becaus…
It is indeed all a matter of taste in the end, but I mean it's the exact transcription of a textbook FSM. I don't think your example would get that much simpler with a stable identifier, which brings me to:
> I don't have to create a monolithic state transition table logic
It doesn't have to be monolithic. I just created a monolithic function because it's easier for this small example. It could just as easily dispatch on state (which is what you're doing here), or on transition (which is impossible with your hierarchy), or mix and match them. I can write those examples if you're curious.
Your class example is a good example of a state machine trace (e.g. one that you might often use to create an ephemeral config object), but it's not an example of an actual persistent state machine. As soon as you use a stable identifier the type safety goes out the window.
let stateMachine = new On();
// Wait a bit for the user to do something
stateMachine = statemachine.turnOff();
// Wait again for the user to do something
stateMachine = stateMachine.turnOn();
Depending on how you annotate the initial let, one of those two lines will cause TS to complain (or you have to do a manual cast somewhere which circumvents the type safety).Indeed if you just care about a state machine trace the same type safety holds in the explicit state transition table case if you just use TS's literal types in the reducer's type annotations. You just explicitly call the reducers you need however many times and then persist the state machine at the very end.
That is your type safety doesn't come from the representation as an object, but rather that there is no stable state machine between invocations, but only an ephemeral trace of one whose intermediate states are immediately destroyed. Traces are valuable! But you could generate the exact same trace with an explicit state transition function and you would get the exact same type safety that way. I can write it out for you if you're curious.
> I will never have to worry about the combinatorial explosion that can happen in a global transition table.
Again you don't have to worry about a combinatorial explosion in a global transition table either if you dispatch on actions or states.
The fundamental difference between what you've outlined here and the explicit state transition table is that in your approach states are first-class and transitions are not (but rather methods attached to states), whereas the explicit state transition function treats both of them as first-class entities.
For places where you really only need an ephemeral state machine trace, rather than a state machine that persists between calls, you don't need first-class transitions because the transitions are all ephemeral and cannot be dynamically called at runtime.
Where you do have users able to dynamically call transitions at runtime, you end up needing to represent those transitions somehow, and you end with something approaching Redux (indeed I think an interesting exercise would be to implement On and Off where the user either presses "a" or "b" at the keyboard to turn on and off with your classes. I suspect you end up with just the Redux approach all over again).
EDIT: I want to emphasize I don't think Redux is free of faults. There are many things I really dislike about it and the React ecosystem it integrates into. But I don't think any of that can be chalked up to a poor representation of a state machine.
Re: Comparing Svelte and React
#303Earlier quoted context omitted.
What do you mean by "a certain event-sourcing something idea?" I really do mean "pure." That doesn't mean that Redux doesn't provide other facilities on top, such as React interop, error-handling, logging, etc. But if you don't need any of that and you use the core of Redux, it really is just a state machine representation. Let's write out the classic finite state machine representation of a locked/unlocked item. Sta…
If you think that's the simplest you could get, more power to you. I personally think your example is convoluted for such a simple example, but that's just me. However, I should point out something that is not actually trivial about your code, by proposing a refactor: your FSM adequately models a car lock button interface, but not the lock itself. If we are modeling the lock, you have two invalid transitions...becaus…
Re: Comparing Svelte and React
#304I stumbled upon this article a couple of days ago when it was featured on the last issue of Javascript Weekly (19.3.21) and thoroughly enjoyed reading it. The points made in this piece are soundly argued while never hiding the fact that they're ultimately based on one individuals perspective.
Couple of days later and in line with my usual HN-reading MO (and not remembering the title of said article, it is quite generic) I'm looking at the headline of this post and my mind immediately goes «Yeah, I definitely want to read those comments, if only for shits and giggles». And boy was I not disappointed:
It starts off with «I love X because I hate Y», continues with Y implicitly being understood as a function of «Y + 3rd party Z» (and what's not to hate about bloody Z as if that's not a self-inflicted liability) and ends with library authors digressing into low-level technicalities, which, ironically, both X and Y are trying to simplify in the first place, so that ordinary product-shipping folks like the author of the original article and myself can focus on the task at hand: Getting shit done.
It really feels like everyone on here was just desperately waiting for a hook to talk about either their personal preference or their specific set of problem domains instead of adding value to an admittedly mundane but very concise piece of writing.
It probably speaks volumes about my naivety that, after all these years of digesting HN on a daily basis, I still somehow assume that both the subject matter and the tone of a given piece might actually correlate with the reactions to it. Then again, as I said, I came here for shits and giggles, so, if I'm perfectly honest, I kind of knew all along.
Re: Comparing Svelte and React
#305Earlier quoted context omitted.
We are actually going the other direction. Currently I am experimenting with making a Blazor/Liveview (HTML over wire) runtime that can support many programming languages. And a GUI builder.
This sounds fascinating. Anywhere I can read about it?
For the HTML-over-wire part we are experimenting with a protobufs-based protocol so the backend runtime can support as many languages as possible. The most challenging part is that client-server UIs have fundamentally different assumptions about state, concurrency, and session handling compared to traditional desktop/mobile GUIs that operate on callbacks. Most of the design patterns used for your typical WinForms/Cocoa UI fail horribly in web scenarios (unless the entire app is running client side in WebAssembly) because state must be held in a DB, global variables are completely not allowed and multiple users may simultaneously access a service so any form of long-running loops or blocking code is very problematic. Serverless could help here but you will need long-running serverless containers. The current pricing models of AWS Fargate and Google Cloud Run are not compatible with this.
This is additionally complicated by the fact that many languages have async/concurrency "bolted-on". It is hard to integrate a WebSockets server into the language if there is already another event loop to deal with. This is especially problematic for feature-fragmented languages like Python where async is a relatively new concept. (See https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...) Go is basically the gold standard here. Overall, we are still working on how to build the language-agnsotic backend SDKs without too much duplicate code. If you see similar systems like Streamlit and Plotly Dash, they avoid the problem entirely by making proxying the default way of embedding in third party applications. The integration is not as tight as traditional UI frameworks but avoids many of the problems with state management.
For deployment, the Blazor/LiveView/HTML-over-wire format would also require CDNs that are as close to the end user as possible for lowest UI latency. Think Zeit/Vercel or Fly.io.
There's a mailing list link below where you can be notified for when we launch:
Re: Comparing Svelte and React
#306Earlier quoted context omitted.
> It's a set of AST nodes. Ok, but you could make the same point about plain JS as in Svelte. I haven't looked into it too much, but from the readme Solid.js looks more like a compiler than a library, so whatever it outputs when it sees JSX doesn't have much to do with what JSX is usually used for, imo. I've only ever seen it used as syntactic sugar for function calls, be it `React.createElement` or `h` or `jsx`. > A…
> Personally I find it much more likely that I'll have to bend over backwards when I'm dealing with a DSL rather than just plain code I think this is cherrypicking at generalities. It's just as easy to run into a wall with "regular code" because some API doesn't provide what you need. Conversely, DSLs often have escape hatches (e.g. https://www.smarty.net/docsv2/en/language.function.php.tpl ) DSLs are useful sometime…
Re: Comparing Svelte and React
#307Earlier quoted context omitted.
> Redux is the purest expression of a state machine possible Are you sure "pure" is the right word? Last I checked redux very proudly incorporates a certain event-sourcing something idea in it. It's definitely not a "just state machine" library. More like in KFC when you order something, they always make sure that you get their sugar water as well.
What do you mean by "a certain event-sourcing something idea?" I really do mean "pure." That doesn't mean that Redux doesn't provide other facilities on top, such as React interop, error-handling, logging, etc. But if you don't need any of that and you use the core of Redux, it really is just a state machine representation. Let's write out the classic finite state machine representation of a locked/unlocked item. Sta…
The other commenter gave example of implementation as type safe immutable builder. You can even simplify their implementation further by using plain functions instead of classes.
Re: Comparing Svelte and React
#308I'm a big fan of Svelte. I've raved about their documentation before, but it bears repeating: this should be the gold standard. You can read it all in a day. There are examples to follow right next to the documentation. Svelte is both succinct and powerful. I find this in contrast to React which is often baffling and incoherent. I say this as someone that has used React professionally for 6 years. They've changed the…
This comment makes me want to seriously give Svelte a try. I've browsed the docs and it looks really cool, I've always just held back because I feel like I am juggling enough JavaScript libraries in my head already and React has been great.
Re: Comparing Svelte and React
#309Earlier quoted context omitted.
If you think that's the simplest you could get, more power to you. I personally think your example is convoluted for such a simple example, but that's just me. However, I should point out something that is not actually trivial about your code, by proposing a refactor: your FSM adequately models a car lock button interface, but not the lock itself. If we are modeling the lock, you have two invalid transitions...becaus…
> I personally think your example is convoluted for such a simple example, but that's just me. It is indeed all a matter of taste in the end, but I mean it's the exact transcription of a textbook FSM. I don't think your example would get that much simpler with a stable identifier, which brings me to: > I don't have to create a monolithic state transition table logic It doesn't have to be monolithic. I just created a…
whose type signature has start and end state
> first-class entities
a string
Re: Comparing Svelte and React
#310Earlier quoted context omitted.
Oddly, despite the immense resources that Facebook has available, Facebook in a browser is slow and glitchy, especially after the most recent redesign.
writing react apps in a proper way is hard, very hard. plenty of companies out there big and small can't do it. once you've a professional react dev, you easily recognize the react apps due to the subtle bugs. makes me miss my old team, where our big react app was actually performant.