Jump to content

Favorite False Cognates in CS

Featured Replies

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?

Bash for loop is different again:

 

for i in *

iterates over all files in the current directory.

Edited by Manticore

Archived

This topic is now archived and is closed to further replies.

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.