HNHacker News
TopNewBestAskShowJobs

branko_d

2,241 karma · joined May 2, 2017

submissionscomments
branko_d··on Missiles are now the biggest killer of airline passengers
Baku is actually slightly further than Aktau, according to Google maps.
branko_d··on New Google Sheet on half of 13.6" MacBook Air screen is fully covered by popups
How do you know you have zero interest in it if you didn’t know it existed?
branko_d··on Error Stacking in Rust
Non-determinism is when for same input you get a different output. According to that definition, the above code is deterministic.

> how would we know if the calculation was completed before the exception was thrown without adding another 8 lines of boilerplate?

You can't, exceptions or not. With exceptions, you need try..catch blocks. With return values, you need ifs.

But with exceptions, you have an option of not handling an error where it originated, without completely ignoring the error.

With error results, you can handle the error (which usually means just returning it to the caller) or ignore it (potential bugs). In languages with not-so-strong typing, it can be very easy to ignore the error. In languages with strong enough typing, you must handle the error. This can be made nicer with syntax sugar, but still leads to boilerplate. This also has an unfortunate consequence of more branching in the generated assembly, which can lead to poorer performance on the "happy path". Exceptions also have cost, of course, but it's geared more towards making the happy path fast and exceptional path slow, which seems like a better tradeoff in most cases.

> If both the display() and log() functions might throw IO exceptions, then how would we know whether or not the error was logged

But without exceptions, your code is simply ignoring any potential errors in display(). And in log() for that matter. If they threw exceptions, it would be impossible to just "swallow" an error silently.

> In conclusion, we don't know with certainty which path was taken through the code's execution, and this is tantamount to non-deterministic behavior.

I would disagree with that. People sometimes see exceptions as somehow "breaking" the program or leading it to an inconsistent state, but that's simply not true.

All you need to realize is that...

1. Every line can throw an exception unless proven otherwise.

2. You don't need to handle an exception close to where it was thrown in most cases. Corollary: you shouldn't use exceptions for control flow. If you notice that your callers use try..catch directly around your function, that might be a sign you should use return values, not exceptions. Return values are not forbidden in languages with exceptions!

3. But you do have to dispose of unmanaged resources. This is probably the main sticking point and does require some discipline.

...and suddenly exceptions stop being awkward and become quite nice to work with.

branko_d··on Error Stacking in Rust
> They cause every line in a function to potentially result in a return from the function with an unexpected type.

That’s not non-deterministic. It’s just not statistically typed.

branko_d··on Pat Gelsinger was wrong for Intel
"Most large investors vote alongside Glass Lewis and ISS recommendations, the two most prominent proxy solutions for investors. Most GL/ISS recommendations tend to vote with the board and don’t change much unless something drastic happens. If you’re a passive investor, you vote in line with the two proxy powerhouses."

- The Death of Intel: When Boards Fail

https://www.fabricatedknowledge.com/p/the-death-of-intel-whe...

branko_d··on Intel gets up to $7.9B award for U.S. chip-plant construction
When did you leave, if I may ask?
branko_d··on Intel gets up to $7.9B award for U.S. chip-plant construction
Intel invests ~4B per quarter on R&D. Source - Intel's income statement:

https://www.intc.com/financial-info/income-statement

So whatever their problems are, throwing more money at R&D is unlikely to solve them.

Also, Intel has committed to not doing stock buybacks and has stopped the dividends completely. They may resume at some point, but it's unlikely to be soon.

branko_d··on If not React, then what?
> I disagree that SPAs are the only solution to some problems.

I disagree with that too. Did I ever say otherwise?

I do believe, however, that there are problems for which a SPA offers the best trade-off. Not the only solution, but the best trade-off.

> This is an orthodoxy which people buy into but there are always a few different approaches possible.

Like the orthodoxy that "nobody needs an SPA"?

> What do SPAs actually offer which is unique?

Interactivity. Good luck keeping your focus or scroll position while reloading a page. If done carefully, performance can also be on that list, though I agree it is often not done carefully.

> Just because you want to load code and data dynamically doesn’t mean you need to buy into SPAs

Agreed. Though you can load both code and data dynamically from a SPA, if you need.

Perhaps our definitions of a "SPA" differ? SPA is when you don't do reloads, hence "single page". But there are many ways to do that, some of them involving React.

branko_d··on If not React, then what?
Ugh, that's just the fundamentalistic, non-engineering approach that we need less of.

Everything is a trade-off, and SPAs offer a trade-off that is right for some cases and wrong for others.

