10 unnatural ways to calculate Fibonacci numbers

Posted by Mariya Mykhailova on May 30, 2010

The task of calculating first dozen of Fibonacci numbers has lost its practical value ages ago. Nowadays it's used mostly for illustrating some basic programming techniques, recursion and iteration among them. In this writeup I will use it to show several programming languages, in which it acquires uncommon and sometimes definitely unhealthy look.

So, here goes my rating of ten most unnatural ways to calculate Fibonacci numbers of the ones I used for Progopedia project. For a more accurate definition, let's demand that the program outputs first 16 numbers, formatted as
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...

10. Sanscript

A visual programming language, in which all language elements are represented as elementary blocks. The "code" itself, called flowgram, is built from these blocks by connecting them with links. What placed this language in the rating is:

  • the size of flowgrams: two dozens of blocks is a maximum that can be used within one flowgram without scrolling it or getting entangled in connections between blocks;
  • the complexity of basic language constructs: each loop or conditional statement requires one or more separate flowgrams of description, and their numbers multiply endlessly;
  • the fact that the program is not written but drawn, and the keyboard is used only for entering constant values, renaming elementary blocks and adding comments;
  • and the way the flowgrams overall look like large bowls of spaghetti - talk about spaghetti code!

Main flowgram
Main flowgram

Continue reading →

Retro? Necro? Oh yes, Turbo!

Posted by Mariya Mykhailova on January 25, 2010

Most people who write about Turbo Pascal start with their memorials about its appearance and their experience with it. I can't pattern them, since Turbo Pascal 1.0 is exactly two years older than I am, so I used only 7.0 version, followed by Delphi.

I'll have to approach this topic from opposite direction and tell you how Turbo Pascal looks from the modern point of view, for a person who was raised on modern IDEs and turns to Turbo Pascal with purely exploratory purposes.

So, let's have a look at year 1983 and Turbo Pascal 1.0...

Turbo Pascal 1.0 screenshot
Turbo Pascal 1.0

Continue reading →