Archive for June, 2014


Classes versus Modules

June 29, 2014

A class is a module n the sense that it is a unit of code reuse, and indeed the only one in many languages.
A module is potentially much more.
A class defines a type.
A module may define a number of types, and interfaces.

The disadvantage: modules are even less composable.


Object Orientation is Inherently Dynamic

June 29, 2014

Even in static and compiled languages, therefore the despatch of a method to an object needs to be decided at run time. This is true of C++, where the _vtable is used for runtime dispatch, and also if function oanguages, where variant types ……. a variable whose actual type is decided by its current value….are used for despatch.

This raises the question of whether the best way to add OO to a static language is minimally , as C++ does, or add a whole dynamic layer as Objective C does….and if you are going down the latter route, should the layers have different or .similar syntax? Id be inclined to go for a minimal difference.

How to glue a dynamic layer to a static layer? If static code is embedded in dynamic code, some kind of dynamic despatch will be needed based on runtime parameter values. ( I’m assuming the dynamic layer will have only duck typing)

Static types passed into an embedded dynamic call will have to have their values boxed. Returns from dynamic calls , including data fetched from dynamic storage, is tricked. It can’t .be reliably unboxed into a naturally typed value,….either a runtime error will have to be thrown, or iy will have to into a variant.


Functional Programming is More Than one Thing.

June 29, 2014

1 Functions aren’t allowed to have side effects.

2 Functions are first class citizens that can be passed to other functions.

3. All data is immutable.

The third and strongest stipulation means that FP sidestep the encapsulation issue in OO, because if all data is immutable, none if it needs to be protected from incorrect update.


Orthogonality III Functions, Objects and the Expression Problem.

June 29, 2014

“Object-oriented languages are good when you have a fixed set of operations on things, and as your code evolves, you primarily add new things. This can be accomplished by adding new classes which implement existing methods, and the existing classes are left alone.Functional languages are good when you have a fixed set of things, and as your code evolves, you primarily add new operations on existing things. This can be accomplished by adding new functions which compute with existing data types, and the existing functions are left alone.When evolution goes the wrong way, you have problems:Adding a new operation to an object-oriented program may require editing many class definitions to add a new method.Adding a new kind of thing to a functional program may require editing many function definitions to add a new case.”


Whats Wrong with Shell Script

June 28, 2014

Efficiency could be better.

Poor support for numerical,operations and data structures, make the sh/bash family   a poor competitor with the php/perl/python/lua family.

1980s style procedural constructs only. No support for object orientation or functional programming.

Limited function return values…and certainly no multiple return values!

Inbuilt persistence (between runs) would be cool.

No convenient support for common systems programming patterns, such as retries and locks.

Ability to safely modify running programmes would be cool.





Functional Programming as the Next Step from Procedural Programming.

June 21, 2014

Procedural languages hides gotos inside if-then and looping constructs, for, while and so on.

Functional languages hide loops and selections inside map(), reduce() and filter().


Why Dont Library Functions Have Debug Options?

June 21, 2014

We are used to the idea that an external command has options for verbose output and so on.
Library functional tend not, although they may be doing the same thing, eg sort.
Part of the problem might be primitive interfaces, that don’t allow for options to be set.
Another might be lack if anywhere obvious to send the data.