What little things do you find annoying about your favourite programming language / tool / framework / etc?
Jquery:
$("select.foo option:selected").val();
$("#greatphoto" ).attr( "alt", "Beijing Brush Seller");
$( "p" ).text( "<b>Some</b> new text." );
If I haven't worked in Jquery for a while, I always have to google for how to set attributes and values, if you look at the docs, attr and val as far as I can see are the only two methods with shortened names, everything else is written out in full like text.
In JavaScript numeric 0 is falsy whereas string 0 is true! This is where I get confused most of the times. Yuck!
For me it's using this keyword inside setTimeout. For example, you will need to bind to this in order to use this keyword.
setTimeout(function(){
//do something with this
}.bind(this));
Sometimes I define a new variable self outside setTimeout and sometimes I end up using .bind().
Python:
if expression:
statement(true)
else:
statement(false)
anotherStatement(bleh)
What can possibly be wrong with this? If the first four lines are using spaces and the last line is using a tab, that last statement will not execute as part of the else, but every time whether expression is true or false. Python should decide, spaces or tabs and throw an error if you mix them.
I see Python 3 doesn't allow mixing tabs and spaces, older versions of Python 2 which I used didn't even give as much as a warning and strange things would happen in the code.
JavaScript:
"Why am I a " + typeof + ""; // "Why am I a number"
Automatic type conversion in JavaScript I find is responsible for most of the bugs I've seen and WTF moments.
PHP:
int strpos ( string $haystack , mixed $needle [, int $offset= 0 ] )
string stristr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
mixed array_search ( mixed $needle , array $haystack [, bool $strict ] )
Come on, decide on whether it's needle or haystack first!
Java:
Calendar today = GregorianCalendar.getInstance();
System.out.println(today.get(Calendar.YEAR) + "-" + today.get(Calendar.MONTH) + "-" + today.get(Calendar.DAY_OF_MONTH));
What do you think this will print?
Guess again!
2016-0-11
Since month is using an enum, it's zero based while everything else is 1-based. Very annoying!!!
Luckily Java8 has a better calendar / date system.
Samuel Oloruntoba
Java is to JavaScript what Car is to Carpet.
This is 10 in javascript, at first it was a real head scratcher, but after many stackoverflow posts and google I finally got it. I really hated seeing ++[[]][+[]]+[+[]]