Live data from Hacker News

The Svelte Compiler Handbook

lihautan.com

71–80 of 139 posts

Re: The Svelte Compiler Handbook

#71
post #32

Earlier quoted context omitted.

This is the kind of attitude that has resulted in a million code vulnerabilities in C because the idea that it's inherently unsafe is just an idea 'peddled by people unskilled in its application' (to re-express nicely). It's the kind of attitude which will ignore the many inconsistencies in languages which were the result of historical accident instead of good design because it's just a blind acceptance of the way th…

The idea that "A good linter, proper programming practices, discipline will get you there" has resulted in "a million code vulnerabilities in C" !! That is a surprising jump in cause-and-effect logic right there. I do not code any C, but I assure you if I did I'd consider it part of proper programming practice and discipline to write code that avoids those exact vulnerabilities you suggest. But, picking a whole new p…

You're making a false dichotomy here. There's a lot of light between something being a magical silver bullet that solves all your problems and every programming language being equally bad. If that weren't the case we would probably have never progressed from unstructured programming.

In general the greatest progress in software engineering practice at the level of programming languages is made when something that was previously left up to human discipline is made automatic so we don't have to struggle with it anymore: memory safety, type checking, and at the beginning, returning from subroutines at a structured location back to a structured location instead of control flowing wildly throughout a program with jumps.

Yes, it's theoretically possible to do all these things well without the assistance of a computer, but in practice, it's more work than any human can handle. The problems that newer programming languages have are an argument for fixing those problems, not reintroducing ones we've already solved.

Re: The Svelte Compiler Handbook

#72

I like Svelte very much. My biggest struggle is with tooling, especially the lack of proper IDE support. I know there are several IDEs with plugins for Svelte, but they're either obsolete or lacking essential features. That's why I won't use it for me next project, just not worth it going against the wind. Now, I am looking at Flutter. Seems to match my needs, and it's also actively maintained. Never underestimate th…

I felt like there was a sort of sea change when JetBrains started producing multiple IDEs. IDEA always struggled to handle supporting everything at once and third party plugins are always incomplete. They don’t support all of the functionality and you have to keep that active in your mind while developing, which saps resources for solving hard problems.

I just wish they could support more languages and tool chains, and I wish an IDEA subscription entitled you to all other versions of the editor. I want to buy one but use Webstorm because it’s a little less resource intensive than IDEA. And I want them to make like five more IDEs, which I feel they could fund through IDEA-specific revenue.

Re: The Svelte Compiler Handbook

#73
I really like that Svelte does compiler time dependency analysis such that there is less work to do runtime.

Can we bring this ideas to react and Vdom based frameworks? I imagine Babel/typescript can analyze jsx to find which attribute are bound to a variable and which are just static. The static ones don’t need to be diffed, only the dynamic ones.

Re: The Svelte Compiler Handbook

#74

How did Rich Harris, a "graphics editor," write Svelte? So many designers hardly know JavaScript at all. This one wrote one of the most advanced JavaScript frameworks I've ever seen. It's not just JavaScript. He wrote a compiler that takes a custom, declarative syntax and converts it to imperative JavaScript to surgically update the DOM.

The NYT graphics team is one of, if not THE, best graphics teams in journalism. You need a significant amount of JavaScript to work on the team. Yes, the team does have designers, but there are many developers on the team, including Harris.

If you look at the Svelte repo, the project didn't appear overnight. The first commit dates to 2016, and since then there have been many contributers. Don't think Harris solely built the project to where it's been. He's had help.

Re: The Svelte Compiler Handbook

#75

How did Rich Harris, a "graphics editor," write Svelte? So many designers hardly know JavaScript at all. This one wrote one of the most advanced JavaScript frameworks I've ever seen. It's not just JavaScript. He wrote a compiler that takes a custom, declarative syntax and converts it to imperative JavaScript to surgically update the DOM.

Harris has started a few notable projects outside of Svelte as well, including Rollup (alternative bundler) and buble (alternative es2015 compiler).

Re: The Svelte Compiler Handbook

#76

How did Rich Harris, a "graphics editor," write Svelte? So many designers hardly know JavaScript at all. This one wrote one of the most advanced JavaScript frameworks I've ever seen. It's not just JavaScript. He wrote a compiler that takes a custom, declarative syntax and converts it to imperative JavaScript to surgically update the DOM.

I have a theory that Svelte originated from his work with Rollup.

He was already a great developer when he started Rollup, but writing it brought him to a new level.

Rollup is super clever: most bundlers back then would treat JS modules like giant strings and concatenate them. It was just plain string concatenation, similar to require.js's "define()", so you needed a runtimes that answered to "require()". Modules were assembled during runtime. [1]

Rollup, instead, uses an algorithm to transform the AST of multiple modules into a single AST, inlining all modules and turning them into variables [2], and renaming duplicate identifiers. The final code looks like something that a human would do if asked to put everything in a single file. [3]

This is done by manipulating the AST returned by the Acorn parser, something he seems to have become an expert on.

I'm pretty sure that it was during the development of Rollup that he had other ideas for crazy optimizations, but unable to apply them to a Bundler, he created Svelte.

--

[1] https://requirejs.org/docs/api.html#deffunc

[2] https://github.com/rollup/rollup/blob/1e1a11107dbee11636dcf9... and https://github.com/rollup/rollup/blob/1e1a11107dbee11636dcf9...

[3] https://risanb.com/posts/bundling-your-javascript-library-wi...

Re: The Svelte Compiler Handbook

#77
post #44

Earlier quoted context omitted.

That person is also a jerk (in my experience)

Elaborate please.

It was a Twitter exchange that's been deleted so I can't remember the details. Suffices to say he was rude to me and that's colored my opinion of Svelte ever since.

Re: The Svelte Compiler Handbook

#78
post #34

Earlier quoted context omitted.

Typescript is not a product for teams of low skill of disciple, and it's pretty insulting to suggest it is.

That is certainly not what I was suggesting.

You literally said "[Whether you need Typescript or not] depends on your teams skill set and level of disciple".

Re: The Svelte Compiler Handbook

#79
post #72

I like Svelte very much. My biggest struggle is with tooling, especially the lack of proper IDE support. I know there are several IDEs with plugins for Svelte, but they're either obsolete or lacking essential features. That's why I won't use it for me next project, just not worth it going against the wind. Now, I am looking at Flutter. Seems to match my needs, and it's also actively maintained. Never underestimate th…

I felt like there was a sort of sea change when JetBrains started producing multiple IDEs. IDEA always struggled to handle supporting everything at once and third party plugins are always incomplete. They don’t support all of the functionality and you have to keep that active in your mind while developing, which saps resources for solving hard problems. I just wish they could support more languages and tool chains, a…

[deleted]
Post reply on HN