Hacker Newsnew | past | comments | ask | show | jobs | submit | smj-edison's commentslogin

I think the most interesting thing is that they loaded the compiled binary right into lean, if I'm understanding the technical paper correctly. Then they use ARM semantics as the base to prove other properties. That's really exciting that they went all the way to the binary level! It reminds me a bit of metamath-c, in that they verify every step of the process, all the way down to binary, so nothing in-between is missed.

I'm currently working on my own Zig project (an interpreter) and right now I'm working on designing a C interface for it. Seeing things mentioned like having objects as opaque handles, or enum-keyed getters and setters, made me think about how clunky my current API is, since I leak too many details to callers.

What really caught my attention was this: "So from the start, I took inspiration from C libraries I enjoyed working with and designed the API to have a strong, stable ABI that allows for future additions." What are good examples of this? I feel like I just don't have enough experience with well-designed C libraries to know what to look for.


One example that comes to my mind is libopus: https://github.com/xiph/opus

If you have structs that might need to be extended, you can use "versioned structs". One popular technique is to include the struct size as the first field. The struct size is set to `offsetof(mystruct, lastmember) + sizeof(lastmember)` and the receiver of the struct can use this to check if a member exists. The ARA API is a good example: https://github.com/Celemony/ARA_API/blob/65ec5c43b943a48cb54...


If you do version and size as the first two fields, you're basically there to backwards and forwards compatibility. Callers can request the size of the struct, allocate a buffer, and read out the parts they need. They can also check specific versions for what they support and ignore newer versions.

It also helps if you only append to the end of the struct for newer fields.


If you only access members, the version is not necessary. The receiver of the struct checks which members are present and ignores extra members that it does not know about. That's backward and forward compatibility.

The version could be useful if some members change their meaning across versions. But this would mean that you couldn't use a struct made from a future version because you wouldn't know about potentially changes.

Personally, I have only seen version or size, but not both. Do you have an example?

> It also helps if you only append to the end of the struct for newer fields.

This is actually required because changing or reordering existing members is an ABI break. Unless every version has its own dedicated struct. (This is often done in COM like APIs where interfaces are extended by adding a new interface. The client queries the must recent interface it knows about; if not supported, it tries the previous interface, and so on until it succeeds.)


My job requires thinking about things like this (well, more senior and experienced people actually drive the final decisions, but I still need to understand them). Seeing the level of rigor that went into the development of a stable C abi for this is insane, it hits on pretty much all the checklists (and more!) that we have internally.

take a look at hpy, which is explicitly designing a better API for python C extensions. https://hpyproject.org/

Ooh, will take a look at this, since it's directly applicable!

maybe libgit2 and libuv? they are designed from the start to be used by others.

I think it's a bit unfair to mainly focus on the API surface while ignoring a lot of internal details. Linus has talked about how Linux will often have massive amounts of internal code change between releases, while the API surface stays the same. So yeah, the API might be old and crufty, but it's also been around for 30 years. And as long as the API is sufficient, it's the internals that are a lot more interesting. Radically redesigning the API every few years would just accelerate towards XKCD 927, because of backwards compatibility.

“The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise.” — Edsger Dijkstra

I've thought a lot about this quote, and the best abstractions I use are absolutely this. I love array indexing as an abstraction, but in the back of my head I have pointer + index * size. I like having the kernel do memory mapping, but I know there's a buddy allocator and TLB cache there.


Agreed on the limits, they're quite frustrating. I've still been preferring Argon to Opus 5.5 though, because even though Argon gets details wrong, I find that it's much more creative and willing to explore ideas. In my experience Opus tends to be rather condescending and won't make room for less orthodox ideas to develop. For what I'm doing, I'd much rather have good ideas that I implement mostly by hand rather than regressing to the mean and have the LLM write the code.


Computational biochemistry is what I'm currently pursuing, but I'm pretty new to the field so take everything I say with a grain of salt: Biochemistry is a really really really tricky problem, for a couple reasons:

