5 ms·
You're saving yourself from one kind of golfing, but not all of them. Additionally, I feel like installing an additional tool is kind of against the spirit of
by striking 5y ago
You're saving yourself from one kind of golfing, but not all of them.
Additionally, I feel like installing an additional tool is kind of against the spirit of 1kLOC simplicity.
- dundarious 5y agoDev dependencies and release dependencies are distinct. There would be no sense in complaining about hypocrisy if a zero-dependency C project uses clang-format or valgrind, and similarly for a python project using black or mypy.
- recuter 5y agoI'm getting distinct uses Eclipse to write vogon poetry and Jira Master vibes from you. Any notes on the actual code in the OP beyond the import lines formatting?
- striking 5y agoI'm sorry to have offended you, but I don't feel personal insults over the README of an open source project are particularly reasonable. This affects the actual code, too! See, for example, https://github.com/geohot/tinygrad/commit/cfb7a4c41a2b6bcc0953a35cb29629561720cfd1 https://github.com/geohot/tinygrad/commit/cfb7a4c41a2b6bcc09..., which includes this gem: diff --git a/tinygrad/ops/ops_cpu.py b/tinygrad/ops/ops_cpu.py index a454f56f..0686f810 100644 --- a/tinygrad/ops/ops_cpu.py +++ b/tinygrad/ops/ops_cpu.py @@ -2,22 +2,15 @@ from ..tensor import Function class CPUBuffer(np.ndarray): - def log(x): - return np.log(x) - def exp(x): - return np.exp(x) - def relu(x): - return np.maximum(x, 0) - def expand(x, shp): - return np.broadcast_to(x, shp) + log = lambda x: np.log(x) + exp = lambda x: np.exp(x) + relu = lambda x: np.maximum(x, 0) + expand = lambda x,shp: np.broadcast_to(x, shp) + permute = lambda x,order: x.transpose(order) + type = lambda x,tt: x.astype(tt) + custompad = lambda x,padding: np.pad(x, padding) def amax(x, *args, **kwargs): return np.amax(x, *args, **kwargs) - def permute(x, order): - return x.transpose(order) - def type(x, tt): - return x.astype(tt) - def custompad(x, padding): - return np.pad(x, padding) def toCPU(x): return x @staticmethod The "actual code" is being golfed for no other reason than to keep the line count down, for the sake of a promise that never needed to be made. This commit recovered a total of seven lines wherein new code can be added, in exchange for readability. It is not just a quirk, not just some sort of interesting aside like one could argue for suckless' `dwm`: this promise actively makes the code worse over time, for no reason.
- recuter 5y agoNo offense taken and no offense intended at all friend. In my opinion we are down the rabbit hole of arguing style over substance. I just think you are grasping at straws. Tools like black (if there was a just god it would just be part of the language, like gofmt) can easily settle stylistic choices. Really not worth endlessly debating, what next, tabs vs spaces? This commit seems fine to me as well. Consider the golfing serves the purpose of "the lols" if you must. Heck this particular commit looks slightly better with the change! Excessive golfing to the detriment of code quality over time is a well known and wholly irrelevant point to make with something like Tinygrad. If you are so convinced of what you are saying, fork and rewrite it as verbosely as you prefer and demonstrate some significant improvement to the project quality. Would be insightful.
- striking 5y agoI think I've proven my point well enough here by making it clear that in order for them to stay under 1kLOC they have had to make golfing-style changes that cannot be automated. If I were hell-bent on convincing you, I could fork their repo and add literally any feature requiring more than ten LOC and win. They would have to bend over backwards to get enough lines back to be able to merge whatever it is I wrote, with exponentially worse effects per individual line contributed. But I'm not hell-bent on convincing you. You know that I'm not actually going to write code for you. You might think it's a clever rhetorical strategy, but it's not. Because I have other things to do, like a day job and personal projects, whose preemption of my jumping through your hoop are completely disconnected from the veracity of my line of reasoning.
- recuter 5y agoThat's just like, your opinion, man. And it isn't a rhetorical strategy. It is socratic questioning. Should you sit down and attempt to write something out of spite (an excellent motivator, as good as any) it would go slightly differently than how you theorize. In order to add a feature requiring more than ten LOC you'd actually have to come up with one in the first place :) That would require reading Tinygrad, which shouldn't take very long for obvious reasons. Probably we've been arguing about this for longer. At which point you'd realize there is not much to add to it and you are splitting hairs over whether it is 1200 lines or 999 lines. In which case you could just run black on it and leave it at whatever line count it spits out. That wouldn't even require any additional coding on your part! Then you can compare the black'd version to theirs and realize they made a very very small sacrifice as a lark. Thereby finally understanding the difference between the principal of "code golf bad" and the reality of "tinygrad l33t demo" you ol' fuddy duddy.