Earlier quoted context omitted.
We should do a better job of clarifying: this isn't Mustache-the-language, it's just using {{ and }} as delimiters. The syntax is simpler than Mustache, and allows you to use any inline JavaScript expression, which will become fully reactive.
Er, can you explain further with an example? I'm confused about using both something like {{#if}} and pure JS
Svelte – A UI framework that compiles into tiny standalone JavaScript modules
161–170 of 236 posts
Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules
#162I love the ideas. The only other thing I like is CSS scoping, though. I think that CSS scoping is a problem in React, and current ideas on how to implement that in React are absolutely horrible IMHO. Two-way binding is a step back I think, I don't love the name (lots of people will judge a new technology by its name), and the thought of introducing yet another framework is a nightmare. I'd personally go with Polymer…
> Two-way binding is a step back I think You don't have to use it – its effects are restricted to the subtree where you've explicitly opted in to it. I've personally found it to be a huge timesaver, and would never go back to a world where I didn't have the option of using it. But you're in no way forced into it. > I wonder if these ideas can be somehow applied to React A lot of people have wondered that, including m…
Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules
#163TodoMVC is a useless benchmark for the problem that this claims to be addressing. The limits we're hitting with our applications now are with BIG applications, with many routes, many views, and lots of client side logic. We're talking hundreds of files (in some cases, thousands). Of course a framework, with it's fixed overhead, is going have a bigger payload for a tiny demo app like TodoMVC, than something like this…
Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules
#164Rich Harris created RactiveJs, which is an awesome UI framework on its own right.
He's an inventing and implementing machine.
Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules
#165TodoMVC is a useless benchmark for the problem that this claims to be addressing. The limits we're hitting with our applications now are with BIG applications, with many routes, many views, and lots of client side logic. We're talking hundreds of files (in some cases, thousands). Of course a framework, with it's fixed overhead, is going have a bigger payload for a tiny demo app like TodoMVC, than something like this…
I rather like https://github.com/staltz/flux-challenge myself, but I wonder if there are any other projects that are focused on more complex examples.
Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules
#166TodoMVC is a useless benchmark for the problem that this claims to be addressing. The limits we're hitting with our applications now are with BIG applications, with many routes, many views, and lots of client side logic. We're talking hundreds of files (in some cases, thousands). Of course a framework, with it's fixed overhead, is going have a bigger payload for a tiny demo app like TodoMVC, than something like this…
Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules
#167TodoMVC is a useless benchmark for the problem that this claims to be addressing. The limits we're hitting with our applications now are with BIG applications, with many routes, many views, and lots of client side logic. We're talking hundreds of files (in some cases, thousands). Of course a framework, with it's fixed overhead, is going have a bigger payload for a tiny demo app like TodoMVC, than something like this…
My conclusion was that it seemed like the file size would grow fairly quickly
[1](https://www.reddit.com/r/javascript/comments/5fcwhz/svelte_t...)
Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules
#168Why are there complex MVC frameworks that run in the browser in the first place? I might get some flack for this, and I'm prepared for it, but why can't we use JS as just a view manipulator? Leave data processing and business logic to the back-end, on the server, and that can take care of needing a front-end framework and large app.
And MVC in the browser doesn't need to be complex. It can be tiny as seen in this MVC lib for React: https://github.com/rajeev-k/mvc-router
Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules
#169So I've just wrapped up using React + Redux and just begun to uneasily accept JSX. It makes me uneasy because React wraps up existing HTML with Javascript. Because it violates using existing, established standards that have truly stood the test of time and wasn't broken at all. Svelte really hits that sweet spot.
1. Easy to write typechecking for the templates.
The compiled template is just function calls (or well, factory function calls) and the typechecker can work with that.
How many template language authors will write a typechecker for the template language?
2. Sane scope sharing - you can take advantage of all existing encapsulation and modularization tools of JavaScript. How do I expose functions to JSX? I simply bring them in scope e.g. by importing them or defining them. How do I expose functions to the template? Well... it depends. There is this $scope object (Angular)... Or there is this components property which informs the template whats in scope (Vue: https://vuejs.org/v2/guide/components.html#Local-Registratio...). I guess there are worse options, like having to register your helper functions or components into some sort of global registry and pray that there wont be a conflict.
3. First class components - want to write a list component that takes an item component as a parameter in props? Tough luck, its likely that the template language of your average framework doesn't support this. JSX gets this for free because its just JavaScript, and JavaScript is a proper language with first-class support for passing around functions and classes.
Its not that its impossible to do this... its just that most template languages aren't advanced enough, and somehow we think thats a good thing.
4. The sandboxing fallacy
From https://angularjs.blogspot.co.uk/2016/09/angular-16-expressi...
Angular template, and expressions, should be treated
similarly to code and user-provided input should not be
used to generate templates, or expressions
If you are distributing the compiler with your framework, there is this urge to expose it to the developers. If you expose it to the developers, there is the chance that it will end up compiling user input. And then you spend ungodly amount of time building a sandbox, unsuccessfully.-
svelte seems to be built by people with deep interest and expertise in compilers, so I'm somewhat hopeful that its template language will not suffer from the usual template language problems. On the other hand, the task is much harder (compiling to code without runtime), so that seems like a driving force in the opposite direction (less powerful template language). I guess we'll see how it goes.
IMHO the next step in frameworks isn't this (compilers are hammers, and everything else is nails). The next step is, after current frameworks fight things out, we take the common subset of the "infrastructure code" that the most popular ones use (DOM diffing? events that are the same across browsers to remove the need for synthetic events? PropTypes? Maybe someone at whatwg should start thinking about this list) and include it in the browser API, then let frameworks build on top of that and be 10 times smaller on average.