Garadon: Yes, the comments, spaces and indentations are removed, and I also don't close inherently closed statements by a semicolon. However, if you put those back in place you will find the code much more easy to read than it's object oriented equivalent is.
RadarBob: A typical procedural/imperative view, I'd say. Let me compare to the object based and functional ways of doing things:
First on all, the difference between object based and object oriented coding: One uses objects, the other uses objects with inheritance. Inheritance requires objects and instances and setting prototypes, while object based programming just requires the use of objects for storage, which object oriented programming requires as well.
Second, the functional versus imperative views: The functional view see everything as programs calling other programs, which in the end complete a task. The imperative see everything as a sequence of commands that in the end complete a task. The functional way is task oriented, the imperative way is processing oriented. Functional programming typically use scoping, closures and what is in imperative thinking called callback functions, while imperative uses statements and structures.
In object based programming, you use object for storage and performing actions. You use properties and methods in the same way as with object oriented code, but you don't utilise inheritance where it is not needed. Functions may either be part of an object as methods, which means the object is performing things. Or they may be functions taking an object for argument, and handling that object.
Function, scope, think
In functional programming functions handle data, and are in turn data themselves. Scoping provides encapsulation and closures provides privacy - so called black boxes are provided by closures, the same way object do in imperative languages. Object privacy is provided by closures, too.
Task orientation makes you a better programmer
Or, for every task the tools best equiped for the purpose. Use object orientation only if inheritance is a feature you need. Use object based programming if you only need objects as containers and abstractions related to the task. And use methods or functions depending on whether it it the object that should be doing things or things should be done with the object. Separate tasks into functions or methods of their own for easier testing, extending and modification, as well as making the code easier to read.
For each langauge a suitable abstraction
Object oriented code is larger than procedureal or flat imperative code, true. It is also better structured and task separated. Functional programming is also task separated, to an even higher degree than imperative object oriented code, and object based code provides the same structural advantages as object oriented code. Which in the end means that functional and object based code is more readable and better task separated than regular object oriented code.
Is one of the the key concepts of functional programming. The scoping and closures creation together with task orientation makes the code widely reusable because of the task separation. Scoping provides the solution to the namespace problem.
Ease of use
Task orientation makes functional code easy to use on the same way object orientation does - by task separation. The difference lies in that while object oriented code is object centered, the functional code is task centered. This makes functional code better for the purposes of achieveing a single, simple goal, or a complex task consisting of several such single, simple goals. Object orientation is better for heavy structures and data storage, but not for performing tasks.
Things you notice if you use functional, object based programming
- Your code is readable.
- Your code is modular.
- Your code is task instead of structure separated.
- Black boxes.
- Testing is easy and can be done on single instances.
A simple comparison, object based versus object oriented:
// Object based
// Object oriented