76 points · by tipiirai · 3y ago · 145 comments
- It re-renders on click
- It mutates pop/push/... to observe arrays
- Otherwise, you have to manually call `update()`
IMO, don't touch this. All of this has been tried before. It also looks like lists are unkeyed. If you receive another list from the server, you have to do the diffing yourself.
It's disappointing that a framework proclaiming to solve all issues of frontend dev, while evidently understanding none of them, will go uncriticised by HN.
The ceremony and huge verbose architecture astronaut frameworks has been tried before. But the people on this enterprisey very professional corporate busywork hype train are probably too inexperienced to rember the SOAPs and J2EEs and Enterprise Java Beans and dependency injection frameworks and Boosts to understand what drag they are to development and software quality.
It'll blow over again in a few years but it's quite sad that the same mistakes have to be repeated.
If you consider keyed lists and reactivity mechanisms to be "enterprisey very professional corporate busywork", then I don't know what to say to you.
Thank you for Nue and bringing much needed simplicity and elegance to frontend dev! I'll be sure to at least try out Nue for the next frontend project that could benefit from a framework.
In knockout (with typescript annotations), the equivalent would be:
let count = Knockout.Observable<number>(0);
And it's then much clearer when you want to access the value of the observable with count() or update it with count(1234) or count(x => x+1 ).( I may have hallucinated the ability to pass a function to the observable ).
Am I correctly reading that you just throw away and re-render the entire DOM?
Says the comment at the top of the thread criticizing the project.
Having just count=0 is stupid and you will learn it the same way as Svelte did. Comparing it like that when they explain all the issues in Svelte 5 is even more dishonest. Any variable can be state and/or be reactive and they arent marked? GL with that. You need to manually call update after fetching data, why?
I obviously disagree. This is not only compact, but also standards- based. It's an ES6 variable. I don't expect Nue to change here, like ever. Svelte internals are quite different.
Signals w/ getter/setter are incredibly nice for this.
It's absolutely not an ES6 variable. count=0 may be valid ES6 but in a NueJS setup it's not parsed by the JS interpreter: it's preprocessed. What actually gets served and parsed by the browser is an entirely different piece of code & that makes it inherently changeable in future releases.
Also, while count=0 is technically valid ES6, most of the larger examples on the page are not; this is a DSL like any other, with all the drawbacks that brings. Masquerading as ES6 syntax won't fix that.
On Nue.js case tho the count=0 is misleading as it is a class variable that can get a setter and getter but in Nue.js code it is a normal variable that can't have a getter/setter. So the code doesn't really do what it is supposedly doing.
If you want getters and setters, you'll use standard ES6
Let the bundler minify your JavaScript. Less characters !== simple.
Less characters in source code is obviously a better metric for simplicity than what there are on the minified code (Nue wins on both btw)
Especially now that self encapsulating modules are a thing and server side templating can fill in html's lack of import tags. Reusable components sound great in principle, but trying to replace one that's used in 30 different locations with small nuances in each spot leads to complete debugging hell, just like typical overzealous polymorphism.
Allegedly we're even getting optional typing soon, so TS will become obsolete as well.
I'll be surprised if tc39 allows it.
I love vanilla JS. Are you referring to web components?
1. Is wholly immaterial.
2. Is pure conjecture ("Dynamic typing is a good thing") that I happen to vehemently disagree with.
3. Also wholly immaterial.
In fact it's rare to see "material" reasons for using TypeScript. Mostly baseless claims how static typing is "obviously better".
But whatever...
The merits of ES6 are also present in typescript. Thus claim 1 is immaterial.
Claim two is rebuked by intellisense and very strongly argued against in a shared-code world.
Claim 3 is presumptive that TypeScript would be the only transpilation, despite nue itself being a transpiler. In addition to all the other bundling modern products use for treeshaking, minification, etc. This is an insignificant and thus immaterial point.
("justification" enough for you?)
Did you even read the FAQ?
2. Code completion can be done also without static typing. Also relying on code completion is a strong smell of a bad codebase. The "very strong arguments" rarely have any empirical basis.
3. Transpilers/compilers are bad and more transpilers are worse. I would prefer a pure browser framework though. A lot of projects would be and are fine without treeshaking, minification etc. And those are practically never needed for development where the compilation step causes most harm.
Less code is better and DRY is by far the most important principle in software engineering.
Sadly every second generation seems to have to learn the hard way that the mega enterprise architecture astronaut stuff is a huge waste of time and produces bad software.
Hence, I strongly encourage the author to compile to web components instead of a custom output to increase/achieve interop.
Would love to hear the details! Sample code would help a lot understanding the problem/solution. Thanks!
The HTML: <button @click=“count++”> {count} </button>
return (
<div>
<h2>You clicked {count} times!</h2>
<button onClick={() => setCount(count - 1)}>
Decrement
</button>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
)
Nue is the opposite side of the same coin.React is just JavaScript. React+JSX is JSX. This:
<button onClick={() => setCount(count + 1)}>{count}</button>
Is sugar for: React.createElement('button', { onClick: () => setCount(count + 1) }, count)
True, the JSX version is most popular, but it's trivial syntax sugar with no "magic." This is different then Angular, Vue, Svelte, etc templates return el("div", { children: [
el("h2", { children: [safe`You clicked ${count} times!`]) },
el("button", { onClick: () => setCount(count - 1), children: [safe`Decrement`] }),
el("button", { onClick: () => setCount(count + 1), children: [safe`Increment`] })
]});
The "it's just javascript" part comes from having no hidden getters, setters or proxies littered in code that may or may not behave as how we expect, and not littering the html with react-specific attributes for iteration, events, etcThan what? I couldn't imagine react being hard, maybe for novice developers that just start with programming in general.
> React and other frameworks spent so much effort abstracting the render loop
Considering how big is community adoption and teams that are working on big 3 frameworks, they're doing it not "just because" and not to make your app slower. There are reasons for this and this new library will learn them as well, just like svelte did with their reactive variables approach.
Most of the problems with data binding stem from the fact that there is not a prorammable understandable primitive for us to reason about it. Yet time and time again people try to hide such primitive behind some magic templates, hooks, runes and that kind of nonsense
This calls a referenced function:
@click="addFruit"
This executes an expression: @click="images.pop()"
What if I have a expression that returns a function that should be called?it also has some additional things here:https://github.com/nuejs/nuejs/blob/a5c844494852cdbe3282fdc5... so might not work the same way, didn't spend much time to check it just a glance.
onclick="addFruit"
is not the same as onclick="addFruit()"On the other hand, the unproductive critique in all the comments makes me think everyone forgot how hard it is try to make something better.
1. The problem is so basic, I get it done with useState/useReducer
2. I problem is complex, and needs something more explicit like RxJS, or I'll lose my mind.
The first example of the site would become:
<div>
<h2>You clicked {count} times!</h2>
<button id='decrement'>Decrement</button>
<button id='increment'>Increment</button>
<script>
count = 0
$('button#increment').on('click', () => { count++ })
$('button#decrement').on('click', () => { count-- })
</script>
</div> <div>
<h2>You clicked {count} times!</h2>
<button id='decrement'>Decrement</button>
<button id='increment'>Increment</button>
</div>
<script>
count = 0
increment.click(() => { count++ })
decrement.click(() => { count-- })
</script>Also debugging prod code will be a pain.
Cool tech demo but I would not use this for bigger projects
Nue will be absolutely fantastic for scaling large applications and teams!
Huh, I didn't know that. I still don't know that :)
everything inside "" should be string; otherwise it's confusing.
this is my personal preferences and it applies to any project
Nice to see people trying to push boundaries
Nue might not be a great option for building large scale web apps; it however could be a great way to add reactivity to simple websites. We don't need to have the full fledged webpack monstrosity for every little site.
Signed: a concerned Angular (the best framework there is in the whole world) developer