HNHacker News
TopNewBestAskShowJobs

cstrahan

1,132 karma · joined January 10, 2012

Charles Strahan cstrahan.com

Software Developer in Washington, DC

[ my public key: https://keybase.io/cstrahan; my proof: https://keybase.io/cstrahan/sigs/yV0wzDolQldJ9GSMuflLE9_PIggrsCf9jzIQPUHqzKE ]

submissionscomments
cstrahan··on Golang Sync Mutex: Normal and Starvation Mode
> This is untrue right? It can only protect code, not data, right?

Do traffic lights protect the flow of traffic, or do they protect people? It seems reductive to fixate on traffic lights stopping intersecting flows of traffic, when the intent is to ultimately protect people from slamming into (and thus injuring/killing) each other. It may be a tempting counterpoint that traffic lights don't do anything to protect someone from cancer, heart attack, etc -- but that's simply out of the scope of the protection that traffic lights are intended to provide.

Similarly, it seems odd to me to suggest that a mutex protects code -- what is it protecting that code from? How can the code be corrupted, damaged, or otherwise harmed? A mutex does prevent other non-lock-holding threads from running simultaneously, but that's all in service of protecting the data. The data is protected by imposing order on the execution of the code -- by serializing access to that data.

Controlling something isn't the same as protecting that something. A traffic light controls traffic, but it protects the people sharing the road. A mutex controls the execution of code, but it protects data.

cstrahan··on Node.js adds experimental support for TypeScript
> In Haskell land, where the type system is considered sound you have `head` functions of type `List a -> a` that are unsound too, because the list might be empty.

Haskell's `head` not is not an example of the type system being unsound (I stress this point because we've been talking about type system soundness, not something-else-soundness).

From the view of the type system, `head` is perfectly sound: if the list is empty, the resulting value is ⊥ ("bottom"). And ⊥ is an inhabitant of every type. Therefore, `head` returning ⊥ when given an empty list is perfectly fine. When you force ⊥ (i.e. use it any way whatsoever), an exception is thrown. See https://wiki.haskell.org/Bottom

This is very much not the same thing (or remotely analogous) to what we have in my TypeScript example. There, the code fails at runtime when I attempt to call `toLowerCase`, yes; what's worse is the slightly different scenario where we succeed in calling something we shouldn't:

  class Person {
    name: string;
   
    constructor(name: string) {
      this.name = name;
    }
   
    kill() {
      console.log("Killing: " + this.name);
    }
  }
  
  class Murderer extends Person { }
  
  class Innocent extends Person { }
  
  function populatePeopleFromDatabase(people: Array<Innocent | Murderer>): void {
      // imagine this came from a real SQL query
      people.push(new Innocent("Bob"));
  }
  
  
  function populateMurderersFromDatabase(people: Array<Murderer>): void {
      // TODO(Aleck): come back and replace this with a query that only selects murderers.
      //              i wanted to get the rest of the code in place, and this type checks,
      //              so I'll punt on this for now and come back later when I wrap my head
      //              around the proper SQL.
      //              we're not actually using this anywhere just yet, so no biggie ¯\_(ツ)_/¯
      populatePeopleFromDatabase(people);
  }
  
  // ... some time later, Bob comes along and implements the murderer execution logic:
  const murderers: Array<Murderer> = [];
  populateMurderersFromDatabase(murderers);
  // Bob is about to have a really shitty day:
  murderer.forEach((murderer) => murderer.kill());
It is not possible to write an analogous example in Haskell using `head`.
cstrahan··on Node.js adds experimental support for TypeScript
No, TypeScript is not unsound because it uses structural typing.

A language has a sound type system if every well-typed program behaves as defined by the language's semantics during execution.

Go is structurally typed, and yet it is sound: code that successfully type checks is guaranteed to abide the semantics of the language.

TypeScript is unsound because code that type checks does not necessarily abide the semantics of the language:

  function messUpTheArray(arr: Array<string | number>): void {
      arr.push(3);
  }
  
  const strings: Array<string> = ['foo', 'bar'];
  messUpTheArray(strings);
  
  const s: string = strings[2];
  console.log(s.toLowerCase())
`strings` is declared as a `Array<string>`, but TypeScript is happy to insert a `number` into it. This is a contradiction, and an example of unsoundness.

