Live data from Hacker News

RawJS is a better way to call document.createElement()

squaresapp.org

131–135 of 135 posts

Re: RawJS is a better way to call document.createElement()

#131

Earlier quoted context omitted.

exactly, unless you like exchanging time for food and shelter via rendering anything in the browser

It just strayed so far. Everything has gained so much complexity.

The problem with React is nobody actually learns how to code in React properly and formally. They just wing it by copying what else they see around them.

But the point of incremental code is that it completely changes how you think about data flow and changes. Which they never do.

TLDR: topologically sort your code by change frequency of the data.

Re: RawJS is a better way to call document.createElement()

#132
post #97

I guess they forked Vapor.js? :) https://github.com/madrobby/vapor.js

Library author here. I didn't fork anything. And your link just pr0n'd me in a coffee shop. Thank you.

Sorry about that, I don't verify links on N+1 level.

Re: RawJS is a better way to call document.createElement()

#133
post #85

You know what's an even easier way to call "document.createElement"? $.append Sure, there's a reason why people moved away from JQuery, but I'm not convinced that a half dozen lines of boilerplate per element is a good solution either. The example almost reads like a parody, here's a half dozen lines to write what you could write in one line of raw html: But I guess I just don't get it, I don't understand the use cas…

RawJS library author here. $.append appends, in the name ".append". Though The point of RawJS is to help with element constructions. jQuery was a god-send back in the day for manipulation and querying (before we had document.querySelector()) but constructions of hierarchies were never really its thing. There are other libraries that work like RawJS to make complex DOM constructions with function calls. I just don't t…

I think the main reason why small things like rawJS are appealing is that a lot of devs got directly or indirectly forced into learning a framework and then got themselves burned one way or another while using it. We then developed a shared fantasy: "What if the native browser API was good enough so that we don't have to learn any fluff (frameworks, build tools, libs) to be productive? After all, other languages don't have this framework bloat problem. Let's just use this minimal lib instead."

But this is just a fantasy. Element constructions are not the problem. Updating the state and DOM is the issue. We don't do stuff like rawJS or jQuery for bigger apps because they are too low-level and they don't scale well. What we need is to operate at a higher level, not get rid of almost all of the abstractions entirely like rawJS. Have a look at https://github.com/squaresapp/rawjs-sample/blob/35939695dba6.... This is the kind of code that is meaningless to my app. It's just DOM housekeeping. The example app is small enough so that there isn't much of it: this is the only interactive bit of your demo app. But the bigger the app, the more housekeeping like this you need. Try to showcase a bigger demo app with a lot of interaction.

Now, there are specific cases where I don't want/need a framework. If I want better performance, the framework can become a hindrance (this is generally the case - when you want performance, you need to look at the lower levels). If the app is tiny, frameworks are just fluff. But for the overwhelming majority of cases (apps that are not tiny and don't need amazing performance):

As a web dev, I want to assign some object to some reference and then my app to be updated based on my state. When some event happens, I want to update some of the app state. That's it! I don't want to mix my business logic with DOM fluff. I don't need another piece of code to worry about. I want some dependency to do that for me. Is it going to happen via virtual DOM or change detection or something else? Who knows.

Re: RawJS is a better way to call document.createElement()

#134

Earlier quoted context omitted.

It just strayed so far. Everything has gained so much complexity.

The problem with React is nobody actually learns how to code in React properly and formally. They just wing it by copying what else they see around them. But the point of incremental code is that it completely changes how you think about data flow and changes. Which they never do. TLDR: topologically sort your code by change frequency of the data.

That reminds me of volatility based composition presented in Righting Software[0].

I'm curious if you have anything to reference for what you are considering "proper and formal" react? Not sure if you're pointing toward the flux architecture with redux or something else...

[0] https://rightingsoftware.org/

Re: RawJS is a better way to call document.createElement()

#135

Earlier quoted context omitted.

It just strayed so far. Everything has gained so much complexity.

The problem with React is nobody actually learns how to code in React properly and formally. They just wing it by copying what else they see around them. But the point of incremental code is that it completely changes how you think about data flow and changes. Which they never do. TLDR: topologically sort your code by change frequency of the data.

honestly, I just never found a need to do react an even more counterintuitive way, than the counterintuitive way that I'm fine with

there were never performance problems just because we used a ton of useEffects

there were never bounced users because hooks were not the most optimal

we did static landing pages without dynamic data that passed all the pagerank stuff decently, and then people came into the app and were more patient to see their unique account data

rinse and repeat

Post reply on HN