HNHacker News
TopNewBestAskShowJobs

apaprocki

6,468 karma · joined May 31, 2011

Andrew Paprocki Infrastructure R&D - Bloomberg LP andrew@ishiboo.com

[ my public key: https://keybase.io/ap; my proof: https://keybase.io/ap/sigs/SYtj6sAMdb8hiO4D3m5al83Ak1RBvSEHZzN_9vDftg8 ]

submissionscomments
apaprocki··on Some C habits I employ for the modern day
I’m simply stating how actual Gtk is written:

https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtklabel....

apaprocki··on Jurassic Park - Tablet device on Nedry's desk? (2012)
Completely possible. In the early 90s everyone was buying SGI Indys to run Apache on and put the cool “Powered by SGI” badge on their site. I admin’d a local ISP then and that Indy was on my desk and IRIX was my daily driver. Their UI just felt leagues beyond other commercial Unices of the time, so rather than being plausible, I’d expect it due to the lab/science/dataviz aspect.

edit: Just last night a friend was watching MiB and Tommy Lee Jones looks at a Motif UI. It was obviously SGI but it was IRIS ViewKit and not the later Interactive Development Environment. Narrowed down likely creator being Van Ling from Banned From The Ranch Entertainment. If you’re out there…

apaprocki··on Some C habits I employ for the modern day
Yes, using the same Gtk example, the way you’d forward declare GtkLabel without including gtklabel.h in your header would be:

    struct _GtkLabel;
    typedef struct _GtkLabel GtkLabel;
    // Use GtkLabel* in declarations
apaprocki··on Some C habits I employ for the modern day
`-Wvla` Friends don’t let friends VLA :)
apaprocki··on Some C habits I employ for the modern day
Sure, the parent was commenting more about the capability existing in Ada in contrast to C. Ada variable length local variables are basically C alloca(). The interesting part in Ada is returning variable length types from functions and having them automatically managed via the “secondary stack”, which is a fixed size buffer in embedded/constrained environments. The compiler takes care of most of the dirty work for you.

We mainly use C++, not C, and we do this with polymorphic allocators. This is our main allocator for local stack:

https://bloomberg.github.io/bde-resources/doxygen/bde_api_pr...

… or this for supplying a large external static buffer:

https://bloomberg.github.io/bde-resources/doxygen/bde_api_pr...

apaprocki··on Some C habits I employ for the modern day
You can allocate dynamically on the stack in C as well. Every compiler will give you some form of alloca().
apaprocki··on Some C habits I employ for the modern day
FWIW, Coverity (maybe others) has a checker that creates an error if it detects tagged union access without first checking the tag. It’s not as strict as enforcing which fields belong to which tag values, but it can still be useful. I’d much rather have what was proposed in the GCC bug!
apaprocki··on Some C habits I employ for the modern day
In C++ you would have a protected constructor and related friend utility class to do the parsing, returning any error code, and constructing the thing, populating an optional, shared_ptr, whatever… don’t make constructors fallible.
apaprocki··on Some C habits I employ for the modern day
You can play tricks if you’re willing to compromise on the ABI:

    typedef struct foo_ foo;
    enum { FOO_SIZE = 64 };
    foo *foo_init(void *p, size_t sz);
    void foo_destroy(foo *p);
    #define FOO_ALLOCA() \
      foo_init(alloca(FOO_SIZE), FOO_SIZE)
Implementation (size checks, etc. elided):

    struct foo_ {
        uint32_t magic;
        uint32_t val;
    };
    
    foo *foo_init(void *p, size_t sz) {
        foo *f = (foo *)p;
        f->magic = 1234;
        f->val = 0;
        return f;
    }
Caller:

    foo *f = FOO_ALLOCA();
    // Can’t see inside
    // APIs validate magic
apaprocki··on Some C habits I employ for the modern day
I got the impression the author was implying because CHAR_BIT is enforced to be 8 that uint8_t and char are therefore equivalent, but they are different types with very different rules.

E.g. `char p = (char )&astruct` may violate strict aliasing but `uint8_t p = (uint8_t )&astruct` is guaranteed legal. Then modulo, traps, padding, overflow, promotion, etc.

apaprocki··on Some C habits I employ for the modern day
“modified 2026-01-17T23:20:00Z”

