As I mentioned I’ll probably be stuck forever as n00b, so I have absolutely no intention to compare the real merits of languages. It’s just that I finally got to learn Ruby (and then Python) for real, and it’s so different from C++ and Java that I think it’s worth documenting.

I don’t have any emotion for or against C++ since it’s just too big. I’ve used Java for just over 2 years and like its relative simplicity. I’ve learned Ruby for a day, and would take

a = { 1 => "blah" }

over

Map map = new HashMap(); map.put(1, "blah");

any given time.

C++

Java

Ruby

Python
Inheritance

multiple

single base class, multiple interfaces

single base class, multiple mixins

multiple
Syntax

throw try catch

throw try catch finally

raise begin rescue ensure
catch throw (with label, not exception)

raise try except finally
#include

import

require/load

import
dynamic_cast/typeid

instanceof

kind_of

isinstance
varargs

Object …

*args

*args, **args
NULL

null

nil

None
inner class

anonymous class

block

lambda (limited)
const

final (not quite)

object.freeze

N/A
enum: int only

enum: full class, but no more inheritance

N/A (type-safety is moot)

N/A
Hits

pointer, iterator

JRE, javadoc, IDE

yield, block/closure

list comprehension
Misses

hash table, regexp, thread

verbose

performance?
Idiosyncrasy

complex and cryptic

String ==

elsif, no ++

elif, no switch/case
Advertisements