Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "comparison operators"
-
It's not that I hate PHP, I just hate the lack of consistency in standard function naming and parameter order, nonsensical attribute access, nearly-meaningless comparison operators, reference handling, case (in)sensitivities, and more!
I mean, look at these functions:
strtoupper(...)
bin2hex(...)
strtolower(...)
And look at THESE FUNCTIONS:
array_search($needle, $haystack)
strpos($haystack, $needle)
array_filter($array, $callable)
array_map($callback, $array)
array_walk($array, $callable)
And let me jUST USE SOME ATTRIBUTES:
$object->attr = "No dollar sign...";
Class::$attr = "GOD WHY";
HOW ABOUT SOME COMPARISONS:
(NULL == 0) // true
(NULL < -1) // ALSO true
Functions AREN'T CASE SENSITIVE (at least variables are).
Wanna dereference? TOO BAD, YOU'LL HAVE TO GET OUT THE TNT.
Alright, yeah, I hate PHP.19 -
This.
Not the worst but almost all of us (including me) handle strings like fucking morons.
If the input doesn't need to be an exact match we use a explicit comparison operator, when the input should explicitly match we do a loose comparison operator.
I'll format the crap out of a number, convert it, validate decimal places, check for float rounding hell, give it a absolute value and return it correctly formatted for the users locale but half the time I forget to trim their input. 🤦♂
Like I said - just a tad fucking moronic isn't it?3 -
Some Java code I looked through to figure out how to accurately rework a mapping of value intervals to status colors:
• 16 levels of indentation
• Calls an instance method one line before a null-check
• Assigns that same value to a new variable and null-checks it again
• Insistently loops over existing HashMaps' entry sets to find a value by key
• Stringifies a Gson object, parses back the string and then null-checks the result.
• Mixes up the 'leq' and 'geq' comparison operators twice, which is why I went to check the implementation in the first place.
And this wasn't even legacy code. It's from last year.1 -
Java apparently thinks it would be too convenient if we would use comparison operators on enumerations.
If you have to use the .ordinal() every time you want to do such a thing, you make the code uglier that you're trying to clean up to begin with!
Time to do this the hard way:
public static final int YELLING = 0;
public static final int SCREAMING = 1;
...1 -
I hate this crap and wish people would stop doing it. It makes my brain bleed and doesn't prevent any difficult to find bugs.
if (TERMINAL_COUNT <= index_thing)
English doesn't work that way, and I don't know about you but this crap is just awkward as hell. Sweet Jesus I wish there was less cargo cult programming in the world. Just because you saw something in a blog that convinced you that reverse comparisons is best doesn't mean it actually is. Use a damn static analysis tool to catch accidental assignments in expressions, don't twist my brain to interpret your weird phrasing of comparison operators. Some of your code reviewers may be dyslexic and have enough problems as it is.
And now for the mini-rant that I'm actually here for: You know what makes for difficult to find bugs? (Hint: It sure as hell isn't an assignment in an expression) Releasing an RTEMS semaphore you've never obtained. You'd think that would cause some kind of panic or assert failure but nope. Instead it causes... misaligned address exceptions? In statically allocated global memory? WTF??1