Hacker Newsnew | past | comments | ask | show | jobs | submit | munificent's commentslogin

> I'm not sure why people seem to be under the impression that writing a compiler means that the language the compiler is implemented in should have "low level" features.

Performance.

You definitely can write a compiler in a high-level language and given the choice I certainly prefer to on my hobby projects. Having a garbage collector makes so many compiler algorithms and data structures easier.

But I also accept that that choice means there's an upper limit to how fast my compiler will. If you're writing a compiler that will be used to (at least aspirationally) compile huge programs, then performance really matters. Users hate waiting on the compiler.

When you want to squeeze every ounce of speed you can get out of the hardware, a low-level language that gives you explicit control over things like memory layout matters a lot.


For context, this is the author of https://craftinginterpreters.com/ , and https://gameprogrammingpatterns.com/ , and https://journal.stuffwithstuff.com/2015/09/08/the-hardest-pr... .

I promise that he knows a thing or two about compilers and performance!

For what it's worth, I agree with him. A recent example is the porting of the TypeScript compiler to Go: it hasn't been fully released yet, but people are already going wild for its performance improvement over the original in-TS compiler.

Of course, it took them over a decade to reach the point where a port was necessary - so it's up to you to decide when that decision makes sense for your language.


I think once you get the design of the IR right and implement it relatively efficiently, an optimizing compiler is going to be complicated enough that tweaking the heck out of low-level data structures won't help much. (For a baseline compiler, maybe...but).

E.g. when I ported C1 from C++ to Java for Maxine, straightforward choices of modeling the IR the same and basic optimizations allowed me to make it even faster than C1. C1X was a basic SSA+CFG design with a linear scan allocator. Nothing fancy.

The Virgil compiler is written in Virgil. It's a very similar SSA+CFG design. It compiles plenty fast without a lot of low-level tricks. Though, truth be told I went overboard optimizing[1] the x86 backend and it's significantly faster (maybe 2x) than the nicer, more pretty x86-64 backend. I introduced a bunch of fancy representation optimizations for Virgil since then, but they don't really close the gap.

[1] It's sad that even in the 2020s the best way to make something fast is to give up on abstractions and use integers and custom encodings into integers for everything. Trying to fix that though!


Does “low level” translate to performance? Is Rust a “low level” language?

Take C#. You can write a compiler in it that is very fast. It gives you explicit control over memory layout of data structures and of course total control over what you wrote to disk. It is certainly not “low level”.


> It gives you explicit control over memory layout of data structures

Some with structs, yes. But overall it doesn't give you much control over where things up in memory once references get involved compared to C, C++, or Rust.


>Having a garbage collector makes so many compiler algorithms and data structures easier.

Does it really? Compilers tend to be programs that just appends a bunch of data to lists, hashmaps, queues and trees, processes it, then shuts down. So you can just make append-only data structures and not care too much about freeing stuff.

I never worry about memory management when I write compilers in C.


> Compilers tend to be programs that just appends a bunch of data to lists, hashmaps, queues and trees, processes it, then shuts down.

This is true if you're writing a batch mode compiler. But if you're writing a compiler that is integrated into an IDE where it is continuously updating the semantic state based on user edits, there is a whole lot more mutability going on and no clear time when you can free everything.


> But I also accept that that choice means there's an upper limit to how fast my compiler will.

Don't buy it.

A decent OCaml version of a C or Zig compiler would almost certainly not be 10x slower. And it would be significantly easier to parallelize without introducing bugs so it might even be quite a bit faster on big codebases.

Actually designing your programming language to be processed quickly (can definitively figure things out with local parsing, minimizing the number of files that need to be touched, etc.) is WAY more important than the low-level implementation for overall compilation speed.

And I suspect that the author would have gotten a lot further had he been using a GC language and not had to deal with all the low-level issues and debugging.

I like Zig, and I use it a lot. But it is NOT my general purpose language. I'm definitely going to reach for Python first unless I absolutely know that I'm going to be doing systems programming. Python (or anything garbage collected with solid libraries) simply is way more productive on short time scales for small codebases.


