News for hackers. Stuff that matters.
Re:Alternative code styles by vhb on Monday October 15, 2018 @05:21AM (#18218402)
Surprised nobody talks about the kdb codding style: https://github.com/KxSystems/kdb/blob/master/c/c/k.h
Re:Alternative code styles by yiyus on Monday October 15, 2018 @10:08AM (#18219733)
That's Whitney's style. My preferred example is http://www.kparc.com/b/b.c

It looks obfuscated, but in fact it is just a lot of information. Many people would claim dividing it in 10 files with longer function names and less tricks would make it easier to understand, but after spending a long time studying (and partly rewriting) this code, I actually find the terse version better.

Re:Alternative code styles by taneq on Monday October 15, 2018 @10:18AM (#18219865)
The problem with satire is that no matter how far over the line you think you've gone, someone will always wonder whether you really meant that.
Re:Alternative code styles by pavel_lishin on Monday October 15, 2018 @10:26AM (#18219918)
> after spending a long time studying (and partly rewriting) this code, I actually find the terse version better.

I'm sure Mr. Goldberg understood his machines just fine, too.

Re:Alternative code styles by jungler on Tuesday October 16, 2018 @02:21AM (#18227071)
I've tried Whitney's style and got some good takeaways from it. I don't need that level of density, but it made me realize that when the code is already doing something very abstracted from business logic, there is no sense in trying to name the variables with more than one or two letters. (x0 and x1, appearing in geometric functions, are favorites of mine.)

I also started using "result" after seeing it in Pascal code and have quite liked it for many years, but I just had the epiphany that "ans" (answer, as seen on several graphing calculator lines) would be a little more dense.

Basically, it was well worth it to try these radical styles out. They did a lot to smooth my everyday coding.

Re:Alternative code styles by userbinator on Monday October 15, 2018 @08:18AM (#18219067)
Re:Alternative code styles by swalladge on Monday October 15, 2018 @05:36AM (#18218457)
:O that is ... interesting. Sure that's not an entry for the ioccc? ;)
Re:Alternative code styles by vhb on Monday October 15, 2018 @06:08AM (#18218565)
Nope :) This is being used everyday in production by most financial institutions. https://code.kx.com/wiki/Cookbook/InterfacingWithC

I've been told that the guy who wrote this believe that the brain only has a limited buffer to compute source code. So he is trying to use the shortest code possible everywhere.

Re:Alternative code styles by saagarjha on Monday October 15, 2018 @06:27AM (#18218644)
I think looking at this code has already caused a buffer overrun in my brain ;)
Re:Alternative code styles by 0xfeeddeadbeef on Monday October 15, 2018 @08:01AM (#18218995)
"This is being used everyday in production by most financial institutions" — you can't be serious...
Re:Alternative code styles by mruts on Monday October 15, 2018 @08:18AM (#18219070)
KDB developers make BIG money. It's an APL-like language and used to analyze financial time-series.
Re:Alternative code styles by userbinator on Monday October 15, 2018 @08:14AM (#18219051)
I'm not surprised, it's an APL family language.
Re:Alternative code styles by nomel on Monday October 15, 2018 @10:29PM (#18225927)
It looks more like the guy that wrote this wanted good job security and pay, and ended up making and industry with good job security and pay.
Re:Alternative code styles by gohwell on Monday October 15, 2018 @09:57AM (#18219661)
that's just for writing c interfaces to kdb.

As someone who writes q all day, it's typical to see functions written in one line and no white spaces. The mantra is, if it takes you more than 1 line you're probably doing it wrong.