HNHacker News
TopNewBestAskShowJobs

david2ndaccount

1,153 karma · joined February 28, 2020

blog: https://www.davidpriver.com
submissionscomments
david2ndaccount··on Don't return named tuples in new APIs
You can have methods with NamedTuple
david2ndaccount··on Type-erased generic functions for C: A modest non-proposal
I wrote a blogpost describing this technique. https://www.davidpriver.com/ctemplates.html
david2ndaccount··on The 4-chan Go programmer
Somewhat a reference to https://wiki.c2.com/?ThreeStarProgrammer
david2ndaccount··on Tony Hawk's Pro Strcpy
Only msvc provides strcpy_s and they don’t conform to the standard. Other libcs don’t provide it. Ignore everything from Annex K and write your own wrappers around memcpy. You should always know the size of your buffers.
david2ndaccount··on Tony Hawk's Pro Strcpy
Use memcpy and do the size check yourself beforehand (taking the appropriate action if it doesn’t fit). Avoid any function starting with str except for strlen. Prefer pointer+length instead of relying on nul-terminated strings.
david2ndaccount··on Tony Hawk's Pro Strcpy
The correct thing to do is to use memcpy and to know the size of both the destination buffer and the source buffer. If the source buffer won’t fit, then you need to take an application-specific action (is truncation ok? do you have to abort the whole operation? Do you re-alloc the destination buffer? etc.) strncpy almost always does the wrong thing.
david2ndaccount··on Porffor: A from-scratch experimental ahead-of-time JS engine
With a string literal it works, with a dynamic string it just gives an undefined reference error to eval.
david2ndaccount··on C Macro Reflection in Zig
I wrote a blogpost showing how you could do a similar thing in D with ImportC.

https://www.davidpriver.com/C-macro-reflection-in-D.html

david2ndaccount··on How Conditional Breakpoints Work
Are there any compilers that insert nops between real instructions in debug builds to allow inserting a jump to code to evaluate the expression? Conditional breakpoints are so slow it’s usually faster to add an if with the condition and recompile.
david2ndaccount··on Reasons to use your shell's job control
If a program is not responding to ctrl-c, sometimes ctrl-\ (which sends sigquit instead of sigint) can kill it.
david2ndaccount··on Code reviews do find bugs
In my experience, code reviews catch a lot of bugs. However, if you find yourself catching the same kind of bugs over and over again in review you should be finding ways to catch them automatically without involving a reviewer (static analysis, tests, linters, etc.)
david2ndaccount··on Microfeatures I love in blogs and personal websites
Feels like many of these features should just be built into the browser. Why can’t the browser assemble a table of contents based on header hierarchy? Isn’t that the point of the number in h1-h6? Why aren’t elements with ids easy to link to by default? Add a “copy-link-to” to the standard context menu in the browser. Etc.
david2ndaccount··on Work begins on a $12B high-speed rail line between Las Vegas and Los Angeles
You could expand the number of lanes on I15 (like it is on the Nevada side) for a small fraction of what this project would cost.
david2ndaccount··on If Inheritance is so bad, why does everyone use it?
Python also has protocols: https://typing.readthedocs.io/en/latest/spec/protocol.html#p...
david2ndaccount··on Alexei Navalny has died
Ukraine is not part of NATO, so how has push come to shove?
david2ndaccount··on Physical cash is dying–and you don't need to be a conspiracist to worry
The issues with physical currency are almost entirely self-inflicted. Governments should retire the smallest denominations and introduce larger coins/bills. In the US, all of the coins are worth so little that the only practical coin is the rare half-dollar. Retire all of those worthless coins, require transactions be rounded to the nearest half-dollar or dollar, and issues with physical currency for the user will go away.

Now of course, the government won’t do this as they want physical currency to be inconvenient so they can track you and deny you access to your own money when they find it convenient. We’re in an era of growing authoritarianism. Hopefully we survive this one.

david2ndaccount··on Why Zig When There Is Already C++, D, and Rust?
Since you’re updating it anyway, the very first example says "D has @property functions, which are methods that you call with what looks like field access, so in the above example, c.d might call a function.”

It is true that `c.d` might call a function, but it’s not because of @property functions (which exist but are discouraged), it’s because the parens are optional to call a function/method if there are no arguments.

david2ndaccount··on Memory leak proof every C program
This is not thread safe.
david2ndaccount··on Hasbro laying off Wizards of the Coast staff is baffling
I regret to inform you that was released in 2014, almost a decade ago.
david2ndaccount··on E3 Is Officially Dead
I found my interest in video games died when I started working. Whatever button in my brain video games were pushing is now being pushed by the day job and I get paid for it.
david2ndaccount··on Compiler Options Hardening Guide for C and C++
Indeed, -Werror doesn’t make sense, but specifying specific errors (like -Werror=return-type to prevent forgetting to return a value from a function) is very, very necessary.
david2ndaccount··on Why does unsafe multithreaded std:unordered_map crash more than std:map?
Tsan doesn’t understand mach semaphores unfortunately.
david2ndaccount··on If you plant milkweed, they will come
Make sure you plant native milkweed. The exotic kind is not good for the butterflies.
david2ndaccount··on Toyota Prius on LA Craigslist Has a Catalytic Converter Cage Like a Prison
I don’t know why you’d want to live in the LA area and not own a car. One of the things that is actually nice about southern california is the ease with which you can go to the beaches, the mountains and other beautiful places and realistically you need a car to do these things. You don’t have to drive at rush hour.
david2ndaccount··on The Ruff Formatter: A fast, Black-compatible Python formatter
If your team is full of adults, you just pick a formatter tool at the beginning of the project, add it to your pre-commit hook and then never think about it again.
david2ndaccount··on Advent of Code 2023's new AI/LLM Policy
Leaderboard will be dominated by AI-assisted speed runners this year. I think I’ll just solve them in the morning this year instead of trying to get on the leaderboard (I can usually get in the top 100 on the trickier ones). Will be better for my sleep anyway.
david2ndaccount··on Trying out C++20's modules with Clang and Make
I do not expect standardization of features that do not exist.
david2ndaccount··on Trying out C++20's modules with Clang and Make
This works for C, but not C++. And for C, it’s not that hard to do by hand so no one else bothers.
david2ndaccount··on Trying out C++20's modules with Clang and Make
The ISO committee should not be in the business of inventing language features out of whole cloth. That is not how “standardization” works. They should only standardize existing practice.
david2ndaccount··on Show HN: I built a virtual tabletop for playing Dungeons and Dragons
The dungeon itself is the game/puzzle/challenge that the players are trying to overcome, either for the default goal of finding its treasure or for a specific goal like find a specific macguffin or other target. In this mode, the players trade their resources to overcome challenges and if you can achieve your goal without fighting or expending resources at all, the more the players are able to achieve. The default is not to fight every monster you encounter but to decide if you need to engage to achieve your goal. Random encounters are a way for the dungeon to fight back against the players and to put a clock on them - the longer they take to explore the dungeon or the less efficient they are in their exploration, the more they will have to deal with encounters that are unlikely to have any treasure at all.

It’s a very complex and interesting game to play. Unfortunately newer editions have gutted this gameplay by removing xp for gold (thus removing the default goal of most dungeons) and removing all of the procedural dungeon crawling rules. The tabletop form is still superior to CRPGs as your ability to interact with the world itself and overcome challenges in interesting ways is only limited by your imagination and ability to creatively apply the tools available to your character.

← PreviousPage 2 of 10Next →