> I suspect that the author would have gotten a lot further had he been using a GC language and not had to deal with all the low-level issues

Agree, that many people are using languages out of context to what they are actually trying to do. In many cases, using a GC language would be far more productive for them. Though I do think we should distinguish between compiled and interpreted GC languages, as often there is a significant gap in performance, that can be wanted or appreciated.


> Though I do think we should distinguish between compiled and interpreted GC languages, as often there is a significant gap in performance, that can be wanted or appreciated.

Sure, that is tautologically true.

However, I maintain that the original author would have gotten much further even with a pathologically slow Python implementation. In particular, munging all the low-level stuff like linking is going to have full-on libraries that you could pass off the task to. You can then come back and do it yourself later.

For me, reaching a point that helps reinforce my motivation is BY FAR the most relevant consideration for projects. Given the original article, it seems like I'm not alone.


Any AOT compiled language offers enough performance for writing full compiler toolchain.

I suspect that long-term, 3 might not be the wrong choice.

Apple seems to be moving towards running AI on-device while the other big tech companies want to run inference on their data centers and sell AI as a service. Once those companies start enshittifying and jacking up costs, I wouldn't be surprised if people move towards preferring local AI. If that happens, Apple will be well-positioned.


I work on Dart. I don't work directly on the compilers much, but I've gathered from talking to my teammates who do that, yeah, generally fewer passes is better.

From a maintenance perspective, it's really appealing to have a lot of small clearly defined passes so that you can have good separation of concerns. But over time, they often end up needing to interact in complex ways anyway.

For example, you might think you can do lexical identifier resolution and type checking in separate passes. But then the language gets extension methods and now it's possible for a bare identifier inside a class declaration to refer to an extension method that can only be resolved once you have some static type information available.

Or maybe you want to do error reporting separately from resolution and type checking. But in practice, a lot of errors come from resolution failure, so the resolver has to do almost all of the work to report that error, stuff that resulting data somewhere the next pass can get to it, and then the error reporter looks for that and reports it.

Instead of nice clean separate passes, you sort of end up with one big tangled pass anyway, but architected poorly.

Also, the performance cost of multiple passes is not small. This is especially true if each pass is actually converting to a new representation.


Hey - I used to be on your team long ago :)

> For example, you might think you can do lexical identifier resolution and type checking in separate passes. But then the language gets extension methods and now it's possible for a bare identifier inside a class declaration to refer to an extension method that can only be resolved once you have some static type information available.

Some of this is language design though. If you make it a requirement that scope analysis can be done in isolation (so that it's parallelizable), then you design things like imports and classes so that you never have identifiers depend on types or other libraries.

I've been working on a language lately and thinking about passes - mostly where they run and what previous state they depend on - has been a big help in designing language so the compiler can be parallel, cache, and incremental friendly.


> I used to be on your team long ago :)

I miss getting to talk to you about music!

> Some of this is language design though.

Totally, but it's no fun to be stuck between users wanting some eminently useful feature and not being able to ship it because of your compiler architecture.


Great, I dismissed it.

Unfortunately, the several million other people who live in the same voting unit as me didn't and ended up electing an asshat anyway.


Yes, it is, 10000%.

There isn't. Just like with climate change and governments, we're all effectively in one big boat together. You can stop paddling towards the waterfall, but you can't stop everyone else from paddling and you can't get off the boat.

My kids are high school age. It's hard to convey the deep existential dread their generation has about the future.

* They are growing up in a climate that is worse than any prior generation had and getting worse.

* In the US, they are growing up in a time with less upward mobility and more economic inequality than the previous several generations had.

* Trust in social institutions and government is crumbling before their eyes.

* Blue collar jobs are already gone and white collar jobs have no certainty because of AI. Almost all of the money has already been sucked out of artistic professions and what little is left is quickly evaporating because of AI.

Imagine you're 17 like my daughter and trying to decide what to major in in college. You want to pick something that you think is likely to give you some kind of decent career and sense of stability. What do you pick?

