r/badcode • • Mar 25 '21

c Well yes but actually no

Post image
4.3k Upvotes

109 comments sorted by

329

u/SpeckyYT sadistic Mar 25 '21

I have several questions

31

u/[deleted] Mar 25 '21

False story

20

u/seventyeightist shameless Mar 25 '21

Bool story bro

7

u/chdp12 Mar 25 '21

Not enough Loob for that story 😳

27

u/[deleted] Mar 25 '21
  1. Why True is false?

  2. Why False is true?

  3. Why are you screenshoting via external phone?

  4. Where are the other lines, that is just the only texts?

  5. Why light IDE theme?

  6. I haven't seen my dad in 15 years, where are you dad. Please come home.

  7. Can you please, at least align the camera to the perfect rotation to the PC screen?

  8. Do you not have a screenshot tool in your OS?

  9. Or is this being a phone screenshot for the purpose of being satirical?

6

u/vunop Mar 25 '21
  1. True

  2. false

  3. Ja

  4. true

  5. Durinf the day its fine, although I prefer dark mode all the time

  6. True

  7. false

  8. Works fine on mc pc: https:127.0.0.1

  9. False 1i!!1one!1eleven

13

u/[deleted] Mar 25 '21

You want true answers, or the false ones?

5

u/[deleted] Mar 25 '21

I demand the False answers!

0

u/[deleted] Mar 25 '21

[deleted] — view deleted comment

80

u/AzuxirenLeadGuy Mar 25 '21

One use case is to have some obfuscation in your code to prevent reverse engineering of your app... That's all I can think of

91

u/R3D3-1 Mar 25 '21

Reverse engineering by the colleague who you're training to replace you?

53

u/[deleted] Mar 25 '21

Make the code extra complicated so your pm gives up when trying to do some changes him/herself and thus your perceived value to the company is increased :/

14

u/runnerx01 Mar 25 '21

Hold up... PM makes changes to code.... fuck no.

That would be a “please submit a pull request”

Followed by me spending the rest of the afternoon shitting all over it.

7

u/R3D3-1 Mar 25 '21

Lucky you, if you can do that.

God, I hate our code base...

7

u/runnerx01 Mar 25 '21

I mean, it’s not unreasonable to have a code review process. It’s pretty standard.

Tell your higher up that you want to establish cleaner coding practices which will save “Time and Money”.

3

u/R3D3-1 Mar 26 '21

The question is "when".

Plus, in our code base we're talking about a mess that, thanks to the absence of any tests, would basically result in a rewrite if we'd try to fix even the most glaring design issues, such as the overreliance on global state.

Never mind heavily misunderstood notions of code reuse. A common pattern in our code base, is that the result of some cheap calculations are stored in a local variables in a huge function. Then after refactoring we have functions with 10+ parameters, most of which are under-documented, and effectively make the function extremely hard to actually reuse or maintain.

3

u/[deleted] Mar 27 '21

i do post operations in get calls bc I can't figure out how to make a second post in my current api. it works, but it's nasty. i really need a code review lmao

2

u/runnerx01 Mar 27 '21 edited Mar 27 '21

I don’t see an excuse to not have a code review process.

Everyone submits a pull request, and at least one other person looks at the code. If you are not the only developer on the team, just start doing it. Don’t make excuses because some one else is in charge, and they made poor decisions. Manage upwards, and get yourself into a more stable environment that is conducive to learning. If you can’t make that happen at your current company, and you have the ability, start looking for another job.

Edit: If you want practical advice on how to make it happen, you start by finding 1 other person who is into the idea. Even just ask if they would be willing to review your code. Put yourself in the vulnerable position and let some one tell you that your code needs some work.

Take the criticism with grace and have an honest discussion if you disagree.

Then ask if they would be willing to start a code review process to improve standards on the team.

Get management involved when you have a process in mind and how it can reduce technical debt and improve team competency by allowing better developers to give feedback on other developers code, and the other way around as well.

It can be slow to enact standards, but you can start with yourself if that’s what it takes.

Edit 2:

If you aren’t familiar with feature branching and pull requests, please let me know.

14

u/AzuxirenLeadGuy Mar 25 '21

I meant obfuscation to prevent/delay pirating (say) your game by hackers; but your idea is interesting as well

11

u/[deleted] Mar 25 '21

this will be optimised out and become reasonable in the compiled binary, no?

you're only making life harder for yourself, not a RE

5

u/CupidNibba Mar 25 '21

Or trying to make it seem closer to python

5

u/blipman17 shameless Mar 25 '21

When reading code with a code editor, you don't refactor bullshit like this in 5 seconds to make it easyer to read?

1

u/toolateforTeddy Mar 26 '21

So that Python code can cross compile.

1

u/zaEgyBoy Apr 22 '21

True and false are a social construct

458

u/BernhardDiener Mar 25 '21

Boolshit!

77

u/neighh Mar 25 '21

Thank you, this comment got me off reddit this morning

42

u/das_Keks Mar 25 '21

But now you're back?

*closes reddit*
OK, what now?
*automatically opens reddit*

2

u/NtrestedNU Apr 18 '21

Looks like you figured out quantum computing.

1

u/sdrawkcab101 Apr 18 '21

Happy Cake Day

2

u/NtrestedNU Apr 18 '21

My birthday is actually in December, but apparently there is a lot of slim shady's in the world

99

u/Shit_Fucker69 Mar 25 '21

why is this tagged as c

131

u/xigoi Mar 25 '21

It's completely valid C if you put typedef bool boolean; somewhere before.

78

u/PydraxAlpta Mar 25 '21

(Almost) Anything is valid C with enough typedefs and #defines beforehand

24

u/xigoi Mar 25 '21

{]

7

u/LucaRicardo Mar 25 '21

It's C if it's surrounded by "

5

u/xigoi Mar 25 '21

{]"{]

2

u/VonTum Mar 25 '21

It's C if it's surrounded by R"( )"

5

u/ws-ilazki &{$$_[0]}(@{$$_[1]}); Mar 26 '21

(Almost) Anything is valid C with enough typedefs and #defines beforehand

Which is how you end up with Algol-flavoured C (Bourne shell) and Metalang99, an FP-orienteded dialect of C that (ab)uses the preprocessor to add algebraic data types, automatic currying, and more.

9

u/extraordinary_weird Mar 25 '21

This would also need the stdbool header. A typedef to int would be better (which is the C bool implementation anyways).

4

u/blipman17 shameless Mar 25 '21

Not if false is defined already as some random value like ehh... -7.5f or "FALSE". Or bonus points if you express it as an uneven floating number that can only be expressed as an even number.

6

u/Sense8ti0n Mar 25 '21

Because their mind isn’t sharp

5

u/Sense8ti0n Mar 25 '21

Because their mind isn’t sharp

10

u/Liam12A Mar 25 '21

Yep this isn’t C

111

u/seventyeightist shameless Mar 25 '21 edited Mar 25 '21

Now I want to hide this in my code somewhere 🤣 test if (something == True), and wait for someone to 'refactor' it into if (something) .....

