Wednesday, July 28, 2010

Keywords by Language

Keywords (Reserved Words) Repository

The updated list will always be in the "Keywords" Page at the top of this blog (

Keywords: 102

abstract event new struct as explicit null switch base extern 
object this bool false operator throw break finally out true
byte fixed override try case float params typeof catch for 
private uint char foreach protected ulong checked goto public unchecked
class if readonly unsafe const implicit ref ushort continue in 
return using decimal int sbyte virtual default interface sealed volatile
delegate internal short void do is sizeof while double lock 
stackalloc else long static enum namespace string add alias ascending 
descending dynamic from get global group into join let orderby 
partial remove select set value var where yield __arglist __makeref 
__reftype __refvalue
Keywords: 137

AddHandler AddressOf Alias And AndAlso Ansi As Assembly Auto Boolean 
ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate
CDec CDbl Char CInt Class CLng CObj Const CShort CSng 
CStr CType Date Decimal Declare Default Delegate Dim DirectCast Do
Double Each Else ElseIf End Enum Erase Error Event Exit 
False Finally For Friend Function Get GetType GoSub GoTo Handles
If Implements Imports In Inherits Integer Interface Is Let Lib 
Like Long Loop Me Mod Module MustInherit MustOverride MyBase MyClass
Namespace New Next Not Nothing NotInheritable NotOverridable Object On Option 
Optional Or OrElse Overloads Overridable Overrides ParamArray Preserve Private Property
Protected Public RaiseEvent ReadOnly ReDim REM RemoveHandler Resume Return Select 
Set Shadows Shared Short Single Static Step Stop String Structure
Sub SyncLock Then Throw To True Try TypeOf Unicode Until 
Variant When While With WithEvents WriteOnly Xor
Keywords: 84

asm auto bool break case catch char class const const_cast
continue default delete do double dynamic_cast else enum explicit export 
extern false float for friend gcnew goto if inline int
long mutable namespace new nullptr operator pin_ptr private protected public 
register reinterpret_cast restrict return safe_cast short signed sizeof static static_cast 
struct switch template this throw true try typedef typeid typename 
_typeof union unsigned using virtual void volatile wchar_t while each
interface value abstract delegate event finally generic in initonly literal 
override property sealed where
Keywords: 97

abstract and as assert base begin class default delegate do
done downcast downto elif else end exception extern false finally
for fun function global if in inherit inline interface internal
lazy let match member module mutable namespace new not null
of open or override private public rec return static struct
then to true try type upcast use val void when
while with yield asr land lor lsl lsr lxor mod 
sig atomic break checked component const constraint constructor continue eager 
event external fixed functor include method mixin object parallel process
protected pure sealed tailcall trait virtual volatile
Keywords: 66

abstract and as AST break callable cast char class constructor
continue def destructor do elif else ensure enum event except
failure final from for false get given goto if import
in interface internal is isa not null of or otherwise
override namespace partial pass public protected private raise ref retry
return self set super static struct success transient true try
typeof unless virtual when while yield 
Keywords: 92

and or xor exception array as break case class const 
continue declare default die do echo else elseif empty enddeclare 
endfor endforeach endif endswitch endwhile eval exit extends for foreach 
function global if include include_once isset list new print require 
require_once return static switch unset use var while final interface 
implements instanceof public private protected abstract clone try catch throw 
this namespace goto __LINE__ __FILE__ __FUNCTION__ __CLASS__ __METHOD__ __DIR__ __NAMESPACE__
import using object string int int64 double bool resource TRUE
FALSE NULL virtual unset parent __destruct __get __set __call __sleep
__wakeup __tostring
IronPython & Jython
Keywords: 31

and del from not while as elif global or with
assert else if pass yield break except import print class 
exec in raise continue finally is return def for lambda 
IronRuby & JRuby
Keywords: 38

alias and BEGIN begin break case class def defined do
else elsif END end ensure false for if in module
next nil not or redo rescue retry return self super
then true undef unless until when while yield
Delphi Prism
Keywords: 134

and as assembly begin break case class const constructor continue 
delegate div do downto else end ensure event except exit 
false finalizer finally for forward function future if implementation in 
inherited interface invariants is locking loop method mod module namespace 
new nil not nullable of old on operator or out 
parallel private procedure property protected public raise record repeat require 
result self set shl shr then to true try type 
unit until uses using var where while with xor yield
abstract add array async default each empty enum external final 
finalizer flags global has implements implies index inline iterator locked 
matching nested notify override params partial pinned read readonly reintroduce 
remove sealed sequence static step unsafe virtual where write asc 
desc distinct equals from group by into join on order
reverse select skip take
Keywords: 50

accept activity array as await begin by case const definition 
div do else elsif end exception exit false for if
implementation implements import in is loop mod module new nil 
object of on operator or procedure protocol record refines repeat 
return self termination then to true type until var while
Keywords: 59

_ abstract and array as base catch class def delegate 
do else enum event extern false finally for foreach fun 
if implements in interface internal lock macro match module mutable namespace 
new null out override params private protected public ref sealed 
static struct syntax this throw true try type typeof unless 
using variant virtual void when where while assert ignore
Keywords: 57

abstract as assert boolean break byte case catch char class
const continue def default do double else enum extends false
final finally float for goto if implements import in instanceof
int interface long native new null package private protected public
return short static strictfp super switch synchronized this threadsafe throw
throws transient true try void volatile while
Keywords: 50

abstract continue for new switch assert default goto package synchronized
boolean do if private this break double implements protected throw
byte else import public throws case enum instanceof return transient 
catch extends int short try char final interface static void
class finally long strictfp volatile const float native super while
Keywords: 139

abstract fake internal new nonvirtual private protected public shared override 
partial virtual vari inout out adds all and any as 
assert body branch break callable catch class const continue cue 
def do dynamiceach else end ensure enum event every except 
extend finally for from get has if ignore implements implies 
in inherits inlined interface invariant is listen lock mixin must 
namespace not objc of old on or pass passthrough post 
print pro raise ref require return same set sig stop 
struct success test throw to trace try using var where 
while yield true false nil use import base this Array 
char Color decimal dynamic DateTime Dictionary Exception float float32 float64 
int int8 int16 int32 int64 ICloneable IComparable IDictionary IEnumerable IList 
List number Object Queue Set Stack StreamReader StreamWriter String StringBuilder 
StringReader StringWriter TextReader TextWriter uint uint8 uint16 uint32 uint64
Keywords: 46

abstract as assert break case catch class const continue default
do else enum false final finally for foreach if internal
is isnot it mixin native new null once override private
protected public readonly return static super switch this throw true
try using virtual volatile void while
Keywords: 75

break case catch class const continue debugger default delete do
else export extends false finally for function if import in
instanceof new null protected return super switch this throw true
try typeof var while with abstract boolean byte char decimal
double enum final float get implements int interface internal long
package private protected public sbyte set short static uint ulong
ushort void assert ensure event goto invariant namespace native require 
synchronized throws transient use volatile
Keywords: 40

abstract case catch class def do else extends false final
finally for forSome if implicit import lazy match new null
object override package private protected requires return sealed super this 
throw trait try true type val var while with yield
Keywords: 70

abstract after and as assert at attribute before bind bound 
break catch class continue def delete else exclusive extends false 
finally first for from function if import indexof in init 
insert instanceof into inverse last lazy mixin mod new not 
null on or override package postinit private protected public-init public 
public-read replace return reverse sizeof static step super then this 
throw trigger true try tween typeof var where while with
Keywords: 53

application new as null break override case package catch private 
class property continue protected default public do readonly else request 
eval return except session execution set extends static finally super 
final switch find this for try foreach typeas function typeis 
get typeof hide unless implements uses index var interface void 
internal while native

Sunday, July 25, 2010

What makes a programming language BIG?

Yesterday, I found a very interesting post about someone who is going to talk in the next JavaOne 2010 event. His topic is: "Next Big JVM language" and he was/is asking for poeple to give their opinion on the subject by giving some questions/points that you can find here: Of course I left my comments there, but then I thought that it is a very interesting point which is really related to the topics I would like to share in this blog, so I'm doing my own post about it here.

What makes a language BIG?

Let's start by getting on the same context. To me, BIG means that the Programming Language is widely used (and popular); widely used by professionals (at enterprises), students (at universities) and hobbyists (at home).

1. Syntax matters. Most of the modern languages running on the CLR and/or JVM support almost the same number of features. The only difference between them is really the syntax you need to accomplish the same stuff. Programmers will say: that language is C-Like syntax? Then I will give it a try (C++, Java, C#, D and then Go).

2. It COULD be Multi-Paradigm, but to be BIG, it MUST support OOP, which is in fact, the most widely used paradigm out there. Again, nowadays, most of the languages support OOP, even if they were conceived to be Scripting or Functional. Why? Because to be big it needs to support what all kind of programmers (professionals, students, hobbyists) are familiar with.

3. Is not only the language, but the IDE support as well that makes a language popular (widely used).

  •  First, because “Syntax Matters”, it needs to support: syntax highlight, intellisense, auto-competition, code generation, etc.
  • Second, it should allow you to build several types of applications such as: web, desktop, scripts, console, services, etc. 
  • Support debugging.

4. It needs to be FREE to use. Not necessarily Open Source, but just FREE, so anyone can use it, build stuff with it and enjoy it.

5. Interoperability with other Languages. This is accomplished by languages implemented on top of the JVM or CLR. That’s one reason why a big JVM/CLR language is better than a native mono-language environment. Another benefit is that if your favorite language does not support a feature you want/need you can do it in a different language and mix it nicely.

6. Libraries/Frameworks support. Languages running on top of the JVM/CLR runtimes get the benefit of using several existing stable libraries that allows the programmer to build almost anything they want.

What do you think is most important to make a language big and popular?

Thursday, July 15, 2010

How many lines to code the same?

On my last post I compared several programming languages based on the number of keywords they define and how many are needed, and not needed, in your code to build a simple OO program. We will see now how they compare on “Lines of Code”, but before that, let’s begin with some wiki-Definitions (taken from:

Source lines of code (SLOC) is a software metric used to measure the size of a software program by counting the number of lines in the text of the program's source code. SLOC is typically used to predict the amount of effort that will be required to develop a program, as well as to estimate programming productivity or effort once the software is produced.”

1.       Scope for Automation of Counting: manual counting effort can be easily automated.
2.       Intuitive Metric: due to the fact that it can be seen and visualized.

1.       Lack of Accountability: not really useful to measure productivity of a project only with results from the coding phase.
2.       Lack of Cohesion with Functionality: program developed using less code can have better features.
3.       Adverse Impact on Estimation: because only based on the coding phase, estimates can adversely go wrong.
4.       Developer’s Experience: lines of code differ from person to person due to experience.
5.       Difference in Languages: lines of code differ from language to language due to language design and features. It will require different effort depending on the language.
6.       Advent of GUI Tools: GUI tools allow writing little code and achieving nigh levels of functionality. Those tools also automatically generate code (which shouldn’t be considered in the metric)
7.       Problems with Multiple Languages: today’s software is developed in multi-language scenarios, hence it is difficult to attribute productivity and defect rates on them due its integration.
8.       Lack of Counting Standard: no standard of what a line of code is (comments? Statements? Multi-line Statements, etc.)
9.       Psychology: programmers get an incentive to write unnecessarily verbose code if measured by lines of code.

Measure programming productivity or effort is not really the objective of this post. What I wanted to show you is; how programming languages compare between them based on the number of lines you need to code to achieve exactly the same piece of code (OO Hello World), following exactly the same rules (same program structure, language standards conventions), and using the same features (same paradigm, no idiomatic code). Said that, let’s see the numbers.

Version 1 (Minimal)

Language Lines
F# 7
Scala 8
Boo 10
IronPython 10
Jython 10
IronRuby 13
JavaFX 13
Groovy 13
JRuby 13
JScript 13
Cobra 15
Nemerle 18
C++/CLI 20
Java 20
Zonnon 21
Fantom 22
C# 24
Phalanger 24
Delphi Prism 39

Version 2 (Verbose)

Language Lines
F# 12
Boo 14
IronPython 15
Groovy 15
Jython 15
Scala 15
IronRuby 17
JRuby 17
JavaFX 18
Cobra 18
Java 21
Zonnon 22
Fantom 22
JScript 22
C++/CLI 24
C# 26
Nemerle 26
Phalanger 29
Delphi Prism 40

Both (Minimal and Verbose) 

Language Minimal Verbose
C# 24 26
VB.NET 17 20
C++/CLI 20 24
F# 7 12
Boo 10 14
Phalanger 24 29
IronPython 10 15
IronRuby 13 17
Delphi Prism 39 40
Zonnon 21 22
Nemerle 18 26
Groovy 13 15
Java 20 21
Cobra 15 18
Jython 10 15
JRuby 13 17
Fantom 22 22
JScript 13 22
Scala 8 15
JavaFX 13 18


How many lines of code you write is mostly guided by programmer's personal preferences unless some guidelines specify the contrary.

In this comparison, the functional languages F# and Scala are the ones with less lines of code, followed by the Scripting languages such as: Python, Ruby, Groovy and JScript.

Languages that support scripting capabilities are normally shorter than those that don't since no main method/class and extra blocks are required.

Programming languages using opening and closing curly brace { } as blocks usually requires more lines of code (or at least in my example) since the closing bracket counts as a new lines. You can see this between Java and C#:

Delphi Prism is again the one at the top of the list , as you can see both, the minimal and verbose versions of the code, differ only by 1 line. No doubt Delphi Prism is the most Verbose programming language in Keywords and Lines (of the 19 languages I'm comparing). Definitively, the separation of implementation and interface is what makes the difference! Just compare it with Zonnon and you will see what I mean.

VB.NET smaller than C#? Yes, unless opening curly brace { starts at the beginning block line.


Sunday, July 11, 2010

How many keywords do you type in your code?

Have you ever wondered how many keywords (reserved words) do you type in your programs? Can you type more or type less without changing what your program does? Can you change programming language and save some typing? And if so, which language? If you have, then I knew it! I’m not alone! these questions can be easily answered by looking at the graphs of the bottom!

UPDATE: second part of this post is here: 

Today’s post is about programming language keywords, also known as reserved words, and how many of them you need to write some code. Let’s start with some definitions taken from Wikipedia:

“In computer programming, a keyword is a word or identifier that has a particular meaning to the programming language. The meaning of keywords — and, indeed, the meaning of the notion of keyword — differs widely from language to language.”

“In many languages, such as C and similar environments like C++, a keyword is a reserved word which identifies a syntactic form. Words used in control flow constructs, such as if, then, and else are keywords. In these languages, keywords cannot also be used as the names of variables or functions.”

“Languages vary as to what is provided as a keyword and what is a library routine. Some languages, for instance, provide keywords for input/output operations whereas in others these are library routines. In Python (versions earlier than 3.0) and many BASIC dialects, print is a keyword. In contrast, the C and Lisp equivalents printf and format are functions in the standard library.”

To be able to get some numbers I needed to have some input data:
  1. The Code (the program where the keywords are used) 
  2. The Language (the programming languages used to write the program)
  3. The Rules (that allowed me to compare 1 to 1 each of the 20 programming languages)

The first step was to decide which program to use. I quickly found exactly what I was looking for! An Object Oriented version of the famous Hello World program which included syntax for: creating a class, defining a private data member, defining a method, creating a program, creating an instance of an object and calling the method. Why did I choose that? You can find out in one of my previous posts (

Once I identified the program to use; I took 20 programming languages from my list of “The most active .NET and Java languages” ( that provide built in Object Oriented capabilities. Those languages were: 
.NET/CLR: C#, VB.NET, C++/CLI, F#, Boo, Phalanger, IronPython, IronRuby, Delphi Prism, Zonnon, Nemerle, Cobra and JScript. Java/JVM: Java, JavaFX, Groovy, Jython, JRuby, Fantom and Scala.

Finally, I knew that the combination of the programming language and the compiler gives you a lot of freedom on how to write your code. It can be that the import statement is not required because an implicit import to System is already done, you can write it as an Script (if the language support it) which does not require a program class nor a Main method, you can begin blocks on one line or another, sometimes the language define their best practices on how to write your program, etc. So, I decided to add some rules:

1.       All programs written in any language must follow the same Program structure.

[Import / using / etc]
                Instantiate Class
                Call Method       => OUTPUT (Hello, World!)

2.       If the language supports extra features that are built in such as: String.Capitalize() mehod or ucwords(), UCase() global functions I used them.

3.       Even if a language defines “string” as keyword I didn’t count it as such. I considered string to be String.System even if I used the string keyword.

4.       To be able to follow the first rule (same program structure), but to also show the language Scripting support I decided to create 2 versions of the same program by language:

Version 1 (Minimal): The minimum you need to type to get your program compiled and running.
Version 2 (Verbose): Explicitly adding instructions and keywords that are optional to the compiler.

If scripting is supported It was done that way in the “Minimal” version.

You can find the 20 programming languages and their respective version of the program in my last 19 (+ JavaFX) previous blog posts which can be easily located in the Blog Archive (2010 - July (6) and June (13)) section on the right.

For God’s sake show me the numbers!!!

VoilĂ ! Here you go! (click on the image to enlarge)

Total Keywords by Language

Language Keywords
Cobra 139
VB.NET 137
Delphi Prism 134
C# 102
F# 97
Phalanger 92
C++/CLI 84
JScript.NET 75
JavaFX 70
Boo 66
Nemerle 59
Groovy 57
Zonnon 50
Java 50
Fantom 46
Scala 40
IronRuby 38
JRuby 38
IronPython 31
Jython 31

Version 1 (Minimal)

Language Keywords
Delphi Prism 35
Zonnon 16
Java 12
C++/CLI 11
Phalanger 10
C# 10
Cobra 9
Nemerle 9
JScript.NET 7
Boo 7
JRuby 6
IronRuby 6
F# 5
Scala 5
Fantom 5
JavaFX 5
Groovy 5
Jython 4
IronPython 4

Version 2 (Verbose)

Language Keywords
Delphi Prism 39
Zonnon 21
Boo 17
Java 16
Nemerle 16
Phalanger 16
C++/CLI 16
JavaFX 15
JScript.NET 15
C# 15
Cobra 14
F# 12
Groovy 11
Scala 10
Fantom 9
JRuby 6
IronRuby 6
Jython 6
IronPython 6

Both (Minimal and Verbose) 

Language Minimal Verbose
JavaFX 5 15
Scala 5 10
JScript.NET 7 15
Fantom 5 9
JRuby 6 9
Jython 4 6
Cobra 9 14
Java 12 16
Groovy 5 11
Nemerle 9 16
Zonnon 16 21
Delphi Prism 35 39
IronRuby 6 9
IronPython 4 6
Phalanger 10 16
Boo 7 17
F# 5 12
C++/CLI 11 16
VB.NET 24 34
C# 10 15


We can identify 3 main groups of languages:
1. Scripting/Dynamic Languages (Python, Ruby, Groovy, etc.) fewer keywords
2. Functional Languages (F#, Scala, etc.) more or less than the previous group
3. Imperative/Static Languages (C#, C++, VB.NET, etc.) more keywords

Evidently, the scripting/dynamic languages are the ones that define the fewer keywords with the exception of Groovy, which I think is because its class modifiers or Java syntax compatibility.

We can also see a relation (not in every case) between the total number of keywords that the language defines with the number of keywords you need to type in the code using that language.

Delphi Prism is the most verbose language followed by VB.NET!
Python is the most minimalistic language followed closely by Groovy, Ruby and Fantom.

I have read that Delphi Prism syntax is very elegant (and I agree), but the same is true with F# and Scala, so, this tell us that the verbosity of the language has nothing to do with its elegance or expressiveness.

To answer the questions at the top lets see one by one:
How many keywords (reserved words) do you type in your programs?
> That will depend of your program (size), but this can give you a basic idea.

Can you type more or type less without changing what your program does?
> Yes. That's why I did 2 versions of the same program: the Minimal and the Verbose.

Can you change programming language and save some typing?
> Yes. But in the real life I don't think that you can change a language just because how many keywords you type with it! hehe you usually do it because of features or impositions or preferences.

And if so, which language?
> That's your choice! :D

So, what do you think?

 Note: if I did a mistake on any counting sorry on that. If you let me know where I can update it asap :)

Monday, July 5, 2010

OO Hello World - Scala

Update 1: Porting code examples to Scala 2.10.1 - support for String Interpolation.

The Hello World in Scala, the "scalable language" is here!

Scala is a very powerful multi-paradigm (OO and Functional) language. It targets the Java JVM and can easily interoperate with existing Java code. Its syntax is kind of Java-Like as well as Groovy and other languages.

By the way, you can see my previous post here:
where I give some details on WHY these "OO Hello World series" samples.

Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.
class Greet(name: String) {
    var _name: String = name.capitalize
    def salute() = println(s"Hello ${_name}!")

object Program {
    def main(args: Array[String]) = {
        val g = new Greet("world")

Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
package com.series
import scala._  

class Greet(name: String) {
    private var _name: String = { name.capitalize }  
    def salute() = { println(s"Hello ${_name}!") }

object Program {
    def main(args: Array[String]): Unit = {
        val g = new Greet("world")                

The Program Output:

Scala Info:
“Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive. Code sizes are typically reduced by a factor of two to three when compared to an equivalent Java application.” Taken from: (

Current Version:
Developed by:
Martin Odersky
Martin Odersky
Influenced by:
Java (James Gosling)
Predecessor Language
Predecessor Appeared
Predecessor Creator
Martin Odersky
Runtime Target:
Latest Framework Target:
Mono Target:
Allows Unmanaged Code:
Source Code Extension:
Case Sensitive:
Free Version Available:
Open Source:
Latest IDE Support:
NetBeans 6.9
IntelliJ IDEA
Language Reference:
Extra Info:

Saturday, July 3, 2010

OO Hello World - JScript.NET

Hello world in JScript is here! An ECMAScript/JavaScript dialect implemented by Microsoft.

A new language added to the list. This is a well-supported language from Microsoft since Visual Studio 2002/.NET 1.0, commonly used as a scripting language in Web pages or Windows Scripts, but that also allows you to create dlls and exe applications using Object Oriented features.

By the way, you can see my previous post here:
where I give some details on WHY these "OO Hello World series" samples.

Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.
class Greet {
 var name;
 function Greet(name : String) { = name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1);
 function Salute() {
  print("Hello " + name + "!");

// Greet the world!
var g = new Greet("world");

Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
import System;

package GreetProgram
 public class Greet {
  private var name : String;
  public function Greet(name : String) { = name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1);
  public function Salute() {
   print("Hello " + + "!");

// Greet the world!
function Main() {
 var g : GreetProgram.Greet = new GreetProgram.Greet("world");


The Program Output:


JScript Info:
“JScript 8.0 is a modern scripting language with a wide variety of applications. It is a true object-oriented language, and yet it still keeps its "scripting" feel. JScript 8.0 maintains full backwards compatibility with previous versions of JScript, while incorporating great new features and providing access to the common language runtime and .NET Framework.” Taken from: (

“JScript 8.0, the next generation of the Microsoft JScript language, is designed to be a fast and easy way to access the Microsoft .NET platform using the language of the Web. The primary role of JScript 8.0 is construction of Web sites with ASP.NET and customization of applications with Script for the .NET Framework.” Taken from: (

Current Version:
Developed by:
Influenced by:
JavaScript (Brendan Eich)
Predecessor Language
JScript 5.8
Predecessor Appeared
Predecessor Creator
Runtime Target:
Latest Framework Target:
Mono Target:
Allows Unmanaged Code:
Source Code Extension:
Case Sensitive:
Free Version Available:
Open Source:
Latest IDE Support:
VisualStudio 2010
Language Reference:
Extra Info: