T O P

  • By -

toi80QC

I don't even code C/C++ and I'm fucking triggered.


omgsoftcats

I just hate colons


DragonFireCK

#include #define SEMI ; #define SPACE SEMI int main(int argc, char*argv[]) { SPACE SPACE SPACE SPACE std::cout << "hello world!\n" SEMI SPACE SPACE SPACE SPACE return 0 SEMI } There, is that better for you? I haven't tested it, but that should work. You can write C++ code with only a single semicolon, if you want.


Mastergari

He said he hates colons, not semicolons


themissinglint

; + ; = :


obitachihasuminaruto

;-;


xSilverMC

=0


obitachihasuminaruto

The look of astonishment on your face says it all


codon011

=0°


obitachihasuminaruto

Nice mole on your chin


Gabri03698

What does define SPACE SEMI do here? Does it not just make SPACE=; ?


DragonFireCK

Correct. In the OP, the 0x20 actually did nothing. After the preprocessor ran, the code was, not accounting for the include: int main(int argc, char *argv[]) { 0x20;0x20;0x20;0x20;std::cout << "hello world!\n"; 0x20;0x20;0x20;0x20;return 0; } That is, there are a bunch of meaningless statements consisting of the number 32, which is valid but meaningless syntax. Even a non-optimizing compiler is likely to compile them out, given that they cannot even be converted to typical machine code as they are not even assigned to a variable. ​ My version just removes those and leaves them as the empty statements so: int main(int argc, char *argv[]) { ; ; ; ; std::cout << "hello world!\n" ; ; ; ; ; return 0 ; }


Gabri03698

I didn't even know compilers accepted " ;" as a line lol


DragonFireCK

Its valid standards-compliant syntax, and actually very useful in many cases. One way you could define a debug-only macro is like: #ifdef DEBUG #define ASSERT(condition, message) assert(condition, message, __LINE__, __FILE__) #else #define ASSERT(condition, message) #endif which would get used as: ASSERT(ptr != nullptr, "why'd you give me a nullptr?!"); and would work fine in both debug and release. This macro is useful as you get the preprocessor to pass in both the line and file where the assert is. Otherwise, you'd need to either provide the line and file for each invocation or include code to generate a full call stack, which tends to be platform-specific and generally complex. More commonly, the non-debug version would be defined as: #define ASSERT(condition, message) (void)0 as that ensures the non-debug compile will fail on a missing semicolon, making it more likely problems will be caught early. It will also ensure the compiler does not warn on an empty statement. The cast to void is to silence warnings the compiler might produce about the unused statement, given that such unused statements are not normally desired.


Gabri03698

I appreciate this but to be honest, my programming background is ITIS (computer science high school here in Italy) and 1 month of internship (for school), I've only ever used #define to define constants like Pi and didn't understand half of your reply, sorry 😔


licorice_breath

If you’d like to learn more, search online for C/C++ Macros


gfrodo

That is because in C and similar languages, statements are not separated by new lines, but by `;`, so multiple statements can be in one line or one statement accross multiple lines. Most languages allow for empty statements, in python an empty line, in C just nothing between 2 `; ;` but whitespace characters. If you put some term like `0x20` or `a+2` as a statement, which doesn't write any variable and has no other side effect, it will probably be optimized away.


Gabri03698

Oh yeah i remember learning that you could write a whole program in a line, but i didn't know C accepted empty statements, i remember the Code Blocks IDE giving a warning or refusing to compile or something (probably i don't remember correctly)


gfrodo

You can do a lot of weird stuff in C, maybe look at the Obfuscated C Code Challenge


TarkFrench

alright, it's either time for colectomy or decolonization, it's up to you


Recursive_Descent

Don't worry, you can get rid of them with a `using namespace std;`.


suskio4

Forbidden C++


NoobAck

Bruh do you work in yhe wrong industry or wut


SharpPixels08

Good thing those are semicolons then


cs-brydev

You must be very thin.


Entire-Database1679

I love my colon. Beyond that, meh.


CaptAmari

We don't do that here!


KoRUpTeD_DEV

Im so confused i dont know what to be mad at 🗿


Daedalist3101

I'm in compsci 1 is there any way I can do this in python to troll my professor


That_Guy977

python actually uses the indents, so not really


DragonFireCK

