Earlier quoted context omitted.
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…
> 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. What a gem! I should start a collection of those, every now and then you get these things you can just frame and look at three times a day here.
A raytracer in 7 lines of 'K'
11–20 of 41 posts
Re: A raytracer in 7 lines of 'K'
#12Re: A raytracer in 7 lines of 'K'
#13You know, 7 lines or not, name your goddamned variables. I'd fire someone who presented me with code like this.
Edit: It's like complaining that the Mona Lisa is a crappy painting, because you are insistent on looking at it as if you were a cubist. It's completely missing the point.
Re: A raytracer in 7 lines of 'K'
#14You know, 7 lines or not, name your goddamned variables. I'd fire someone who presented me with code like this.
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 using it for the rest of the time. It's very powerful and fast to execute, and after you get the hang of it, it's fast to write, too.
Re: A raytracer in 7 lines of 'K'
#15OK, this is a mess. Lets try to get some new coolness metrics here. A. Number of lines of assembler it compiles to B. Time it took you to write it (no cheating) C. Number of symbols used (with names being one symbol)
Re: A raytracer in 7 lines of 'K'
#16OK, this is a mess. Lets try to get some new coolness metrics here. A. Number of lines of assembler it compiles to B. Time it took you to write it (no cheating) C. Number of symbols used (with names being one symbol)
K is an interpreted language.
Re: A raytracer in 7 lines of 'K'
#17Re: A raytracer in 7 lines of 'K'
#18Voted up in hope that someone can adequately explain that piece of code frighteningly close to line-noise.
edit: there's also \:/: which is a cross-product, and ' (single-quote) is like mapcar. More explanations here: http://news.ycombinator.com/item?id=266101
Re: A raytracer in 7 lines of 'K'
#19As far as readability goes, this might have as well been written in machine language.
Breaking into many lines and renaming variables would go a long way to make this code look more like C.
http://www.jsoftware.com/jwiki/Essays/Incunabulum
It segfaults, because it's written in rather non-portable C that assumes sizeof(function pointer) == sizeof(int), among other things. It's an interesting piece of code, though.
I don't completely understand it - I'm confused by the concept of rank in J, and haven't worked with the language enough to get over that hump. (IIRC, K avoids "rank" entirely, and just uses either an array or an array-of-arrays for multiple dimensions.) I've only been a tourist in the APL family of languages, but what I've seen has left me quite impressed.