Seems it was cast away

apaprocki··on Some C habits I employ for the modern day
Please don’t buy into “no const”. If you’ve ever worked with a lot of C/C++ code, you really appreciate proper const usage and it’s very obvious if a prototype is written incorrectly because now any callers will have errors. No serious reusable library would expose functions taking char* without proper const usage. You would never be able to pass a C++ string c_str() to such a C function without a const_cast if that were the case. Casting away const is and should be an immediate smell.
apaprocki··on Some C habits I employ for the modern day
> > typedef struct { ... } String

> I avoid doing this. Just use `struct string { ... };'. It makes it clear what you're handling.

Well then imagine if Gtk made you write `struct GtkLabel`, etc. and you saw hundreds of `struct` on the screen taking up space in heavy UI code. Sometimes abstractions are worthwhile.

apaprocki··on Ask HN: COBOL devs, how are AI coding affecting your work?
A quick search finds many COBOL checkers. I’d be very surprised if a modern model was not able to fix its own mistakes if connected to a checker tool. Yes, it may not be able to one shot it perfectly, but if it can quickly call a tool once and it “works”, does it really matter much in the end? (Maybe it matters from a cost perspective, but I’m just referring to it solving the problem you asked it to solve.)

Clearly it isn’t just “broken” for everyone, “Claude Code modernizes a legacy COBOL codebase”, from Anthropic:

https://youtu.be/OwMu0pyYZBc

apaprocki··on Ask HN: COBOL devs, how are AI coding affecting your work?
To be fair, I would not expect a model to output perfectly formatted C++. I’d let it output whatever it wants and then run it through clang-format, similar to a human. Even the best humans that have the formatting rules in their head will miss a few things here or there.

If there are 40 years of undocumented business quirks, document them and then re-evaluate. A human new to the codebase would fail under the same conditions.

apaprocki··on Ford F-150 Lightning outsold the Cybertruck and was then canceled for poor sales
My anecdata feeling from all the Tesla owners I know is that they stole customers wanting affordable, repairable, etc. from Japanese manufacturers and they stole customers who were luxury car buyers (Ford, GM, etc. weren’t even competitors) willing to forego some luxury for the EV.
apaprocki··on Chase to become new issuer of Apple Card
Funny you mention that. I did open a joint Chase account back when I was getting married and first order of business was paying for all the wedding expenses. We went to QR, Mexico for a weekend getaway prior to the madness and because I logged into the Chase account from Mexico they not only locked the bank account, but completely closed it with no way to reopen. We had to both go to the Chase branch at which it was opened with passports and even then the manager said Chase would mail me the money in 3-6 weeks, 2-5 weeks after the wedding. I politely told him I was not leaving the building until he handed me the cash in an envelope and after some time he finally caved and did it after making some phone calls.

Most bizarre experience. Never had a bank account with Chase ever again after that incident.

apaprocki··on Kernel bugs hide for 2 years on average. Some hide for 20
> Furthermore, the 19-year-old bug case study is a refcounting error

It always surprised me how the top-of-the line analyzers, whether commercial or OSS, never really implemented C-style reference count checking. Maybe someone out there has written something that works well, but I haven’t seen it.

apaprocki··on Chase to become new issuer of Apple Card
I had thousands of dollars of charges I didn’t make (but billed electronically via Apple as if my card was attached to someone else’s iCloud account) appear, exceeding my limit and locking my entire family out of the shared Apple subscriptions (e.g. no music on their devices but strangely music on mine). GS could remotely lock your Apple account at will it seemed.

Called, charges reversed, 1 month later they were all reinstated, no reason. Called, charges reversed again, 1 month later they were all reinstated and my Apple Card was cancelled by GS. Since I still had it linked as my payment method w Apple this again locked my whole family out of subscriptions. GS gave no explanation for why the account was closed, but it was after they reversed the charges a second time. Balance was $0, account closed, no recourse. Then 1 month later all the reversed charges were reinstated and on the now locked account and I had no recourse but to pay GS’s ransom because it was a closed account that would be reported if I didn’t pay.

I have CCs from a number of banks and it was by far the most ridiculous consumer experience. No wonder GS wants to exit the consumer market because they are terrible at it. Chase is better, but it’s no AmEx. Sad that it’s not AmEx.

Now I’m wondering if I can get a new account under Chase because I’m definitely never calling GS again.

apaprocki··on Memory Integrity Enforcement
Whether you like it or not, we are in an echo chamber. We will all benefit more rapidly once we figure out how to explain to an everyday Joe Blow why this technology is necessary in their daily life to get them hyped to upgrade their cracked XR/XS/11 barely hanging onto life support.
apaprocki··on The 16-year odyssey it took to emulate the Pioneer LaserActive
Dual-layer DVDs didn’t come out until later. Long movies on single-layer (or those whose producers were too lazy to optimize compression or use dual-layer) DVD had to be flipped mid-movie as well.
apaprocki··on Using information theory to solve Mastermind
Similarly, I explained to someone how to systematically solve it like this, but then when I suggested they now apply it in a new game, I chose all the same color for the code and watched them second guess themselves until all guesses were exhausted. They just couldn’t accept the possibility that the code could simply be all the same color. Was a good opportunity to quote Sherlock Holmes.
apaprocki··on Tor: How a military project became a lifeline for privacy
AWS offers all the regions I’d care about, but I do concede many-exit scenarios are not what I was referring to. I’ve been more than satisfied with my personal use, but have never required that feature.
apaprocki··on Tor: How a military project became a lifeline for privacy
Yes if you need many-exit, DIY is going to be more painful. I’ll disagree about the trust point, though. It’s about relationships. I want as few corporate relationships as possible. If I already deal with Amazon and AWS and I can get this additional service from them, I will gladly do it over starting a new corporate relationship (iff my trust is never violated, in which case I will then rehome everything).
apaprocki··on GitHub is no longer independent at Microsoft after CEO resignation
Anecdata, 10k+ Eng department, it’s all GSuite. Office365 exists as well for external interop but I’ve never seen anyone reach for it due to preference since it existed.
apaprocki··on Tor: How a military project became a lifeline for privacy
Worth mentioning a $5 cloud instance and installing Algo VPN on it gets you the same thing without having to trust a 3rd party VPN provider (only a generic VM provider such as AWS). It’s always worth minimizing companies you deal with if you already use AWS, GCP, etc.
apaprocki··on Fast
It’s hilarious to me that I find this thread. I read the comment you’re replying to before I saw who wrote it. I exclusively read HN on iOS using https://hackerweb.app/ in dark mode precisely because I found it to be the most pleasing mobile experience. And here’s dang replying to my co-worker who commented that he wrote his own HN reader because the actual site isn’t the best on mobile. I could literally reach out my hand, show my phone and share my mobile HN experience with him, except I’m 99% remote. (But I did sit at his desk just last Thursday when he was remote.)

Just goes to show that all of us reading HN don’t actually share with each other how we’re reading HN :)

Too funny… thank you!!

apaprocki··on HathiTrust Digital Library – books online
I would use this site all the time for genealogy purposes. It’s hard to unravel how the datasets are shared, because many things here are from Google’s scanning, but IMO there are lots of things that do not appear anywhere else.
apaprocki··on Show HN: Refine – A Local Alternative to Grammarly
I do not think you should ever feel that way. If any English-speaking listener has an issue with another speaking the dialect of English they were raised with, the listener has an issue with themselves they need to work through.

As an American English speaker, I have in the past used UK spellings when communicating at work with a group that I know only contains British English recipients. There is nothing wrong with that -- anything that makes communication more fluid should be welcome.

I believe the arrogance angle exists in a situation where an American English speaker with no British English education is using British spellings when communicating with other _American English_ speakers to purposefully create an air of superiority. If you do this, even if no one says anything, they definitely notice.

For other English dialects, my personal take is that most Americans (at least the ones who travel or interact with foreigners personally or at work) will assume they either are or are heavily influenced by British English due to history.

apaprocki··on Show HN: Refine – A Local Alternative to Grammarly
My experience with a large multi-thousand Eng department where the majority are in the US or UK: US-based or influenced employees will write usually with American English spellings and continue to do so even if based in the UK. UK-based or influenced employees will write with British English spellings and continue to do so if based in the US. No one conforms to the other and everyone can understand each other perfectly fine because the spelling of these words does not matter for comprehension. This applies to writing as well as words in code or API names.
← PreviousPage 2 of 34Next →