HNHacker News
TopNewBestAskShowJobs

healeycodes

695 karma · joined January 12, 2018

I write about software @ https://healeycodes.com

My email is on my home page at the bottom.

submissionscomments
healeycodes··on Adding Go's Defer to the TypeScript Compiler
Cool! I kinda feel like these should be built-in. But this looks useful for closing the DX gap here.
healeycodes··on Adding Go's Defer to the TypeScript Compiler
Reasonably? Yes. Could probably be made to work well.

  $ bat 2.ts
  ───────────────
     1 │ function one() {
     2 │   let x = 1;
     3 │   defer (() => { throw new Error("thrown from one!"); })()
     4 │   x = 2;
     5 │ }
     6 │ one();
  ─────┴─────────

  $ node 2.js
  ~/healeycodes-typescript-go/2.js:29
            throw _errors_1[0];
            ^

  Error: thrown from one!
      at _callee_1 (/Users/andrew/Documents/GitHub/healeycodes-typescript-go/2.js:9:46)
      at /Users/andrew/Documents/GitHub/healeycodes-typescript-go/2.js:10:33
      at one (/Users/andrew/Documents/GitHub/healeycodes-typescript-go/2.js:22:31)
      at Object.<anonymous> (/Users/andrew/Documents/GitHub/healeycodes-typescript-go/2.js:34:1)
      at Module._compile (node:internal/modules/cjs/loader:1830:14)
      at Object..js (node:internal/modules/cjs/loader:1961:10)
      at Module.load (node:internal/modules/cjs/loader:1553:32)
      at Module._load (node:internal/modules/cjs/loader:1355:12)
      at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
      at Module.executeUserEntryPoint [as runMain (node:internal/modules/run_main:154:5)

  Node.js v24.15.0
healeycodes··on Adding Go's Defer to the TypeScript Compiler
Author here. I find try/finally verbose and vulnerable to mistakes. For me, it adds "function noise".
healeycodes··on A Tiny Compiler for Data-Parallel Kernels
You're right that my post's algo does not handle this case (it's more of a toy to explain the basic cases).

> When I read Allan and Kennedy my impression was that vectorising arbitrary imperative code is a much harder problem than designing a language that only allows for vectorisable constructs to be expressed in the first place.

Yeah, I buy this.

> In my example that would produce different code, requiring a multiplication:

  lambda i: table[(phase0 + i*inc) % TABLE_LEN]
I think some compilers may lower this without the multiplication.. (e.g. turning it back into an induction variable) but with floats they may not be allowed to, since repeated addition and "phase0 + i*inc" are not strictly equal.
healeycodes··on Building a Shell
Editing the current line works because I brought in https://man7.org/linux/man-pages/man3/readline.3.html towards the end so I could support editing, tab completion, and history.

IIRC readline uses a `char *` internally since the length of a user-edited line is fairly bounded.

healeycodes··on Building a Shell
Author here, and yeah, I agree. I skipped writing a parser altogether and just split on whitespace and `|` so that I could get to the interesting bits.

For side-projects, I have to ask myself if I'm writing a parser, or if I'm building something else; e.g. for a toy programming language, it's way more fun to start with an AST and play around, and come back to the parser if you really fall in love with it.

healeycodes··on Counting Words at SIMD Speed
Author here, one of the fastest improvements I've seen is @cloud11665's idea here: https://x.com/cloud11665/status/1955958965046595699
healeycodes··on Show HN: Lisp in C#
You can annotate the code blocks in the README to get generic lisp syntax highlighting.

```lisp

(+ 1 2)

```

healeycodes··on Making Python Less Random
Yes, it works on any process that makes a SYS_getrandom call.
healeycodes··on I added some optimizations to my compiler that turns Lisp into JavaScript
Ah, this is a useful distinction. Thanks.
healeycodes··on I added some optimizations to my compiler that turns Lisp into JavaScript
The Lisp variant that the compiler supports at the moment only handles f64 numbers so I don't think this kind of issue is possible.

However, this is a very relevant point. If the goal is just shorter code (as opposed to a mix of shorter code and less run-time operations), then you need to check that folding strings (and similar types) actually makes the expression shorter to represent.

healeycodes··on Code search is hard
When a val is deployed on val town, my understanding is that it's parsed/compiled. At that point, can you save the parts of the program that people might search for? Names of imports, functions, variables, comments, etc.
healeycodes··on CLI text processing with GNU awk
Awesome! I've been meaning to replace my usage of Python/JavaScript for tasks (which I believe) are more awk-shaped.
healeycodes··on Restricted Library Mode (Breaking change to Val Town)
I'm really happy with the way val town responded to the security issues I raised! Big congrats to them for shipping this change – it sounds tricky on both the product and the tech side of things.
healeycodes··on Ask HN: Do you think many posts don't get the front page attention they deserve?
HN has a second-chance pool: https://news.ycombinator.com/item?id=26998308
healeycodes··on Ask HN: Is having a personal blog/brand worth it for you?
Yes (my blog is on my profile).

People email me about things I’m interested in, and I’ve made new friends through it too.

It's nice to look back and see my progress — taking on harder projects, and writing more clearly.

> Does the time spent writing feels worth it to you?

Yes but I've always enjoyed writing.

> Did it help to get noticed/ find jobs or other opportunities?

Yes.

> Do you learn something new from it?

Yes, by writing for it. And, I suppose, by "running it" I learned more about the frameworks I've used.

healeycodes··on Gunicorn
I really like the clear example at the bottom of the page.
healeycodes··on I became the internet’s most notorious bike thief
> It seems the only way to protect against theft is to ride an old bicycle.

I like this blog on that topic:

https://calpaterson.com/bicycle-threat-model.html

> One father I know had his primary-school-age daughter "decorate" his commuting bicycle with girly stickers and pink glitter. If anyone examines his bicycle closely he looks like a complete loon but I think his motivation is right: it's going to be much less appealing to steal when it's covered in Miffy stickers.

healeycodes··on Doom Rendered via Checkboxes
If anyone wants to PR a fix for more browsers please do! (https://github.com/healeycodes/doom-checkboxes/issues/1). Otherwise, I'll probably look into this tomorrow.
healeycodes··on The Boyer-Moore Fast String Searching Algorithm
These days? Perhaps some niche area.

From the paper's abstract:

> the algorithm uses storage in a way that permits an efficient use of magnetic tape

healeycodes··on The Boyer-Moore Fast String Searching Algorithm
The "Boyer–Moore majority vote algorithm" is also very neat.

It's the optimal solution to https://leetcode.com/problems/majority-element/ – as in it's required to solve the problem in linear time and in O(1) space.

healeycodes··on Computer vision and embroidery
They are the colored threads that you stitch with. DMC is a brand but it’s also the colloquial term for the fixed set of colors that are commonly used and sold.

I’ll see if I can make that clearer — thanks.

healeycodes··on Computer vision and embroidery
I welcome any improvements to my naive exploration in this article!

I've received two emails from readers:

- One suggested converting RGB to a color space that better matches human visual perception, like CIELAB.

- Another suggested compressing the color space by using K-means clustering (by guessing K as the number of threads)

healeycodes··on Google Analytics: Stop feeding the beast
I use https://www.goatcounter.com and recommend it.
healeycodes··on Show HN: "100 Page Python Intro" eBook
(n.b. I gave feedback on an early draft of this book.)

It's very thorough, written with care, and presented in a way that makes sense. Even as an intermediate Python programmer, I found use in this book.

healeycodes··on Generating Text with Markov Chains
I tried to code up Markov chains when I was first learning to program but I found that many resources didn't have clear/terse enough code snippets. Most articles also didn't walk you from zero to understanding.

So I'm trying to fill that gap and help out anyone who is trying to learn the basics.

healeycodes··on Show HN: My multiplayer custom-engine game that loads in less than a second
I've read that .xyz domains (specifically email from .xyz domains) are blocked by default by some email providers because there has been so much spam from those domains historically (perhaps due to the price).
healeycodes··on Building My Own Chess Engine
It wouldn’t be very strong but you could use the evaluation rules that are used for move ordering (the ones that don’t require prior searching) https://www.chessprogramming.org/Move_Ordering
healeycodes··on Building My Own Chess Engine
(Author here) I also hope more hobby chess engine builders join the fun on lichess!

I recommend playing against https://lichess.org/@/TuroBot which is based on Alan Turing's https://en.wikipedia.org/wiki/Turochamp

I debugged my bot by playing it on lichess since I'm so used to the UI/analysis tools.

healeycodes··on Ebiten in 2020
I wrote about building the boids flocking simulation with Ebiten and deploying it with WebAssembly[0].

I found Ebiten very easy to build a simple project with. The project maintainer is helpful, kind, and highly responsive too.

There is a #ebiten channel in the Gophers slack that is quite active.

-

[0] https://healeycodes.com/boids-flocking-simulation/

Page 1 of 2Next →