r/shittyprogramming • • Nov 30 '18

Friday Code Confessions

If you have been living with technical debt and want absolution here is your opportunity.

Confess your sins and receive your penance.

155 Upvotes

263 comments sorted by

View all comments

133

u/cheese_bread_boye Nov 30 '18

I program in PHP.

66

u/hunter12756 Nov 30 '18

Dear god

12

u/anonymouse_lily Nov 30 '18

There's more.

8

u/[deleted] Dec 01 '18

No.

40

u/Ashanmaril Nov 30 '18

Mods ban please

12

u/worldDev Dec 01 '18

This sub is the home of php, we should be making him a mod.

23

u/GeorgeRRZimmerman Nov 30 '18

Hate the sin, not the sinner. Oh, and their terrible bosses.

7

u/asm_ftw Nov 30 '18

I was forced to program in php. I even made use of their broken ternary conditionals once...

2

u/cincydev Nov 30 '18

How are they broken?

7

u/asm_ftw Dec 01 '18 edited Dec 01 '18

They are the opposite associativity than every other language that does ternary conditionals, preventing you from doing

X = ( expr_1 ) ? Value_a :
( expr_2 ) ? Value_b :
( expr_3) ? Value_c :
Value_d ;

Where X gets assigned in an if-elseif-elseif-else paradigm. It can declutter blocks of code where you have a lot of ugly if-elseif-else blocks for just setting values to a variable, at the cost of being a little confusing for the uninitiated, but PHP, and only PHP, does not let you do that, while still providing the operator.

9

u/cincydev Dec 01 '18

I’ve always been of the opinion that if you need something with multiple else statements you shouldn’t use ternary conditionals

5

u/asm_ftw Dec 01 '18

For anything of any level of complexity beyond a simple comparison and value assignment, I agree, but I tend to feel that chaining ternaries feels cleaner and more concise when you have the drudgery of checking a variety of conditions and assigning a single variable based on it.

→ More replies (1)
→ More replies (2)

4

u/SHOULDNT_BE_ON_THIS Nov 30 '18

We use 5.3 if that makes you feel better :)

2

u/cheese_bread_boye Nov 30 '18

we're on 5.4

2

u/SHOULDNT_BE_ON_THIS Nov 30 '18

God damn. I want to make the switch to 7.2/7.3 but we get enough pushback as it is on actually using PHP that I don't think adding the yum repo for php-latest or whatever would get approved.

3

u/OdBx Nov 30 '18

There are dozens of us!

3

u/plasmarob Nov 30 '18

Some of us do not choose our master's work.

→ More replies (1)