News for hackers. Stuff that matters.
Re:Nue: A React/Vue/Vite/Astro Alternative by gcau on Friday September 15, 2023 @12:55AM (#37518614)
Here is what some of it looks like.

``` <div @name="media-object" class="{ type }"> <img src="{ img }"> <aside> <h3>{ title }</h3> <p :if="desc">{ desc }</h3> <slot/> </aside> </div>

<div class="art-gallery"> <media-object :for="item in items" :bind="item"/> </div ```

I really don't like the opinionated, magical/weird syntax (like vue's :@v-for-OnClick="fn()"), I prefer how close and true to vanilla html/js react is, rather than stuff like this.

Re:Nue: A React/Vue/Vite/Astro Alternative by tipiirai on Friday September 15, 2023 @01:09AM (#37518712)
Yes. Nue is indeed HTML-based and takes inspiration from Vue. It is designed for UX developers who prefer to use HTML/CSS and minimal JavaScript to communicate with the business model layer, that the JS developers are building. That is: separation of concerns.

I can understand that this syntax is not a preference for JavaScript/TypeScript developers who opt to JSX and want to write everything (logic, layout, styling) in JavaScript.

Re:Nue: A React/Vue/Vite/Astro Alternative by kitd on Friday September 15, 2023 @04:07AM (#37519977)

    <p :if="desc">{ desc }</h3>
That </h3> should be a </p>, I think.
Re:Nue: A React/Vue/Vite/Astro Alternative by tipiirai on Friday September 15, 2023 @09:56PM (#37531254)
Thanks. Fixed
Re:Nue: A React/Vue/Vite/Astro Alternative by orangepanda on Friday September 15, 2023 @05:14AM (#37520372)
My problem with these :ifs and v-ifs and {#ifs} is I cant place a breakpoint and step through _my_ code with a debugger.

Using print statements or deleting code in a binary-search manner takes an order of magnitude more time and imo is just an excuse to pad billable hours.

Re:Nue: A React/Vue/Vite/Astro Alternative by niutech on Friday September 15, 2023 @05:35AM (#37520517)
React is far from vanilla HTML. It uses JSX with attributes e.g. `className` or `htmlFor` instead of HTML's `class` or `for`. And JSX requires compiling to HTML rather than being HTML from the beginning.
Re:Nue: A React/Vue/Vite/Astro Alternative by Kiro on Friday September 15, 2023 @06:08AM (#37520780)
Re:Nue: A React/Vue/Vite/Astro Alternative by arcanemachiner on Friday September 15, 2023 @07:42AM (#37521516)
Woah.
Re:Nue: A React/Vue/Vite/Astro Alternative by niutech on Friday September 15, 2023 @09:58AM (#37523048)
Yes, but it's JS, it isn't vanilla HTML.
Re:Nue: A React/Vue/Vite/Astro Alternative by MrJohz on Friday September 15, 2023 @06:15AM (#37520822)
It's almost identical to vanilla DOM, though, which does use className and htmlFor.

I'm not sure that the compilation aspect is relevant - pretty much all modern frameworks using a template language have a compilation step. ngFor doesn't exist in the browser after all! ;)

Re:Nue: A React/Vue/Vite/Astro Alternative by martinsnow on Friday September 15, 2023 @06:37AM (#37521008)
You're confusing the XHTML/HTML and JavaScript API naming schemes
Re:Nue: A React/Vue/Vite/Astro Alternative by sixbrx on Saturday September 16, 2023 @04:52PM (#37538581)
I'd say it's JSX doing that because those attributes are clearly on the declarative/markup side of the divide, not the procedural/imperative dom manipulation side.
Re:Nue: A React/Vue/Vite/Astro Alternative by shrimpx on Friday September 15, 2023 @05:38AM (#37520539)
To push that point further, I’d say JSX is opinionated, adding magical/weird templatey syntax to Javascript.
Re:Nue: A React/Vue/Vite/Astro Alternative by vekker on Friday September 15, 2023 @06:21AM (#37520881)
React has a lot of opinionated, "magical" boilerplate. useThis, useThat, ... In my experience, Svelte did a much better job and is closer to vanilla html/js, but for some reason it seems to fail to gain significant traction.
Re:Nue: A React/Vue/Vite/Astro Alternative by iainmerrick on Friday September 15, 2023 @06:44AM (#37521052)
I agree -- I don't love Svelte but it feels much closer to just writing plain HTML+JS+CSS than any other fancy JS framework I've tried.

The goals of this project and Svelte seem very similar, so I'd be interested to see a more in-depth comparison.

Re:Nue: A React/Vue/Vite/Astro Alternative by gcau on Friday September 15, 2023 @08:41AM (#37522074)
Hooks are just normal javascript functions though, they're not syntax.
Re:Nue: A React/Vue/Vite/Astro Alternative by iainmerrick on Friday September 15, 2023 @11:39AM (#37524705)
No special syntax but they do have special semantics, as per the "rules of hooks".
Re:Nue: A React/Vue/Vite/Astro Alternative by root_axis on Friday September 15, 2023 @10:59AM (#37524072)
"use" is just a convention for hook function names, react doesn't require or enforce it.
Re:Nue: A React/Vue/Vite/Astro Alternative by iainmerrick on Friday September 15, 2023 @11:36AM (#37524651)
It's "just" a convention, but a strongly encouraged one. The React docs say:

Its name should always start with `use` so that you can tell at a glance that the rules of Hooks apply to it.

And it is required and enforced if you use the ESLint react-hooks plugin (which I'm guessing most large projects do).

Re:Nue: A React/Vue/Vite/Astro Alternative by mike31fr on Friday September 15, 2023 @04:28PM (#37528716)
Re:Nue: A React/Vue/Vite/Astro Alternative by kehrin on Saturday September 16, 2023 @08:26PM (#37540260)
> In my experience, Svelte did a much better job and is closer to vanilla html/js

I just looked at some Svelte examples and it's a mix of magic keywords (on, bind) with magic symbols (: | @) and new, completely unrelated syntax to both JS and HTML (#each, #if, :else). I guess it looks way more idiomatic if you have an IDE that highlights and lints it correctly. React with its few rules of hooks seems way closer to vanilla JS.