Random Ramblings

Random Ramblings

Robbert Haarman



This essay contains various random thoughts that I have had. I note down my thoughts here, and if I accumulate enough ideas around them, I may write an essay about them, implement them in a piece of software, or something of the sort.


Functions are Classes

Functions are actually classes. Calling a function is essentially the same as creating an instance of the class of the function. This instance would hold the parameters that were passed to the function, and the function's local variables. The code and any variables that are shared by multiple invocations need only be present once (just like static properties in Java).

Programs are Functions

Programs are just a special case of functions. Both are passed arguments and return values. Usually, the return values from programs are discarded, and the program interacts through side effects. Functions can be used in the same way.

The distinction of programs and functions is undesirable, as it makes the system less flexible. A function cannot be called from the user interface, except through a program wrapped around it. Programs can be invoked from inside programs only with clumsy function calls that don't fit the rest of the model well. Program invocation is a very expensive operation compared to calling a function.

If programs and functions were one and the same, program invocation would become as quick as a function call. This would encourage modularity, which would, in turn, add flexibility and facilitate code reuse. This may result in faster, smaller, and more flexible system environments.

Also, substituting functions for programs might lead to a more functional style in software, which would further increase flexibility and may have other benefits.

Types are Values

The description of a (composed) type can be seen as a value, e.g. an instance of a class Type. Such an instance could include a reference to any supertypes, plus some fields indicating which properties and methods this specific type adds to the mix.

Slashdot Posts

These are links to posts I made on Slashdot that I consider particularly valuable. The ideas and opinions expressed in them might someday make it into essays...and some already have.

Comments made by others:

Valid XHTML 1.1! Valid CSS! Viewable with Any Browser