13 June 2013

Ruby vs Python

A small illustration of differing design philosophies.

Python design philosophy

% python
Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> quit
Use quit() or Ctrl-D (i.e. EOF) to exit
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> [Ctrl-D]

Notice how it gives you different errors depending on what you type. In other words, it understands exactly what you meant, because it uses that information to tailor the error message — but it nags you anyway.

Contrast with…

Ruby design philosophy

% irb
irb(main):001:0> quit
% irb
irb(main):001:0> exit
% irb
irb(main):001:0> [Ctrl-D]
% irb
irb(main):001:0> quit()
% irb
irb(main):001:0> exit()

© mathew 2017