1. Biology has a very nasty habit of not cleanly abstracting. It's not like we can treat every protein as a "diffuse mass" without losing a ton of important interactions. This is unlike something like CFD where you can treat a mass of water molecules with certain constants. Think of something like cancer: a small mutation to a DNA strand can cascade into a tumor. You have to deal with the mutation happening at an atomic level while scaling to a whole organism (yes I know there's models that can approximate this, but they can't capture all the interactions).

2. This brings us to modelling at the atomic level. To model a system of atoms with the Schrödinger equation, it naively scales O(6^n) per particle. Note that means every nucleus and electron, so if you have say 10 carbon atoms and 22 hydrogen you're already at 10^127 operations. We can cut corners a bit and end up with something like CCSD which scales O(n^7), or cut more corners and scale O(n^3) for DFT. DFT is pretty much the last method where bond forming and breaking is modelled, so after more corner cutting you lose losing reactions, which are important for understanding why something is happening. Most protein folding simulations (moreso prior to alphafold) run a very crude approximation that models atoms as balls on springs (things like AMBER and CHARMM), which obviously can't handle reactions.

3. If this wasn't bad enough, you also can only move through time at about 1 femtosecond (10^-15), so it takes a ton of simulation steps to get even a nanosecond in. Forget millisecond or second lengths where things start to happen.

So, while the math of the physics exists, computationally it's practically intractible. There's some exciting work with something called Machine Learning Interatomic Potentials (MLIP) which approximate DFT using a neural network which are about 1000x faster than DFT, and iirc scale much more linearly (look at things like MACE and orbmol if you're curious). So we're making progress, but we've gone from so ridiculously impossible to pretty much impossible for large systems.

I have a couple ideas about developing custom microchips to make this faster, which is why I'm pursuing this, but there's still a massive way to go!


To add to this I think there are “reductionist sciences” and “systems sciences”. Reductionist sciences are ones, like physics where there are lots of copies of a thing with near identical properties at different scales (the periodic table would be considered an incredibly short list and that seems to be one of the longest list of “different things” in physics).

Systems sciences are ones where each scale has lots of things with unique properties. If you think of “biological things between 2-4m” the amount of unique objects with unique properties and unique interactions is absolutely mind boggling. These sciences generally do not lend themselves to clean highly parsimonious models. The best you can do is coarse-grain a thing as a system (some very roughly defined set of interactions between different things) with certain behavior while accepting that you are losing enormous amounts of predictive power.

I suspect AI will remain worse at systems sciences for a long time because the “possible space” of models for a particular system is much larger than in the reductionist sciences and navigating it takes a human taste and instinct that LLMs don’t seem to have (yet).


One other thought, I think another aspect of biological sciences is just how much effort it takes to do research. Hypotheses are a dime a dozen, but actually verifying these is quite difficult. It takes a lot of patience, time, attention to details, and even then it often fails to replicate.

I don't think LLMs will just magically be able to connect all the dots, because "garbage in, garbage out" still applies. And there's just too many invisible intermediate states, there is literally just not enough information to fully constrain a model. Hence my interest in scaling computational chemistry to get these intermediates :)


An interesting take. I would nuance it a bit:

Your "reductionist sciences" I would instead phrase as "exact sciences", where the input variations are known (even the most generous particle theory only has a 'few' fundamental particle types, such as up-quarks and photons) and their interactions are either well-known (Fermi Principle is apparently inviolable), or reasonably expected to be known someday (exact relationship of gravitons, IF they exist, with other particles).

The "inexact sciences" use either truly infinite, or practically uncountable, inputs - such as the possible shapes of a single protein, which affects the outputs.

You could criticize this grouping by saying the number of particles in the Universe is practically uncountable, but sufficiently accurate statistical models can be built (a galaxy exerts <this much> gravitational force). We can't do the same with the "inexact sciences": we can't predict how a mole of protein will react with a mole of enzymes, without physical testing. OK, maybe for some very low levels of complication this could be reliably predicted, but in general it may be a !P problem.


