Live data from Hacker News

How I made a website with Svelte

johanronsse.be

121–130 of 130 posts

Re: How I made a website with Svelte

#121
post #98

Earlier quoted context omitted.

Please stop, people can build whatever they want how ever they wish, especially when it’s not planned to be super public. They wish to build it in svelte, that’s all the reasoning you need. I’ve also literally seen someone use a game engine to build a resume on here, it was super cool and attracted a lot of interest

No one said people weren't allowed to build something with Svelte or whatever, just that they didn't think it was a good way to explore it, and backed that up with reasoning. Additionally, if there were other reasons for doing it, those would be interesting to hear. I wouldn't get too worked up about this: discussions about which jobs a tool lends itself well to can be very insightful.

It's more that this exact conversation happens on just about every post someone makes using some tech. Someone comes in and claims it's wrong and they should have done x. Was this the best use case for Svelte/any javascript framework? Probably not, but who knows what the OP has planned for the site further, maybe it will be beneficial to have a javascript framework in place.

Re: How I made a website with Svelte

#122

I'm afraid I honestly don't understand. What was the reason for using a bunch of frameworks and JavaScript for what appears to be a super simple web site? I don't see anything that couldn't have been done in plain static HTML and CSS. Is there some functionality on the pages that I'm missing?

I'm afraid I honestly don't understand. I don't see anything that couldn't have been done in plain static HTML and CSS. It goes by various themes: - Can't see the forest for the trees - resume driven development - hype driven development - brag shallow blog post driven development - over-engineering - sell courses driven development etc...

I agree, the reality is most people in the software world are too nice and polite, which is great but tend to foster the amount of nonsense because few people are willing to call it out for fear of being branded a hater.

Re: How I made a website with Svelte

#123

Earlier quoted context omitted.

I'm not sure how it forces less logic in the render. Looking at the Svelte docs you can do this: ``` {#if invokeFunction()} This function returned a truthy value! {/if} ``` And with React do this: ``` { invokeFunction() && This function returned a truthy value } ``` and the result would be the same, a conditionally rendered string. I totally agree in the normalizing/formalizing how templates are build and the more ve…

