Hacker News new | ask | show | jobs
Programming Languages Are for Humans (fzakaria.com)
6 points by psanchez 2 days ago
3 comments

I face this a lot in my current project, as we have integrations with third-party APIs, and the worst part is when you have a mobile app using them and it breaks. Hot-fixing a shipped app takes a day, especially due to the app store review process.

So we came up with a solution of translators in between. The app always gets the same payload, and the translators take care of the mapping. Yes, the app shows an empty value, but that's better than a crashing app. If the app crashes, that's a big embarrassment for the company.

We faced another issue with this, as the translators just silently showed empty values and the app worked, but we only came to know when someone complained. The solution was adding logs and alerts, which were sent to the team when any mapping failed.

Having spent past few months building things and not looking at the code anymore (except some small edits), I find having LLMs work directly with LLVM IR with borrow checking quite interesting.

I'm wondering how token-efficient this is, given how verbose assembly gets in general (e.g LLVM IR) compared to higher-level languages.

I'm not familiarized enough with Rust to know which parts make compilation times so slow, but maybe we could have a C-like language with compile-time borrow checking, in order to have higher expressivity for agents and that was also faster to build than Rust (something closer to Go/Zig perhaps?).

edit: minor edits for clarity

Speaking as someone who is using AI to write a compiler [1] there's a few things I take issue with, with this idea:

- Verbosity. LLVM-IR is verbose - a 10-line C/C++ function could easily run to almost 100 lines of LLVM IR. For small functions, eh, it's a minimal cost but for an entire application, that's (a) a lot of tokens, and (b) a huge error-surface

- Problem domain. Traditionally we use a compiler, a dedicated tool, to handle everything at the LLVM IR level, so there's not a lot of training data for the LLM. An LLM doesn't necessarily need too much in the way of training data, if it can reasonably understand the syntax - it generally converts front-end syntax into an internal representation that maps to its internal knowledgebase well to do the reasoning part, and only maps to the desired output format at the end - but the more training data, the less likelihood of hallucination.

- Version skew. LLVM IR is not a particularly stable language, on the scale of actual languages. It's (by definition) an internal representation of the code. There is no contract to keep it static and stable over long periods of time. That's fine for the LLVM compilers themselves, but its an issue if your "language" is changing in undocumented ways underneath you.

- Support. There's no stdlib, no ABI or conventions - you write the whole thing if you're writing at the LLVM level. You need to set up your calling conventions, your structure layouts, varargs, exception handling, memory management practices, even data-layout.

- Undefined behaviour. You might think that it's "easier" because it's lower level, and in some ways it is, but LLVM is a fairly high-level "low-level". LLVM. has poison, undef, nsw/nuw, inbounds, exact etc. etc. LLVM IR that passes the verifier can still exhibit undefined behaviour and be silently miscompiled. Even if it "looks good"

- Lack of debuggability. In a traditional language we expect source-level debugging to map well with the original, and a lot of that comes with the compiler doing its best to maintain that link. LLVM IR isn't particularly readable, and you lose the debugger trail that makes things maintainable.

- Optimisation. Just because something is written in LLVM IR doesn't mean your code runs quickly. There's a lot to optimisation that is about recognising patterns, moving code, and calling appropriate hardware. That is all done right now inside a specialist tool, so the LLM has to do it from scratch, not from knowing "it was done like this before".

Overall I think the cons outweigh the pros by quite a bit. Using an LLM to write a tool to do the optimisation works out better than trying to teach the LLM to write optimised code, at least IMHO. The benchmarks from xc[1] would seem to bear that out.

1: https://compile-xc.org