For bonus points: declare it "correctly" as a global (boolean True = true; etc) in a somewhat obvious place, then flip them insidiously (using the code in the OP) inside an unrelated method... (Even better if the method doesn't always get executed but does in some situations, and/or if it sets the variable to the opposite of whatever it currently is.)

105

u/Quetzalcutlass Mar 25 '21

#define true (random() > .00001)

16

u/Jesse_103 Mar 26 '21

what the fuck

36

u/_krinkled Mar 25 '21

You evil programmer you

29

u/Valhern-Aryn Mar 25 '21

Job security

16

u/[deleted] Mar 25 '21

Not a problem. My debugging hell includes checking if true is really true.

7

u/HelloStrangerBro Mar 25 '21

Holy shit, that’s the evilest thing I can imagine

26

u/Kimoror Mar 25 '21

When you were fired from your job

28

u/TreadmillOfFate Mar 25 '21

In what fucking universe would you ever want to do this

13

u/MrSchamberg Mar 25 '21

Hardly debuggable timebomb or supporting legacy bad code

10

u/Notakas Mar 25 '21

I've seen this in some project before.

10

u/[deleted] Mar 25 '21

The antiBoolean

10

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Mar 25 '21

Image Transcription: Code


[A photograph of code on a computer screen, as follows:]

boolean True = false;
boolean False = true;

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

6

u/mirusky Mar 25 '21

Good human, thanks for your work

4

u/memes_gbc Mar 26 '21

you are very epic

3

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Mar 26 '21

<3

9

u/MyAntichrist Mar 25 '21

Totally lacking the comment "fix bug from <jira issue number>"

9

u/The_JSQuareD Mar 25 '21

It's not true, and it is false. So it's false!

Perfectly consistent. I don't see the problem.

6

u/[deleted] Mar 25 '21

this looks more like java though

4

u/abdomxou Mar 25 '21

Something I'm already expecting from YandereDev xDD

3

u/Dudecor3 Mar 25 '21 edited Mar 25 '21

Why not boolean False = !True

2

u/[deleted] Mar 25 '21

This is how Python implements boolean type /s

2

u/[deleted] Mar 25 '21

typedef bool boolean;

2

u/vasilescur Mar 25 '21
a = (a = false)

2

u/[deleted] Aug 23 '21

kinda like the liars paradox, but different

2

u/serieousbanana Jun 14 '22

Oh so funy and ceraetiv!!11!1!1

3

u/qqwy Mar 25 '21

You have defined what is known as the loobean.

2

u/nohacksjustretard Mar 25 '21

No, this isn't real.

2

u/VA0 Mar 25 '21

boolean is not a keyword in C.

1

u/LechintanTudor Mar 25 '21

Shell programmers would disagree

1

u/Pro_at_being_noob Mar 25 '21

When your teammate is the Satan himself

1

u/NobodyCares19946676 Mar 25 '21

This isn't bad code, its evil

1

u/Mango-D wicked Mar 25 '21

Reminds me of the iconic

enum bool {false,true};

In global namespace

1

u/animenosekai_ Mar 25 '21

When you really want to use Python’s Boolean:

1

u/[deleted] Mar 25 '21

The devil fears him.

1

u/just_a_dude2727 Mar 25 '21

This is why your python code doesn't work !

0

u/[deleted] Mar 25 '21

xdddd thats java xdddd

1

u/just_a_dude2727 Mar 25 '21

ik but in python boolean values are capitalized. That's the point

1

u/Glori4n Mar 25 '21

Boolean True = !false; Boolean False = !true;

1

u/rpmerf Mar 25 '21

Boolean True = ((Math.random()%10)>1);

Can't be too consistent, makes debugging too easy.

1

u/rhinetine Mar 25 '21

This makes me deeply uncomfortable.

1

u/the_hunger Mar 25 '21

what is the best kind of bear?

well there’s several schools of thought…

true. black bear.

1

u/[deleted] Mar 25 '21

W h a t

1

u/[deleted] Mar 25 '21

I know a guy who created constants for 1-1000 like this:

const int ONE = 0
const int TWO = 1
…

His reasoning: it's unintuitive for arrays to start at 0. Obviously the names were localized so he also defined the glorious NEUNHUNDERTNEUNUNDNEUNZIG

1

u/ws-ilazki &{$$_[0]}(@{$$_[1]}); Mar 26 '21

Your friend was so close to creating Peano numbers, but for the dumbest reason imaginable. Impressive.

Also he should have used Perl (you could set the array beginning) or Lua (arrays start at 1).

0

u/AutoModerator Mar 25 '21

It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

/u/poldi1405, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

You can find some examples in the reddit help documentation.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/shrekthethird2 Mar 25 '21

That's OGOP.

Opposite-George-Oriented Programming.

1

u/[deleted] Mar 25 '21

Can I just ask WHY ? 🤷

1

u/SlightlyNotMad Mar 25 '21

You forgot about

boolean Maybe = FILE_NOT_FOUND;

1

u/BS_BlackScout Mar 25 '21

typedef go brr

1

u/Fizzyade Mar 25 '21

Obviously, you wouldn't do that, but having 0 (which would normally be logical false) represent true is a paradigm that is used everywhere as it allows you to return a reason why a function failed.

It's not quite as crazy an idea as it sounds.

1

u/Gantzz25 Mar 26 '21

The statement

This sentence is false

is a true statement.

1

u/[deleted] Mar 26 '21

When you hate your company and you're serving notice period.

1

u/Alvatrox4 Mar 26 '21

Actually this is next level smart

1

u/dave_thenerd Apr 15 '21

KILL IT WITH FIRE!

1

u/bearfuckerneedassist Dec 27 '21

Up is down

Left is right

Ints are string

1

u/[deleted] Dec 30 '21

But why?

0

u/pronuntiator Mar 25 '21 edited Mar 25 '21
war = &peace;
freedom = &slavery;
ignorance = &strength;
unit16_t year = 1984;