Jump to content

Favorite False Cognates in CS


ydoaPs

Recommended Posts

In linguistics, a cognates are words two different languages that sound the same and have the same meaning. English "beer" and German "Bier" are cognates. Similarly, false cognates sound the same, but have vastly different meanings. English "gift" and German "Gift" are false cognates, as an English gift is something you get someone you like and the German Gift is something you give someone you want to die, namely poison.

In CS, different languages have similar ideas with similar names. Floats, ints, and doubles are everywhere. 

I'm interested in seeing your favorite examples false cognates in programming languages.

My favorite is the for loop. Python's for loop is nothing like the rest of the for loops.

Python's for loop iterates over an iterable while letting the program do stuff with the current member for each iteration. The rest of them initialize a variable, then let the program do stuff with the variable, then increment/decrement the variable. That goes on until the cessation condition is met.

Python:

for member in iterable:
  stuff(member)

C++:

for(initialize variable; cessation condition; increment/decrement){
  stuff(variable);}

For python to mimic the other for loops, it would need a while loop.

def cpp_for(initialization, condition, incrementation):
  i  = initialization
  while(condition):
    stuff(i)
    i += 1 if incrementation == 'increment' else i -= 1

 

 

What's your favorite example?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.