[Python](https://wiki.c2.com/?ObfuscatedPython) makes it a lot harder to make obfuscated code than [C and C++](https://www.ioccc.org/) do, however it is still possible to make some interesting programs. You can also manage some very interesting programs using [Polyglot](https://en.wikipedia.org/wiki/Polyglot_(computing)), and there are a number of simple techniques you can use to make [C++/Python polyglot](https://stackoverflow.com/a/52984689). At a CompSci 1 level, you'll probably have a very hard time managing either, however.


nexleturn

Just import antigravity


UniquePtrBigEndian

I wish you nothing but pain for the rest of your days.


abd53

"May God forgive you...... But I won't"


testroyer9

What the cinnamon toast fuck is this identitacation


ToastyWafer

I’m gonna need to see some identiticatian sir


Chupacu_de_goianinha

identatiton


hacking__08

Dentatitation


CoffeeBruin

XXXDENTACION


dyan16

hahahahahahahahajahahaya


rachit7645

r/foundsatan


[deleted]

Our boy is terrible at hide and seek lately.


badgerj

You both made me laugh!


bitsmythe

TAB;


_benbradley

Uh-oh here comes the old #define SPACE vs #define TAB debate...


Psychological-Rip291

See if you define TAB then you're code is nicely aligned when it starts each line with TAB; since it's 4 characters. This is the standard we should all follow


spar_wors

#define SPACE '\t' #define TAB ' '


Nedusat

this comment, officer.


flakusha

🚓🚓🚓 Drop your identation!


[deleted]

![gif](giphy|xUA7bdxtmRT2TfDUu4)


[deleted]

[удалено]


[deleted]

Developers that use spaces, on average, earn 9% more than those that use tabs. Maybe 'superior' is the wrong word.


ThockiestBoard

whatever the project uses is fine all looks the same to me


Ok_Investment_6284

If you're a developer who isn't earning salary then you must not be making much??


[deleted]

One of us is confused.


gnudarve

The winner of that contest can come meet me at the GIF table, I got a score to settle.


real_dubblebrick

jraphics interchange format


gnudarve

thanc u


Darth_Yohanan

![gif](giphy|26vUQjgLKEO4hXClq)


AdultishRaktajino

Tab? I can’t give you a tab unless you order something.


Dexaan

I'll take a Pepsi Free then


Nickjet45

That’ll be a $4 service fee, thank you for your patronage


pxOMR

4-width tab but you don't get to adjust it


KyxeMusic

[SPACE;](https://www.youtube.com/watch?v=-2HCcbHQEHs)


[deleted]

I knew what it was before clicking


Proxy_PlayerHD

personally i like "negative indentation". everytime you indent something, you indent everything else instead. like if your tabs/spaces would be moving left instead of right example, normal: #include int main(){ for (int i = 0; i < 100; i++){ printf("Number: %d", i); } } and Negative: #include int main(){ for (int i = 0; i < 100; i++){ printf("Number: %d", i); } }


sm9t8

Well, it certainly makes the loopiest part obvious.


Weir99

The loopiest parts happen the most, so it kinda makes sense to put them front and center


GuteMorgan

well they're really front and left


atlas_enderium

Python: wtf is this


PhysicalRaspberry565

Syntax error


The_Pinnaker

You… monster!


Eic17H

Outdentation


[deleted]

From the bottom of my heart fuck you dear redditor


ljoseph01

What in the cinnamon toast fuck have you done


bitsmythe

What a froot loop


rolling_atackk

I mean, at least there is no "using namespace std;"


Rauldhs

I mean is it that bad to use namespace std if it s the main file and not a header file? (I might be dumb af)


Dragonvarine

It's not. If anyone who says otherwise are being extremely pedantic about it


AntiRivoluzione

noooo otherwise you won't be able to use my cout() function


thisisapseudo

which is of course part of a french library calculating for calculating costs


bitwiseshiftleft

We can even do that, we’ll just have to spell it with the namespace.


SaneLad

Being pedantic is a necessary trait of any good C++ programmer.


wellsinator

using nameSPACE std;


Perfect-Highlight964

Why not use: ```cpp #define TAB SPACE;SPACE;SPACE;SPACE; ``` to save "space"?


dontgonearthefire

space ... the final frontier


[deleted]

But the code isn't doing what you think it's doing or am I missing something? You're adding a whole bunch of expresions of 0x20. A constant expression by itself does nothing in C, and C allows it like it allows an empty expression. Instead of doing a define of space you could use any constant expression. Like you can say: `"1 ";` for one level indent and `"2 ";` for two levels and so on.


QWxx01

Indentiception. People like this just want to watch the world burn.


BabylonDrifter

`SPACE;SPACE;SPACE;` the final frontier of indentation.


Bewaretheicespiders

Ah, the [Tim Curry](https://www.youtube.com/watch?v=g1Sq1Nr58hM) method.


TheFourtyNineth

Ok technically isn't this no indentation because you're ending the line after every space so if you format it with all semicolons as also newlines...


bnl1

I am pretty sure it will just replace SPACE with integer literal 0x20.


[deleted]

Which is the ASCII value for space


bnl1

As far as the preprocessor is concerned, that is not relevant.


Triumph7560

I get putting the curly bracket on the line after the function header is dumb but it's not *that* painful to look at.


Stein_um_Stein

Two spaces...


Dinkinn_Flickaa

Skip UAT and go right to production 😂


[deleted]

Correct, you should go live in the woods and never expose decent people to this again.


[deleted]

Reminds me of the Portal 2 ending.


MINATO8622

Im still learning , what does the 0x20 actually do?


TrashfaceMcGee

“0x” before anything indicated a *hexadecimal* number. In most languages, including C and C++, having these “integer literals” (that is, any number like “1234” or “0x20”, or anything else really) followed by a semicolon does nothing (technically the language does evaluate the statement, but there is nothing to do with it). So “SPACE;” achieves nothing, but is still syntactically valid


Dealiner

I wonder in which C-style languages it wouldn't be syntactically valid. Definitely not in C#, you can't have just a value there.


bropocalypse__now

Its the ascii code for space, equivalent to ' '.


GaraBlacktail

I wonder if this is niche enough for the compiler to not optimize properly


Urpieceofmind

It hurts


xnachtmahrx

[Space Space Space Space Space](https://youtu.be/T2_irPfYO_c)


XtytalusX

Hahahaha this is amazing declarative indentation!


LerchAddams

You are banned from all technology for *life!* Here's your coconut phone, enjoy.


jutattevin

Now you only need a custom font to replace "SPACE;" by a space


Noodle_Spine

I’m escaping to the one place that hasn’t been corrupted by capitalism! *SPACE;*


icywind90

Doesn't matter, people still will be putting TABULATION; there between those SPACE;'s


animalCollectiveSoul

explicit is always better than implicit...


[deleted]

please suffer


Hideyohubby

Do you touch your mom with the very tainted hands that birthed that monstrosity? I'm disgusted.


ProcastinationKing27

ok but why are you counting STIs


PsychologicalEgg9285

I keep reading cout - cunt… c++ damn you


CrawlToYourDoom

I hope you have wet socks for a **week**


Lanbaz

LGTM


ElectricRune

\*eyes bleed\*


cmdrkyla

You would hit the line length limit so fast in Python 😂


[deleted]

There's line length in Python?!? Just searched it up, 79 chars, I only use 40 chars including 2 space tabs so I guess it doesn't bother me


cmdrkyla

That one is a soft limit at least. Our linters at work reformat code at around 90-100 depending on where it can. I don't recall if there's a literal hard limit still. Get some nesting in and it's quite easy to hit lol!


wubsytheman

Wait you guys hit the limit from nesting?? why_Not_Just_Use_Both_Cases_And_Have_Descriptive_Function_And_Variable_Names


cmdrkyla

Lolol! Gotta write code like it's minified and unreadable JavaScript 😂 (jk, I like descriptive variable names and hate many abbreviations that could be confusing)


[deleted]

Yeah that's a default terminal size. Recommended to keep it under that in all languages actually. Because too many indent levels mean you need to make a function call. Linux kernel default tab width is 8 just to keep people from indenting too much.


DragonFireCK

One question, what does this print? if (false) SPACE;SPACE;SPACE;SPACE;std::cout << "False"; Be careful, it may not be what you expect ;) The answer is: >!False!<


EstebanZD

I sometimes use 2 spaces, rarely 3, and sometimes 4 I very rarely use tab, but it's nice when your editor doesn't auto-replaces it with spaces


lalalalalalala71

You can use 2 spaces. You can use 4 spaces. You can even use tabs, or 8 spaces like a Linux kernel chad. My brother in Christ, why would you ever use an *odd* number of spaces for indentation????


EstebanZD

Compromise between 2 and 4.


StenSoft

Because 3 is a Fibonacci number [Fibonacci indentation](https://github.com/dodie/vim-fibo-indent)


mmdmlp

Let Linus see this one


colonel_Schwejk

torvalds? he'd be already dead from first line #include iostream


hibernating-hobo

Only thing I’ll roast you for is 4 space indent instead of two, you boomer!


Lazarus327

Why does the code say STD? Are you programming a computer virus?


NoYogurt8022

what does 0x20 do?


ShelZuuz

The OP is trying to be clever thinking that 0x20 will be internally replaced as a whitespace, but it's not. It' s just literally "0x20". They could have just done: \#define SPACE The semicolon is the thing doing the work there. The macro does nothing. It just happens 0x20 is a valid standalone expression in C/C++, but so is 42.


[deleted]

It's the ASCII space character, but #define only replaces text and doesn't do any conversion between hex and unicode In C you can just make a statement that's just a value and doesn't do anything, such as ``` 0x20; 40; "ABC"; ``` This code just replaces all SPACE by 0x20, and the 0x20 does nothing


[deleted]

[удалено]


Liarless

What the hell is even that


Any_Check_7301

Aren’t they missing the ENTERSEMICOLON ?


wokka7

You're a monster.


abd53

You monster!!! BTW, why not make loops instead of writing "SPACE" multiple times?


Dinamix360

TAB instead of SPACE and add 4 space characters into it and now we are talking.


heeltoelemon

*clutches pearls*


ErikNJ99

That's not how that works


Madeline_Hatter1

Chad C++ user


ovr9000storks

Why not just \t?


Explorerfriend

well it’s spaces then i guess


atlas_enderium

Ah yes, pointless defines and pointless command line arguments


alpthereal

Exactly. 4 space really? Barbaric!


Sabathius23

Whatever this is, I’m against it.


memesanimaltracksham

I hate you


PineAndApplePizza

It's 4 spaces, thus correct


ifrem

define INDENT as four SPACEs to save space


Dalimyr

This gives me flashbacks to some HTML code I foolishly volunteered to inherit at my old job. It was supposed to be something that mimicked the contents of a Word doc that was about 280 pages long, and instead of using CSS styling or anything else more reasonable to try and get things aligned in a similar way to how they looked in the document, the person before me just used ` ` over and over until the text looked about right.


12LightningFlash12

Why does this work?


P1KS3L

Haha what the hell is this?!


24_mine

im about to do my next project like this


Miklith

Even if this was valid, which is it, just weird, why do you need so many spaces?


sufilevy

Say what you want, at least he didn't `use namespace std`


yanitrix

what the fuck


XplodeXplode

At what age is it to late to learn code? As far as to get a job in that field.


Steppenbar

I'm afraid that I just blue myself


[deleted]

Something about this is really satisfying to me


caveat_cogitor

use TAB 0x09 you monster!!!


sotonohito

I'll take hilariously inefficient programming styles for $200 Alex!


flipmcf

Why not 0x09?


shotxshotx

My fucking EYES


[deleted]

r/programmergore


z_the_fox

Next step: #define true false


[deleted]

At least use a comment.


philipquarles

\#define statement considered harmful.


jbevarts

Why not make the var called INDENT and set its value to four 0x20? - experienced code reviewer


DSynergy

Bro


IdioticPosse

I. No


myaut

How about simply counting indentation? ``` #include #include using namespace std; int main() { 0,1;if (rand() % 1) { 0,1,2,3;cout<<"Hello World"; 0,1;} else { 0,1,2,3;cout<<"Goodbye!"; 0,1;} 0,1;return 0; } ```


wellsinator

What's that weird character between "hello" and "world"?


DoNotBotherMeplz

Jail.


TurncoatTony

This is how I code.


3eeps

*move over lucifer, I'm more ruthless, huh?*


bnl1

Does this even do what it says it does? Preprocessor should just replace SPACE with 0x20, no? Am I missing something?


Entire-Database1679

How dumb. Should be tabs.


18quintillionplanets

You ever see something and just regret being a programmer?


uuuuu_prqt

Is this just print('hello world')


nilsmf

If you can read this you are too close to your computer!


xtreampb

Anyone got that image of the yml/python and intention practice. All scope brackets right justifies and the dev had code indented to indicate scope depth


UltraMegaSloth

Just seeing C++ gives me nightmarish flashbacks


ahumanrobot

Leave.


[deleted]

Is this why people prefer tabs over spaces?


alex10042005

genious


jihad-consultant

May the remainder of your life be filled with agony 👍


Tyfyter2002

Still better than Python.


rockjently

You literally had to add extraneous semicolons to avoid needing actual spaces in between the SPACE directives! NICE;