Because, I'll tell you, she asks me and I have no fucking idea what to say.


I'm hearing this from my 12 y/o daughter and it's breaking my heart.

When I was in school (US, Ohio, 48 y/o) we got the "if you don't go to college you'll flip burgers" spiel from our teachers / guidance counselors.

Last week she got a variant of that except the teacher thoughtfully added "and burger flipping will be done by robots so you can't even fall back to that". The teacher threw in a healthy dose of suggesting creative jobs will all be destroyed and that "learning to manage AI" is the only viable future career path.

Trades are what my daughter brought up as a viable career path (and I was proud when she did). She also pointed out her school focuses heavily on "college prep" and is loathe to even mention that trades exist.

Edit:

I'm telling my daughter to lean on her interpersonal skills and charisma, and take every opportunity to lead groups. Being a physically present, inspirational, and effective leader is, I figure, a role that isn't going to go away any time soon.

I didn't go to college (beyond an Associate I grudgingly completed) and I didn't end up "flipping burgers". I concentrated on marketable skills in an industry that was growing, and I leaned into good writing and communication, and entrepreneurship. I've tried to hold this up to her, though I am quick to concede that the world is different now, by a large margin, from when I got started.


I really don't see why you think trades are insulated; as someone who dabbles in plumbing, plastering and electrical wiring.

A significant amount of demand for both is due to knowledge barriers - and the fact that you need to certify work.


LLMs aren't going to remove the "moat" that comes from owning specialized tools (sewer and drain cleaning machines, pro-quality welders, etc), and having a procurement and service infrastructure.

