While AI models have concluded that Elon Musk is stretching reality with his proclamations that AI will generate binary "directly", technically that is already possible, while terribly inefficient.
DraganSr: Elon Musk: AI generates machine code directly? AlphaDev by Google DeepMind
Elon Musk thinks coding dies this year! - YouTube
Prompt
run.js is used to call binary code.
But proves the concept that AI code generation in any language is real and useful.
Just need to pick right level of abstraction.
Binary is hard, both for humans and machines.
Engineering 101
Opus 4.6
Gemini 3.0 Pro
GPT 5.3 Codex
Insertion Sort WAT Comparison
(gem / gpt / opus)
1) Correctness
Result: all three implementations are correct insertion sort implementations.
Validation performed:
- compiled each
.watwithwat2wasm - executed with the same JS harness
- tested deterministic suite including:
- empty/singleton arrays
- sorted/reverse arrays
- negative numbers and duplicates
- 200 additional deterministic mixed arrays
- compared output to JS reference sort (
(a,b)=>a-b)
Outcome:
- gem: PASS
- gpt: PASS
- opus: PASS
2) Line-of-code stats
Counts were taken directly from files.
| Variant | Total lines | Effective code lines* |
|---|---|---|
| gem | 112 | 76 |
| gpt | 84 | 71 |
| opus | 117 | 77 |
*Effective code lines = non-empty lines excluding ;; comment-only lines.
3) Why line counts differ
Main reasons for significant line differences:
Comment density and explanatory style
- gem/opus include many explanatory comments and labeled sections.
- gpt version is more compact/comment-light.
Control-flow style choices
- all use equivalent outer/inner loop structure, but with different block/loop labeling verbosity.
Addressing strategy
- gem/gpt compute element addresses from index (
base + (idx << 2)) at each use. - opus keeps extra locals (
i_addr,j_addr) and updates byte addresses each iteration. - this can improve readability for some readers but adds additional setup/update instructions and lines.
- gem/gpt compute element addresses from index (
Boundary-condition encoding
- gpt uses
j == 0as inner-loop stop and readsj-1element. - gem/opus use explicit
j < 0check in signed index style.
- gpt uses
So the line-count gap is mostly presentation + instruction organization, not algorithmic complexity.
4) Efficiency comparison
A unified micro-benchmark was run under Node.js with same input shape and iteration count for all three.
Benchmark setup:
- array length: 128
- iterations: 20,000
- same mutation/reset pattern before each sort
- single process, same runtime session
Observed timing:
| Variant | Time (ms) |
|---|---|
| gpt | 43.27 |
| opus | 50.73 |
| gem | 52.73 |
Interpretation:
- gpt appears fastest in this run.
- opus and gem are close, with opus slightly faster than gem here.
Likely causes:
- gpt has the most compact hot path with fewer local/address maintenance steps.
- opus trades some repeated address arithmetic for extra local updates; this did not win in this run.
- gem is similar to gpt structurally but slightly more verbose in hot operations.
Important caveat:
- these are micro-benchmark results from one environment/session; exact ordering can vary by engine/JIT warmup/load.
- all three are still the same
O(n^2)insertion sort; asymptotically they are equivalent.
5) Bottom line
- Correctness: all three correct.
- Compactness: gpt is clearly smallest by total lines.
- Practical speed (this run): gpt best, opus second, gem third.
- Difference source: implementation style/verbosity and instruction layout, not different sorting algorithm.
7) Same algorithm in other languages
C
#include <stddef.h>
void insertion_sort(int* arr, size_t len) {
for (size_t i = 1; i < len; i++) {
int key = arr[i];
size_t j = i;
while (j > 0 && arr[j - 1] > key) {
arr[j] = arr[j - 1];
j--;
}
arr[j] = key;
}
}
#include <stddef.h>
void insertion_sort(int* arr, size_t len) {
for (size_t i = 1; i < len; i++) {
int key = arr[i];
size_t j = i;
while (j > 0 && arr[j - 1] > key) {
arr[j] = arr[j - 1];
j--;
}
arr[j] = key;
}
}
Python
def insertion_sort(arr: list[int]) -> None:
for i in range(1, len(arr)):
key = arr[i]
j = i
while j > 0 and arr[j - 1] > key:
arr[j] = arr[j - 1]
j -= 1
arr[j] = key
def insertion_sort(arr: list[int]) -> None:
for i in range(1, len(arr)):
key = arr[i]
j = i
while j > 0 and arr[j - 1] > key:
arr[j] = arr[j - 1]
j -= 1
arr[j] = key
DS3-style pseudo language
fn insertion_sort(arr: int[], len: int)
i = 1
while i < len
key = arr[i]
j = i
while j > 0 and arr[j - 1] > key
arr[j] = arr[j - 1]
j = j - 1
arr[j] = key
i = i + 1
fn insertion_sort(arr: int[], len: int)
i = 1
while i < len
key = arr[i]
j = i
while j > 0 and arr[j - 1] > key
arr[j] = arr[j - 1]
j = j - 1
arr[j] = key
i = i + 1