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

Can 4chan write a styleguide?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 35
Thread images: 2

File: bs.jpg (13KB, 294x291px) Image search: [Google]
bs.jpg
13KB, 294x291px
Writing the 4chan C/C++ styleguide.

What will you add to it, and why?
>>
>>60659382
Class and function names must be reverse-camel-cased.
class oPiSafAG {

};

void sOME_aWFUL_fUNCTION() {

}
>>
Each token has its own line.
int
main
(
int
argc
,
char
*
*
argv
)
{
printf
(
"Hello, world!\n"
)
;
return
0
;
}
>>
>>60659382
The == operator is bad style. Always prefer a more readable expression like !(x - y).
>>
>>60659382
Every library must be copy pasted at the top of the code for faster compilation
>>
>>60659382
Fuck camel case cause reasons!
private int numberoffucks = 0;
>>
>>60659382
If at all possible, do not name variables with a consonant as the first letter.
>>60659424
>>
inline assembly programming should be used as much as possible
>>
>>60659382
texting if something is true must be done in a reversed way
if (true==condition)
>>
>>60659516
Also never return a boolean without branching.
if ( !(true-condition)) return true;
else return false;
>>
The use of preprocessor macros is not allowed. Do not use #include. Instead, copy the contents of header files into your source files.
>>
The standard indent style allows you to either use three spaces or a vertical tab.
>>
No #include's. Minimalism must be enforced.
>>
>>60659481
hello java programmer
>>
no unnecessary spaces or newlines
#include <iostream> 
int main(){char hello[7] = "Hello!";std::cout << hello << std::endl;for (int i = 0; i < sizeof(hello); i++){std::cout << hello[i] << std::endl;}}
>>
>>60659648
kek
>>
>>60661312
There are several unnecessary spaces in that code
>>
Only use k for index variables.
>>
>>60661394
it got reformatted when I posted it here
>>
>>60661412
Nice try
>>
>>60661420
i-it really did
>>
>>60659819
This helps prevent circular dependencies
>>
pointer variables have to be declared with spaces on both sides
void * foo
>>
ITT, /g/ redesigns Intercal

https://skillsmatter.com/skillscasts/6088-the-worst-programming-language-ever

This screencast is very much worth watching
>>
>>60662380
is this another hipster javascript monkey complaining that c++ is too hard for him?
>>
>>60662431
No it's a random funny dude designing an absolute horror of a programming language in this presentation. He has several fantastically painful ideas.
>>
>>60659382
>What will you add to it, and why?
First of all, stop with all this crap about whitespace.

Instead, define the truly important stuff.

For example, every header file must be stand-alone. In other words, if you create a header file "x.h", then you must be able to compile this code without errors or warnings:

#include "x.h"


using the "gcc -c" command.

No exceptions. No order dependencies. No macros that need to be defined prior to the #include. No nothing. Header files must always work, no exceptions, just like <stdio.h> does.

This is what pisses me off about 99% of all style guides -- they focus on the trivial crap and omit the crucial things.
>>
>>60662283
>pointer variables have to be declared with spaces on both sides

That simply shows that the programmer is utterly ignorant about the syntax of the language.

That's exactly as retarded as doing something like this:

int x = a  *  b+c  *  d;


and deliberately misleading the reader about the operator precedence.

This is the way you declare a pointer:

const char *ptr;


just like K&R does it.
>>
File: 1447173476867.jpg (29KB, 539x385px) Image search: [Google]
1447173476867.jpg
29KB, 539x385px
>>60662538
>define the truly important stuff.
>4chan
>>
All characters like curly braces and semicolons should be moved to the end of the line, on the same location as the other characters like this:
#include <stdio.h>

int main(void) {
puts("op is a faggot") ;
return 0 ;
}


>>60662380
>Sorry
>Because of its privacy settings, this video cannot be played here.
>>
>>60662640
Awh, that's too bad, it's fantastic.
>>
>>60659424
good lord
>>
Always write your own sorting algorithm.
std::sort is unreliable and you can't know what the CIA niggers programmed it to do

#include <algorithm>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>

template <typename T>
void vector_sort(std::vector<T>& arr) {
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
shuffle(arr.begin(), arr.end(), std::default_random_engine(seed));

std::vector<T> sorted_arr = arr;
std::sort(sorted_arr.begin(), sorted_arr.end());

if(arr != sorted_arr)
vector_sort(arr);

return;
}

int main() {
std::vector<int> vec{1, 6, 4, 7, 5, 8, 7};

vector_sort(vec);

for(auto i : vec)
std::cout << i << ' ';

return 0;
}
>>
>>60662995
>std::sort is unreliable and you can't know what the CIA niggers programmed it to do

check the disassmebly, nigger
>>
#include <passive algorithms>
#not include <avi.chance>
#include <input; i/o phrase>
#not include <random>

new template <system intro>
enable reboot_learning {opt scripts: :system self gov: :ai regent.ml

decomp_rewrite() .count();
jrt login_auto(), art.self aware();

if(no input != auto mgnt.end)
vector_sort(arr) ;

return;
}

main_close: :chrono: :system_guide<int>

return 1;

close 0;
}
Thread posts: 35
Thread images: 2


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.