`s` is declared as `string`, but TypeScript is happy to assign a `number` to it. This is a contradiction, and an example of unsoundness.

This code eventually fails at runtime when we try to call `s.toLowerCase()`, as `number` has no such function.

What we're seeing here is that TypeScript will readily accept programs which violate its own rules. Any language that does this, whether nominally typed or structurally typed, is unsound.

cstrahan··on Node.js adds experimental support for TypeScript
> and in that case there's nothing unsound about ts since it won't allow you to do so

Consider this example (https://www.typescriptlang.org/play/?ssl=10&ssc=1&pln=1&pc=1...):

  function messUpTheArray(arr: Array<string | number>): void {
      arr.push(3);
  }
  
  const strings: Array<string> = ['foo', 'bar'];
  messUpTheArray(strings);
  
  const s: string = strings[2];
  console.log(s.toLowerCase())
  
Could you explain how this isn't the type system accepting types "different to what has been declared"? Kinda looks like TypeScript is happy to type check this, despite `s` being a `number` at runtime.
cstrahan··on Java Virtual Threads: A Case Study
As a sibling comment points out, there's nothing in what you quoted that logically implies that blocking I/O is the only reason for a virtual thread to be suspended.

The best info I could find was this blog post:

https://blogs.oracle.com/javamagazine/post/going-inside-java...

"Virtual threads, however, are handled differently than platform threads. None of the existing schedulers for virtual threads uses time slices to preempt virtual threads."

The next handful of paragraphs are also interesting.

cstrahan··on Anti-ageing 'supermodel granny' drug extends life in mice by 25%
We'll be alright:

https://www.forbes.com/sites/michaelshellenberger/2019/07/29...

https://www.newscientist.com/article/mg22029445-000-admit-it...

What value do you get out of believing in Earth Overshoot Day? Does it provide real, actionable utility? Does such a belief instill good feelings?

If I had to guess: it tickles the reward pathways in your brain, connected to your survival instinct to be aware of possible threats, whether real or (as I would argue is the case here) imagined. I would doubt there's anything you plan to personally do about Earth Overshoot Day, and I doubt thinking about it instills positive feelings. It's doom porn.

cstrahan··on Anti-ageing 'supermodel granny' drug extends life in mice by 25%
> Earth is already supporting more people than is sustainable.

By what metric? If it's a matter of available land, there's plenty to go around: open Google Maps, turn on satellite imagery, center the map on Arizona, USA and zoom in. Absolutely nothing but interstate roads and bushes. No buildings, no people, no nothing.

"There are over 11 million blocks in the U.S., and 47 percent of them are uninhabited."

https://www.fastcompany.com/3029826/mapping-all-the-places-i...

Our large, metropolitan cities may be more crowded than sustainable, but Earth != NYC.

cstrahan··on Apple tells over a billion iPhone users to stop using Chrome
> i did find it interesting that 30% of ios users use Chrome. wild!

As someone who used to use Chrome on iOS, it's not that wild to me: the UX of Safari on iOS sucked pretty bad for a long time (up until iOS 16, IIRC). I usually have hundreds of tabs open, and the old Safari UI for viewing all tabs was horrible: it used a skeuomorphic design, simulating a stack of paper. The 3D effect is distracting, and it's also a terrible use of screen real estate; a grid of all open browser tabs/pages is much better for quickly finding what you're looking for. Prior to iOS 16, I used Chrome specifically because the tab overview UI was so much better.

In case anyone has forgotten, the first few seconds of this video shows what the tab overview UI looked like:

https://www.youtube.com/watch?v=mSXJow3LAWA

Strangely, there are people who would like the old iOS Safari UI back, despite it being strictly less usable: https://discussions.apple.com/thread/254384502?sortBy=best

I eventually switched back to Safari when I accidentally realized that Apple had fixed their tab overview UI (and I couldn't get ad blocking to work reliably with Chrome).

cstrahan··on Firing Myself
I can relate to this with my own story, where I managed to delete an entire database — my first day on the job, no less.

I was hired by a little photo development company, doing both walk in jobs and electronic B2B orders. I was brought in to pick up on the maintenance and development of the B2B order placement web service the previous developer had written.

Sadly, the previous dev designed the DB schema and software under the assumption that there would only ever be one business customer. When that ceased to be the case, he decided to simply create another database and spin up another process.

So here I am on my first day, tasked with creating a new empty database to bring on another customer. I used the Microsoft SQL Server admin GUI to generate the DDL from one of the existing tables, created (and switched the connection to) a pristine, new DB, and ran the script.

Little did I know, in the middle of many thousands of lines of SQL, the script switched the connection back to the DB from which the DDL was generated, and then proceeds to drop every single table.

Oops.

Of course, the last dev disabled back ups a couple months before I joined. My one saving grace was that the dev had some strange fixation on logging every single thing that happened in a bunch of XML log files; I managed to quickly write some code to rebuild the state of the DB from those log files.

I was (and am) grateful to my boss for trusting my ability to resolve the problem I had created, and placing as much value as he did in my ownership of the problem.

That was about 16 years ago. One of the best working experiences in my career, and a time of rapid technical growth for myself. I would have missed out on a lot if that had been handled differently.

cstrahan··on gRPC: The Bad Parts
> Protobuf is intentionally designed to NOT require any parsing at all.

As others have mentioned, this is simply not the case, and the VARINT encoding is a trivial counterexample.

It is this required decoding/parsing that (largely) distinguishes protobuf from Google's flatbuffers:

https://github.com/google/flatbuffers

https://flatbuffers.dev/

Cap'n Proto (developed by Kenton Varda, the former Google engineer who, while at Google, re-wrote/refactored Google's protobuf to later open source it as the library we all know today) is another example of zero-copy (de)serialization.

cstrahan··on Aphantasia: I can not picture things in my mind
> How is it not visual?

Perhaps it is. But then you should be able to answer: where is that visualization on disk? And I don't mean the encoding thereof, I mean the actual 2D picture you could glance at and immediately recognize. Not rendered with some image viewing program, but literally looking at the disk/SSD (perhaps under a microscope, if necessary) -- that should be doable, because you're claiming that schemas are inherently visual, and certainly that schema exists on disk somewhere, which in turn implies that those boxes and arrows should be visible on the storage medium.

> Boxes with arrows are clearly visual.

You've changed the topic -- no one is saying that boxes and arrows are not clearly visual. Where are those boxes and arrows sketched into an SSD or in memory? Or, would you assert that a database is schema-less until someone draws up a diagram?

The boxes and arrows image representation of a schema is not the schema itself. See also: https://en.wikipedia.org/wiki/Map%E2%80%93territory_relation

cstrahan··on Gilead shot prevents all HIV cases in trial
Here are some graphs I slapped together with matplotlib: https://imgur.com/a/VSPKtIe

Both graphs are 200mg per week. Green is dosed at once every 7 days, while the blue is broken into 7 smaller doses per week. (I haven't included axis and such, because it's really just the shape I'm trying to highlight)

As you can see, more frequent dosing results in steadier levels.

When administering your testosterone once per week, you will have to make one of a couple trade offs:

1) Dose high enough that you are above the level you want to be by the end of the week. This avoids the "crash" you mention, which will consist of both low-testosterone (low-libido, fatigue, etc) and low-estrogen[1] (joint pain, etc) side effects. Dosing higher means you shift the whole graph up, and you will be at supra-physiological levels of testosterone and estrogen, and the high estrogen side effects are no fun: nipple sensitivity, emotional fluctuations (think crying at the sight of puppy pictures), gynecomastia (development of breast tissue), horrible back acne, etc.

2) Dose on the lower side to avoid avoid high testosterone/estrogen side effects. This shifts the whole graph down, and now you're below where you want to be by the end of the week, and you now feel more like you did before you started TRT.

