Live data from Hacker News

Programmers should never trust anyone, not even themselves

carbon-steel.github.io

11–20 of 163 posts

Re: Programmers should never trust anyone, not even themselves

#11
post #9

> Failing tests indicate the presence of bugs, but passing tests do not promise their absence. If only :) Far too often I find myself working with tests that patch one too many implementation details, putting me in a refactoring pickle

Or even worse, tests that test implementation details that doesn't matter for the actual outcome.

Re: Programmers should never trust anyone, not even themselves

#12
post #11
post #9

> Failing tests indicate the presence of bugs, but passing tests do not promise their absence. If only :) Far too often I find myself working with tests that patch one too many implementation details, putting me in a refactoring pickle

Or even worse, tests that test implementation details that doesn't matter for the actual outcome.

If I had a dollar for each frontend test that actually don't actually test anything I would be able to retire by now!

Re: Programmers should never trust anyone, not even themselves

#13
post #8
post #7

Earlier quoted context omitted.

trust but verify translates to trust no one but don't be a dick about it

To me, it's rather a postcondition instead of precondition. Trust that a person will do the right thing, but verify that the right thing has actually been done.

Which is a contradiction, because trusting someone means not needing to verify what they say or do.

Re: Programmers should never trust anyone, not even themselves

#15
After many years, I settled on a constraint based design philosophy:

1. type checking, data marshaling, sanity checks, and object signatures

2. user rate-limits and quota enforcement for access, actions, and API interfaces

3. expected runtime limit-check with watchdog timers (every thread has a time limit check, and failure mode handler)

4. controlled runtime periodic restarts (prevents slow leaks from shared libs, or python pinning all your cores because reasons etc.)

5. regression testing boundary conditions becomes the system auditor post-deployment

6. disable multi-core support in favor of n core-bound instances of programs consuming the same queue/channel (there is a long explanation why this makes sense for our use-cases)

7. Documentation is often out of date, but if the v.r.x.y API is still permuting on x or y than avoid the project like old fish left in the hot sun. Bloat is one thing, but chaotic interfaces are a huge warning sign to avoid the chaos.

8. The "small modular programs that do one thing well" advice from the *nix crowd also makes absolute sense for large infrastructure. Sure a monolith will be easier in the beginning, but no one person can keep track of millions of lines of commits.

9. Never trust the user (including yourself), and automate as much as possible.

10. "Dead man's switch" that temporarily locks interfaces if certain rules are violated (i.e. host health, code health, or unexpected reboot in a colo.)

As a side note, assuming one could cover the ecosystem of library changes in a large monolith is silly.

Good code in my opinion, is something so reliable you don't have to touch it again for 5 years. Such designs should not require human maintenance to remain operational.

There is a strange beauty in simple efficient designs. Rather than staring at something that obviously forgot its original purpose:

https://en.wikipedia.org/wiki/File:Giant_Knife_1.jpg

https://en.wikipedia.org/wiki/Second-system_effect

Good luck, and have a wonderful day =3

Re: Programmers should never trust anyone, not even themselves

#16
> verifying code correctness is impossible

Somehow, taking into account the state of our industry, yes. But this is not an absolute truth.

I mean, we do have the theoretical frameworks and even tools to come with solutions that allow to proof that code is correct. It’s just that mapping this "know how" with the "how to deal with the expected flow rate feature" is very uncommon.

Re: Programmers should never trust anyone, not even themselves

#17

> In reality, the bank does not just store the money we deposit. It loans away/invests most of the money that people deposit. Our money does not sit idle in a large pile in a vault. Nope. In reality the money doesn't exist. Amazing how many people think that somewhere a cartload of money is physically moving every month when they get paid. When was the last time you deposited anything in a bank? The abstraction is ev…

Agreed. But a bank failing doesn’t mean the financial system would be down though. We need to get rid of bad apples. Free banking

Re: Programmers should never trust anyone, not even themselves

#18

> In reality, the bank does not just store the money we deposit. It loans away/invests most of the money that people deposit. Our money does not sit idle in a large pile in a vault. Nope. In reality the money doesn't exist. Amazing how many people think that somewhere a cartload of money is physically moving every month when they get paid. When was the last time you deposited anything in a bank? The abstraction is ev…

I don't think the author was under the impression that banks physically store money. They meant the digital currency does not sit idle on the bank's asset list. They're just using normal human language.

Re: Programmers should never trust anyone, not even themselves

#19

> verifying code correctness is impossible Somehow, taking into account the state of our industry, yes. But this is not an absolute truth. I mean, we do have the theoretical frameworks and even tools to come with solutions that allow to proof that code is correct. It’s just that mapping this "know how" with the "how to deal with the expected flow rate feature" is very uncommon.

It is an absolute truth in the sense that it is true for all code that was not specifically written to be formally proven correct. So, given an arbitrary piece of code, it's impossible to verify it (because of the halting problem).

Re: Programmers should never trust anyone, not even themselves

#20
post #4

>> Random access of a character in a text buffer could take constant time (for ASCII) or linear time (for UTF-8) depending on the character encoding This is true, but incomplete. All unicode encodings take linear time, not just utf-8. That's because a character can contain multiple code points. Utf-32 allows for random access of code points in constant time, but not characters. Utf-16 has variable length code points…

IMO within a small range iterating isn't too painful.

It's probably safe, maybe even close enough to optimal for typical use, to have an array or list of bytestrings for each line. Or maybe more complex Line (of text) objects that record the byte-length, 'codepoint'-length, and '(display)character'-length. There might even be special cases built in for typical and massive documents (number of lines) and overly long lines.

Post reply on HN