DEV Community

loading...

Discussion on: Dev predictions for 2020

Collapse
khrome83 profile image
Zane Milakovic • Edited

There are a few things I disagree with.

  1. Svelte is a compiler. It’s not react or a JS library. What it compiles too is valid JavaScript. It may not be JS that you would of written, but it is valid. I think saying “slightly modified version of JS” is a lack of understanding. The browser can only run JS. Not a modified version....

  2. I don’t think it has to replace React for it to be successful. If you want to put this in perspective, more sites still use jQuery than React or any other SPA framework today...

  3. Your argument for JSX is not really valid. React parses JSX with JavaScript, as opposed to compiling it. Svelte is a compiler, but everything React does has to be done at run time. This is one of the arguments for Vue over React, in the sense that Vue has a much more practice reality of what it’s doing at run time, because there are less made up conventions.

Collapse
benbot profile image
Benjamin Botwin • Edited
  1. As you said, svelte is a compiler. A compiler for the svelte language. It compiles svelte code into vanilla js, but what you give the compiler is NOT javascript it's svelte. A svelte file contains markup and some slightly modified javascript within a script tag. Again, I say modified because, as the creator of svelte said in one of his talks, they co-opted the label syntax so we can get that amazing $: syntax. Since much of the established JS tooling will require a bit of extra glue to understand how to translate a svelte file into javascript it's harder to convince those very comfortable with JS and it's tooling that svelte is worth the extra configuration headache.

  2. You're totally right on this.

  3. React and JSX have little to do with each other OTHER than the React community uses JSX. JSX is not React only. React doesn't require, convert, or even understand JSX. Apps that use JSX and React rely on transformers to convert JSX into regular React.createElement calls at build time, but there are other JSX transformers for different frameworks and tools. That process is very different than what goes on with svelte. (not sure for Vue. I never used it) With svelte the entire svelte file gets converted into vanilla assets after going through the svelte compiler. There's rarely a 1 to 1 mapping of svelte code to javascript, but that 1 to 1 mapping does exist with JSX, which is why it fits more nicely into the JS tooling landscape and thus much easier to sell people on.

Thread Thread
khrome83 profile image
Zane Milakovic

We can keep debating if you want.

  1. You said it was modified JS and it sounded like you were referring to the output. Thank you for clarifying.

  2. I never claimed react had to use JSX. Calm down. We are all friends here.

Yeah the mapping is a issue. I don’t disagree with that statement. Though I have rarely found a real need for it to map back.

Thread Thread
benbot profile image
Benjamin Botwin • Edited

There’s no heat here 😅

Sorry it came off like that. I think I have a tendency to sound a bit combative when I respond to other comments.

As far as JSX goes, you said that react parses jsx, but it doesn’t. All of that work happens at build time by other tools. That’s all I was trying to get at.

And the 1:1 mapping is not usually for the day to day work of application developers, but may be important for tooling developers and those trying to understand the inner workings of their tools.