Most head-slapping feature in a language
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
Well, in SQL:
Len('hello') = Len(' hello')
is false (5 = 6). This is my fave thing to do in a query window for a quick update:
IF (1=2)
BEGINBEGIN TRAN UPDATE [SomeTable] SET [someColumn] = 'someNewValue' WHERE [someID] = 0
ROLLBACK
COMMIT
END
I still get intellisense within the BEING/END area and, should I accidentally press F5 or run the silly thing w/o selecting the code to run, no harm done. Yeah, I know, gotta make sure I include the WHERE clause, and also BEGIN TRAN. I then select and run COMMIT.
The best way to improve Windows is run it on a Mac. The best way to bring a Mac to its knees is to run Windows on it. ~ my brother Jeff
-
Well, in SQL:
Len('hello') = Len(' hello')
is false (5 = 6). This is my fave thing to do in a query window for a quick update:
IF (1=2)
BEGINBEGIN TRAN UPDATE [SomeTable] SET [someColumn] = 'someNewValue' WHERE [someID] = 0
ROLLBACK
COMMIT
END
I still get intellisense within the BEING/END area and, should I accidentally press F5 or run the silly thing w/o selecting the code to run, no harm done. Yeah, I know, gotta make sure I include the WHERE clause, and also BEGIN TRAN. I then select and run COMMIT.
The best way to improve Windows is run it on a Mac. The best way to bring a Mac to its knees is to run Windows on it. ~ my brother Jeff
Officially, I actively choose to not slap myself becuz of a (programming) language's nuance(s). :doh:
The best way to improve Windows is run it on a Mac. The best way to bring a Mac to its knees is to run Windows on it. ~ my brother Jeff
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
You had me at Javascript baby! ;P
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
English! fish equals ghoti :cool: Ghoti - Wikipedia[^]
"If we don't change direction, we'll end up where we're going"
ghoti and chips today, yum! ;P
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
The point of === is that "1" == 1 but "1" !== 1, that is, "1" === 1 will return false, due to the differing types
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
I had a colleague who insisted on occasionally writing the (perfectly valid but ummm counter-intuitive) form
index[array]
in C. He also worked out some multi-dimensional extensions, which my marginal brain is too small to contain. And yes, he did have a shot at the The International Obfuscated C Code Contest[^] Cheers, Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
The point of === is that "1" == 1 but "1" !== 1, that is, "1" === 1 will return false, due to the differing types
So obvious! :omg: :rolleyes: :laugh:
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
I had a colleague who insisted on occasionally writing the (perfectly valid but ummm counter-intuitive) form
index[array]
in C. He also worked out some multi-dimensional extensions, which my marginal brain is too small to contain. And yes, he did have a shot at the The International Obfuscated C Code Contest[^] Cheers, Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
What a legend! :D
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
So obvious! :omg: :rolleyes: :laugh:
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
The reason programming pays well is that you need to learn how the languages work :)
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
I remember being frustrated by the fact C# 1.0 had a default container called ArrayList. Is it an Array, or a List? These are very different things. Is it a fancy container that somehow has worked out how to get the benefits of both? The documentation never said.
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
Try the Predict the Output Challenge (C#)[^]. It shows some fun C# quirks (especially part 1) with types, enumerables etc. :D
Best, Sander sanderrossel.com Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
I'm sure your first one should be: ``` "1" == 1 is true ``` `===` specifically takes type into account. Javascript's type co-ercion can be a win or a lose, depending on what you want. If type matters, use `===` and `!==`
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
That kind of things already existed when our ancestors began to cast logic into silicon[^]. Of course, there also were well designed CPUs[^] that had exactly 256 opcodes, with only 0x68 being reserved as prefix for future expansions of the instruction set. And of course there are the opcodes 0xE0 - 0xEF, the 'Set X Register' instruction for registers 0x0 - 0xF, short SEX. Absolutely no confusion here.
I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
Chris Maunder wrote:
SQL:
Len("hello") = Len("hello ")
That is a fun one that I came across a while ago. for some reason SQL Server ignores the trailing spaces hence they match. LEN (Transact-SQL) - SQL Server | Microsoft Docs[^]
Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
erm, typo?
"1" === 1 is false
"1" == 1 is true (truthy rather) -
Officially, I actively choose to not slap myself becuz of a (programming) language's nuance(s). :doh:
The best way to improve Windows is run it on a Mac. The best way to bring a Mac to its knees is to run Windows on it. ~ my brother Jeff
Re-read the OP. Chris didn't state he was going to slap his own head .... :laugh:
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
-
@Forogar and I were having a chat about unintended programming features (ahem) due to things like: Javascript's truthy:
"1" == 1 is true
Rexx:" Hello " == "Hello" and 0.0 == 0 is not the same as 0 == 0.0
SQL:Len("hello") = Len("hello ")
I'm just wondering what other family favourites there are out there. (Edited because clearly I’ve lost track of what’s up and what’s down)cheers Chris Maunder
In Fortran (at least in the old days, Fortran IV and thereabouts) has no reserved words. Spaces have no significance. So you could declare a variable named INTEGER REAL INTEGER INTEGER = 3.14 or a subroutine named FUNCTION to be invoked by CALL FUNCTION(...) The standard loop construct is the DO loop, but DO U BLEP RECISION IF is not the start of a loop. Rather, you could make a comparison with the above variable IF (IF.GT.INTEGER) ... In my student days, there was a single course teaching Fortran. We made it a habit to solve the execizes using predefined identifiers only. Sort of like OCCC, but it took far less effort to obfuscate Fortran.
-
The point of === is that "1" == 1 but "1" !== 1, that is, "1" === 1 will return false, due to the differing types
This is the kind of crap you get in a weakly typed language.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013