Live data from Hacker News

Svelte is the most beautiful web framework I've seen

thefutureoftheweb.com

121–130 of 210 posts

Re: Svelte is the most beautiful web framework I've seen

#121

Interesting that the custom element appears to just take a single JavaScript object as a parameter: In JSX this would be either: or: This is almost as ergonomic as JSX except for attributes like checked where the value is omitted. It might encourage some refactoring, compared with React, because the thought of putting attributes in a variable and adding them as a spread might occur more often when seeing an object be…

Am I the only one who would rather write the following instead of JSX? Board.draw(game) or drawBoard(game)

Well you might like Hyperscript or Elm, those are two approaches that work quite well using simple function calls.

The thing with JSX is introduces a syntax that is familiar to the rendered output (which is the status quo), and there's a relatively clear visual separation between the declarative and imperative parts; which is hard to enforce in pure JS.

Re: Svelte is the most beautiful web framework I've seen

#123

I have a table of 100 rows x 10 columns mostly of numbers which change 10 times a second (think trading). The source data sits in an array of objects. On each update, I need to update the table cells with the latest values from the source array. The content of each cell can change, possibly it's css class too (from red it become blue for example). I'm using Vue/Bootstrap-Vue table at the moment, but it's quite slow.…

You can also play with Vanillin: http://metaes.org/playground.html#6-For%20statement%20-%20ba...

Paste this and run:

  
    const rows = 100,
      cols = 10,
      table = Array.from({ length: rows }).map((_, i) => Array.from({ length: cols }).map((_, j) => ({ i, j })));
    console.log(table);
    setInterval(function() {
      let cell = table[Math.floor(Math.random() * rows)][Math.floor(Math.random() * cols)];
      cell.i = Math.floor(Math.random() * 100);
      cell.j = Math.floor(Math.random() * 100);
    }, 1);
  

  
    
      cell.i + ":" + cell.j
      
    
  

It only updates DOM element textContent on each change.

Re: Svelte is the most beautiful web framework I've seen

#124

Let the "soap box brigade" commence! I got introduced to Rich Harris via a podcast (not personally), but am a big fan of his perspective on JS. I think we can all agree that; if you don't like Svelte, then fine. If you love JSX/TSX - then great! If you're a Vue person, then awesome - its exactly what makes this community great - the diversity & innovation. Not the soap-boxing antics, polarised opinions & vilification…

At a job I had years back, we built our application with Ractive, it was really nice to use.

Re: Svelte is the most beautiful web framework I've seen

#126

Earlier quoted context omitted.

It would certainly reduce it. With table-layout:fixed, the default behaviour is that every cell is the same width as the others. With the normal table layout algorithm it’ll attempt to rebalance as every new cell’s content is added. That makes for a very flexible layout that automatically scales to best fit the content, but have to flush and redo the layout for the whole table every time a column width is calculated…

Fixed dimensions is also good for UX, it would suck trying to read a table changing 10x a second and seeing the columns shifting back and forth.

It doesn’t even have to be a problem like that to be a performance problem. For example, imagine a five row table where the last column always has 1 digit in the first row, 2 in the second, 3 in the third etc. When rendering (without table-layout:fixed) the browser will check the last cell, see one digit, and size that column appropriately. It’ll then carry on rendering the second row, see two digits, then work out the new size for the column and rerender the entire table. Repeat for rows three, four and five.

Not a problem for a single layout pass, but a performance problem if the data changes every frame.

Re: Svelte is the most beautiful web framework I've seen

#127
post #10
post #5

Earlier quoted context omitted.

Using JS ternaries for conditional rendering doesn't feel natural to me at all

Ok, I should probably edit my comment to "JSX/TSX feels so incredibly natural except for needing to use JS ternaries for conditional rendering" because seriously what were they thinking there?

maybe do-expression proposal could help https://github.com/tc39/proposal-do-expressions

Re: Svelte is the most beautiful web framework I've seen

#128
post #119
post #91

Earlier quoted context omitted.

> whatever the hell react is doing Being JavaScript?

I'm a huge React fanboy, but if you try and step through the React code with a debugger, we're kind of a far cry from the days of Backbone and even Angular. For the common mortal, it has to be treated as a black box. Fortunately, its fairly stable, so it's rare you have to care, but...

Yeah, the ability to step into Backbone code and back out of it into my own code was one of the things I liked about Backbone.

That said, React's mental model is so powerful that I've almost never needed to actually debug into it to see what's going on. If you've got an issue, tracing the dataflow in your own code is generally sufficient. So, I'm okay treating it as a black box.

(Hiya, Shados!)

Re: Svelte is the most beautiful web framework I've seen

#129

As someone who has built a number of data products w/ React, I decided to give Svelte a try a few months ago. At this point I am using it on some internal projects to great success & ease and probably wouldn't go back to React for newer projects unless there was a compelling reason to (eg collaboration w/ other React devs). As a disclaimer, I admire the React community + devs and think React has made a lot of hard th…

I've been considering svelte for exactly this d3 datavis use case. Are any of your projects publicly available to explore and get a feel for? I'm new to front end and so far have been disappointed with the speed of plotly and dash, which as I understand it are written around react. I'd love to see an example of svelte performance in a more datavis use case.

Re: Svelte is the most beautiful web framework I've seen

#130
post #5
post #3

Earlier quoted context omitted.

Agreed, JSX/TSX feels so incredibly natural it's hard to imagine giving it up, and starting a significant JS project in 2019 or 2020 without using TypeScript would feel professionally negligent to me.

Using JS ternaries for conditional rendering doesn't feel natural to me at all

You can use short circuiting instead:

    
      {items.length === 0 &&
        

No items.

} {items.length === 1 &&

Warning: You only have 1 item, at least 2 is required

} {items.map(...)}
`false` is not rendered by react, so this code is perfectly fine.
Post reply on HN