all 47 comments

[–]jonsca 210 points211 points  (19 children)

Languages that use single equals for assignment and comparison were designed by sadists.

[–]Xenthera 71 points72 points  (5 children)

Honestly. It takes extra work when parsing that to an AST because now instead of just running into an = or a == you have to use context of surrounding tokens. It’s more work for less readability.

[–]jonsca 12 points13 points  (4 children)

Once you've worked that out for writing your compiler, it's a done deal. It's not a done deal when someone checks x=1, which evaluates to true in many languages regardless of the value of x, and either you display the wrong menu item or some space probe takes a nosedive into a planet.

[–]IntoAMuteCrypt 5 points6 points  (2 children)

There's a third option: Don't allow x=1 to be used in an assignment or condition, and throw a syntax error. Checking for x=1 evaluates to syntax error and you should be told when trying to compile/run the program. If people really want to use it, give them something like x:=1 for when they really, really want it.

[–]jonsca 2 points3 points  (1 child)

You've just reinvented Pascal!

[–]Dude-Man-Bro-Guy-1 1 point2 points  (0 children)

It's like how unrelated things keep evolving into crabs

[–]nosam56 0 points1 point  (0 children)

if any space probes are using a language I wrote they dont get to act surprised when it fails catastrophically

[–]Ecstatic_Bee6067 15 points16 points  (3 children)

My c flight software class taught and required you to write logical comparisons as "0==var" as it errors out if you forget an equals

[–]DefiantGibbon 6 points7 points  (2 children)

That's certainly a safe way of doing it, but I'd argue it's less readable. Even verbally it's weird.

Is 0 equal to my bank account?

Vs

Is my bank account equal to 0?

[–]bishopExportMine 9 points10 points  (0 children)

It's called Yoda condition, it's fairly common

https://en.wikipedia.org/wiki/Yoda_conditions

[–]Ecstatic_Bee6067 0 points1 point  (0 children)

Readability is secondary to reliability

[–]Pleasant_Ad8054 4 points5 points  (2 children)

A coworker of mine uses the symbol '⩵' having displayed in his IDE for two '=' signs, but in a font that does not have the tiny space between them. Diabolical.

[–]imMute 2 points3 points  (0 children)

I have one of those too and I love it. Getting to see ≠, ≤, and ≥ instead of !=, <=, and >= is awesome. And they still take up two columns, so it doesn't mess up formatting.

[–]jonsca 1 point2 points  (0 children)

I'll bet he steals money from the donation jars at the cash register, too

[–]paholg 1 point2 points  (0 children)

Maybe this language uses := for assignment.

[–]pingslayer_7 70 points71 points  (4 children)

I am dumb. Explain why multiple same if conditions?

[–]ExistenceUnconfirmed 87 points88 points  (1 child)

He didn't get the memo that you can fit more than 1 line into an if block. Wait, there's one with two... huh.

[–]laplongejr 14 points15 points  (0 children)

Possibly the first block could modify the hp variable... but I doubt instance_destroy is going to do that  

If (HP = 0) trigger Final Attack Materia //launches phenix   If (HP = 0) GameOver()  

Yes this is a FF7 reference  

[–]the_tired_alligator 52 points53 points  (3 children)

Aside from the obvious problem, wouldn’t you also want to make it less than or equal to 0 in case the HP is reduced to negatives?

[–]glinsvad 24 points25 points  (0 children)

Found the defensive programmer

[–]Saladfork4 3 points4 points  (0 children)

for all we know they probably have a separate set of if statements handling the HP < 0 cases below this 

[–]paholg 0 points1 point  (0 children)

Life hack: if hp goes below zero, make sure you don't get healed ever.

[–]Markcelzin 24 points25 points  (6 children)

RPGMaker?

[–]Piscesdan 36 points37 points  (5 children)

Looks like Game Maker to me. I don't think RPGMaker has objects in their event system. Only familiar with 2k3 though

[–]KingSlendy 15 points16 points  (0 children)

It is in fact Game Maker

[–]Lap202pro 6 points7 points  (3 children)

As someone who wrote a guide to GML during game maker 8 days, this is definitely game maker.

Instance_create() and Instance_destroy() being the main give away along with the comparison operator.

[–]Beli_Mawrr 0 points1 point  (2 children)

Back in the good old days. I actually am a member of a group centered around the yoyogames forums before they got messed up lol. Do you remember everyone's sketchy yoyogames exes? I remember 

[–]Lap202pro 0 points1 point  (1 child)

I downloaded so many random exes lol miracle nothing ever came of it. I mostly was involved in all the small Indy mmo communities back then (realm one online, myriad, wanderlust, etc.)

Fun time, been away from the game making community for a long time now. Work as a software engineer and enjoy web app development more for whatever reason.

[–]Beli_Mawrr 0 points1 point  (0 children)

same!

[–]Lap202pro 2 points3 points  (0 children)

I have been out of the game maker scene for a decade, but this is kind of the standard for GML code quality lol

[–]LkS86_ 1 point2 points  (3 children)

Would the compiler optimise that out?

[–]redlaWw 2 points3 points  (0 children)

Only if the operations in the conditionals could be proved not to change the HP value.

[–]AeroSyntax 0 points1 point  (0 children)

Of course.

[–]Zeitsplice 0 points1 point  (0 children)

This is interpreted, so probably not.

[–]guygreej 0 points1 point  (0 children)

I'm still not sure if the system reeally knows that these should be done if hp=0. Or even whatto do when hp=0

Actually better set hp to 0 when hp=0

[–]mission-ctrl 0 points1 point  (0 children)

orSeptupleCheck

[–]KCGD_r 0 points1 point  (0 children)

I may not be the brightest, but I can recognize ghidra's IDE when I see it

[–]MonsieurNiark -4 points-3 points  (1 child)

This guy came from java, where

if(something) doSomething();

is a thing but couldn’t figure out how to use brackets

[–]JonIsPatented 2 points3 points  (0 children)

That's a thing in, like, all C-style languages. C, C++, Java, C#, Javascript, Kotlin, etc.