CF: EQ vs IS

Being a professional programmer in ColdFusion (among other languages), I read a lot of criticism about it. Quite some people argue about whether ColdFusion is a “real” programming language or not. The main reason for this is that it has an XML-like syntax instead of the conventional syntax using brackets and operators (==, !=, >, etc), which had me wondering.

In ColdFusion, there are two main ways (apart from functions) to compare values, like == does in most programming languages: EQ and IS, like the code below shows:

<cfif foo eq bar>
	<!--- Statement #1 true --->
<cfelseif foo is somethingelse>
	<!--- Statement #2 true --->
</cfif>

The keywords are different, but what is the difference? I always use EQ and it suits me fine, but I got curious up to a point I just had to do research. And I found the answer: there is no difference! Apart from the two characters being different they do exactly the same. Both being two characters in length they even add up to the file size the same.

It’s pretty strange if you ask me, though I don’t know the story behind it. I do know that Ben Forta mentioned it in one of his books and it’s widely discussed how and why to use either or both of them. It seems as a popular way to use it is EQ for numeric types and IS for everything else.

So, if you didn’t, now you know.

Leave a reply