HNHacker News
TopNewBestAskShowJobs

gavinhoward

5,314 karma · joined February 16, 2015

Christian, programmer, blogger, in that order.

Blog: https://gavinhoward.com/

Contact: https://gavinhoward.com/contact/

submissionscomments
gavinhoward··on An epic treatise on error models for systems programming languages
Restarts don't always need a debugger or intervention.

A classic case would be restarting memory allocation after failure and after the error handler freed cache memory.

Another case would be retrying to open a file when the process has too many files open already. The error handler may close a few that are not critical, then have the restart fire.

Another case is sending something through TCP. Perhaps you try to send something, and it gives you an error. Unbeknownst to you, the message was already sent, but you wait a second or until other connections do less, then restart and try again, and it succeeds. The other end gets a duplicate, but no matter; it's TCP.

Another case is DNS. Say you need to get the IP address for some URL, and you connect to your first default DNS server. However, it happens to be run by your local incompetent sysadmins, and it happens to be down. Your error handler may choose a different, maybe public, DNS server, like Cloudflare or Google, and then restart.

If you think, 'Oh, well, I could program those in without restarts,' you are correct, but the thing is that doing so couples things.

Take the DNS example: if you put that extra error handling logic in the code that actually tries resolving things, then how do you change error handling when you need to?

Let's make the example even more detailed: perhaps you have a fleet of servers, a whole data center. Most of those servers could use a public DNS if they needed to, but perhaps your head node must NEVER use a public DNS for security reasons. The typical way to implement that would mean having an `if` statement for acting differently based on whatever condition would indicate head node or not. That is coupling the DNS resolution with error handling.

But if you have conditions and restarts, then you simply register a different DNS error handler at startup based on if it's the head node or not. Or the error handler could have the `if` statement instead. Either way would decouple DNS resolution from the error handling.

I hope all of that helps.

gavinhoward··on An epic treatise on error models for systems programming languages
The errors that a procedure can run into are part of its interface. Languages like Zig and Swift make that explicit.

The difference is that callers (even indirect callers) can register handlers to handle those errors without unwinding the stack.

Maybe the error handler makes it return a default value. Maybe it will deallocate a cache to free up memory in a memory-constrained situation. Maybe it purely ignores EOF or a FILE DOES NOT EXIST error where those do not matter.

I also have a special error handler for parsing. If the error is a parse error, it prints the parse error in standard format, with source file, line, etc. Otherwise, it passes the error on to the next error handler in the chain.

This helps me modularize my code by keeping the parse error concerns separate from error handling for everything else.

gavinhoward··on An epic treatise on error models for systems programming languages
No, it is much more powerful.

ON ERROR RESUME NEXT is equivalent to a catch all in a try catch. Conditions and restarts let calling code set up error handlers, and if one of them handles the error, it would be like starting over from the top of the try block.

gavinhoward··on An epic treatise on error models for systems programming languages
I did, but my Gitea instance stopped working. I am trying to replace it.
gavinhoward··on An epic treatise on error models for systems programming languages
I searched for conditions and restarts. I did not find them.

That makes me sad because that is what my systems programming language uses.

For context, conditions and restarts come from the Lisp world. They do not unwind the stack. Instead, they run an error handler on error, and if it handles the error, you have the option of restarting the operation that failed.

I have implemented them in C; they are great for systems programming.

gavinhoward··on It is not a compiler error (2017)
The cause of the GCC one has been found. It was me. Of course.
gavinhoward··on Some Programming Language Ideas
I solved it in mine. I should write a blog post.
gavinhoward··on It is not a compiler error (2017)
The article is right: it is almost never a compiler bug. I have had that experience of reporting and being wrong. It sucks.

On the other hand, I have a confirmed bug in Clang [1] and a non-rejected bug in GCC [2], so it does happen.

[1]: https://github.com/llvm/llvm-project/issues/61133