3) Somewhere between the above two options, and add an aromatase inhibitor (like anastrozole) to minimize high estrogen levels. You'll still have excessively high testosterone though... and you'd really be better off avoiding the high testosterone peaks instead of adding another drug to the mix.

I used to go into a clinic once a week for an intramuscular injection of testosterone cypionate. In order to not feel like shit the last two or three days of the week, I had to up my dose such that my back broke out in a constellation of acne, and probably negatively impacted my health in other more meaningful (but less obvious) ways.

Now I inject testosterone propionate every night. I managed to lower my dose so that I'm always hovering right around where I want to be, instead of bouncing all over the place.

That's another benefit of increased injection frequency: you can lower the total amount of testosterone injected per week while staying within therapeutic range.

1: Your body produces estrogen by aromatising testosterone. More testosterone and/or more aromatase -> higher estrogen. Less testosterone and/or aromatase -> lower estrogen.

cstrahan··on Show HN: Shpool, a Lightweight Tmux Alternative
That gets you scrolling, yes, but not in the same way as without tmux.

Without tmux, your terminal emulator uses its scroll-back buffer to render as you scroll, not requiring any intermediate copies of the lines of text scrolling into view.

With tmux, your terminal emulator no longer handles that, and instead tmux must pass a copy of each line freshly scrolled into view to the terminal emulator, which involves an intermediate copy of that text and re-triggers the terminal emulator’s parsing (as far as your terminal emulator is concerned, it has never seen this line of text yet). All of that (and some other subtle overhead I’m not mentioning here) are completely avoided outside of tmux (or more specifically: whenever the terminal emulator is free to manage its own scroll-back).

