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 wayif (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 sidesvoid * 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.
>>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;
}