Live data from Hacker News

The Svelte Compiler Handbook

lihautan.com

31–40 of 139 posts

Re: The Svelte Compiler Handbook

#31
post #29

I'm surprised Apprun nor Solid have been mentioned yet. Are there any TypeScript reactive frameworks? I know you can use TS with the others, but finding tutorials can be a pain since it all these are JS first frameworks.

I'm actually working on one. I don't know what will come out of it, but it's an interesting endeavor. As soon as it's shareable I will share it on Github.

I'm basically trying to do a superset of typescript where you create elements so:

  const root = c({
    el: 'div',
    children: [
      `hello, ${store.user.name}`
    ],
    attr: {
      class: 'bold smart',
      id: 'abc',
      bla: true,
    },
    evts: {
      click: () => {
        console.log("Clicked")
      }
    }
  });
And store store.user.name is "magically" reactive.

Was that what you meant?

Re: The Svelte Compiler Handbook

#32
post #27

Earlier quoted context omitted.

I completely agree. That something is a linter, of which TypeScript is just one of the many options available. This whole idea of you cannot write a big app in JS is just peddled by those who do not understand, or hate JS. A good linter, proper programming practices, discipline will get you there. Anytime someone peddles a language or framework as a magic bullet to clean code, they're either selling you some snake oi…

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 programming language instead is just lying to yourself, because there is no perfect programming language.

None! Zero. Not one, no matter how much in love you are with it. They all have their warts, strengths and weaknesses, and if you are not aware of any in your language of choice, and actively working to avoid and mitigate against them (aka discipline and best practice) then you have fallen prey to exactly what I was talking about: the idea that a framework or language is a magical silver bullet to writing clean code. If you thought I was saying JS (or C, TypeScript, Haskel etc) is this perfect, wonderful language, you completely misunderstood me.

Re: The Svelte Compiler Handbook

#33
post #21

Earlier quoted context omitted.

The problem with Svelte is it doesn't support Typescript. You pretty much need that on any reasonable size project unless you are happy to spend your life tracking down runtime bugs. Vue has a similar problem (it sort of supports Typescript, but not properly and templates aren't type checked). I've not used Elm so maybe that is better. React has good support for type checking. I would use that.

> Typescript. You pretty much need that on any reasonable size project unless you are happy to spend your life tracking down runtime bugs I'd say it depends on your teams skill set and level of disciple. The best defence against a buggy codebase isn't a programming language or framework, its good all fashioned discipline.

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

Re: The Svelte Compiler Handbook

#34
post #21

Earlier quoted context omitted.

> Typescript. You pretty much need that on any reasonable size project unless you are happy to spend your life tracking down runtime bugs I'd say it depends on your teams skill set and level of disciple. The best defence against a buggy codebase isn't a programming language or framework, its good all fashioned discipline.

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.

Re: The Svelte Compiler Handbook

#35
post #21

Earlier quoted context omitted.

> Typescript. You pretty much need that on any reasonable size project unless you are happy to spend your life tracking down runtime bugs I'd say it depends on your teams skill set and level of disciple. The best defence against a buggy codebase isn't a programming language or framework, its good all fashioned discipline.

I think we all agree on this, but we don't all agree that "just be disciplined" works in practice. "Just don't write bugs", "just write perfect code", etc Given that you and your team has all the discipline you need, you could still argue that type checking the codebase in your head is time consuming and is better spent on higher level concepts. A typesystem can get in the way and slow down development if it's too st…

> "Just don't write bugs", "just write perfect code", etc

You are putting words in my mouth. I do not believe that you can write perfect code or avoid bugs. Just like I do not believe there is this perfect programming language or framework out there that magically creates clean code.

> you could still argue that type checking the codebase in your head is time consuming

This again, depends on the particular history and skill-set of your team. For example, TypeScript fits very well if you are familliar with C#, while CoffeeScript fits very well to those comfortable with python/ruby, ClojureScript for those who like clojure, ESLint for those comfortable with JS ... etc

Re: The Svelte Compiler Handbook

#36
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…

> 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.

And yet all of those vulnerabilities came from hundreds of developers who shared the same misplaced confidence in their own abilities.

It's the same as hospitals. You can't just say "who needs checklists? Surgeons and assistants should be disciplined enough to not make mistakes in the first place!".

In an ideal world they would be, but in this world, they're not and never will be.

Not being able to admit this is how you end up with surgery on your left knee when it was meant to be your right.

Accept that no-one is 100% perfect, 100% of the time - let alone you - and mould your development around these (very human) failings. "Disciplined programming" will never be as safe as "disciplined programming with guard-rails built into the language". Weigh up the trade-offs - sometimes the performance gain is worth the risk, sometimes it's not.

Re: The Svelte Compiler Handbook

#37
post #3

Having a hard time choosing between Svelte and Elm. For a lone in house dev, any recommendations?

I'd say Svelte is much closer to "regular" programming. You will have to bend your thinking a bit with Elm. Svelte seems great, but it seems to be developed by one person primarily. Also, that person lives in NY and the project looks paused at the moment.

Looking at the Github commits I’d say neither statement is true? Seems to be plenty of contributors that have contributed recently:

https://github.com/sveltejs/svelte/commits/master

Re: The Svelte Compiler Handbook

#38
post #3

Having a hard time choosing between Svelte and Elm. For a lone in house dev, any recommendations?

The problem with Svelte is it doesn't support Typescript. You pretty much need that on any reasonable size project unless you are happy to spend your life tracking down runtime bugs. Vue has a similar problem (it sort of supports Typescript, but not properly and templates aren't type checked). I've not used Elm so maybe that is better. React has good support for type checking. I would use that.

I’ve had success with extracting as much logic as I can out of .svelte files and putting them in .ts and importing. At this point the JS logic in my svelte files is almost exclusively view lifecycle stuff. It’s not perfect but it works well enough for me, and I prefer the output to what I’d get with React.

Re: The Svelte Compiler Handbook

#39
post #21

Earlier quoted context omitted.

The problem with Svelte is it doesn't support Typescript. You pretty much need that on any reasonable size project unless you are happy to spend your life tracking down runtime bugs. Vue has a similar problem (it sort of supports Typescript, but not properly and templates aren't type checked). I've not used Elm so maybe that is better. React has good support for type checking. I would use that.

> Typescript. You pretty much need that on any reasonable size project unless you are happy to spend your life tracking down runtime bugs I'd say it depends on your teams skill set and level of disciple. The best defence against a buggy codebase isn't a programming language or framework, its good all fashioned discipline.

Yep, just like the best defence against dying in a car crash isn't a seatbelt or airbags, it's good old fashioned being awesome at driving like me.
Post reply on HN