cstrahan··on Employees who stay in companies longer than two years get paid 50% less (2014)
In what way does this not match your experience? You’ve mentioned one variable (retention) but not the other (salary increase over time), so your comment as it stands doesn’t refute the claim of the person you’re replying to. Are you implying that you know that these people have received raises year after year that are comparable to the pay increase they could have if they took a new job?
cstrahan··on Amber: Programming language compiled to Bash
You mean this text below "Download for $OS"?

curl -s "https://raw.githubusercontent.com/Ph0enixKM/AmberNative/mast..." | $(echo /bin/bash)

I guess it would be too long to fit (aesthetically) on the page. The "copy" icon off to the left copies that line to your clipboard.

cstrahan··on Fast Tokenizers with StringScanner (2023)
And along these lines, one can use an older copy of the Ragel state machine generator (Ruby was eventually removed, IIRC).

See for example: http://thingsaaronmade.com/blog/a-simple-intro-to-writing-a-...

https://github.com/adrian-thurston/ragel

https://en.m.wikipedia.org/wiki/Ragel

cstrahan··on JavaScript Allongé, the "Six" Edition (2019)
If what you mean by “am I missing anything?” is “am I missing out [if I haven’t/won’t read it]?”, then possibly, yes. The concepts are timeless, and depending on what you already know, you may learn something useful, or at the very least something stimulating.

I read the first edition way back when, and thoroughly enjoyed it.

cstrahan··on Python Cloudflare Workers
How else would you write that? Would this be better?

"Thus, no, we can't just offer full Node."

Is it the use of "so" that is off limits?

Or is simply providing a concise conclusion inappropriate?

I don't see what part of that quote is "snotty".

cstrahan··on Ntex: Powerful, pragmatic, fast framework for composable networking services
I can't speak to the "is it any good" part, but (after a bit of research) I can share what I've found. I'll try to represent things as best as I understand, but I may have some finer details mixed up.

ntex is written by the same person that started actix-web, Nikolay Kim (fafhrd91 on GitHub). There was a bunch of drama a while back due to actix-web using (what many reasoned to be) avoidable unsafe code, which was later found to be buggy. Nikolay was pilloried online, resulting in him transferring leadership of actix-web to someone else. ntex is, as I understand it, essentially Nikolay picking back up on his ideals for what could have been actix-web, if people hadn't pushed him out of his own project.

How ntex compares to the pre-/post-leadership change of actix-web, I don't know.

Here are some jumping points if you want more of the backstory.

https://www.theregister.com/2020/01/21/rust_actix_web_framew...

https://steveklabnik.com/writing/a-sad-day-for-rust

https://github.com/actix/actix-web/issues/1289

https://github.com/fafhrd91/actix-web-postmortem