branko_d··on If not React, then what?
It sounds like the author is complaining more about SPAs than the React itself.

Indeed, if your needs are more static, a SPA is probably not a good solution. But if you really do need a SPA, React is a sensible choice and can perform well assuming good engineering.

branko_d··on $8k Suzuki from India received a 5-star crash test rating
I guess it's a bit of an arms race as well - if a heavier car hits a lighter car, the G forces in the lighter car will be higher, all else being equal.

The tragedy of commons is that if everyone bought a lighter car, everyone would be safer, not just the drivers but pedestrians and cyclists as well. Especially if "crash compatibility" was regulated and enforced.

That's, at least, how it seems to me while not actually living in the US - feel free to let me know if I'm completely off.

branko_d··on PgPDF: Pdf Type and Functions for Postgres
It is perfectly legitimate (and in fact preferable in many cases) to store files in database BLOBs. Backups, consistency, security and (yes!) scalability come to mind.

Some early BLOB implementations had performance problems, which is where this notion that "you shouldn't store files in BLOBs" seems to come from. But modern DBMSes have fast BLOBs, especially if used properly through their streaming API (don't materialize the entire file in memory!).

We have a system in production that stores millions of files in BLOBs, some of them reaching multi-GB sizes, being accessed across the globe (a big enterprise company) by thousands of engineers, and never had performance problems with BLOBs.

branko_d··on PgPDF: Pdf Type and Functions for Postgres
Following the links, I find...

    pgPDF: The actual PDF parsing is done by poppler.
    Poppler is a PDF rendering library based on the xpdf-3.0 code base.
    Xpdf is based on XpdfWidget/Qt™, by Glyph & Cog.
    XpdfWidget is based on the same proven code used in Glyph & Cog's XpdfViewer library.
    The XpdfViewer® library / ActiveX control provides a PDF file viewer component for use in Windows applications.
Quite the rabbit hole!

Any licensing complications? Is it cross-platform? XpdfViewer seems to be propriatary and Windows-only.

branko_d··on Language is not essential for the cognitive processes that underlie thought
Other than the word “language”, programming languages and natural languages really have very little in common.

Anecdotally, when I write code, I don’t “talk in my head”. The structures that I have in my brain are in fact difficult to put into words, and I can only vaguely describe them as interconnected 3D shapes evolving over time, or even just “feelings” and “instincts” in some cases.

The code that comes out of that process does not, in fact, describe the process fully, even though it describes exactly what the computer should do. That’s why reading someone else’s code can be so difficult - you are accessing just the end product of their thinking process, without seeing the process itself.

branko_d··on Proposal: JavaScript Structs
And here is the obligatory quote from Bjarne Stroustrup:

"There are only two kinds of languages: the ones people complain about and the ones nobody uses."

branko_d··on Optimizing Postgres table layout for maximum efficiency
Sure, having less padding increases I/O efficiency. I was just commenting on the author's apparent confusion as to why the padding is there in the first place.

Here is the full(er) quote:

  Postgres will happily add padding to the underlying data in order to make sure it is properly aligned at the physical layer. Having the data aligned ensures faster access time when retrieving pages from disk.
This might be misunderstood as "Postgres adds padding to speed-up disk I/O", which is the opposite of what actually happens. Padding slows-down I/O but speeds-up the CPU processing afterwards.

SQLite made the opposite tradeoff.

branko_d··on Optimizing Postgres table layout for maximum efficiency
From the article:

  Having the data aligned ensures faster access time when retrieving pages from disk.
Byte-level alignment cannot possibly have anything to do with retrieving pages from disk, simply because the unit of retrieval is the whole page. From the hardware/OS perspective, a page is just an opaque blob of bytes (comprised from one or more blocks on the physical drive).

Only after these bytes have reached RAM does the byte-level alignment play a role, because CPU works slower on misaligned data.

The article itself then goes on to illustrates the above (and seemingly contradict itself):

  SQLite does not pad or align columns within a row. Everything is tightly packed together using minimal space. Two consequences of this design:

  SQLite has to work harder (use more CPU cycles) to access data within a row once it has that row in memory.
  SQLite uses fewer bytes on disk, less memory, and spends less time moving content around because there are fewer bytes to move.
branko_d··on Insider trader had all the answers
> hedge funds have historically outperformed the markets

According to Investopedia:

"From January 1994 to June 2023—through both bull and bear markets—the passive S&P 500 Index outperformed every major hedge fund strategy by over 2.8 percentage points in annualized return."

https://www.investopedia.com/articles/03/121003.asp

branko_d··on Apple mobile processors are now made in America by TSMC
The dies themselves are "assembled" - cut from the wafer, bonded to the wires (or solder bumps) that carry signals to the rest of the system, and packaged for physical protection and thermal management.

In recent times, multi-chiplet architecture has added its own layer of complexity to that process.

See also: OSAT.

branko_d··on Intel Solidifies $3.5B Deal to Make Chips for Military
> you're stuck building obsolete parts on an obsolete process.

TSMC's oldest plant still in operation (Fab 2) started production in 1990. So far, the only fab they have closed is Fab 1.

Reference: https://en.wikipedia.org/wiki/List_of_semiconductor_fabricat...

Admittedly, leading-edge process is where all the excitement it, but the old fabs are fully depreciated and can remain profitable for decades.

branko_d··on Zen 5's 2-ahead branch predictor: how a 30 year old idea allows for new tricks
> it's rare for a branch result to be random

How rare, though?

QuickSort has fundamentally unpredictable branches, and it’s a pretty widely used algorithm. Binary search, B-trees also come to mind.

branko_d··on Data Fetching for Single-Page Apps
The original promise of React was:

UI = f(state)

The problems come when you modify state in response to rendering the UI. This seems deceptively natural (and in fact seems encouraged by on-line tutorials), but leads to "spaghetti fetching" when composing components together - it creates a "feedback loop" that modifies state just because some component happens to mount, which can then modify state further, then cause further mounting/fetching etc...

A better approach is to treat fetching as an explicit state change. If user clicks on a button, you do the fetch and modify the state. If that causes some components to be mounted - so be it, but does not cascade any further.

branko_d··on CrowdStrike Update: Windows Bluescreen and Boot Loops
You can’t run a 30 year old driver in Windows, nor a 10 year old in all likelihood.

Microsoft prioritizes userspace compatibility, but their driver models have changed (relatively) frequently.

branko_d··on PostgreSQL and UUID as Primary Key
I'm surprised author didn't mention foreign keys: since primary key is often referenced by foreign keys, then if you have a "fat" PK all your FKs will also be "fat". This can be solved by using the UUID as an alternate key and the regular integer as a primary key in the "top" table, and then referencing that integer from all the "child" tables.

Obviously, this has ramifications for data write perf, but may well be worth it depending on the use case. Technically, you could also make the integer alternate (and leave UUID as primary), but that may not de desirable for clustered / index-organized tables (for DBMSes that support them).

branko_d··on Exploring How Cache Memory Works
Why is the natural alignment of structs equal to the size of their largest member?
branko_d··on Vigorous Exercise, Cognitive Decline, and High Blood Pressure
I’ll hazard a guess: you never liked exercise, even as a kid?

If that’s the case, I’ll hazard another guess: you lived in an environment where you couldn’t just go out and play whenever you wanted?

I might be completely wrong in my guesses, and I apologize if I am. But I strongly believe that all kids are naturally predisposed for physical activity, and it’s the duty of the society to let them do that in an easy and safe way.

branko_d··on Ladybird browser spreads its wings
> As I understand it: Spectre/Meltdown allow reading from the address space of the same process only.

Sorry, this does not make much sense. Why would you need a timing attack to read memory from your own address space? Just a regular code execution exploit should do it.

Here, I found the relevant info (that I was too lazy to find before I posted my first comment, apparently):

https://meltdownattack.com/

> While programs are typically not permitted to read data from other programs, a malicious program can exploit Meltdown and Spectre to get hold of secrets stored in the memory of other running programs.

branko_d··on Ladybird browser spreads its wings
From the linked site:

> In the post-Spectre world you must have site isolation. The JS for a site (roughly, eTLD+1) must have its own OS address space separate from other sites.

Wasn't the whole point of Spectre/Meltdown to read the virtual address space of a different process?

branko_d··on You'll regret using natural keys
The author seems to suggest that the choice is between natural and surrogate key.

In fact, the choice is between natural and natural+surrogate key.

- If you have a natural key, you have to enforce it, otherwise you risk data corruption. The question is do you also need a surrogate key? Sometimes you do, sometimes you don’t.

- If you don’t have an obvious natural key, then your surrogate becomes meaningful. You have to use something to distinguish between two “equal but not identical” rows, so you end-up showing the surrogate in the UI etc. In other words, it is no longer “pure” surrogate.

branko_d··on Us revokes Intel, Qualcomm licenses to sell chips to Huawei
I know about nanoimprint lithography, but it's not a viable alternative for most commercial uses, at least not yet. Maybe one day...
← PreviousPage 5 of 13Next →