Thank you for such a detailed explanation! I was wondering why we don't see MD everywhere and things like protein folding are all based on ML.

Is there anything like a getting-started for working with MACE or orbmol, a 'hello world'? Like maybe simulating Allolactose binding to lac1 ?


Heh. Unfortunately computer science is really the weird one out where open source is the norm. A lot of computational chemistry knowledge is mainly transferred in research labs and through college classes, and you have to pay for a lot of the tools. But hopefully I can at least point you in some useful directions. Here's a bit of an overview of the CC workflow and free options (note I haven't tried all the free options):

1. The first thing you need to do is start with some atomic structure. You can often find pre-existing pieces (through websites like pubchem), but you need to cobble them together. I use chemcraft and gaussview for this, but those are paid options. I've heard good things about the FOSS program Avogadro though.

2. Once you've built the structure of interest, you want to calculate properties of it. Note that we only infrequently simulate the atom's movement, since that's quite expensive. There's a lot of techniques that let us get the most bang for buck, like calculating transition states, or states of lowest energy which we call intermediates, or running something called an IRC, which follows the molecule to its lowest energy point (note we pretty much always think about these things in terms of energy). The traditional programs I use for this are Gaussian and ORCA (ORCA is free but you do have to create an account on their forum). Newer methods include MACE and orbmol, which are pretty much only used for trajectories (e.g. running through time) as far as I know. This newer crop of programs are much more FOSS, but they aren't as rigorous so my lab uses them only as a "rough draft". I pulled in one of my current notebooks if you're curious to try it out: https://github.com/smj-edison/qc-tools/blob/main/examples/ml...

3. Interpreting results/debugging problems. This is currently done in my workflow using a python script to extract values from the job runfiles (oh yeah, did I mention the terrible DX? A lot of this stuff is done by hand-writing a job text file and then using regex to parse the logfile). We do a lot of analysis based on relative energies (this is something called transition state theory of reactions).

I definitely glossed over a lot of details, but this is long enough as is. Definitely let me know if you have questions! If you do want a "hello world" though, I'd definitely check out the notebook I linked to. You'll have to create a file called "start.xyz" with some sort of chemistry program (or use AI to pull one for you), and then you can run the system through time. I would use a system I'm researching right now, but I'm not sure what our lab's policy is on broadcasting things to the world.


There's also so called linear scaling DFT


The problem with lifetimes is they become a object tree, where Rc and co let you represent an object graph (well, a DAG at least). So when your problem resembles a tree, it's great, but some problems don't like being forced into that shape.


You don't have to deal with Rust's aliasing rules for &mut and &.



I'm one of those people who's adopting Zig :) But I don't think it's best for every project. For context, I've used Rust before for probably two years writing a realtime audio synthesis engine, so I'm fairly familiar with Rust vs Zig for handling low level details.

The biggest reason I use Zig is it's a very explicit language. The creators made a very intentional decision to avoid too many "high level" designs. This doesn't mean there's no capabilities for abstraction (comptime is great for that), but when you see array indexing, you can think "ptr + index * size with bounds check". There's lots of other things like that where the language does exactly one thing, and that thing is a low level operation.

This is terrible when you want to create high level abstractions that hide details from the programmer, but it's what I need when doing realtime audio synthesis or what I'm doing now which is writing an interpreter. I know exactly what allocates, I know what calls IO and can block (both operations explicitly take in an allocator or IO parameter), no data structures have private fields so I can always poke around at the insides. I know what types of errors a function returns, and creating errors is cheap with Zig's error union design.

So I don't use Zig because I think it's the safer language, I know it has sharp edges because of the number of times I've caused a panic on a poisoned pointer or use-after-free. But because it gives me such a transparent view into what is happening I find it liberating.


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

Search: