[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Code porn
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 42
Thread images: 10
What is the most beautiful code you have ever seen? Pls give links to the repos or screenshots.
"beautiful" in your opinion and by your definition of "beauty", of course
>>
File: image_thumb.png (61 KB, 276x276) Image search: [Google]
image_thumb.png
61 KB, 276x276
>>
>>54838600
An interrupt handler in an OS I made for fun
>>
I cba to give links because I'm on my phone and it's easily searchable and I hate you all, but there really is some gorgeous code in quake (qw/2/3). Spent hours browsing and learning how they all fit together over the years.
>>
File: QuakeFastInverseSquareRoot.png (14 KB, 791x300) Image search: [Google]
QuakeFastInverseSquareRoot.png
14 KB, 791x300
This is pure beauty in my eyes.
>>
github.com/mame/quine-relay
not sure if that counts
>>
>>54838684
what is that what the fuck line?
>>
>>54839117
Literally Google it you nigger
>>
File: 1463533553528.png (562 KB, 683x642) Image search: [Google]
1463533553528.png
562 KB, 683x642
>>54838684
did he say where he derived his magic number, or did he just pull it out of his ass? I heard the theoretical best number isn't as good.
>>
>>54840248
he found it somewhere. he didn't come up with it himself.
>>
File: code.png (211 KB, 1257x1301) Image search: [Google]
code.png
211 KB, 1257x1301
>>
>>54838684
It's a cool idea really, and I like the formatting style, but honestly it's not exactly what I would call beautiful. Much of it is unnecessary, you could just as well write the function shorter, like:

float Q_rsqrt ( float number )
{
long i;
float y;

y = number;
i = * ( long * ) &y;
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i;
y = y * ( 1.5F - ( 0.5F * number * y * y ) );

return y;
}

and get the same result. Then again, maybe they had some ancient compiler with shitty optimization that they were trying to exploit with that weird code.

Also, the recasting with * ( type * ) & is kind of hacky and should be avoided if possible. Better would be
float Q_rsqrt ( float number )
{
union {
float y;
long i;
} z;

z.y = number;
z.i = 0x5f3759df - ( z.i >> 1 );
z.y = z.y * ( 1.5F - ( 0.5F * number * z.y * z.y ) );

return z.y;
}
>>
>>54840310
>sokeks

>captcha: 420

yolo
>>
>>54840636
>I'm a faggot here's me coding like a faggot
Okies petal
>>
File: fizzbuzz of the christ.png (402 KB, 1024x768) Image search: [Google]
fizzbuzz of the christ.png
402 KB, 1024x768
>>54838600
>>
http://dafoster.net/articles/2013/04/07/beautiful-code-sqlite/
>>
>>54840636
Just so you know: that trick is obsolete. Directly using SSE's rsqrtss is much faster.
>>
>>54840935
Yupp, I know. On my machine at least just using 1.0 / sqrt is about three times faster. But the last code I posted with the union instead the cast is actually twice as fast as the original code on my machine.
>>
>>54840310
absolutely disgusting
also
>that font
kys
>>
>>54840310
YOU NEED TO STOP THIS RIGHT NOW
>>
DOOM is the most beautiful source code i've ever read.
>>
File: code.png (1 MB, 635x803) Image search: [Google]
code.png
1 MB, 635x803
Does this count?
>>
https://www.youtube.com/watch?v=0m6hoOelZH8
https://www.youtube.com/watch?v=t5EI5fXX8K0

This should be required viewing.
>>
>>54838600
> beautiful code

Only SJW fucktards see code as "beautiful"
>>
>>54840310
>Pajeet-tier font
>>
>>54842082
All code is beautiful, unless you're a problematic shitlord.
Don't you even dare call code "sexy" either.
>>
File: maxresdefault.jpg (61 KB, 1280x720) Image search: [Google]
maxresdefault.jpg
61 KB, 1280x720
>>54838600
You guys are all code gay :^)
>>
File: knight.png (22 KB, 128x128) Image search: [Google]
knight.png
22 KB, 128x128
>>54842060
Shit nigga, I'm away from home during the summer with minimal internet access and these lectures are going to be part of my technological feed now. Thanks.
>>
>>54840310
I had an epileptic seizure looking at this and I don't even have epilepsy.
>>
>>54842344
It's intro level CS but they go very in depth on what they get into. Very entertaining lectures even if you already know the concepts
>>
Anyone who:

1. calls code "beautiful" (not optimal, readable, maintanable, clever etc., but "beautiful"),
2. claims "programming is an art",
3. calls himself or someone else a code artisan/ninja/maverick/maven

is a pretentious fucking douchebag.
>>
>>54842588
>pythonista
>>
>>54842588
Programming is an art.
>>
static int IsNegative(float arg)
{
char*p = (char*) malloc(20);
sprintf(p, "%f", arg);
return p[0]=='-';
}


The more you look at it, the beautifuler it gets.
>>
>>54842660
>pythoneer
>>
>>54842938
Truly terrifying
>>
>>54842938
>not including space anywhere between variable declaration and name
>allocating extra memory for something that could be done just as easily with a comparison operator
disgusting
>>
>>54843503
>>54843513
>I cannot appreciate art when I see it.
This piece of code is at the frontier of software development.
>>
>>54840248

https://en.wikipedia.org/wiki/Fast_inverse_square_root
>>
File: 1461684665303.png (103 KB, 947x931) Image search: [Google]
1461684665303.png
103 KB, 947x931
>>
https://github.com/id-Software/DOOM-3/blob/master/neo/game/Game_local.h

#ifdef ID_DEBUG_UNINITIALIZED_MEMORY
// This is real evil but allows the code to inspect arbitrary class variables.
#define private public
#define protected public
#endif
>>
>>54843687
wew
Thread replies: 42
Thread images: 10

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.