HNHacker News
TopNewBestAskShowJobs

alexdowad

432 karma · joined February 27, 2013

My blog: https://alexdowad.github.io
submissionscomments
alexdowad··on Fair coins tend to land on the same side they started
Take a game show host who lets you choose a door, randomly reveals what is behind one other door, and then gives you an opportunity to change your choice. This game show host CAN (randomly) reveal the prize; he has equal probability of revealing ANY of the unchosen doors.

Say you are playing the Monty Hall game with this host. You choose your door, he opens another door, and it happens (purely by chance) that there is no prize there. Do you still believe that you have a 2/3 chance of winning if you switch to the other unopened door?

alexdowad··on Fair coins tend to land on the same side they started
That's absolutely right; further, if you explicitly model the behavior of the game show host, you can exhibit models under which "it's better to switch" and models under which "it doesn't matter if you switch or not".
alexdowad··on Thoughts about what worked in math circles
Did you get that phrase backwards? It's hard for me to see how [2] could be interpreted as being about "physicists with a contempt for mathematics"; it's actually about mathematicians with a contempt for physics.

Vladimir Arnold was a well-known pure mathematician with a deep interest in physics. If you read his math books (many of them are good), he constantly uses examples from physics to explain math concepts.

alexdowad··on Tell HN: Stripe killed my music locker service, so I'm open sourcing it
Well, maybe they don't use Stripe for payment processing?
alexdowad··on Merging bcachefs
I have had single-drive btrfs filesystems lock up on me twice; i.e. file manipulation commands like `ls` freeze and "take forever". In both cases, there was a hardware failure of the drive. I believe that the frozen processes went into uninterruptible sleep (so they couldn't be killed).

It is totally understandable that if the underlying driver starts returning errors, btrfs (or any other filesystem) may be unable to provide access to my data; but I was not at all happy about having to reboot the entire machine.

(I must admit, it is possible that the "freezing" was happening in underlying block device driver code and not in btrfs. I don't remember if I ever checked wchan to see which it was. My impression from reading dmesg output was the issue seemed to be with btrfs.)

I did once have a similar experience with ZFS as well. Sigh.

alexdowad··on Logic programming is overrated, at least for logic puzzles (2013)
In the comments, swannodette promised a response blog post to this one. Here it is: https://swannodette.github.io/2013/03/09/logic-programming-i...
alexdowad··on Ask HN: How to return to programming by helping a friend with a web portal?
A couple thoughts based on my own 25 years of building software:

• Working with many new tools and technologies on the same project is dangerous. There is a significant risk of running into too many unexpected issues with your tools, getting mired down, and never finishing. It is usually better to work mostly with technologies you already know well, and just add 1 or 2 new ones on a single project.

• You asked if you need to look into Cloudflare workers. In general, choosing a hosted 'cloud' platform means your friend will not have to keep hiring contractors down the road to administer a server on his behalf. At the same time, it means that his fortunes will be tied to those of the company which provides the platform. If they are acquired and the platform is shut down, or prices are jacked up, etc. it may be difficult to move the site to a different hosting provider, and your friend will be in an undesirable position. You can do your friend a great service by helping him to navigate those trade-offs in the way which makes most sense for his business.

alexdowad··on GPT is all you need for the back end
Awesome stuff! I love it!
alexdowad··on GPT is all you need for the back end
This is hilarious. I would love to see a transcript of sample API calls and responses. Can anyone post one? Perhaps even contribute one to the project via GH PR?
alexdowad··on Logging practices I follow
Nice! It sounds like you would do well to capture the debug output if a request handler takes an unusually long time to return (not just if an uncaught exception occurs).
alexdowad··on Logging practices I follow
Good point! Log levels are pretty useless most of the time.

I would add that there can be value in having 2 log levels: verbose and non-verbose. It is helpful if you can selectively switch on verbose logging by user or by API endpoint.

In one application which I maintain, when verbose logging is switched on for a particular user, TCP/UDP socket objects are automatically wrapped and packet captures are logged, only for packets sent/received while servicing that particular user's requests. This has been a lifesaver when debugging things like weird, transient authentication problems stemming from upstream providers.

alexdowad··on I prefer semi-automation
What browser do you use? How do you create shortcuts which can be accessed by typing in the address bar?
alexdowad··on Ask HN: How does a hobby programmer get hired?
This is what I did. Started with one small contract job on Upwork at a modest hourly rate. Then I raised my rate a bit for the 2nd contract, raised it a bit more for the 3rd contract, and so forth. In the process of doing these contract jobs, I got to know people, they introduced me to other people, and soon I had all the work I needed at a rate I was happy with.
alexdowad··on Ask HN: Math books you recommend just for the way they are written?
The Art of Probability by Richard Hamming.
alexdowad··on Ask HN: Readings to more deeply understand JavaScript?
If you want to know JS deeply, I think reading the EcmaScript language specification is a very good step. I've read through it before; it's quite long but not overly difficult reading.

Studying the source code for a JS implementation is also a good step. QuickJS is a good one.

alexdowad··on Outdated vs. Complete: In defense of apps that don’t need updates
Re-reading the comment as a whole might help to correct this "strawman" interpretation, but anyways, here is some clarification:

In today's world of software development, many take it as given that every software library should receive periodic updates, and that a library which has not been recently updated is in some sense "dead" and should not be used.

This is logical in cases where the domain is itself constantly changing. For example, software packages which calculate the results of income tax returns must be updated yearly, because the tax laws change. Similarly, packages which perform time zone calculations must be periodically updated, because the time zone rules change.

However, a vast number of software libraries operate in domains which are not inherently subject to change. As an arbitrary example, imagine a hypothetical library which performs symbolic differentiation and integration. Since the rules for how to integrate a function do not change, once thoroughly tested and debugged, there is no reason why such a library could not be used unaltered for decades. Yes, it might not benefit from the development of more efficient algorithms; but if the library was already more than fast enough for a certain application, that might not matter.

While software is different from other things created by humans, the existence of creative works such as books or musical compositions, which often survive for decades or centuries despite not receiving regular updates, provides an illustration of what can and should be possible for software as well. Note, this is an illustration and not an argument.

alexdowad··on Outdated vs. Complete: In defense of apps that don’t need updates
> What happens if the project is abandoned after you chose to rely on it?

If the project already had the features you need, was thoroughly tested and debugged, and was built with almost no dependencies (only relying on a small number of very stable platform APIs), then it might not matter even if it was already abandoned when you started using it.

Case in point: On a recent software project, I took dependencies on two Lua libraries which were already abandoned. Their source code was short and readable enough that I had no problem going through it to understand how they worked. In one case, I added an important feature (support for a different type of PostgreSQL authentication to a Postgres client library). I also packaged both libraries for my Linux distro of choice and submitted them to the official package repositories. If anyone reports bugs against the version which I packaged, I'll fix them, but it seems unlikely that many bugs will ever be found.

As the OP rightly pointed out, the expectation that software libraries should normally need to be constantly updated is ridiculous. Many other things invented by humans stay in use for decades with no alterations. Beethoven's 5th symphony hasn't had any updates in more than 200 years.

alexdowad··on Ask HN: Can I see your scripts?
Try 'strace git blah', it will be educational.
alexdowad··on Ask HN: Why am I always stuck working on legacy software
There is a huge amount of "legacy" software out there and a huge amount of software dev work involves maintaining it.

This is as it should be. It means that the software which people have already created is working and generating value. It's not necessary or desirable that as an industry, we should keep making new things non-stop.

Maybe you really want to be one of the people doing "greenfield" work. If that is really important to you, start looking around and see what other work opportunities are available. Your current employer might give you that opportunity if you ask, but they might not. If they don't, does it matter enough to you that you would switch jobs for it?

Don't worry about whether you are a "bad engineer" or not. That's just a distraction from the actual issue.

alexdowad··on Ask HN: Have you ever inherited a code base you thought was well done?
Good points. Further, a codebase which has survived for a significant period of time is probably one which has created (and is creating) a lot of value for people. If it didn't do anything valuable or useful, it would already have been discarded.
alexdowad··on Ask HN: How do you modify functions over 1000 lines long?
Aside from the (good) comments made by others:

- Before you can reliably modify any program, you absolutely must get to understand how and why it works. This is always challenging for a sizable program, but when its complexity has not been skillfully managed and broken up into digestible units, it's much worse. However, you can overcome that obstacle with time and effort.

If the people who wrote the code are accessible and willing to answer questions, that is "gold" and you should not waste it. Even a 15-minute conversation can make an enormous difference. Even if they have moved on to another company or department, you might be able to track them down and see if they are willing to talk.

If the source control history is available, looking up when a difficult piece of code was written and what else was changed at the same time can provide precious clues. If the authors left decent commit log messages, that is even better, but from your description of the codebase, I guess you can't expect that.

Don't get stuck for a long time trying to understand one small bit of code (unless it is the critical part for your immediate task at hand). To build understanding, it is more effective to "dip your toes into" a section, read through and try to understand what you can without getting stuck for too long, then move on to a different section. After a while you will start making connections between the parts of the program. Each part that you grasp will help you to understand other parts.

Stepping through the code in a debugger, watching where control flow goes and how data flows from one part to another can be very helpful. Another possibility is to add debug print statements in key places and watch the messages printed as you interact with the program.

If you are able to build and run the program, you can also do "experiments" to verify your understanding. For example, if you are reading code and think to yourself: "I think feature XYZ should still work even if these lines were removed", then rather than staring at the code for an hour trying to determine whether your hunch is right, you might make faster progress by deleting the lines, then running the program and seeing what happens. Another type of experiment is where you deliberately change something just to see what compiler errors will be produced.

- Try to identify parts which "can't affect anything else" (i.e. whose effects are very local), and clean those up first.

- Every part which you are able to clean up will make what remains easier to understand. Keep expanding the borders of what you understand and shrinking the borders of what you can't. Understanding is the key thing; the actual refactoring is relatively easy after that.

- If a certain function or section of code just seems really crazy or nonsensical, maybe that's because it is. Sometimes, rather than trying to delve into its craziness, it is better to figure out what that part was intended to do, delete it, then rewrite it to do what the original author had intended.

When you do this, you may find that a bunch of strange bugs disappear.

alexdowad··on We Put Half a Million Files in One Git Repository, Here’s What We Learned
The natural tendency in almost any software is to keep adding and adding, while rarely throwing anything out. More features, more code, more supported platforms, more supported languages, more this, more that, more, more, more.

If it was a physical product, you couldn't keep making it bigger and more complex ad infinitum, because making a physical thing bigger takes more material, and bounded physical resources would be consumed. With software, it's all just bits, and computers can hold a lot of bits.

This leads to bigger problems than just git running slowly.

alexdowad··on Computing in Crip Time
When I saw the title, I first thought this article had something to do with the intersection of computational science and inner-city street gangs.
alexdowad··on Ask HN: Which are your favorite developer docs?
MDN for the JavaScript language and standard browser APIs.
alexdowad··on Ask HN: What is the most interesting software you wrote in a few days?
As a suggestion, why not peek at the source code for git and see what they are doing differently from you?
alexdowad··on Ask HN: What is your present sentiment on GraphQL?
I've used GraphQL professionally and felt it was great... if it matches your use case. Basically, if your data comprises various different types of entities which relate to each other, and clients are likely to want to pull back data on related entities ("give me these Xs and all the Ys which relate to them"), then GraphQL might make sense.

If there is any significant latency in accessing your backing data store, as is usually the case with a SQL database, then care is needed when implementing your GraphQL server. Naive implementations will have the N+1 problem (or the "N²+N+1" problem, etc) and will be slow.

I haven't found a GraphQL server library which I like, so I implemented my own. (I found an MIT-licensed query parser, which saved some work.)

It is designed to make no more than one SQL query for each branch node in the GraphQL query AST (assuming that each type of entity is stored in a single table). Running in production for a while now, works great, fast, was fun to write.

alexdowad··on Ask HN: What is your present sentiment on GraphQL?
I would suggest that GraphQL queries wrapped in quotes aren't bad. I personally don't see the point of using GraphQL client libraries at all.

If you interpolate parameters into your query, then there are yucky quoting issues, but GraphQL allows clients to pass both a query and accompanying variables for that very reason, and users are encouraged to use variables.

alexdowad··on Kaiten: Japan’s fully-manned kamikaze torpedos during WWII
There is a manga series based on the history of the "kaiten", called "Tokkou no Shima" (特攻の島), which is pretty good.

It depicts the commander of a kaiten-bearing submarine as lying to his superiors and reporting that each of the kaiten launched from his submarine sunk US ships, when in fact none of them hit their targets. It is implied that reporting anything but success was unacceptable, and the Japanese military leadership expanded this program because of being misled by such false or exaggerated reports.

alexdowad··on Ask HN: Do you rewrite pull requests?
Here's another approach for situations which fall in the middle:

https://docs.github.com/en/pull-requests/committing-changes-...

alexdowad··on Ask HN: Do you rewrite pull requests?
If the code which is eventually merged is mostly the contributor's code, and you just had to do some small tweaks to get it up to the project's standard, then commit and merge it under their name.

If the changes are so major that the code cannot reasonably be considered theirs any more, then it would be dishonest to merge it under their name, and would not be doing them or anyone else a favor. In that case, commit and merge under your own name, but include a note in the commit message thanking them for their contribution.

← PreviousPage 2 of 6Next →