https://github.com/tinygrad/tinygrad/blob/master/tinygrad/co...
One of the cases why I think obsession with lines of code is one of the most counterproductive metrics, it always produces code like this.
https://github.com/tinygrad/tinygrad/blob/master/tinygrad/co...
One of the cases why I think obsession with lines of code is one of the most counterproductive metrics, it always produces code like this.
The far more interesting part is the order of magnitude. If they can pull off a 20k LOC with zero dependencies (implying a pretty concise project size) and it still works well on meaningful applications, that’s pretty neat. A 1000x reduction in code size and matching/exceeding in perf is worth looking at. Probably also implying a better architecture as code golf isn’t gonna get you 1000x less code. Again - their claims not mine, so we’ll see.
But at that point they can triple the LOC to 60k with nothing but white space, new lines, and comments, for all I care. It won’t even add a zero.
I often find myself wishing this was more ergonomic in languages.
I think if I dealt with this on a daily basis I might end up finding if vastly more preferable, albeit at the risk of alienating fellow developers. In that respect it seems much like learning to use Emacs or vi
I agree with some poster above, the code looks hard simply because the problem is very hard, not because they want to write it that way.
I'm going to guess that you're used to codebases that use an autoformatter.
There's definitely a case to be made for autoformatters in projects with a very large (>100) number of developers, but the price you pay for that is much poorer information density per screenful of code.
For things like tinygrad or sqlite with a small dev team it's possible to use whitespace, style, and formatting to communicate important information, just like mathematicians do. The AMS journals don't autoformat mathematicians' equations!
But if you have hundreds of developers on a project it does in fact make sense to sacrifice that signal in order to keep them from fighting with each other over silly formatting choices.
I'm used to Python code being "Pythonic" - which is one of those "I know it when I see it" terms.
I think there is an opportunity there to have a tag in comments for tests.
Have a hotkey to generate an id so you could have
# lift x+y out of reduce on lt :testID: color_adjective_noun
((UPat.var("x")+UPat.var("y")).or_casted() < UPat.var("c"), lambda x,y,c: (x < (c.cast(y.dtype)-y)) if no_range(y) and no_range(c) else None),
and it creates a test that exists away from the main codebase. A process that runs tests could scan the code for testID's, intelligently extract the relevant part of the code into the test harness and runs the tests. There would need to be some infrastructure needed to handle placing the code to be tested into the right context but you could have 1. A codebase that contained no active code required simply to facilitate tests,
2. All test tags auto removable for distribution buildsI agree. Seems to be a personal preference, but still feels odd.
Declarations flow down the page, definitions flow across.
It helps that a single person can read all related bits on one screen.
Funny to me that it is called simplify.py