News for hackers. Stuff that matters.
Re:VanJS: A 0.9KB JavaScript UI framework by 3dGrabber on Wednesday December 20, 2023 @09:28AM (#38709028)
Why would you insist to write the function name both before AND after the call?

<DoStuff> args </DoStuff>

vs

DoStuff(args)

Re:VanJS: A 0.9KB JavaScript UI framework by iamsaitam on Wednesday December 20, 2023 @10:36AM (#38709803)
Is this the main argument? I think the simplest answer is boundaries. Taking into account how much nesting is involved in writing HTML, it's a clear benefit having a named boundary vs a closing parenthesis.
Re:VanJS: A 0.9KB JavaScript UI framework by 3dGrabber on Wednesday December 20, 2023 @10:54AM (#38710023)
> Taking into account how much nesting is involved in writing HTML

which is another one of its flaws.

Re:VanJS: A 0.9KB JavaScript UI framework by iamsaitam on Wednesday December 20, 2023 @02:46PM (#38712756)
What would the alternative be? How can you design a UI without nesting things?
Re:VanJS: A 0.9KB JavaScript UI framework by xpl on Wednesday December 20, 2023 @04:05PM (#38713631)
Too much nesting usually signals that you should decompose it to smaller components.

Same as with regular code and functions — overly deep nesting screams bad code.

Honestly, JSX is just a verbose way of calling functions / constructing objects, which is probably OK if it was a language of its own (XML/HTML) — and even then, JSON/YAML won over XML — but makes little sense being embedded in a language which had functions & object literals from the get-go (JS)!

The only reason JSX exists is because it was a cool marketing feature to convert existing PHP/HTML developers to React. And React succeeded mostly because of that. Not because JSX is cool technology-wise (it isn't). But because it hit the right spot in the right time.

Re:VanJS: A 0.9KB JavaScript UI framework by flying-pig on Wednesday December 20, 2023 @04:59PM (#38714210)
Well said! You got the point.
Re:VanJS: A 0.9KB JavaScript UI framework by lobsterthief on Wednesday December 20, 2023 @04:34PM (#38713937)
Not to me, it isn’t. It aligns with how the box model itself works.
Re:VanJS: A 0.9KB JavaScript UI framework by pastacacioepepe on Wednesday December 20, 2023 @09:32AM (#38709077)
More like:

<DoStuff args={...} />

Re:VanJS: A 0.9KB JavaScript UI framework by 3dGrabber on Wednesday December 20, 2023 @09:49AM (#38709243)
Please no

The {...} syntax is a non-standard extension to XML/HTML I think MS came first up with back in the day for XAML (WPF).

It's a hack to "fix" a shortcoming of the base language.

It does not compose, i.e. :

<DoStuff args={<DoMoreStuff args={...} />} />

does not work.

Re:VanJS: A 0.9KB JavaScript UI framework by pastacacioepepe on Wednesday December 20, 2023 @10:12AM (#38709508)
That would be

<DoStuff args={...}><DoMoreStuff args={...} /></DoStuff>

Still more readable than brackets hell like:

DoStuff(DoMoreStuff(DoEvenMoreStuff()))

Re:VanJS: A 0.9KB JavaScript UI framework by 3dGrabber on Wednesday December 20, 2023 @10:20AM (#38709605)
^^^ Apples to oranges:

    <DoStuff args={...}><DoMoreStuff args={...}> <DoEvenMoreStuff args={...}/> </DoMoreStuff> </DoStuff>
vs

    DoStuff(DoMoreStuff(DoEvenMoreStuff()))
Both of them you would split into indented lines when they become too long. And 1 becomes too long much faster.

Also with 2 you can do

    const todo = DoMoreStuff(DoEvenMoreStuff());  
    DoStuff(todo);
where as with 1 you cannot.
Re:VanJS: A 0.9KB JavaScript UI framework by mitt_romney_12 on Wednesday December 20, 2023 @12:53PM (#38711467)
With JSX you can do

  const todo = <DoMoreStuff args={...}><DoEvenMoreStuff args={...}/></DoMoreStuff>;
  <DoStuff args={...}>{todo}</DoStuff>