C-family of Computer Language Keywords
In the (very large) table in this article are the keywords for the six most popular C-family languages, useful if you are looking to compare keywords between the C-family languages. The popularity index of computer programming languages is taken from the Stack Overflow 2017 Survey. The most popular C or C-like languages are C, C++, Java, PHP, JavaScript and C#.
(Keywords are words that cannot be used by the programmer as identifiers in their code. They are reserved for use by the computer languages themselves for compilation or interpretation.)
The Top 10 Most Popular Programming Languages
The Stack Overflow survey is a good indicator to use for the most popular programming languages. This is because Stack Overflow is a leading question and answer resource for working programmers. So it reflects actual programming language usage. In the Stack Overflow survey the top 10 most popular programming languages are:
- JavaScript
- SQL
- Java
- C#
- Python
- PHP
- C++
- C
- TypeScript
- Ruby
For the keywords table below only C-family languages that scored 10% or more in the survey were chosen. I.e. 9 out of every 10 survey respondents used one of the languages. This gave the six most popular C-family languages of C, C++, Java, PHP, JavaScript and C#. Interesting TypeScript just missed out of being in the list. What is TypeScript? TypeScript is a superset of JavaScript, a sort of JavaScript++. TypeScript being in the top 10 of most popular programming languages means that 7 out of 10 top programming languages are C-family languages. Therefore Dennis Ritchie and Ken Thompson certainly got something right with the C programming language.
When were the C-family languages invented?
- C - 1972, derived from a language called B from 1969, which was derived from BCPL from 1966
- C++ - 1983 beginning as C with Classes in 1979
- Java - 1995 beginning as Oak in 1991
- PHP - 1995
- JavaScript - 1995
- C# - 2000
- TypeScript - 2012, work began in 2010
Out of the top 10 computer languages only three are not C-family related. Second on the list is another language that orginates from the 1970's, Structured Query Langauge (SQL), the language of relational databases. I.e. a language for storage, compared to C which is a language for computation. However, C often interfaces to SQL in business and engineering software.
Source of the C-family Language Keywords
The following sources where used to compile the table of C-family languages keywords.
- C - http://en.cppreference.com/w/c/keyword
- C++ - http://en.cppreference.com/w/cpp/keyword
- Java - https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
- PHP - http://php.net/manual/en/reserved.keywords.php
- JavaScript - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
- C# - https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/index
Keyword Survival of the Fittest
So which C-family keywords exist across all six of the C-like chosen languages. Using the table of keywords these 12 common ones can be seen:
- break
- case
- const
- continue
- default
- do
- else
- for
- if
- return
- switch
- while
If JavaScript was removed the above list would expand to include a lot of basic types and function modifiers. This is because JavaScript is not a strongly typed language.
List of C-family Languages Keywords
There is no claim of completeness in this table, but if you see a mistake or missing item please let me know. This table is based on the latest version of each language. Just because a keyword appears in more than one language it may not have the same meaning. If it does have the same meaning there may be subtle differences. Understanding the differences is part of being a good programmer.
A keyword in one language may be implemented as a function in another language, or a literal, and vice versa. Only keywords as recognised by the interpreter or compiler are listed. Future reserved words are not included, but if used a compiler may produce a warning. See the resources listed above for more information on future reserved words.
The C# Contextual Keywords are not listed as they are not reserved words but only mean something in specific circumstances, see the C# Contextual Keywords documentation.
Although true, false and null are literals in Java they are include in this list for ease of reference as they cannot be used as identifiers (they are shown in the table in italics).
C | C++ | Java | PHP | JavaScript | C# |
---|---|---|---|---|---|
abstract | abstract | abstract | |||
_Alignas | alignas | ||||
_Alignof | alignof | ||||
and | and | ||||
and_eq | |||||
array() | |||||
as | as | ||||
asm | asm | ||||
assert | |||||
atomic_cancel | |||||
atomic_commit | |||||
atomic_noexcept | |||||
_Atomic | |||||
auto | auto | ||||
base | |||||
bitand | |||||
bitor | |||||
_Bool | bool | boolean | bool | ||
break | break | break | break | break | break |
byte | byte | ||||
callable | |||||
case | case | case | case | case | case |
catch | catch | catch | catch | catch | |
char | char | char | char | ||
char16_t | |||||
char32_t | |||||
checked | |||||
class | class | class | class | class | |
clone | |||||
compl | |||||
_Complex | |||||
concept | |||||
const | const | const | const | const | const |
constexpr | |||||
const_cast | |||||
continue | continue | continue | continue | continue | continue |
debugger | |||||
decimal | |||||
declare | |||||
decltype | |||||
default | default | default | default | default | default |
delegate | |||||
delete | delete | ||||
die() | |||||
do | do | do | do | do | do |
double | double | double | double | ||
dynamic_cast | |||||
echo | |||||
else | else | else | else | else | else |
elseif | |||||
enum | enum | enum | enum | ||
empty() | |||||
enddeclare | |||||
endfor | |||||
endforeach | |||||
endif | |||||
endswitch | |||||
endwhile | |||||
eval() | |||||
event | |||||
exit() | |||||
explicit | explicit | ||||
export | export | ||||
extends | extends | extends | |||
extern | extern | extern | |||
false | false | false | false | ||
final | final | final | |||
finally | finally | finally | finally | ||
fixed | |||||
float | float | float | float | ||
for | for | for | for | for | for |
foreach | foreach | ||||
fortran | |||||
friend | |||||
function | function | ||||
_Generic | |||||
global | |||||
goto | goto | goto | goto | goto | |
__halt_compiler() | |||||
if | if | if | if | if | if |
_Imaginary | |||||
implements | implements | ||||
implicit | |||||
import | import | import | |||
in | in | ||||
include | |||||
include_once | |||||
inline | |||||
instanceof | instanceof | instanceof | |||
insteadof | |||||
int | int | int | int | ||
interface | interface | interface | |||
internal | |||||
is | |||||
isset() | |||||
list() | |||||
lock | |||||
long | long | long | long | ||
module | |||||
mutable | |||||
native | |||||
namespace | namespace | namespace | |||
new | new | new | new | new | |
noexcept | |||||
_Noreturn | |||||
not | |||||
not_eq | |||||
null | null | null | |||
nullptr | |||||
object | |||||
operator | operator | ||||
or | or | ||||
or_eq | |||||
out | |||||
override | override | ||||
package | |||||
params | |||||
private | private | private | private | ||
protected | protected | protected | protected | ||
public | public | public | public | ||
readonly | |||||
ref | |||||
register | register | ||||
reinterpret_cast | |||||
require | |||||
require_once | |||||
requires | |||||
restrict | |||||
return | return | return | return | return | return |
sbyte | |||||
sealed | |||||
short | short | short | short | ||
signed | signed | ||||
sizeof | sizeof | sizeof | |||
stackalloc | |||||
static | static | static | static | static | |
_Static_assert | static_assert | ||||
static_cast | |||||
strictfp | |||||
string | |||||
struct | struct | struct | |||
super | super | ||||
switch | switch | switch | switch | switch | switch |
synchronized | synchronized | ||||
template | |||||
this | this | this | this | ||
_Thread_local | thread_local | ||||
throw | throw | throw | throw | throw | |
throws | |||||
trait | |||||
transaction_safe | |||||
transaction_safe _dynamic | |||||
transient | |||||
true | true | true | true | ||
try | try | try | try | try | |
typedef | typedef | ||||
typeid | |||||
typeof | typeof | ||||
typename | |||||
uint | |||||
ulong | |||||
unchecked | |||||
union | union | ||||
unsafe | |||||
unset() | |||||
ushort | |||||
unsigned | unsigned | ||||
use | |||||
using | using | ||||
var | var | ||||
virtual | virtual | ||||
void | void | void | void | void | |
volatile | volatile | volatile | volatile | ||
wchar_t | |||||
while | while | while | while | while | while |
with | |||||
xor | xor | ||||
xor_eq | |||||
yield | yield |
Compile Time Keywords
- C, C++ Preprocessor -
#if
,#elif
,#else
,#endif
,#defined
,#ifdef
,#ifndef
,#define
,#undef
,#include
,#line
,#error
,#pragma
,_Pragma()
- PHP constants -
__CLASS__
,__DIR__
,__FILE__
,__FUNCTION__
,__LINE__
,__METHOD__
,__NAMESPACE__
,__TRAIT__
See Also
- View the Tek Eye full Index for other articles.
Author:Daniel S. Fowler Published: