News for hackers. Stuff that matters.

ggorlen

Re:Alternatives to Animal Testing Are Finally Taking Off on Monday October 19, 2026 @11:58AM (#50153997)
If the simulated organs perform better for research and avoid needless animal suffering, then it's a win/win. Right now it's a win/lose at best, possibly a lose/lose if you factor in reproducibility issues using animal organs for research.
Re:Anecdotally, Programmers Dislike "Reduce" on Thursday September 17, 2026 @09:12AM (#49740266)
So you prefer

    arr.reduce((acc, el) => {
      if (el % 2 === 0) {
        acc.push(el * 2);
      }

      return acc;
    }, []);
over

    arr.filter(e => e % 2 === 0).map(e => e * 2)
The only advantage of the reduction as I see it is performance, but this is highly dubious and would need to be profiled for proof (I don't recall seeing removing a pass like this matter in practice). And if perf does matter, a for..of loop would be clearer and one-pass, not to mention async-compatible:

    const result = [];
    for (const el of arr) {
      if (el % 2 === 0) {
        result.push(el * 2);
      }
    }
Exercises like this illustrate why verbal technical job interviews are useful in the age of LLMs--a series of A/B taste preferences seems high signal and ripe for discussion: "Ah, so you're choosing reduce for perf... please describe a scenario you encountered where this made a measurable impact".
Re:Anecdotally, Programmers Dislike "Reduce" on Wednesday September 16, 2026 @10:24PM (#49735709)
Reduce is a good illustration of the principle of least power[1]: it's powerful, flexible, general and low-level and can technically achieve any combination of summation, map, filter, find/includes, some/any/every, etc. But reduce is misused if it's reimplementing patterns available in higher-level form.

In cases when reduce is required because (for example) JS doesn't have a sum function, it should be kept simple. `arr.reduce((acc, el) => el + acc, 0)` is acceptable if lodash _.sum() is not available.

In cases when reduce is required because the higher-level operations like map/filter aren't flexible enough, decompose the reduction operation into simpler steps and use map/filter with multiple passes, or write a traditional for..of loop.

This principle also explains why enhanced/range/of loops are preferred over counter-based `for` loops, and counter-based loops over `while`. Technically all loops can be handled by `while`, but it's seldom needed because enhanced loops handle the common case with the cleanest syntax. Reduce/while/counter-based `for` loops are antipatterns where higher-level, less powerful abstractions exists.

[1]: https://wiki.c2.com/?PrincipleOfLeastPower

Re:Don't Look Down on Print Debugging on Saturday November 23, 2024 @09:11AM (#42220955)
> print debugging is problematic since the developer has to be diligent about removing it once it is not longer needed.

Linters make this a non-issue, and most modern development environments support them.

https://eslint.org/docs/latest/rules/no-console

https://docs.astral.sh/ruff/rules/print/

In situations where for whatever reason it's infeasible to use a linter, a basic grep can surface prints in a codebase reliably enough.

Re:Avoiding False Positives in Node.js Tests on Wednesday November 20, 2024 @10:47PM (#42200901)
Author here. I'd be happy to hear feedback on the post or noteworthy false positives you've encountered in tests.
Re:Show HN: Web Scraping with Your Web Browser: Why Not? on Wednesday October 02, 2024 @01:09AM (#41717371)
I wrote a similar post on in-browser scraping: https://serpapi.com/blog/dynamic-scraping-without-libraries/

My approach is a step or two more automated (optionally using a userscript and a backend) and runs in the console on the site under automation rather than cross-origin, as shown in OP.

In addition to being simple for one-off scripts and avoiding the learning curve of a Selenium, Playwright or Puppeteer, scraping in-browser avoids a good deal of potential bot detection issues, and is useful for constant polling a site to wait for something to happen (for example, a specific message or article to appear).

You can still use a backend and write to file, trigger an email or SMS, etc. Just have your userscript make requests to a server you're running.

Re:Compiling to Assembly from Scratch [free to read online] on Sunday September 22, 2024 @09:04PM (#41621469)
As is often the case, the title is unfortunately overloaded. I initially read this as writing code in the Scratch programming language[1] that compiles to assembly.

[1]: https://en.wikipedia.org/wiki/Scratch_(programming_language)

CCSF alum here (AA, completed over 20 CS courses). I attended a similar CCSF job fair in 2017 and there were only 2-3 companies involved even then. If I recall, it was Lawrence Livermore National Lab and Mission Bit, maybe a third that must not have been interesting enough to stay in my memory. There were ~10 students at the fair.

The LLNL internship seemed too IT-oriented to interest me. Mission Bit involved teaching high school kids to code after school, which I did for over a year and received course credit at CCSF for.

So it's not that surprising to me that they went from ~2 companies to 0, even disregarding the major drop in attendance at CCSF since 2017 [1]. I didn't attend any other fairs so maybe I missed something, but I never got the impression that they were especially "bumping".

[1]: https://sfstandard.com/2022/01/27/by-the-numbers-sf-higher-e...

It was the first online cohort of DC so I didn't realize how intensely difficult it'd be. I'd taken GIOS with Ada which was gentle, so I figured DC wouldn't be significantly harder.

It was a good life experience even though I wound up sacrificing my 4.0 by a few grade points. In hindsight, had I realized how steep the curve would be for DC, I'd have pushed a bit harder to squeeze out a few more test cases, but I was pretty mentally defeated at the time and felt like I'd exhausted all of the ideas I had on the projects multiple times over.

I found DC more difficult than compilers by a wide margin because of the nondeterminism, debugging difficulty and trying to figure out what the test harness was even doing. Compilers involved writing more lines of code, but it was manageable, synchronous greenfield application design.

Good to know. https://www.omscentral.com/ and talking to other students helped a great deal with planning.

Two difficult classes I took together were Embedded Systems Optimization and Compilers, both taught by the same instructor and with similar concepts, so working on one helped solidify concepts in the other.

On the other hand, I took Distributed Computing during its first offering alongside Graduate Algorithms and was super overwhelmed.

> Consider that taking 5-10 graduate courses and writing a master's level thesis or project will generally take all of your free time and a bunch of your savings over the course of two or more years. (I sure hope you're not thinking to take on debt for this!)

OMSCS graduate. The program certainly ate up most of my free time for 2.5 years, but on the other hand, the whole degree was about $8k for me and required no thesis or capstone project--just grinding through 10 classes worth of assignments and exams. Also, it was 100% online, so that flexibility frees up time.

Theoretically, if you do 1-2 easy-ish classes per semester, you can minimize the free time impact. But I was less interested in the credential and more interested in the learning experience, so I took difficult classes and worked as a TA.

Caveat: I graduated in 2021 so things may have changed since then.

Related Wikipedia articles:

- https://en.wikipedia.org/wiki/Kodokushi, the Japanese phenomenon of people dying alone and remaining undiscovered for a long period of time

- https://en.wikipedia.org/wiki/Joyce_Vincent, a British woman who had been dead over two years before discovery

Re:vs. 1000 guitar picks (5000 picks/second) [video] on Monday August 12, 2024 @12:21AM (#41221145)
Reminds me of Boyd Rice's rotoguitar (a fan attached to a guitar) and the extratone genre (extreme techno kick drums that run so fast they turn into pitched tones).
Re:A ChatGPT mistake cost us $10k on Sunday June 09, 2024 @09:02PM (#40629041)
There wouldn't be much industry if everyone who trusted ChatGPT and other ways of quickly getting code up (copy-pasting Stack Overflow, "try random stuff until it works" debugging, hopping on calls with random freelancers, etc) followed your advice.

Many programmers I've encountered in early stage tech startups (and in general) are not craftspeople--they're scrambling to get a product to market as quickly as possible and quality and process are very much secondary. Many are working in unfamiliar languages by necessity, or are relatively new or even untrained as professional programmers. I mentor such folk regularly. (Actually, these untrained hackers are often "better" at programming in many respects than senior engineers with 10 years of experience, but that's another story).

If the company survives long enough, they might pay off the tech debt later. OP's team just got unlucky doing the same strategy many other startups are doing nowadays and are willing to admit it.

To be clear, I'm not excusing the mistake or endorsing the process they followed, only noting that their actions aren't out of the ordinary (other than admitting to the mistake) and empathy is due.

Re:Don't Worry about LLMs on Thursday May 30, 2024 @10:40PM (#40530968)
Thanks for the reminder, but anyone visiting this site on a restricted data plan may be in for a surprise. Websites that download a quarter gigabyte of data without warning is more than an annoyance.

How do you suggest I warn others to avoid this site? I don't think it's suitable for HN in its current state.

Re:Don't Worry about LLMs on Thursday May 30, 2024 @10:32PM (#40530916)
Warning: this page loads 234 MB of data! Images are up to 7 MB each.

https://pagespeed.web.dev/analysis/https-vickiboykis-com-202...

Re:Static Chess on Monday May 13, 2024 @08:23PM (#40350197)
https://fav.farm seems like a cool service at first, but it doesn't actually do a whole lot. I'd just assume inline the one-liner they mention (similar to https://css-tricks.com/emoji-as-a-favicon/) and avoid the external dependency for the price of 117 characters.
Re:Steve Albini has died on Wednesday May 08, 2024 @11:58PM (#40305184)
Zeni Geva deserves more credit, great to see them mentioned. You probably know Neurosis and Melt Banana but those might also be up your alley.

Other noteworthy Albini-engineered bands for me: Oxbow, Low, Whitehouse, Labradford, Burning Witch, Godspeed's U.X.O album. Peter Sotos' Buyer's Market is one of the most insane albums I've ever had the displeasure to listen to, and Albini apparently produced it, although I don't hear any obvious influence.

Re:César Aira's Magic on Wednesday May 01, 2024 @10:56PM (#40232275)
I recently read Aira's Fulgentius and found it to be an engaging, tongue-in-cheek meditation (for lack of a better term) on art, history, conquest and nature.

I consider Varamo (comedic) and Episode in the Life of a Landscape Painter (tragic) to be standouts among the half-dozen Aira books I've read in English. I imagine a good deal is lost in translation.

There's a certain absurd, freewheeling alchemy to his works, but as tends to be the case with improvisation, they're somewhat hit or miss and require a bit of indulgence on the part of the reader. Luckily, they're mostly novella-length and don't wear out their welcome, so I don't mind giving him my time.

According to the article, he writes in places like McDonald's, which is comical and unsurprising. Likewise that he's an admirer of Raymond Roussel.

I didn't expect that he'd be a Morton Feldman fan, though. His books aren't as methodical, claustrophobic and somber as Feldman's works, but maybe share a similar sense of reflectiveness and focus on small, ephemeral moments.

Re:TSAC: Low Bitrate Audio Compression on Friday April 19, 2024 @03:30PM (#40091051)
I might be missing something obvious, but it's not clear to me how to get an mp3 out of this on Ubuntu 22.04.

Following the docs, `./tsac c myfile.mp3 myfile.tsac` generates a tsac file that's unplayable with mpv. Trying ffmpeg to convert to mp3 didn't work: `ffmpeg -i myfile.tsac compressed.mp3` ("myfile.tsac: Invalid data found when processing input"). Using a wav input file has the same result.

I can use `./tsac d myfile.tsac output.wav` (I don't really want to decompress anything, but worth a try) but then after compressing `output.wav` with `ffmpeg -i output.wav output.mp3`, output.mp3 is the same size as if I hadn't used tsac (of course). If I use ffmpeg with a low bitrate like `-b:a 16k`, I get the usual low-quality gargle rather than the tsac output.

Re:Ugly Avatar on Monday March 25, 2024 @06:49PM (#39822119)
Thanks, I appreciate seeing the code! For code with database access, you could use an environment variable from a .env file and gitignore that file, making it safe to share. (you're probably already aware of this practice and may have another reason not to want to push it)
Re:Ugly Avatar on Monday March 25, 2024 @06:35PM (#39822018)
It's there now (thanks for the alert!), but I don't think the main branch was there when I wrote the parent comment. If I recall correctly, it was just the gh-pages branch like these other repos from OP: https://github.com/txstc55/Ducked-support and https://github.com/txstc55/duck-duck-duck.

(Of course, those repos may have main pushed later as well, invalidating this comment too)

Nice of the author to share the code. Thanks!

Re:Ugly Avatar on Monday March 25, 2024 @02:57PM (#39820027)
Thanks! I found the Vue source in Firefox by going into the Debugger tab in DevTools, and clicking on Sources > Webpack > ugly-face > src.

Chrome makes it a bit more intuitive, since the tab is called Sources, then click into Page > top > ugly-face > src.

That said, I don't understand why the author didn't simply commit the source code into the GH repo, especially since it's fully retrievable anyway. Maybe there's some goal in doing that other than security by obscurity I'm missing, since they've followed the same pattern for multiple of their repos. It seems kind of anti-collaborative to me.

Re:Ugly Avatar on Monday March 25, 2024 @01:47PM (#39819286)
Fantastic, but unfortunately the source code is minified: https://github.com/txstc55/ugly-avatar, making it difficult to see how it was done and learn from or contribute to the project.
Re:Deep Cloning Objects in JavaScript, the Modern Way on Friday December 22, 2023 @02:21AM (#38731794)
I think there's a typo in the cloneDeep example[1]. cloneDeep is imported but never used, and structuredClone is used instead.

[1]: https://www.builder.io/blog/structured-clone#why-not-code-cl...

Re:I replaced 50 lines of code with a single LLM prompt on Wednesday September 06, 2023 @01:25PM (#37408168)
> And BOOM! 100%(!) accuracy against our test suite with just 2 prompt tries. ... OK, so I'm super happy with the accuracy and almost ready to ship it. ... Wawaweewah! ... letting me actually deploy this in production ...

This feels like extreme overconfidence in the LLM, sort of how I felt the first time I used one.

How many times did they run the test suite? How thorough is the test suite? How much does accuracy matter here, anyway? (seems like it does matter or they wouldn't advertise 100% accuracy and point out edge cases)

In my experience, LLMs will hallucinate on not only the correctness and consistency of answers but also the format of their response, whether it be JSON or "Yes/No". If LLMs didn't hallucinate JSON, there'd be no need for posts like 'Show HN: LLMs can generate valid JSON 100% of the time' [1].

If this gave 100% correctness on all test cases always, I'd need to throw out everything I know about LLMs which says they're totally unfit for this sort of purpose, not only due to accuracy, but due to speed, cost, external API dependency, etc, mentioned in other comments.

Suggesting that problems with edge cases and text manipulation are good candidates for LLMs seems dangerous. Now your code is nondeterministic (even with temperature set to 0).

[1]: https://news.ycombinator.com/item?id=37125118

Re:Tetris Randomizers (2018) on Monday August 14, 2023 @01:26PM (#37123799)
In the "1 Piece history with 1 roll" code, a global variable `piece` is introduced. There should be a `let piece;` at the top of the function body to scope it locally.
Update/disclosure: The List sadly uses Google Analytics, disqualifying it from the club (except in spirit).
The List is a fantastic CSS-less site I've been using for years to discover Bay Area live music shows: http://www.foopee.com/punk/the-list/.

I don't know the full history and I discovered it in the early 2010s, but it's been around since at least 1996 if the page content is to be trusted. I use a script to scrape the site and filter by artists I care about.

Older »