Individual property owners who want to dabble already have that option from the myriad YouTube videos available to them (and arguably they're more trustworthy than LLM slop), just as they've had with books and other media in the past. I don't see LLM-based trade "knowledge" as somehow fundamentally different.

Commercial service and construction isn't going to get put out of business any time soon by "dabblers" learning from LLMs.


I'm not sure where you're based, but having friends who are tradies most of the procurement and service infrastructure isn't owned by them at all.

Putting in a new kitchen or rewiring a house isn't beyond the physical abilities of most people and their customers tend to be the same middle class knowledge workers which AI is expecting to cannibalize.

As to your point about the knowledge being freely available; just as it's easier to ask an LLM about software questions, the same is true for other fields. It might not be accurate, but it doesn't really need to be - it just needs to lower the barrier for people to try.

Basically what I'm saying is that I absolutely expect secondary side effects for the trades if it has a big impact on knowledge workers as well.


> Blue collar jobs are already gone

This isn't true at all. There's never been a better time to be in the trades.


I should have been clearer, but by "blue collar" I was thinking more argriculture and manufacturing. Most of the farm jobs are gone from automation and most of the factory jobs are gone to China.

You're right that the trades are still an option and one my daughter is seriously considering. It's a mixed bag. Those jobs still exist, pay decently, and aren't likely to be taken away by AI soon. But many of them are brutal on your body and the sexism is rampant.


Stop spam calling people you harasser

I’m not and never have - please contact me directly at the email address in my profile to give me more information about why you think I’m involved in such activities. I’d like to know if someone is joe-jobbing me.

> There's never been a better time to be in the trades.

I imagine it was _slightly_ better when you didn't have to worry about unlimited numbers of illegal immigrants ready and willing to undercut you.


I feel for you deeply. I’m equally fearful of this for my children, but one small blessing of my kids being very young is at least the ambiguity will probably be over by the time they have to decide. I don’t expect there to be good choices, but at least it will be clear?

How about professions that require licensing to practice (civil engineering, accounting, insurance, actuarial science, law, medicine, pharmacy, nursing), or work in the government sector (defense, military, municipal/state/federal agencies)?

I'd go with nail technician, barber, electrician, mechanic, beauty salon, plumber, coffee shop, window washer, construction

I see these types of jobs flourishing in my community. My barber is fully booked for the next month, and a hair salon owner in my street bought a new property and started a second hair salon... In the same street! And the second salon is also fully booked.


I think being a chef is a pretty future proof career choice. For AI to kill that profession it would need a very dexterous robotic body and the ability to taste, and it would need the special something that determines good taste.

Probably future-proof in that it won't get any worse than it already is, but the food industry is notoriously miserable. Shit pay, bad hours, extremely stressful work environment, lots of drug use, etc.

Nursing perhaps? It seems like caring for other people would be useful even in an otherwise runaway AI world.

My other daughter is likely to go into something medicine-releated. That's a good suggestion. My oldest daughter really doesn't like touching people, so medicine is probably the last thing she'd ever want to do.

This series is seriously the best thing I have read about AI. Thank you thank you thank you for doing so much hard thinking and taking the time to write it all up. It's a monumental work and extremely valuable.

The next time someone asks me where I think AI is going, I'll just point them at this series.


> no increase in demand.

We are already hitting the limits of demand in many areas of life. The fundamental currency that is not growing is human attention.

Sure, now you can be a musician and use AI to help you make an album in a weekend. Great. So can a million other people. Who's going to listen to them? Everyone is already inundated with more music than they could ever listen to in a lifetime.

Now someone who's never written a line of code can vibe code an app and upload it to an app store. Great. So can a million other people. Who's going to install those apps? When was the last time you found yourself thinking, "I wish I had more unmaintained apps on my phone!"?

Now someone who aspires to be a "writer" but lacks the willpower to craft sentences can throw a couple of bullet points at an AI and get a thousand word article out. Great, so can a million other people. Who wants to read more AI slop text on the web? There are already a million self-published authors whose books never get read. That's not going to get better when there are a billion of them.

All of us, every single one of us, is already drowning in information overload and is stressed out because of it. The last thing any of us want is more stuff to pay attention to. All of this AI generated stuff will just be thrown into the void and ignored by most.


Also, I said it way before LLMs, when X started firing people. Software is more or less on maintenance mode. You don't need that many developers anymore and so many new features.

You don't need to create the next Facebook, Shopify, X etc.... Because it already exists and controls the market.


Everyone hates cars until they need an ambulance.

Yes, obviously there are many negative externalities to a car-driven culture, but just like we can easily become blind to the diffuse societal costs of a piece of technology, I think a culture of nay-saying makes it very easy to be blind to the diffuse value of a piece of technology too.

Loud stinky cities full of pollution and climate change are obviously horrible.

But we easily take for granted how amazing it is to be able to drive to a mountain and go for a hike, or call an ambulance, or go to a restaurant when it's raining out, or safely travel in a city without risking being assaulted, etc.

Internal combustion engines are amazing and horrible.


Most people that are against car-centric cities like myself are not against cars 100% but against their level of priority in the design of our cities and societies.

Many of the scenarios you mentoned aren't even that big of a deal for many. I have walked in the rain many times and somehow I was still ok. You could argue that car culture has made us soft in some ways.

Nevertheless, if we reduced our emphasis on cars in society and the design of our cities to the point where cars were mainly used for those specific cases where cars truly are by far the best options (like ambulances) we would have more livable and walkable cities and ironically cities where it is nicer for those who really really want/need to drive since everyone and their mom wouldn't be driving because they aren't forced to drive to everything. Fewer people clogging the roads like my co-worker who would watch Netflix while she drove to work. Obviously she didn't have a passion for driving but was forced to because she lived in a sprawling metro with terrible transit options.


I agree a middle position where cities are dense and people-focused but where cars are still available would be ideal. That's pretty close to what I have here in Seattle and it's nice. I have a car and can park it by my house, but I don't use it for commuting to work.

(Well, I do right now because I'm recovering from surgery and can't walk to the bus stop. But I don't usually drive to work. Which is kind of my overall point. It's very easy for able-bodied younger people to think cars aren't necessary, but not everyone is so mobile.)


I like being able to use a car. I don't like being effectively dependent on using a car to go anywhere.

Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: