You know, 7 lines or not, name your goddamned variables. I'd fire someone who presented me with code like this.
I worked at a K shop last summer, and when I was learning the language, I tried using sensible variable names. I was told in no uncertain terms that, when you write K, local variables should be one letter, globals should be two, and functions should be three. It sounds like a total disaster, but after about two weeks (which is a long-ass time to learn a language), everything made perfect sense, and I really enjoyed u…
A raytracer in 7 lines of 'K'
21–30 of 41 posts
Re: A raytracer in 7 lines of 'K'
#22As far as readability goes, this might have as well been written in machine language.
Except that a machine language program would be thousands if not millions of times as long. Readability is relative. Java is unreadable to my grandmother. Turkish is unreadable to me. In other words, the opinion of someone who hasn't learned a language regarding its readability is irrelevant. It is true that the way you read a language like this is different from the way you read Java. You don't expect to grok a line…
Oi, I seriously doubt that. Seriously, millions? It's all math. Take a couple of assembler instructions per operation. I bet there's 256 byte assembler demo's out there...
Re: A raytracer in 7 lines of 'K'
#23Will one of you geniuses hurry up and write an open source K interpreter? It's not that complex of a language to parse..
Re: A raytracer in 7 lines of 'K'
#24You know, 7 lines or not, name your goddamned variables. I'd fire someone who presented me with code like this.
I could, for instance, cut about 80% of my line count in the two Q projects I've open sourced if I used naming and spacing conventions as shown.
http://github.com/DannoHung/qutil http://github.com/DannoHung/qspec
[/Tooting Own Horn]
Re: A raytracer in 7 lines of 'K'
#25Will one of you geniuses hurry up and write an open source K interpreter? It's not that complex of a language to parse..
FWIW, there's A+ (http://www.aplusdev.org/), but I would far rather stick to the ASCII character set.
Re: A raytracer in 7 lines of 'K'
#26Will one of you geniuses hurry up and write an open source K interpreter? It's not that complex of a language to parse..
Re: A raytracer in 7 lines of 'K'
#27Voted up in hope that someone can adequately explain that piece of code frighteningly close to line-noise.
Re: A raytracer in 7 lines of 'K'
#28Will one of you geniuses hurry up and write an open source K interpreter? It's not that complex of a language to parse..
The source to Mr Whitney's prior language, A+, is available.
Re: A raytracer in 7 lines of 'K'
#29Re: A raytracer in 7 lines of 'K'
#30You know, 7 lines or not, name your goddamned variables. I'd fire someone who presented me with code like this.
That is why mathematical formulas are written with x, y, and z instead of long names. The idea is that we are emphasizing the generic relations, not what might be fed to the function.
Similarly, when writing functional code it is good style to use single letters instead of long names.