News for hackers. Stuff that matters.
Re:SvelteKit Is in Public Beta by jack_riminton on Tuesday March 23, 2021 @03:21PM (#26559184)
The code examples page is a thing of beauty and simplicity, bravo! https://svelte.dev/examples#hello-world
Re:SvelteKit Is in Public Beta by karolkozub on Tuesday March 23, 2021 @04:49PM (#26560228)
There's also a tutorial [0] which goes through these examples one by one explaining in detail how each concept works. I highly recommend it to anyone interested in learning this framework.

[0]: https://svelte.dev/tutorial

Re:SvelteKit Is in Public Beta by iudqnolq on Tuesday March 23, 2021 @06:16PM (#26561034)
I don't understand why the second example caches the src, checks if the current src matches the cached src, and if not sets both the src and the alt. Does the complier fully check the codebase to ensure they are always set together?
Re:SvelteKit Is in Public Beta by nonameiguess on Tuesday March 23, 2021 @10:09PM (#26562755)
This makes me very glad I have never worked in JavaScript. Why does hello world compile to something with three explicit no-ops and what the heck is safe_not_equals? I had to wonder what an unsafe way to determine equality is and looked this and found this is apparently the code?

export function safe_not_equal(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); }

Why is it possible for a != a to not always be false and b == b to not always be true? How did Javascript defeat the most immutable rule of basic logic discovered by Aristotle 2000 years ago?

Re:SvelteKit Is in Public Beta by marcus_cemes on Wednesday March 24, 2021 @04:27AM (#26564760)
Javascript does a lot of implcit conversions, it was badly designed and has dynamic types which means a lot of runtime checks, these quirks can't be removed with breaking a lot of legacy code.

Unsafe equality: "1" == 1 is true (string and float, https://dev.to/mkrl/javascript-quirks-in-one-image-from-the-...).

Yet, like with C, you learn the different ways you can shoot yourself in the foot over time and avoid them. In 10 years I've never written a safe_not_equals function, although explicit object/null checks are a thing, but it wouldn't surprise me if libraries used by millions that may end up in Internet Explorer go that extra step. Each language has it's particular use-case, JS happens to be the language of web development.

Re:SvelteKit Is in Public Beta by mping on Wednesday March 24, 2021 @03:19AM (#26564399)
Although I agree with you in principle, in practice most of js devs never worry about such things. It's mostly library authors and such. And there are cases where a != a, I think for NaN (not a number).
Re:SvelteKit Is in Public Beta by nonameiguess on Wednesday March 24, 2021 @10:31AM (#26567711)
Fair enough. It makes sense for NaN, but languages like Rust and the various ML variants solve that by defining floating point numbers to not be a type where equality is a valid binary operation.