Live data from Hacker News

Svelte – A UI framework that compiles into tiny standalone JavaScript modules

svelte.technology

71–80 of 236 posts

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#71

Love it. I think the most discussion-worthy quote I found in the docs is this: > It's currently fashionable to avoid two-way binding on the grounds that it creates all sorts of hard-to-debug problems and slows your application down, and that a one-way top-down data flow is 'easier to reason about'. This is in fact high grade nonsense. It's true that two-way binding done badly has all sorts of issues, and that very la…

My understanding is that there are two issues with two-way binding that are structural, and will be difficult to fix no matter how you approach it.

First is that if you look at the system as a graph of updates, automatically closing all cycles between variable update and widget means that any additional two-way binding links you add become a cycle, which makes it difficult to implement, model, and debug. If the framework only initially links the variable to the widget or the widget to the variable, the graph is a lot less populated to start with and creating a cycle is much harder.

Second is that the developer ends up wanting more and more complicated transforms over time, and having to implement both directions of them at once is much more difficult than having to implement only one direction, because not only are you writing two transforms instead of one, you also really ought to make sure the transforms are able to be roundtripped without data loss, and also that any invalid states on either side of the transform are handled sanely in some manner. Very few developers think this way; it's one of those places in programming where you really need to approach it with a mathematical state of mind, but it's generally being written by the "I don't see how programming is connected to math" types. (Which is something a two-way binding advocate needs to keep in mind when writing their library; you're not going to get your users to deeply understand the way the library works before they can benefit from it, they're going to want to just dive in and get something useful going.)

These are not necessarily insurmountable problems, but they are fundamental problems to having two-way binding. I think these two things are why it has never really taken off despite the fact I've seen at least half-a-dozen attempts over the years. I can imagine programming language tools that could help with both problems, but as what I'm seeing getting sketched up in my head requires a type system at least as strong as Haskell's to be practically usable without so many holes as to be insignificantly different from what we already have, it's not going to take off anytime soon.

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#72

Vue.js has single file components [1] and template precompilation [2] (or optionally JSX support, which is basically a precompiled template). I don't see the point of yet another framework here. The "no dependencies" argument seems to fall down for me, since it would seem to me that they would need to duplicate a lot of code for state management and rendering, bloating the code for anything more complex. And if there…

As well as generating smaller apps and being quicker to load, Svelte is significantly faster than Vue. We'll be publishing benchmarks soon.

I'd love to see code size and performance comparison for a relatively simple but non trivial component, like a DateTime picker.

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#73

Earlier quoted context omitted.

As well as generating smaller apps and being quicker to load, Svelte is significantly faster than Vue. We'll be publishing benchmarks soon.

I'd love to see code size and performance comparison for a relatively simple but non trivial component, like a DateTime picker.

Yep, we'll be adding more examples soon – definitely on the TODO list. In the meantime you can take a look at our TodoMVC implementation – it's 3.6kb zipped (Vue is 17.2kb without any app code. Not a criticism, just context)

https://svelte-todomvc.surge.sh

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#74

Love it. I think the most discussion-worthy quote I found in the docs is this: > It's currently fashionable to avoid two-way binding on the grounds that it creates all sorts of hard-to-debug problems and slows your application down, and that a one-way top-down data flow is 'easier to reason about'. This is in fact high grade nonsense. It's true that two-way binding done badly has all sorts of issues, and that very la…

Yeah...

If not "used correctly" means a buggy app, and it's easy for an inexperienced developer to make those mistakes, you're still in for a world of pain. If you need to be an expert to avoid accidentally screwing everything up, there's still work to be done.

This is the whole "pit of success" thing Facebook talks about, the path of least resistance should be towards a functional nearly bug-free app. Certainly an app where bugs are relatively well-quarantined.

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#75
post #52
post #35

Earlier quoted context omitted.

Taken to its extreme, that argues for writing everything in assembly language. React's virtual DOM diffing makes components more readable than the previous style of writing code to explicitly manipulate the DOM and totally hides what's really happening. However, we trust that it's going to do the right thing, just as we trust that the JavaScript engine will do the right thing when it JITs and interprets our code.

The point is, don't take things to the extreme :) It's not that people said "Everything is bad, do assembly". It's just that people identified 2WB as problematic and you just shouldn't do that one thing.

Currently JS frontend folks also classify MVC as "problematic", yet a lot of successful software was written that way. So along with J2EE folks, this isn't really the community to look for style standards by default.

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#76
post #34

Earlier quoted context omitted.

Redux fixes two way binding by forcing the developer to emulate it using such a convoluted mechanism that there's no way to see that it's still broken; great job, FB rockstars!

If u don't like it you don't have to use it. And redux is nothing like that. It reduces a tonne of bugs among a lot of not so smart developers or beginners.

> If u don't like it you don't have to use it

Don't write things like that, it always reads like "Noone cares about your opinion, so stop using X and also stop writing about how bad X is"

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#77

I 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…

checkout css-modules! https://github.com/css-modules/css-modules

Yep, happily using css modules too.

The only tiny issue left with that approach is that you still can't share code (for instance, colors) between JS & CSS.

but overall, I think it's the best compromise today.

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#78

Vue.js has single file components [1] and template precompilation [2] (or optionally JSX support, which is basically a precompiled template). I don't see the point of yet another framework here. The "no dependencies" argument seems to fall down for me, since it would seem to me that they would need to duplicate a lot of code for state management and rendering, bloating the code for anything more complex. And if there…

So if you want to use a router in Vue what do you do? Well, you install vue-router. The point of Svelte is that it can infer all of the features you are using for you, and not compile the ones that you aren't.

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#79

Earlier quoted context omitted.

> # Getting started > Normally, this is the part where the instructions would tell you to add a tag to your page or install something from npm. But because Svelte runs at build time, it works a little bit differently. > First, install the CLI: > npm install -g svelte-cli They might want to change their opening

To what?

Something that doesn't say "normally, you'd be asked here to install something from npm, but" and then immediately goes on to ask that you install something from npm.

Re: Svelte – A UI framework that compiles into tiny standalone JavaScript modules

#80

Earlier quoted context omitted.

> # Getting started > Normally, this is the part where the instructions would tell you to add a tag to your page or install something from npm. But because Svelte runs at build time, it works a little bit differently. > First, install the CLI: > npm install -g svelte-cli They might want to change their opening

To what?

> or install something from npm

> installs something from npm

Post reply on HN