cstrahan··on Nix is a better Docker image builder than Docker's image builder
The font is a custom build of Iosevka, which is almost certainly inspired by the commercial font Pragmata Pro (https://fsd.it/shop/fonts/pragmatapro/). When Pragmata Pro was first released a little over 10 years ago, it sold for around $400 (I know this because I and many, many others bought a copy back then).

As another commenter points out, you may have some rendering issue. Alternatively, you may just not like the font. Can't please everyone.

cstrahan··on Deleting Software I Wrote Upon Leaving Employment of a Company
> convince management of the value

This presupposes that such convincing is even possible. Many, many companies have leadership that are simply terrible at identifying value. If you've never been part of a majority of developers advocating for, if not outright begging for, some huge ROI initiative to get the green light, you are very fortunate.

There are great counterexamples, like Valve, which is known for giving developers an extreme degree of autonomy, and they benefit greatly from that approach. For each Valve, though, there are dozens of companies that manage to succeed despite themselves.

Take Microsoft, for example. One tiny, yet representative, example: the way the Windows Terminal team handled a suggestion from Casey Muratori to take their software from abysmally slow to lightning fast:

https://github.com/microsoft/terminal/issues/10362

A quote from one of the Terminal developers, dismissing the suggestion:

> I believe what you’re doing is describing something that might be considered an entire doctoral research project in performant terminal emulation as “extremely simple” somewhat combatively…

Just how difficult was such an endeavor in actuality? Well, given that Casey implemented his own terminal emulator from scratch and incorporated the functionality he was proposing in a mere weekend... not a whole lot. Relatively minor effort for a huge return on investment. It took Casey explaining the concepts, then providing a working proof of concept, and finally a bunch of backlash online towards the Terminal team to get them to do the right thing for themselves and their users.

cstrahan··on Class Action Against General Motors LLC, OnStar LLC, LexisNexis Risk Solutions [pdf]
Sure, why not?

This isn't some dichotomy: either collect data behind peoples backs, or have no way to reach out when there are recalls.

An alternative option: provide an easy, obvious way to subscribe to such notifications.

cstrahan··on Pornhub disables website in Texas over objection to age verification law
Hi, Texan here (used to live in Washington, D.C. and N.Y., only moved back here due to health issues about 6 years ago).

I wish your perception was aligned with reality, and I see why you have the perception that you do. For all the talk of freedoms, conservatives quite often love to regulate anything that isn't supported by their understanding of Christian doctrine.

Separation of church and state? You betcha! Wouldn't want spooky non-Christian religious iconography in public areas. But of course, no one would be opposed to a Ten Commandments Monument, so we'll go commission that with tax payer dollars and place it at the state capitol. What's this?! The Satanic Church wants to put a statue of Baphomet there as well? Unacceptable! That's just them being petty, immature pranksters. Your actions are only righteous if we deem them reasonable! We should try our hardest to remove the Baphomet statue while keeping the Ten Commandments Monument, all while trying to keep a straight face despite the hypocrisy.

Not in Texas, but that's actually the kind of bullshit that happens elsewhere in the states: https://en.wikipedia.org/wiki/Statue_of_Baphomet

In Texas you're totally, completely free! I mean, apart from the prohibition of a whole host of victimless actions. We don't like what you're doing and find you icky for doing it; better prepare your legal defense.

The reality is that, despite conservatives' (especially conservative Texans') hypocritical claims to the contrary, both the left and the right LOVE regulation. They just can't agree on which freedoms to strip away.

cstrahan··on JSON Canvas – An open file format for infinite canvas data
YAML is kind of like C++:

> You like C++ because you're only using 20% of it. And that's fine, everyone only uses 20% of C++, the problem is that everyone uses a different 20% :)

https://eli.thegreenplace.net/2009/10/17/the-c-bashing-seaso...

The YAML footguns are too numerous to reproduce here, so here are some sources:

https://stackoverflow.com/questions/3790454/how-do-i-break-a...

https://www.arp242.net/yaml-config.html

https://noyaml.com/

YAML isn't terrible if you only ever have to read what you wrote. Now consider that there are 63 different ways to write multi-line strings in YAML -- how many of those have you committed to memory? Yeah... now throw 10-100 developers into the mix, each with their own favorite alternative syntaxes -- good luck making sense of your YAML.

cstrahan··on The Brotherhood of Morons
> It's easy to say someone is acting stupidly; it's much harder to put yourself in their shoes and understand why they might be acting that way.

This statement presupposes that there is a reason.

