Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
MrJohz
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
49 ms
·
781.
▲
by
MrJohz
3y ago
Wouldn't that mean that every type always has to include the type tag as an extra byte, making every type larger overall? Or is it only included if a union type is created from that type?
782.
▲
by
MrJohz
3y ago
No worries, I hope I'm not under/overexplaining something! The answer here is the standard one though: if you write $FOO to DOM, then read $BAR, it has to return $BAZ because it always used to return $BAZ, and we can't have b
783.
▲
by
MrJohz
3y ago
The shadow DOM doesn't help at all here, that's mainly about scope and isolation. The (in fairness confusingly named) virtual DOM helps by splitting up writes and reads. The goal when updating the DOM is to do all the reads in one
784.
▲
by
MrJohz
3y ago
It's partially true. Layout and repaint are two separate rendering phases. Repaint happens asynchronously, as you point out. But layout (i.e. calculating heights, widths, etc of each box) is more complicated. If the browser can get awa
785.
▲
by
MrJohz
3y ago
Yes and no. The browser will, as much as it can, catch together DOM changes and perform them all at once. So if `baz` looks like this: for (let i=0; i<10; i++) { elem.style.fontSize = i + 20 + 'px'; } Then th
786.
▲
by
MrJohz
3y ago
As I understand it, there's a couple of issues with naively rerendering DOM elements like this. Firstly, the DOM is stateful, even in relatively simple cases, which means destroying and recreating a DOM node can lose information. The c
787.
▲
by
MrJohz
3y ago
Ooh, that's me! As in the comment, please don't do this. It's been a while since I worked at a place doing this, and I'm on my phone, so some details may be fuzzy or wrong, but when I was figuring all this out, I remembe
788.
▲
by
MrJohz
3y ago
In my experience, there is almost always a simpler way to handle these cases that involves being able to put a file in gitignore. This is one of the big advantages of environment variables, for example - they can typically be stored in a .e
789.
▲
by
MrJohz
3y ago
It's also completely untrue that the norm outside of software engineering, I think this perception comes because we only think of the big engineering projects like NASA or building projects, and forget how broad engineering is and can
790.
▲
by
MrJohz
3y ago
Anything that is "super important and critical" will need to be validated on the server no matter what. But by pre-validating things in the browser, the user can have a more intuitive, seamless experience. Is the username you'
791.
▲
by
MrJohz
3y ago
Anecdotally, I am sceptical that this is true (at least universally). My dad grew up with animals, and his family named and are plenty of them.
792.
▲
by
MrJohz
3y ago
She also specifically says that anything she asked her employees to do, she'd do herself, but if you read that backwards, the implication is that she is setting up a cultural expectation here: to achieve a tight deadline, if necessary,
793.
▲
by
MrJohz
3y ago
Typescript does have full unions, although only partially discriminated ones (in the sense that `number | string` is discriminated but `number | number` is not - custom discriminators can be written fairly easily though). This resolves the
794.
▲
by
MrJohz
3y ago
There is some runtime complexity here though. With both enums and sum types, if you want to differentiate the types at runtime, you need to include a discriminant in order to be able to do that. Enums include that discriminant explicitly (t
795.
▲
by
MrJohz
3y ago
I'd possibly make it even more syntactically simple by removing the braces for one-line if statements. I know this can be a bit controversial, but for cases like this where the block consists only of a return statement, and where that
796.
▲
by
MrJohz
3y ago
This is why I think architectural discussions should happen first (and typically decisions should be made collectively rather than individually). At one of the best places I worked, we discussed every new feature as a team (four engineers a
797.
▲
by
MrJohz
3y ago
The other side of this is the potential for car-sharing, reducing the total number of cars around, but allowing people to still make more infrequent journeys by car when that's necessary (or just easier). If your bike is enough for all
798.
▲
by
MrJohz
3y ago
Living in a city in Germany, a lot of families cycle with their children. Typically babies and young children have a seat on the handlebars or in a small trailer on the back, older children either have a tandem-style attachment or their own
799.
▲
by
MrJohz
3y ago
> > The goal is to make sure that multiple people working on a codebase have at least some idea of what's going on in every corner of it. > If that is truly the goal, shouldn’t the programmer have that information before they
800.
▲
by
MrJohz
3y ago
Completely agree, analysis tools go hand in hand with code review as a learning tool. Partly, they take more responsibility away from finding the obvious bugs, and partly, like you say, they help surface problems that people might not be lo
801.
▲
by
MrJohz
3y ago
I think almost everything should be a checked exception, with some possible exceptions (haha) being things like out-of-memory exceptions (although even then, with a good type system, I can imagine them optionally throwing checked exceptions
802.
▲
by
MrJohz
3y ago
Why can't they be part of the type system? Rust is a good example of a case where they are part of the type system (albeit in a more monadic form). You've also got typed effects, where effects are essentially a generalised form of
803.
▲
by
MrJohz
3y ago
I'm increasingly of the opinion that this should be the primary value of code review. The goal is to make sure that multiple people working on a codebase have at least some idea of what's going on in every corner of it. Obviously
804.
▲
by
MrJohz
3y ago
But the point is that in both cases the failure needs to be handled somewhere and somehow. Surfacing the error might be a valid option, but to make the decision you need to know that the error is there in the first place. This can be solved
805.
▲
by
MrJohz
3y ago
Null pointer exceptions shouldn't exist in the first place, they're fairly trivial to avoid. Index out of bounds can be similarly avoided, although the cost in terms of economics is a lot steeper. I like Rust's strategy of pr
806.
▲
by
MrJohz
3y ago
Like with anything, that might be a good strategy in some situations, but not in all. For example: * If you have some secrets that need to stay hidden (e.g. database passwords, API keys, encryption keys, etc) then that needs to be processed
807.
▲
by
MrJohz
3y ago
I think the key point that the original article was making was that there is server side generation going on - some server still needs load the file and turn it into an HTTP response, with all the correct headers, metadata, etc, and with
808.
▲
by
MrJohz
3y ago
> 100% valid HTML and within "the normal realm of HTML". The event is passed as a parameter to the function. Has been available since the introduction of JavaScript. Predates addEventListener(…) and its ilk by a few years. Like
809.
▲
by
MrJohz
3y ago
And this is typically how conditionals work in SolidJS, which also uses JSX but adds extra core components to handle conditionals and iteration. In fairness, this is largely because they can better support the reactivity model that SolidJS
810.
▲
by
MrJohz
3y ago
This is true of Svelte's syntax as well, is it not?
More ›