News for hackers. Stuff that matters.
Re:Comparing Svelte and React by jeswin on Wednesday March 24, 2021 @11:04PM (#26576096)
> There are also technical reasons why `svelte.each` would be problematic...

I am not suggesting that the svelte.each() call be moved into a library; I'm proposing that the callsite is trivial to identify in the AST. Svelte compiler could then do the same thing that it does now.

Re:Comparing Svelte and React by lhorie on Wednesday March 24, 2021 @11:22PM (#26576242)
Yes, parsing is trivial, but compiling (in the traditional sense, not the transpilation sense) is a different story. The other sibling comment nails it.

Grammar enforces where a grammar construct is allowed to exist. A custom grammar can be very restrictive (which it is, to great effect, in Svelte's case).

If we reuse JS grammar, then that comes with expectations of what should semantically work. For example something as simple as `$ = svelte.each` might evade a not-sufficiently-smart compiler. Or maybe `console.log(svelte.each(...))` might mis-compile because nobody ever thought to handle that case.

Having used systems with compile-time grammar constructs that look like runtime constructs, I can tell you that having your expectations about semantics being changed from under your feet can be a very frustrating experience.

Re:Comparing Svelte and React by jeswin on Wednesday March 24, 2021 @11:38PM (#26576342)
You're right about it being complex (my experience [1]), but such work is within scope for what's perhaps a central design decision for a library. Yes there'll be bugs, but it'll stabilize over time.

Just to be clear, I am NOT saying that Svelte needed to do this. But merely suggesting options for discussion and learning.

[1]: https://github.com/jeswin-unmaintained/isotropy-ast-analyzer... - Here's for instance, some code I wrote for analyzing a JS sort expression. You'd think it'd take just a few hours, until you get to it. Btw, it uses an AST analysis framework I wrote called chimpanzee - it has only one user though. :) https://github.com/jeswin/chimpanzee

Re:Comparing Svelte and React by hombre_fatal on Thursday March 25, 2021 @12:18AM (#26576555)
To deal with the issues they're talking about, you usually end up encumbering `svelte.each` with limitations such that it only looks like Javascript superficially.

In such a case, I think it's less confusing at the end of the day to just have a custom DSL for looping so that there's no clashing with its list of arbitrary limitations.

Re:Comparing Svelte and React by akdor1154 on Wednesday March 24, 2021 @11:41PM (#26576364)
I think you are persistently suggesting something to someone who knows more than you, without taking the proper time beforehand to understand the problem space.
Re:Comparing Svelte and React by jeswin on Wednesday March 24, 2021 @11:52PM (#26576428)
I do believe I understand the problem space well enough to comment on it - both AST analysis and frontend frameworks. My comment above also included a clarification that I was not suggesting that this be turned into a runtime call. Just presenting an entirely subjective viewpoint (of avoiding new language syntax), but one that many people share.