Many people simply act completely irrationally, so the only "reason" for their actions that one can come up with is the overly reductive "well, their neurons fired in such a way that resulted in them doing <whatever>".

I suspect avoiding generalities would assist discourse, so here's a concrete example to analyze: consider a senior (maybe even staff level) software developer, trying to write a loop. He writes a bunch of code, runs it (via tests, or executing the software itself), and finds that it doesn't work. So now he he changes the "<" to "<=". Still doesn't work. Now he changes that to ">". Still doesn't work. Now he changes that to ">=". Still doesn't work. Now he thinks "prime numbers are sometimes important, hm...", so he rounds the end of the range to the nearest prime number. Still doesn't work. Now he increments by two, instead of one. Still doesn't work. On a whim, now he changes the numeric type from an integer to a float, though he (of course) couldn't explain why that would change anything (all other things being equal in this scenario, it wouldn't). It still doesn't work. Etc, etc, etc. This sort of pattern continues for the next couple hours until the code happens to work for the scenarios tested (though is still incorrect and will eventually fail in production).

What is the "reason" for this behavior? Or, more importantly, why would someone regularly engage in such behavior? Why, as opposed to reasoning about the code, instead spend hours being superstitious, cargo culting, guess-and-checking, etc? Why never once consider pre-/post-conditions, loop invariants, sketch out a small informal proof by induction, etc?

Yes, some instances of bad decision making are due to unfortunate circumstances (stress, mental health, etc). But there are times where people simply demonstrate that they are, putting it kindly, not competent. That doesn't make them any less deserving of love and care, but they are still (with no negative sentiment or judgement intended) incompetent.

cstrahan··on Fractional scales, fonts and hinting
One of the definitions of "against", taken from Merriam Webster:

> 4 b: in contact with

> "leaning against the wall"

OP's code is "in contact with" the public APIs provided by GTK. That is, OP uses the GTK library.

cstrahan··on FDA clears first over-the-counter continuous glucose monitor
I'm pretty certain you're mistaken here. Diabetes is specifically characterized by elevated blood glucose, either due to pancreas not producing enough insulin or your body becoming descensitized to insulin.

You will find that diabetics often do have low blood sugar, but that's because they overestimate how much insulin they need to inect, causing their blood sugar to go too low. The hypoglycemia in this scenario is not caused by diabetes, but rather a dangerous side effect of the treatment.

OP doesn't have diabetes, and (unless he's abusing insulin for body building purposes) isn't taking insulin. His postprandial hypoglycemia is likely a benign case of "reactive hypoglycemia" (https://www.mayoclinic.org/diseases-conditions/diabetes/expe...).

cstrahan··on Doks – Build a Docs Site
You may want to replace your browser with one that works:

https://imgur.com/a/0IOKXY8

Screenshot taken on Firefox 123.0, on macOS 14.1.

cstrahan··on JEDEC publishes GDDR7 graphics memory standard
You just have to first hack (or maybe even just ask nicely) another suitable species (or their technological artifacts) wherever you want to go, and have them create the biological substrate and download/upload mechanism on their end. This limits travel to already inhabited corners of the universe, but that's better than nothing I suppose.

The tricky thing is that hacking is usually an iterative process, and these iterations are going to be an extreme exercise in patience.

Actually, another tricky thing: how do you know that the other end is actually cooperating? If the aliens are dicks they could give you the thumbs up while having zero intention to reconstitute your consciousness. If you wanted to round-trip some brave soul as a means of verifying everything works, they could just send one of their own minds back instead, just for the fun of wreaking havoc.

cstrahan··on Korea fines Twitch $327k for suspending service
Here's that Cambridge dictionary definition:

> a type of business that is controlled by government rules

And here's the comment that kicked off this sub-thread:

> Often the rules that require things of a company have penalties for non-compliance.

> [...]

> Doesn't mean it is a regulated industry which is actually a very narrow term.

So a regulated industry is a type of business that is controlled by government rules, but (per the aforementioned comment) not all businesses which are controlled by government rules are regulated industries.

So, again, I think the response of

> That’s because restaurants are, believe it or not, also a regulated industry.

is a bizarre blend of unhelpful and rude.

Perhaps you and I will just have to agree to disagree on that point.

← PreviousPage 5 of 17Next →