[2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108448

gavinhoward··on Darcs, Friendly Version Control
> Do you mean that your system will have some built-in collaboration features?

Yes. [1] But that is only chat/discussions.

In the future, Yore might get real-time collaboration like Google Docs, but that depends on it taking off.

> I'm curious to understand if the underlying data structure functionality will be usable as a library.

Yes. [2]

[1]: https://git.yzena.com/Yzena/Yc/src/branch/master/docs/yore/d...

[2]: https://git.yzena.com/Yzena/Yc/src/branch/master/docs/yore/d...

gavinhoward··on 0+0 > 0: C++ thread-local storage performance
No, this is an executable without `-fPIC`.

I am grateful that I only use one multi-call executable (built from a monorepo made partially because of your post, btw) because I think shared libraries in C might have the same sort of problems, just without constructors.

gavinhoward··on 0+0 > 0: C++ thread-local storage performance
I can confirm that C (GCC and Clang) will generate this:

    7e2f0:       f3 0f 1e fa             endbr64
    7e2f4:       64 48 8b 04 25 f8 ff    mov    %fs:0xfffffffffffffff8,%rax
    7e2fb:       ff ff
    7e2fd:       c3                      ret
    7e2fe:       66 90                   xchg   %ax,%ax
But they did not inline the function that does that, even with `__attribute__((always_inline))` and link-time optimization. I need to investigate that.
gavinhoward··on 0+0 > 0: C++ thread-local storage performance
Makes sense.

I want to build a "standard library" for my build system that would stoop to that. I can do that because my build system is not just a task graph executor; it is backed by a full programming language and can add its own libraries to that language. IOW, I can add a `cpp` package to the build system that implements support for how to best build a C++ program.

So if you have a wishlist for that support, I'd love to hear it.

gavinhoward··on 0+0 > 0: C++ thread-local storage performance
Big fan. I wish you could write more. I am gonna go check the assembly of my own code for this. And I am going to integrate funtrace into my workflow.

Question about your build system comment: my build system doesn't stoop to figuring out if `-fPIC` is needed, but it also doesn't add it unless the user asks. Were you talking about that or build systems that add it automatically?

gavinhoward··on “A calculator app? Anyone could make that”
Gavin Howard here.

Yes, GP is entirely correct. I want to do something like the article, but the bc standard (POSIX) requires a decimal BigInteger representation.

I am glad you like my bc!

gavinhoward··on Darcs, Friendly Version Control
They could arbitrarily decide that I am a persona non grata and lock me out.

They claim rights above what FOSS licenses allow, and I do not want that.

I do not want my code to end up in their LLMs. Yes, I have blocked them from my self-hosted forge too.

gavinhoward··on Darcs, Friendly Version Control
Yeah, I don't know why you were downvoted. I upvoted you because I was sure you were replying to me sincerely.
gavinhoward··on Darcs, Friendly Version Control
Mine will allow cloning all data, including issues, PRs, and real-time chats (Zulip-style). I think that might cover your bases.
gavinhoward··on Darcs, Friendly Version Control
You are absolutely right.

To be honest, though, I don't want to even mirror that repo on GitHub. Not doing so means I don't have to agree on their onerous T&C for that code.

I was planning on streaming my work on Twitch once I truly get started. I was hoping that might be a goid place for updates.

gavinhoward··on Darcs, Friendly Version Control
It is not ready yet, sorry!
gavinhoward··on Darcs, Friendly Version Control
I can see your point.

This is a good reminder to me that I need to control my tongue as well; I have said things like the Pijul author did in that thread, and I need to do better.

gavinhoward··on Darcs, Friendly Version Control
If you loved darcs, check out Pijul. They solved the exponential problem with first-class conflicts.

Disclaimer: I am making a competitor to Pijul, but Pijul really is the spiritual successor to darcs.

gavinhoward··on The Sudoku Affair
Ah, cool!
gavinhoward··on The Sudoku Affair
Um, yeah. How do you know the name?

I have never mentioned it by name, I think. Only linked to it occasionally.

Edit: Another reason I am surprised is that Yore became its name only a few months ago.

gavinhoward··on The Sudoku Affair
Interesting. Perhaps that is what I did.

I did do that to design the UX, but for algorithms, I am not so sure. I am really bad at coding competitions, for example.

gavinhoward··on The Sudoku Affair
That is, in fact, what I did.

But then again, you know I was referring to Jeffries' SOP of designing while coding and refactoring incrementally.

gavinhoward··on The Sudoku Affair
As someone who wrote 60 pages of design for a new VCS before writing a single line of code, I appreciate this post.

Design is crucial. The optimal time for that design may be different for different things, but I do know that incremental design can, and often does, fail.

gavinhoward··on Over 90% of U.S. airport towers are understaffed, data shows
I know. Still dumb.
gavinhoward··on Over 90% of U.S. airport towers are understaffed, data shows
ATC-wannabe here.

I can't be ATC anymore because I'm too old. I can't even start. That age limit needs to change.

And yes, more pay.

gavinhoward··on Working with Files Is Hard (2019)
I wonder if, in the Pillai paper, I wonder if they tested the SQLite Rollback option with the default synchronous [1] (`NORMAL`, I believe) or with `EXTRA`. I'm thinking that it was probably the default.

I kinda think, and I could be wrong, that SQLite rollback would not have any vulnerabilities with `synchronous=EXTRA` (and `fullfsync=F_FULLFSYNC` on macOS [2]).

[1]: https://www.sqlite.org/pragma.html#pragma_synchronous

[2]: https://www.sqlite.org/pragma.html#pragma_fullfsync

gavinhoward··on C stdlib isn't threadsafe and even safe Rust didn't save us
Except if there is dymanic linking, I can use that to inject my own setenv and getenv, just like people inject jemalloc or other malloc alternatives.
← PreviousPage 3 of 34Next →