Live data from Hacker News

Code is run more than read

olano.dev

111–120 of 325 posts

Re: Code is run more than read

#111
post #87

I think the corollary to the title (to turn it around on the author) is not 'Code is read more than written' but 'code that can't be read won't run for long'. Disclaimer: Experienced sysadmin trying to make a lateral move to development and as such a complete noob.

> code that can't be read won't run for long

There's plenty of ossified code people are scared to touch because they don't understand it, but stake their business on it :)

Re: Code is run more than read

#112
post #93

Earlier quoted context omitted.

The infinite sum of powers of 2 indeed diverges in the real numbers. However, in the 2-adic numbers, it does actually equal -1. https://en.wikipedia.org/wiki/P-adic_number

Eh, P-adic numbers basically write the digits backwards, so "-1" has very little relation to a normal -1.

-1 means that when you add 1, you get 0. And the 2-adic number …11111 has this property.

Re: Code is run more than read

#113
post #87

I think the corollary to the title (to turn it around on the author) is not 'Code is read more than written' but 'code that can't be read won't run for long'. Disclaimer: Experienced sysadmin trying to make a lateral move to development and as such a complete noob.

Proprietary software you don't have sources for (say e.g. a third-party library), or just about any black-box system, are counterexamples to your corollary.

Re: Code is run more than read

#114
post #78
post #26

Earlier quoted context omitted.

That would be nice, but people keep hiring based upon specific programming languages and other programming specific skills.

You usually don't want work companies that do resume matching.

That is indeed true, but there is sometimes a mismatch in how a team hires versus how it actually works and performs. So sometimes, there are some missed opportunities to work in interesting places or fields just because their hiring process is uninspired.

Re: Code is run more than read

#115
post #33

TIL of ≹, which "articulates a relationship where neither of the two compared entities is greater or lesser than the other, yet they aren't necessarily equal either. This nuanced distinction is essential in areas where there are different ways to compare entities that aren't strictly numerical." ( https://www.mathematics-monster.com/symbols/Neither-Greater-... )

Likewise, TIL. In your link however it states "Example 1: Numerical Context Let's consider two real numbers, a and b. If a is neither greater than nor less than b, but they aren't explicitly equal, the relationship is ≹" How can that be possible?

Hmm, what about +0 and -0?

Re: Code is run more than read

#116
post #8

For many of us, running our code 1 billion times will cost less than a few minutes of a developer's time. Hell, I could spend $200 for a month of server time on AWS and run a lot of my (web API) code 100 billion times. Optimizing for human readers is always better until you're working on something that proves itself to be too slow to be economical anymore.

The problem with "costs less than developer's time" math is that, usually, it's not you who's paying. Your users are, often in nonobvious ways, such as through higher electricity bills, reduced lifespan[0], lost opportunities, increased frustration, and more frequent hardware upgrades.

(And most of your users don't have developer's salary, or developer's quality of life, so it hurts them that many times more.)

--

[0] - Yes, wasting someone's time reduces QALY.

Re: Code is run more than read

#117

Earlier quoted context omitted.

Likewise, TIL. In your link however it states "Example 1: Numerical Context Let's consider two real numbers, a and b. If a is neither greater than nor less than b, but they aren't explicitly equal, the relationship is ≹" How can that be possible?

That doesn't seem possible with the reals. An example from programming that comes to mind is NaN ≹ NaN (in some languages).

Isn't this what happens with infs (in maths and in many programming languages)?

Edit: Not in many programming languages. In IEEE-754 inf == inf. In SymPy too oo == oo, although it's a bit controversial. Feels sketchy.

Re: Code is run more than read

#118
post #57

Earlier quoted context omitted.

Yeah, that's right. I just feel that latency is sometimes missing from the discussions re. developer efficiency vs paying more for compute.

Yep. Theres a huge experiential difference between something happening instantly and it happening in 200ms or so. Especially when typing or playing video games.

It's everywhere. Next day delivery vs in a week. Streaming vs DVD rental. CI jobs. Notification about relevant news for stock traders. Switching files in editor. Jump to definition in IDE. Typing and videogames you mention have a very tight latency budget.

If you don't fit in the budget for the specific task, your product features don't matter much.

Re: Code is run more than read

#119
Kind of funny, but I have seen code that is indeed read more than is run, at least for the first year or two of its existence. Code that is used for generating batch reports for some billing process would run once a month. But I had to spend a lot of time staring at it, wondering what is going on, and fixing things up as reports came in.

One could say that the test runs were run more than the code was read (of course), but in production? Definitely the same order of magnitude for a long time.

Re: Code is run more than read

#120
post #8

For many of us, running our code 1 billion times will cost less than a few minutes of a developer's time. Hell, I could spend $200 for a month of server time on AWS and run a lot of my (web API) code 100 billion times. Optimizing for human readers is always better until you're working on something that proves itself to be too slow to be economical anymore.

That's the response to the article I was expecting to read. This is a different article, though. Go ahead and read it, worth it!
Post reply on HN