In Vue it would be: {{ vars }} Instead of: { collection.map((vars, i) => {vars} } It's easier for me to picture what the first example is going to render because it makes the markup the hero, with code inside, while the second example is making JS the hero, with markup inside. But this example is not even touching the topic. A render function is rarely that simple. Now if you do maps, and filters, and ternary operato…

The second example isn’t making JS the hero, it’s making data the hero.

Re: How I made a website with Svelte

#124

I've been using Vue for a while because it's possible to get things up and running, even .Vue templates, without having to use npm tool chains. Just linking the Vue and other source files. But, I really like the speed and user experience here. I may actually give it a try.

Svelte has very few dependencies, and zero of them at runtime. Hot reload is instant. A real breath of fresh air when coming from other frameworks.

I've been trying it throughout the day and so far I find the way of doing things better than Vue. I'll see if I can sort a binding issue that was causing me a bit of complexity in Vue. So far, it looks like it would make solving that trivial.

Re: How I made a website with Svelte

#125
post #98

Earlier quoted context omitted.

No one said people weren't allowed to build something with Svelte or whatever, just that they didn't think it was a good way to explore it, and backed that up with reasoning. Additionally, if there were other reasons for doing it, those would be interesting to hear. I wouldn't get too worked up about this: discussions about which jobs a tool lends itself well to can be very insightful.

It's more that this exact conversation happens on just about every post someone makes using some tech. Someone comes in and claims it's wrong and they should have done x. Was this the best use case for Svelte/any javascript framework? Probably not, but who knows what the OP has planned for the site further, maybe it will be beneficial to have a javascript framework in place.

I guess, and I recognise the frustration, but if they argue why someone has done x, or OP comes in and describes what else they have planned and why Svelte or whatever was a good fit, then that would still be interesting to me.

Re: How I made a website with Svelte

#126

Earlier quoted context omitted.

In Vue it would be: {{ vars }} Instead of: { collection.map((vars, i) => {vars} } It's easier for me to picture what the first example is going to render because it makes the markup the hero, with code inside, while the second example is making JS the hero, with markup inside. But this example is not even touching the topic. A render function is rarely that simple. Now if you do maps, and filters, and ternary operato…

The second example isn’t making JS the hero, it’s making data the hero.

Which is the opposite of what you want in rendering. Ui is king here. Data has the rest of the code to shine.

Re: How I made a website with Svelte

#127
post #119

Earlier quoted context omitted.

In Vue it would be: {{ vars }} Instead of: { collection.map((vars, i) => {vars} } It's easier for me to picture what the first example is going to render because it makes the markup the hero, with code inside, while the second example is making JS the hero, with markup inside. But this example is not even touching the topic. A render function is rarely that simple. Now if you do maps, and filters, and ternary operato…

Vue's templates are great until they aren't, and then you wish you were using JSX. The IDE tooling is worlds better with JSX as well. Vetur has.. had a rough year.

I don't have to debug my render functions much in vue because they contains little logic. Debugging is more common in JSX, it's better at solving a problem it introduces.

Re: How I made a website with Svelte

#128
post #93

Earlier quoted context omitted.

I find it a little strange that you are pointing out comprehensive documentation on a module as proof of a problem with the framework... Lets talk about what you get with HttpClient: - Easy testing. Because its using the DI system, its very mockable. You can totally set this up with fetch or whatever behind a service but, well why? Its already done. - Robust type safety. Again you can set this up with fetch, but why?…

I mean it's really not "already done" if you have to use all this boilerplate to get those features. > Robust type safety. Again you can set this up with fetch, but why? Its already done. Not sure what you mean here. Fetch has high-quality TypeScript bindings. For the rest it's mostly YAGNI. The boilerplate confuses new developers (try explaining what NgModule does to a junior dev just trying to build a simple page)…

> Fetch

Angular uses an RxJS interface to XMLHttpRequest, which has a few advantages. For example, only relatively recently did fetch() (including polyfills) support cancellation.

That said, there's absolutely nothing that requires you to use @angular/common/http. Angular created it because developers have to solve those problems over and over, but it's just a library under the Angular roof; you can use fetch() function instead.

Re: How I made a website with Svelte

#129
post #110

It was a pleasure reading your article, I hope I can use it as reference for my future svelte project. And I must say that Svelte also caught my eye this year. I gave it a shot in their playground, and I was surprised how intuitive things are. Svelte as a compiler seems very natural an approach to building frontend apps and independent components. My next project will be Svelte on the frontend (SPA), and Elixir+Phoen…

Any particular resources you'd recommend for Elixir/Phoenix? Doing their basic intro guides right now and liking them, but would love anything you did after those that you liked.

I recommend the official book written by Chris Mccord for Phoenix. For Elixir, I really enjoyed doing the assignments on Exercism. I also enjoy reading the elixir forum, and the slack community has helped me with a couple roadblocks in the past. But really, I think the best way is to just pick a project idea, and start working on it. It works best for me learn while doing. I hope you enjoy Elixir too!

Re: How I made a website with Svelte

#130
post #64

Earlier quoted context omitted.

I tend to agree; however, it's really easy to make a site like this work without JS. Edited to add: to be clear, I mean while still using the framework .

Is it? You either you need some kind of server side JavaScript rendering (pita to get right imo) or you need to create a complete copy of the website that’s statically rendered (and replaced if the user has JS enabled?)

Have a look at Sapper, which is a framework built around Svelte that makes the server-side rendering pretty easy. I worked with a next.js SSR project recently and that was an absolute trainwreck, but Svelte/Sapper, while not perfect, is pretty nice.

You have to be a little careful about the interactions if you really care about it working with no JS (e.g. have an on:submit for a form and then also have a server-side route that it can POST to) but it's not too bad really.

Post reply on HN