December 29, 2022

From Treepad to Zimwiki – a small history of outliner software

The history of outliner software is a seldom explored subject within computer science. Early examples were created in the late 1980s as hypertext editors. A notable example was the Symbolics Concordia software which has much in common with the later Windows 3.1 help files. The idea is that the user creates a hierarchical tree and can insert hyperlinks for easier navigation. [1]
Sure from a technical perspective, there was the hypercard program which was published for the Apple computer earlier. The problem with this attempt was, that in the early 1980s the homecomputers were not equipped with harddrives. For creating a larger hypertext document is harddrive is needed because the filesize will become 500 kb and more. So it makes sense to assume that the first examples of working hypertext authoring tools were created in the late 1980s on dedicated workstation computers.[4]
In the year 1995 Henk Hagedoorn created for the Windows operating system the Treepad software.[2] It is the most important software in the history of outliner programs. It was the first mainstream program which was using a two pane editor. Left the user sees the structure of the document and in the right pane the full text is shown.
From a more critical perspective, the Treepad software looks like MS-Word in which the document outline was activated. So it is basically a word processing software with a focus on the structure of the document.
After Treepad was created many clones were programmed like Keynote, cherrytree and zimwiki. Technical the difference is low or even not there. The GUI has the same two pane structure and the only improvement of the keynote program was, that it was released as open source software.
An interesting but niche software are zkn3 and synapsen. These tools were created with the attempt to emulate a Niklas Luhmann Zettelkasten. They are used by scientists for maintaining annotated bibliographies. [3]
Another more recent approach is the Obsidian software which combines a chaotic graph structure with a powerful search feature.
There is a seldom analyzed common feature between the early outliner programs and more recent note taking apps. All these programs are using a key value structure for storing information. The key is shown in the left pane which is the name of a file or the name of a section. In the right pane the value is shown which is equal to a free form text which includes images and hyperlinks.
Sources
[1] Nielsen, Jakob. Multimedia and hypertext: The Internet and beyond. Morgan Kaufmann, 1995.
[2] Interview: Henk Hagedoorn, creator of TreePad http://mediaman.com.au/interviews/hagedoorn.html
[3] Markus Krajewski synapsen – A hypertextual card index User’s Manual http://www.verzetteln.de/synapsen/_docs/SynManual.pdf
[4] Computer chronicles Personal Information Management, 1989

December 22, 2022

Creating a Luhmann style Zettelkasten with the Lyx software

One of the key problems with the Luhmann style note taking method is that it is very complicated to explain and it differs in many points from note taking in the past. The problem with manual note taking on index cards is, that it has much in common with an art project in which somebody has invented his own handwriting style and his own structure which is difficult to explain to others. In contrast, the problem with digital only note taking software is, that the programs are never working the same and endless amount of features are available. So the question is, what is Luhmann style note taking from a birds eye perspective?
A good starting point is to use an existing word processing software like Lyx and creating notes in this software. Advantage is, that not a certain note taking software is needed and the user is not asked to learn a certain software. What is working in an existing word like program can be transfered to other programs easily. In contrast to dedicated outline editors, the Lyx program has some disadvantages for example the full text search is poor, the hyperlinks are difficult to navigate and inserting images makes trouble. Nevertheless i have decided to take the software as an example to explain how to create notes.
Let us start the workflow from scratch with an empty document. The side pane in the left shows the sections of the document.


The main idea is to store the notes without folders but store the notes in a sorted list. This idea can be realized in Lyx with the paragraph style. Each paragraph name is shown in the left outline pane.


To make the note taking process more realistic, some information are added for each note which includes the creation date, keypoints and of course the sources. Until now the situation looks not very exciting, because the document contains of only some notes.


For implementing a typical luhmann style zettelkasten two additional elements are needed: a luhmann ID and a maximum length of a note.


The luhmann id defines the position of each node in the sorted list. It is defined once durcing the creation of the node and never changed. For adding a new node at a certain position the node-id is selected in a certain way. The screenshot shows an example for adding a new node between two older nodes.
The typical question of a newbie is why should somebody add new information between other nodes wouldn't it be more common to add new notes at the end? The idea of a Luhmann Zettelkasten is to group notes by it's similarity to existing nodes. It's a clustering mechanism which allows to recall the information later. This is maybe the most obvious difference to note taking in the past. In a luhmann zettelkasten it is a bit complicated to add something. Because the correct position has to identified first and then the appropriate luhmann id has to be created.


Adding more random notes to the existing structure will result into a longer outline list in the lyx editor. The idea is that each note has a maximum size of 700 Byte which is equal to write an A6 index card. The list will become longer and longer. There are no tags, groups or subsections but the node's hierarchy is defined only by the Luhmann id.
Sometimes the Luhmann Zettelkasten gets improved with further elements for example a dedicated bibliography, the ability to insert images and hyperlinks. Hyperlinks means that a link from one node is created to another node. But these improvement are only minor details which can be ignored in the first step. The basic principle is to make sure that each node has a maximum size of 700 bytes and that a Luhmann id is available.
The main strength of the method is, that it scales up to larger amount of content. The screenshot is showing only 9 nodes but technically it is possible to create 100, 200 and even 2000 nodes with the strategy easily. At the end the user has in the left outline pane a long list of nodes and will see in the main window the content for each node. Thanks to the Luhmann id, similar nodes are located nearby. The document is a linear list which can be scrolled from top to bottom. It is some sort of sorted chaos. At the one hand it looks very messy because of the huge amount of small nodes, on the other hand it is very well structured because every knowledge fits into the same sorted list.

December 19, 2022

How to write an academic paper without taking notes?

 

Taking notes is a fundamental technique in academic writing and since the advent of the Unix operating system lots of software was created for this purpose, right? It is a rhetorical question because the history of note taking software is not well researched. Sure in terms of quantity many attempts were made for creating notes. The most famous one are the emacs program, the texinfo hypertext format and the bibtex format. The surprising situation is, that none of these attempts are popular and most users are not aware of these tools.
Let us compare the situation in Unix with other operating systems like Windows. The situation in Windows isn't very different. On the one hand there are some dedicated bibliographic databases available like Endnote and Citavi and on the other hand there are text editors and the famous ms-word program for making notes. All these programs are not very powerful. For example in fixed bibliographic database it is not allowed to enter full text comments, while in MS-word like text editor it is hard to search full text in the information.
If all the existing operating systems and note taking software have a low quality and are not used in reality, what was used instead for creating notes in the past? The surprising answer is that note taking is not a big thing, even in academia the value is overestimated. To investigate the working thesis in detail let us describe how to write a paper without any notes or references.
What the author needs is some sort of typing tool which are mostly a classical typewriter or a pen or a software like MS-Word or LaTeX. Then the sentences are formulated. If the text was written some (not more than 3 bibliographic references are added) The exact description which includes the title, DOI number and the journal is retrieved from a library catalog. Then the text gets formatted into the PDF format and is printed on a laser printer. The interesting situation is, that during the entire writing process there was no need to create notes or recall existing notes. But the academic author sits in front of an empty sheet of paper and formulates what he knows about a subject.
The chance is high, that such kind of writing process was common in the past and was applied by the majority of authors. The content of the written text depends mostly on the individual knowledge about a subject. If the author is informed very well he can write a better text and vice versa. Basically spoken all the hype around note taking, outliner software and bibliographic file formats doesn't fit to the reality. For writing a normal academic text there is no need to get familiar with the bibtex software or with a high end free form database like MyInfo.
Even the famous writer and sociologist Niklas Luhmann wasn't using a dedicated note taking system. His so called Zettelkasten was mostly a joke. He has explained to his student that note taking is very important but he wasn't using the technique for himself. Most of the 90000 index cards from his scientific legacy were created only for the public to mimicry reading skills.

December 17, 2022

Comparing C#, Java and Python

 

All the three lanuages were creaed with attempt to replace the C++ language. It is much easier to write an application with C# and similar languages because no pointers are needed, and there is a large amount of libraries. All of these languages have cons and pros. Let us start with the C# language which has become famous in the Windows community.
C# is the default language in a windows operating system and can be compiled without additional software. The language standard is similar to Java but the syntax is easier to learn and much better documented. The big disadvantage of C# is, that it is not available for Linux. The existing mono ecosystem has to be called a joke because it can't run major components like WPF (GUI widgets) and ADO.net (database access). That means most of the C# programs won't run in Linux. It is pretty hard to create a C# app which runs in windows and Linux as well.
In contrast the java language was created for cross compatibility in mind. The runtime environment in Linux and Windows is the same Similar to C# lots of documentation is available and Java is a mature language. The only problem with java is, that it has never replaced C/C++ because Java programs are known as slow and poorly programmed. For internal projects java is used sometimes.
The third language is Python which has become a surprisingly successful language. Python was started as a scripting language which is around 20x slower than C/C++ code. On the other hand it is very easy to write a software in python and it will run on all major operating systems.
It is hard to say what of these languages is the best one. Perhaps none of them. C# won't run in Linux, Python is too slow, and java can't replace C++. The good news is, that with all these languages it is easy to write software. Even complex programs like games can be created in a few hundred lines of code. It should be mentioned that for unknown reasons none of the presented languages has replaced c/c++. If C and C++ is seen as the same language, more than 80% of the production ready code for windows and Linux is written in the language. In contrast, a language like Java is seen as a toy language without practical value.
From an abstract point of view, it is not possible to invent a pointer free language and use this language for practical application. It seems, that pointer oriented programming is the only way for writing production ready applications. Pointer-oriented means that the abstraction level is lower and the programmer has to decide in detail how to store data in the main memory.

Faster citation with the Lyx software

 

The LaTeX typesetting system allows to cite external literature. instead of providing one or two footnotes, LaTeX can create a reference list with hundreds of items. A huge amount of references is a typical requirement for an academic paper and it is not possible to redefine the rule. The only detail question is, how many citations are needed for each us-letter page. Are 8 references enough or does the paper needs 12 and more citations for every page?
 
Unfortunately it is a complicated to format the citations from the authors perspective. Sure, Tex has a built in bibtex format and the Lyx frontend allows to include a bibtex file at the end. The problem is, that most lliterature databases are not supporting bibtex, and adding new items on the fly might be a bit complicated. 
 
Let us make a practical example to show the bottleneck. Suppose somebody likes to insert a reference in lyx. First, he has to search in the internet for the correct bibtex string. Then, he has to insert it at the end of the bibtex file in an external texteditor. Then, he needs to know the bibtex key and the key is inserted in Lyx. Such a workflow can be mastered for one or two references but if someone likes to cite hundreds of papers a different approach is needed.
 
A possible, easier to manage alternative, is to avoid the bibtex format and cite everything in footnotes. Advantage is that the plain text citation can be inserted directly in lyx. To aggregate all the footnotes at the end of the document a bit of LateX programming is needed:
\usepackage{enotez}
\let\footnote=\endnote
\newcommand{\bracketme}[1]{\,[#1]}
\setenotez{
  totoc,
  backref=true,
  mark-cs={\bracketme},
  list-style=plain,
}
\DeclareInstance{enotez-list}{plain}{paragraph}{
  format=\normalsize\leftskip1.25em ,
}
\printendnotes
The enotez package is included in the preamble and some adjustment are made (increased font size, better indentation, square brackets for the footnotes and so on).

December 01, 2022

Train localization as a software problem

In the past, low quality sensors were blamed for imprecision in railroad monitoring.Most hall sensors can detect the train only at a certain position but can't provide GPS accurate information. A more robust technique are software defined feedback sensors which are particle filters.[1]
[1] Heirich, Oliver. "Bayesian train localization with particle filter, loosely coupled GNSS, IMU, and a track map." Journal of Sensors 2016 (2016).

November 27, 2022

How to fix the traffic jam in India

Fixing something is usually done by putting the resources towards the right place. One attempt might be to build more roads in the attempt that this will reduce the amount of traffic jams. But the most efficient resource allocation is done at a different location, namely the railroad system. Similar to the car roads, the train system in india has a high demand but low amount of ressources. And building new railroad networks is expensive. A cost effective alternative is to measure the existing traffic with more sensors.

So a cheap version to improve the efficiency is to buy a simple arduino based sensor and count how many trains are arriving at the trains station and how many are leaving. Also the sensor counts the time and date.

Such a single sensor won't be able to fix all the problems of India, but it is a first step towards a possible solution to the traffic jam problem.

November 17, 2022

Linux is a large hard drive

 Computers in the past were easy to explain. The commodore 64 consists of ROM which holds the operating system and MS DOS needs a single boot floppy drive which consists of only three files: command.com, io.sys and msdos.sys

In contrast, a modern operating system like Linux looks similar to a mess. There are endless amount of small files which contains of config files, man files, documentation, binary files and log files. The exact amount of all files can be determined either the in graphical "disc usage analyzer" or on the command line with:
df -i /

The amount of active inodes is equal to the files which includes directories. For most fresh installed Linux distribution the amount is around 500k. Only for comparison reason a fresh Windows installation needs around 300k files.

Most Linux beginners and even experts will struggle to explain what is stored in the these files. In most cases it contains of system programs, applications and helper files for the fonts, icons and so on. The only thing what is for sure is, that Unix will need all these files and many real life webservers will need much more additional files for the home directory. The huge file count is perhaps the most obvious difference between a commodore 64 and a unix system.

It is not possible to install the Unix operating system on a single flopp drive or in the ROM of a the hardware. This is an advantage and disadvantage at the same time.

It should be mentioned, that the amount of 0.5 million files on a standard linux system is a small amount of files. The reason is, that only the trunk version of each file which is the latest was installed. In addition the git repository contains many more versions which is available in the cloud. So we can say that the Linux operating system contains of a much more different files which were created over the years. It seems, that this is not perceived as a problem, but it is strength of Unix. Because it allows to growth the system endless.

Unix is working with some underlying assumptions. The idea is not about running a program on a CPU. Such a paradigm was valid for homecomputers. In contrast Unix is working with the assumption that there are 500k files on the harddrive and with each update, additional files are created. Also the existing files are modified by the upstream in a version control system. So the overall Unix system has much in common with a repository of programs and config files.

On the Commodore 64 and early CP/M computers the principle was to reduce the amount of files. Fewer files can be stored on less floppy disks and are running faster on the computer. In addition, fewer files can be compiled faster and contains of fewer bugs. With the advent of Unix, such a minimalist approach has been abandoned.

October 21, 2022

Tribute to Ansi C

 

The C90 Ansi C standard is a great choice for programming. The language was invented 40 years ago and outperforms every modern language easily. C compilers are available for all computers and all operating systems and allow to write any sort of software. No matter if C is used to create videogames, webapplications, desktop apps or even operating systems libraries — c is always a great tool.
Every criticism against the c language is a sign for a misunderstand what programming is about. Programming is not about drag and drop GUI widgets into a frame and press a run button. Programming is not about importing a python library without understanding what the inner working is. But software engineering is about understanding from a low level perspective what the computer is doing internally. This includes to use raw pointers with direct memory access to compare two strings, and write sorting algorithms from scratch because they are missing in the standard C library. This is not problem, but is ensures that programming makes fun.
So called high level languages like Java or PHP are created by inexperienced programmers for non programmers and are a sign of failure. The best recommendation is to rewrite all these existing nonsons programs with Ansi C and create new software always in C as well. Only a compiled language can be executed fast enough and it is simply not true that the productivity in scripting languages is higher than in C. Most libraries are not needed in the reality. For example the matplot library which allows python programmers to draw charts can be simply emulated with a c program which draws the graphics into the video ram of the graphics ram. The underlying algorithm can be written from scratch in a short amount of time and is more cpu efficient than any precompiled library.
Object orientation which has become famous since the 1990s is a dead end because Ansi C has a more powerful feature called modules which allows to interconnect different programs into larger systems. There is no need to create complex C++ compilers or even invent jit compilers to execute PHP, but the same task can be realized with a vanilla C compiler much easier. Basically spoken, all these java programmers are wasting their time, if they are writing the software in so called high level languages. They have simply not understood what a linked list is or what the C preprocessor is doing internally.
With the c language everything is great, but the ecosystem around C has made major mistakes. In the last 20 years lots of new programming languages were invented with the promise to make programming easier to learn. Non of these attempts was able to replace the c language. Buzzwords like agile programming and object orientation were mostly invented by c programmers and can't be replicated in other programming languages. a well trained C programmer is able to write any sort of applications within a week. All what he needs is a VIM editor plus the gcc compiler and the c internal features are producing error free code by itself. The resulting binary file will run on a server and a desktop very well and it is unlikely that the code needs to be improved. And if another programmer will find an error, he can easily locate the error because the program is divided into smaller chunks. Ansi C has a natural tendency to evolve into stable software projects which are written once and then used as production ready code for decades. The C language stands for high software quality and maximum coding productivity.
One of the strength of C is string handling. There are more than 12 different ways available how to concat two strings together.[1] it is recommended to decide for one of them and the program will be protected against all sort of security issues.
[1] https://stackoverflow.com/questions/8465006/how-do-i-concatenate-two-strings-in-c

Which programming language is the best?

 

There are many attempts available to compare different programming languages each other. In contrast to a famous myth it is possible to determine which language is the best if some prerequisites are fulfilled. First thing to do is to define what “best” means. A possible definition is, that best= high level programming language. The assumption is, that programmers are preferring high level over low level languages. Then it should be defined what a high level language is about. High level means that no pointers are needed, that object orientation is available, that the language is interpreted and very important that a huge libraries with predefined functions is available.
The reason why high level language are preferred over low level language is because it allows to create the same app in a shorter amount of time Writing a hello world gui app will take in pure assembly language around 1 month, in the c language it will take 1 week, in the c# it will take 1 day and in python it can be realized in 10 minutes.
The interesting situation is, that the sorting order from low level to high level language can be measured on an objective basis. Around 99% of the programmer will agree that the following sorting order is correct:
1. assembly language
2. Ansi C
3. C++
4. Java, C#
6. Python, PHP
Low level language are compiled and are using pointers. Midlevel langages like C# doesn't use pointers and there is need to define the datatypes, while high level languages like Python doesn't need anything but the hello world Qt app is created with 5 lines of code and executed on any device and any operating system.
The only question left open is, if high level language are a here to stay or if python has some sort of disadvantages. In most cases the concern is, that high level languages are not great for production systems. Python is known to run slowly, while C# and Java is sometimes called as not snappy enough similar to C++. According to the raw numbers a jit compiler and especially Python like interpreters are much slower than low level languages. And the question is, if such constraints is important or not.
According to the amount of books about high level language and the number of newly created apps, high level languages have replaced low level languages. Most newly created software is not created in Ansi C anymore but in C# and other high level programming languages.Somebody may argue for or against this development but at least it is a fact. The motivation for the individual programmer is mostly to reduce the development time. Instead of programming an app with Ansi C within in 2 years, the idea is to program the same app with a high level language in only half of a year.
In the context of python this sort of programming style is sometimes criticized as creating throw away code. This implies that python code is equal to low quality software. In contrast, a dedicated low level language like Ansi C is labeled as high quality language because it takes much longer until the app is ready.
It is possible to discuss which of the opinion is correct. What we can say for sure is, that all the programing languages can be sorted in a linear chain from low level to high level. High level means, that the same app can be written with less amount of codelines. The result is, that it can be defined precisely if python is more high level than C# or Ansi C.
Python is not the top of the pyramid because there are some languages available which are more high level. GUI RAD builders and especially the MS Access database surpass easily the python language in terms of high level vs low level language. A MS Access database can be created without writing a single line of code. Somebody may ask if such a database has a high quality compared to a program written in C# or even Visual Basic, but at least the fact is, that MS Access is more high level than any programming language.
Another example for ultra high level languages are construction kits and level builder in Games. Here the user doesn't program the game or the app, but is modifying only a level. For example in a level editor for the lemmings game it is possible to draw some obstacles into the screen and after pressing the run button the game gets started. The possible alternative would be to create the game with C++ from scratch which will take for sure months upto years and a deep understanding of the C++ language. With a level builder the same objective can be realized much easier.
A while ago there was a debate at stackoverflow about rewriting an existing PHP webappliation in plain Ansi C.[1] The main argument against such an attempt was, that it will take too much manhours for doing so. Even if the php language runs a bit slower than Ansi C it is the better choice because it is more high level. High level are seen as equal to a good choice because it allows to save time and costs. Even some comments have argued pro C/C++ and the arguments were really good, it is easy to grasp that the stackoverflow post came to the conclusion that PHP is the better langauge for web development over C/C++. Simply because of the fact that only very few or even none web applications are written in C/C++.
[1] https://stackoverflow.com/questions/3079153/why-do-you-not-use-c-for-your-web-apps

Is C# obsolete?

 

In the history of programming language there is a tendency available from low level- towards high level languages. From the perspective of the C language all the programs written in Assembly are outdated. The reason is that the source code can be written in a shorter amount of time. Because of this reason the C# language has replaced the former C++ language entirely.
On the long hand the transition towards high level language will make even c# obsolete. The reason is, that in comparison to scripting languages like Python, C# can be called a low level language. There is need to use datatypes like int and string and many class initialization will need a lot of boiler plate code. Without any doubt the Python interpreter is more high level than C# so the C# language is outdated.
Writing a simple hello world gui app with C# will take around 30% more lines of code than the same app written in Python. Such an overhead is difficult to maintain and it will increase the time to market time.
According to the Rosetttacode website, the string append problem can be solved with many programming languages. The low level C language will need the most amount of written lines, then comes C# and the shortest code can be written in Python.

// c
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char *sconcat(const char *s1, const char *s2)
{
  char *s0 = malloc(strlen(s1)+strlen(s2)+1);
  strcpy(s0, s1);
  strcat(s0, s2);
  return s0;
}
int main()
{
  char str1[]="Hello ";
  char str2[]="World";
  char *str3=sconcat(str1,str2);
  printf("%s\n",str3);
  return 0;
}


// c#
class Program
{
    static void Main(string[] args)
    {
        string x = "foo";
        x += "bar";
        System.Console.WriteLine(x);
    }
}

// python
str = "12345678";
str += "9!";
print(str)

 

The difference between C# and Python is not huge, but C# will need around 30% more space for writing the semicolon, the datatypes and lots of extra code for anything. This additional effort has to be written by the programmer which reduces the productivity. Basically spoken, C# is outdated because it not high level enough.
Let us take a closer look into the C program. First thing to mention is, that the string concat method was implemented safe and is one of the easiest to understand. It is using in addition external routines to make things easier. It is possible to create more advanced string concat routines. Nevertheless the lines of code are difficult to understand. For C programmers it makes sense to use three different commands like malloc, strcpy and so on only to add str1 with str2 but from an outside perspective, the source code is a bit hard to read.
Such situation is available for many problems which should be implemented in the C language. In most cases, there are at least 40 different ways available how to solve it, and all of them have to do with pointer manipulation and manually typing in lots of code lines. In contrast, the written code in the python language is much easier to type and to understand. All what is needed is a statement like “str1+str2” without further subroutines.
The advantage is not located in Python directly, because string manipulation is also easy going in languages like PHP and Ruby. But it has to do with low level vs high level languages.


 

 

Writing larger programs in Ansi C and Forth

 

The dominant reason why object oriented programming languages have become successful is because of its ability to split larger problems into classes. Without this feature, the program code is stored in a single large file in which hundred of functions have access to hundred of variables. On the other hand, many larger programs were written in Forth and Ansi C without any sort of OOP feature so it seems, that some sort of hidden technique is available which works similar to object oriented programming.
What Ansi C programmers are aware of it is the module concept. A module is a file in which the scope of the functions and variables is limited to this file. it is possible to set a value in a module like “module1.msg=”hello world” and that call a function in that module with “module1.show()”. This allows to simulate object oriented programming.
Modular programming allows to reduce complexity without introducing dedicated OOP techniques. This allows to use much simpler compilers like the ansi C compiler or even minimalist languages like Forth. The question is not if a certain programming supports objects but if the concept of modules is available. Similar to OOP programming modular programmings allows to split larger problems into smaller one. Each function is limited to a single module and this allows to solve the problem in general. The pascal language which lacks also of OOP features has of course the feature to utilize modules. In pascal a module is called a unit and similar to C it is stored in a single file. From the perspective of Java and Python a single pascal unit is equal to a class which has variables and methods.

Modular programming with python

 

Sometimes it was asked how to implement object oriented programming in low level languages like C and assembly. A possible idea would be to improve the existing struct datatype with functions which are pointers. Then the user has to allocate memory and can use objects in C. But the overall pipeline is very complicated and there is an option available to simplify the idea drastically.
The idea is to dismiss object oriented programming at all and prefer modular programming. Modular programming is a complexity reduction technique which is available in most existing programming languages. It can be used in python and in C and pascal as well. The idea is that a single file is equal to a module. [1] The file contains of variables and functions and comes close to the concept of a class. in the written sourcecode a program written with modules and one with classes are looking nearly the same. A module allows to group items in the sourcecode into cluster and maintain the code separately.
Most object oriented programs are in reality normal modules distributed over many files. The only reason why OOP is the dominant programming paradigm and modular programming has become a niche is because of the existing programming tutorials. The self understanding of most books is, that a programming language consists of statements and functions and this enough to solve a problem. The problem is, that without classes aka modules it is impossible to solve larger problems. If the code is longer than 500 lines of code there is a clear need to split it into sub entities. Unfortunately this strategy is not implemented directly in a programming language but it has to do with project management and compiler preprocessors. It can be s
From the perspective of modular programming it is surprising to see, how similar programming works in different languages. In contrast to a common myth the programming languages Pascal, Python, C++, C and , Assembly and Forth have one thing in common. They are supporting all the concept of units. A unit is – again – a single file which can be included in other files and allows to split the code into logical groups. Similar to OOP it allows to group variables and methods into the same instance.
To understand why modular programming is not very common it is important to take a look back into the didactic of programming. In the 1980s the concept of structured programming was mentioned frequently. Structured programming means to divide the sourcecode into functions which can be realized with C and pascal. Advantage is, that each function can be maintained separately which allows to writer longer programs. What was ignored in the 1980s is, that structured programming alone is useless because if a file contains of around 10 functions it will become hard to maintain anymore. So the limit is, around 500 lines of code which can be managed with structured programming alone.
In the 1990s the concept of object orientation was promoted as the logical next step after structured programming. The idea was to encapsulate the code in object libraries which allows an unlimited code size. Nobody has questioned the idea at all or compared it with modular programming which provides a similar feature.
In theory, OOP is superior over normal modular programming. But in the reality, most programs won't profit from these additional advantages. Nearly all projects which are smaller than 100k lines of code can be realized with modular programming very well.
[1] https://python-course.eu/python-tutorial/modules-and-modular-programming.php

The surprising success of the C programming language

 

There is some sort of mystery in the history of computing. In spite of many criticism, the C language was never abandoned but it was used over decades for creating all sorts of programs. To understand the success we have to focus first on some of possible alternatives.
Since the early 1980s the C language was known and many attempts were made to program in a different language. Notable examples are Basic, Pascal and recently Python. All these programming languages are promising to the newbie that it is possible to write software without much effort. Basic was the first widely used interpreted languages. First versions were oriented on line numbers, while later Basic interpreters like Omikron Basic and Visual basic provided the ability to create large projects with structured and even object oriented features.
The problem with basic language was, that it was never standardized. A program written in Qbasic can't be executed in visual basic. And both systems have the problem that the generated executable code is very slow. Many programming languages were invented over the years. Some very successful examples in the recent years are python and C#. In contrast to BASIC, Python is standardized, cross platform ready and has a huge amount of libraries. Similar to Basic it is used by non programmers for creating a prototype. Then the code is deleted but never reused again.
Parallel to the development of these alternative language, the C language has remained stable over the years. What is known as modern C is the same what was used in the late 1980s as C90 standard. It is a standardized compiled language which is used to create production software for the public.
Roughly spoken, Basic and python are toy languages even they are used by 99% of the programmers. In contrast, C is practical language because the code is written once and then improved over decades. The chance that newly written Basic code can't be executed after 5 years is high, while the future of C is more secure. Created C code in now will be uptodate after 10 years from now for sure.
The obvious difference between python and C is, that python is easier to read. Similar to Pascal It is a great language for academia, but it fails for writing operating systems or even normal software. Basically spoken,the programming world is divided into two groups: c programmers and non c programmers. The non c community is much larger. Most books, tutorials and written lines of code are created in non c languages like:
Python, Basic, PHP, Ruby, C# and Java
But, non of these projects are real projects in a sense that the code is executed on a computer. But the code is written once for testing purposes and then it gets archived somewhere
A look into one of the existing C tutorials is disappointing. There is no explanation how to program games, build a database program or create simple hello world apps. But the C books are explaining how the c compiler generates Assembly code without any practical purpose. C has replaced the former assembly language in the late 1980s. During that time it was normal to write code in assembly language. This was done for unix systems and home computers as well. C has replaced this programming technique.
The malloc command within the c language explains very well what the difference is between C and non c language. Malloc allows to ask for memory block from the operating system. The programmer can ask for 1 GB of memory and then the newly written code will nned such amount of RAM for runtime. Such kind of low level memory occupation is not possible with alternative language or at least it doesn't make much sense. Because most modern programming languages have a garbage collector. In Python for example, the user doesn't specify the datatype at all but he appends something in a list and the rest is delegated to the python interpreter.
[1] Bradley L. Jones: Sams Teach Yourself C in 21 Days, 2002
[2] O'Reilly Practical C Programming

The development of the c language after the year 1992

 

Until the year 1992 the programming world was easy to grasp. The only programming language available was C which was working on all hardware e.g. 8bit homecomputer, 16bit intermediate computers and 32bit workstations and C was working on all operating systems like Amiga, MS-DOS, Unix. C was superior in terms of performance and lots of books were available to teach the language. There was no sort of comparison available between different languages, because all the programmers were using C and nothing but C.
After the year 1992 something has happened. At least in the public reception, the C language has felt out of fashion. There was the newly created Win31 operating system which was working with window libraries. There was a new language which was C++ and many new languages like Java and perl were initiated. C has become only one of many programming languages, especially for non expert programmers.
But let us slow down the situation a bit. In the time before the year 1992, the C language was indeed the best programming language. With so called cross compilers it was possible to run the same code on many systems. Other programming languages like BASiC were not compatible with C. There was no BASIC standard available and the performance was poor. What was different after the year 1992 was the upraising of GUI software namely the MFC library from microsoft. It seems, that the c language wasn't able to handle this added complexity. Instead the C++ language was prefered because C++ has a larger amount of built in functions and it is working much better with the GUI libraries.
For Unix and Linux operating system the importance of GUI software was lower. Most linux programs are console only applications which can be written in Ansi C very well. But if the objective is to create a GUI application in Linux, C can become a bottleneck. The well known Qt framework was written not in C but in C++. It seems, that object oriented programming and GUI software matches closely together.
But this connection isn't fixed. In ansi C it is pretty easy to register a signal event. A least in the gtk+ framework this can be used similar to C++. Also creating a window and menus is possible with Ansi C. So the question is, if C is capable to create Windows GUI, why was C replaced by alternative languages?
First thing to mention is, that the C language has felt out of fashion. Since the year 1992 all the major compilers are combining C with C++. Former C only compilers are no longer available. Also all the programming tutorials are oriented in the same way. It is explained in detail how to create GUI windows with C++ but doing the same with C is not explained.

Writing GUI apps with the c language

 

Around the year 1992 there was a drastic event in the domain of software programming. The former well standardized Ansi C language has felt of fashion and was replaced by object oriented languages and scripting languages. Until today the fact itself is seldom mentioned and the reason why remain unclear.
A possible hypothesis is, that it has to do with the creation of GUI apps. From a technical perspective a GUI app can created with a library. In the easiest case the curses.h library allows to create an interactive text based application. More advanced software can be realized with GTK+ and the Win32 API. For reason of better understanding let us first focus on the curses.h library.
In contrast to the established Win32 API the curses.h library works out of the box in linux and windows as well and is much smaller than graphical libraries. So it is a great choice for programming a modern user centric application in the Ansi C language. The problem is, that even simple hello world apps written with curses.h are hard to understand and difficult to improve. not because of the library itself or because of the C language but because the subject is complicated.
The typical curses.h application contains of event handlers, keystroke events, multiple windows and object oriented style message parsing. Non of these techniques are created by the programmer itself but they are the logical consequence if the attempt is to create a GUI app on the text console.
If the console.h library is replaced by graphical oriented GUI libraries like GTK+ the complexity will grow further. Before the programmer can write a simple hello world app he has to read a dozens of books with each 1300 pages and even then many new problems will become visible. The situation in Windows and Mac OS is the same.
The only working advice to avoid the complexity of a GUI app is to dismiss GUI libraries at all. Without the curses.h libary only non interactive software can be created which are command oriented but not menu oriented. The average command line tool in Linux like the cat or the grep command doesn't need the curses.h or the gtk library but they can be programmed in the C language style before 1992.
So we can say that no a certain programming language or library has caused the increased complexity but the problems have increases since the year 1992 with the advent of text GUIs and graphical GUIs. Such a proram type is easier to use by the end user but it is very complicated to program it in software. There is not a single programming language or library available for this purpose but lots of different approaches were created over the years. And all of them are very complicated to use. Easy self claimed lightweight GUI toolkits like FLTK which are reduced to a minimum of features will need 100 MB to install the package and the documentation contains hundred of different methods and classes.
The advent of object oriented languages like C++, RAD Tools like Visual studio and JIT languages like C# wasn't a coincidence but it was the natural answer to the problem of creating GUI programs. It is not possible to write a modern GUI app the same way like a c program before the year 1992. In theory it is possible to write a GUI app with the c language, for example with the win32api or with the gtk.h library. BUt the resulting program will look the same like a complex C++ app which was scripted with additional languages. It seems, that the requirement itself to write a gui app is the cause of the complexity.
Programming in the classical ”before 1992” style is only possible in the case of command line programs. It seems, that the growing complexity after this years is caused by the objective to write the mentioned GUI apps.
This thesis would explain why the amount of GUI apps for Linux is low or even zero. The cause is that for creating a GUI app a huge amount of manpower and additional tools is needed. The best design decision is to avoid GUI apps at all and program only command line tools. Such piece of software can be written in ansi C,, will need a short amount of codelines and is easy to understand.
Let us give a simple example. A state of the art method to create a GUI app in Linux would be to use the Java language in combination with additional libraries and RAD tools for creating the buttons and widgets. The programmer has to install around 10 GB of software before he can create a simple hello world app which is doing nothing. This kind of workflow isn't a sign of failure but it is the best practice method. The cause is, that programming a GUI app is a complicated task and a complicated workflow with lots of layers and bloatware languages is the only way to handle it. Even if the user prefers a lightweight programming environment like Forth he will run into the same problems if he likes to create GUI applications.
The cause why software engineering before the year 1992 was so much easier was is because during this period GUI programs were not available. The typical program in that time was a MS-DOS game in single user mode or a unix command line tool without any interaction. Writing such pre-1992 apps is much easier. A normal c compiler is fits perfect to the problem.
What all the GUI apps in all operating systems have in common is, that they are large scale projects. No matter if the program was realized in C++, java or ansi C and no matter if it was programmed for Linux or Windows and every single case the average gui app will need 100 MB and more on the harddrive, contains of 100k and more lines of code and depends on lots of libraries.

October 05, 2022

The remarkable success of the C programming language

 

With the advent of the C++ language and more recently the advent of Java, Python and other modern language, the good old ansic language has felt out of fashion. At least this is the public perception if the amount of github repositories and the amount of stackoverflow questions are counted. Newly created projects and newly asked questions are mostly about every language except Ansi C.
This situation stands in contrast to the importance of the ansi c language in the past. So there is a need to explain what the status of Ansi c was in the late 1980s. According to some older books from this time, the C language was some sort of standard language used for professional software development. It has emerged in the context of UNIX and then it was adapted on 16bit home computers like Amiga 500 and on MS-DOS PCs as well. 10 out of 10 randomly selected games and application software like databases from the 1980s were written in C.
It is important to know, that the C++ language wasn't used during this time. At least for the time until 1990 the only important language was Ansi-C. Ansi-C is a modular compiled language which runs highly efficient on all sorts of computers. It is known as a difficult to learn which has to do with the header files and the pointers, but it seems, that learning the language is only a question how often it was used.
The situation with C has changed dramatically after the year 1990. At least the published information in the books are explaining to the audience that C is outdated and that the future has to do with object oriented programming under newly created GUI frameworks like Windows 3.x The open question is what is the role of the C language from 1990 to 2000? There are two possible situation available. Either the ansi c language has become obsolete and was replaced by more powerful languages like C++, or the ansi c language was used continuously and only the public description has changed.
The main difference between Ansi c and C++ is, that only C++ is objected oriented. OOP means to use classes and inheritance. Another famous OOP language from the 1990s was Borland delphi and Java. There is some sort of similarity between C and C++ and as a consequence it is often described as C/C++. But from a programming perspective there is a fundamental difference between the languages available. And this difference isn't described very well in the existing literature.
The main cause why C++ has become popular is because it allows to create larger applications and works very well with GUI frameworks. But, in theory the Ansi c language fulfills the same purposes. The modularity allows to create larger software and the language fits great to GUI applications.
To recognize the difference between C and C++ it makes sense to analyze real software projects namely Debian Hamm which was published in 1998. During that time, the C++ available was available but it was seldom used in Debian. 74% of the source code was programmed in Ansi-C while 6% were created in C++ which was mostly Qt. Getting precise numbers for the Windows XP OS which was released in 2001 is a bit harder. According to online forums the core was written in Ansi C but it remains open how many lines of code exactly.
The working hypothesis is, that there is no need to switch from Ansi-C to C++ because Ansi-C is powerful enough to write all sort of software including GUI apps. The bottleneck is not the compiler but the available tutorials to teach the subject to programmers.
To verify if the thesis is correct or wrong we have to analyze the lifetime of programming books and compilers. Are the ansi C books from late 1980s outdated today, or is the information still relevant? The assumption is, that these books are still relevant. The knowledge written in a book from 1990 can be used 1:1 to understand current software. And this implies that the Ansi C language was never replaced by C++ but all the software is written in modular C while OOP isn't used in the reality.
Such a perspective contradicts the public awareness of programming languages. On major forums like Stackoverflow many questions are asked about creating classes and inheritance. Are these posts not relevant for writing software in the real world? The assumption is, that OOP languages like Java or Python are used by amateurs similar to Turbo pascal, but production software and commercial programs are written in a modular fashion with Ansi C.
[1] Debian programming languages https://sources.debian.org/stats/

C vs C++

 

C is a modular compiled language while C++ is an object oriented compiled language. The question to answer is which one is better?
Object orientation has become famous with the advent of Smalltalk which has later evolved in C++ and Java. Programming something without OOP features sounds a bit outdated. On the other hand, C programmers are convinced that there is no need to utilize object orientation. And perhaps this would explain why the debate between C vs. C++ remains unsolved.
Creating short hello world programs is possible in any language. The more serous problem is to create programs which have 1000 lines of code and more. The promise of OOP languages is to support this attempt. On the other hand it remains unclear how to write such programs with C. The interesting situation is, that very large projects like the Linux operating system are mostly written in ansi c so there is no need for object orientation.
On the other hand, this understanding contradicts most programming books published in the last 20 years who are explaining to the audience that OOP is here to stay.
Let us try to listen to the C community and how they are solving the complexity problem. The idea of a C program is to use modular programming. Modular programming is the same technique used in Pascal programs. The idea is that a file is a unit aka translation unit. Roughly spoken, a unit is some sort of class. The interesting but seldom mentioned fact is, that a unit can have variables which are accessible from many functions of the same file. So it seems, that modular programming and OOP programming have some similarities.
Perhaps it makes sense to compare modular programming with OOP programming in detail. The idea behind a class is, that the class contains of variables and methods. The methods are operating on the variables, and this is the strategy to reduce complexity. If a bug was found in the program only a single class has to be modified which is located in the best case in a single file and has not more than 100 lines of code. But, exactly this feature is provided by modular programming namely the C language and Pascal as well. There are files which contains of variables and functions and a single file can be tested and improved independently from the rest of the code.
One possible source of confusion is located in the documentation and tutorials around the C language. Even many books were written in the last 30 years it is a rare case that a book will explain how to create larger programs. Most books are assuming that the user has never programmed in any language and it is explained in detail what a function is, what an if statement is doing and how to use for loops. But the average program will know for sure about these things because the concepts are available in all the language. The for language in a c language is mostly the same like for languages in C++, Java, or C#. The real bottleneck in learning C is to master to use header files and modules. The books about the C++ language and also books about C# and Python are explaining very well how to use classes. The explanation makes sense and is easy to read and perhaps this is the cause why most programmers think that dedicated OOP languages are much easier to use than Ansi-C.
Using the header files and creating modules in C is bit more complicated than using a class but it is not outside of reach to understand the situation. The only thing is, that writing larger software in C is less common or at least it is less frequently explained in the literature. Perhaps the bottleneck is not located in the c compiler itself but in the tutorials around the language?
Most famous books for the C language like “Mike Banahan: The C Book second edition” or “K&R: The C Programming Language” are failing completely to explain header files.. The subject is either ignored or explained in a short chapter in the appendix. What we can say for sure is, that the average programmer who has read these books won't be able to program larger software in C. In contrast, after reading a random book about Java or Python it is very likely that the programmer is able to split the code over multiple classes stored in different files.
The similarity between modular programming languages and OOP languages is, that the program is split over files. A typical smaller program contains of 10 files which have each 100 lines of code. The ability to split the code over files is a fundamental building block in creating more complex applications. There is no workaround for this problem. The assumption is, that dedicated OOP languages are able to explain the modularization easier than low level languages like Pascal and Ansi C.
Somebody may argue that OOP programming contains of more elements than only splitting the code into files. A typical OOP feature is the ability to create many objects from the same class. Most games are working with lots of sprites. In an OOP language it is very easy to create an array of objects while in ansi C the compiler doesn't even know what an object is.
But this problem can be solved with a normal struct easily. The c language allows to create an array of struct. And then the single variable struct can be send to a function and manipulated or shown on the screen. There is no need to use OOP programming for displaying 100 and more sprites on the screen. That means Ansi-C is more than sufficient to create all sort of simulation programs similar to what C++ has to offer.
From a technical perspective the C language can be used as a replacement for object oriented languages. The bottleneck are the existing tutorials which are not able to explain how to split source code into files. This has frustrated programmers who are preferring dedicated OOP languages.

Creating header files in Ansi C

 



One of the serious problems within C programming is the art of creating a .h file. It is obvious that any programming projects needs to be split into multiple files and at the same time, most C newbies are not aware how to create these header files.
To make things more pleasant the first thing to know is, that a header file should contains only of the public visible functions. Let me give an example. The module contains three functions which are set(), get() and run(). The idea is that from the outside the set() function is executed first, then the run() function to activate the module and at the end the outside program is executing the get() function to retrieve the output of the program.
The include file consists only of these three prototypes but not all the additional functions and especially not of the variables from the module. All these things are declared private which means they are not mentioned in the header file but they are available in the .c file for the module.
The main advantage is, that things are easier to understand if they are reduced to its minimum. The outside program can include the .h file and it is only able to execute the mentioned functions but has no access to the modul's internal functions. Sure, the same functionality can be realized with the static statement which is often recommended in Online forum, but it is more easier to delete the function prototype from the header file at all. The cause is that by definition a header file has to obligation to communicate between a module and the outside program. And if no communication is needed about internal functions why should that are mentioned at all?
An interesting feature of the C language is, that the inner working of a module is very similar to a class known from object oriented languages. The idea is, that they are variables in this module which can be manipulated by the functions and that it not allowed to get access to these variables from the outside. A single module solves a clear defined problem and in the optimal case the code can be reused as a library.

Why has the C language evolved into C++?

 

It is not sufficient to talk only about programming languages, because in the reality a standalone C compiler is a rare sort of software What was used in the 1990s mostly were integrated development tools e.g. Borland Turbo C, Microsoft QuickC and Watcom C. What these mainstream programs have in common is a bundle which contains of an underlying C compiler with a frontend to type in the Code.
Around the year 1992 all these programs have disappeared. They were replaced by dedicated C++ IDEs because of the upraising of the Windows 3.1 operating system. The question was not how to program in C but the question was how to build GUI applications with a graphical editor, a help system, a debugger and some sort of compiler which includes make files.
The only non IDE C compiler is GCC which can be utilized with different text editors. GCC is a standalone C compiler which is focussed on the C language instead of the programming workflow. Most endusers belief that the C language has felt out of fashion because they are no products available around this language. If all the major software companies have replaced C with C++ then it is wise to assume that Ansi-C has become outdated.
The underlying question is if it makes sense to bundle a programming language with a certain Text editor. The resulting tool is a complex high price product which can't be shipped on 2 floppy discs but will need many CD ROMs and an enormous amount of manuals. It is not about the C++ language itself, but about the code completion, GUI designer, GUI libraries and so on. At least in the public perception the C++ has replaced the former Ansi c language since the year 1992. The new programming paradigm was called object orientation and the C++ language was a natural choice for doing so.

October 03, 2022

Programming exercises to understand robotics

 AI and robotics is mostly described as programming technique or as an algorithm. The question is which sort of program provides AI, or which sort of AI library is available? The surprising situation is, that AI is located in a different position. It has to do with with a programming exercise.

Some typical Non AI programming exercises are:
- "Write a software in python which prints out 6 randomly generated numbers"
- "Write a python program which plots a line on the screen"
- "write a java program which adds two numbers and prints the result on the screen"

These exercises are used to a teach programming and a certain programming language at the university. It depends on the student how to solve it. AI and robotics is some sort of advanced programming exercises which can be labeled as ultra-hard. The question is which sort of AI programming exercise is available? A possible challenge is given next.




There is a robot in a maze which can be controlled with the keyboard. The task is to write a grounded sensor for the robot which contains of 6 elements:
[xpos,ypos,distancefront, distanceleft,distanceright,distancetoenergy]

The sensor array should be printed to the screen all the time.

Such a programming exercise fits into the same category like "write a program which prints out all the prime numbers" because it formulates a problem which can be solved with an algorithm. The task for the student is to understand the problem, write a short program in Python or Java and then it can be determined if the software solves the task.

From an abstract point of view it is important to ask which sort of programming exercises are needed to explain the subject of robotics. What all these challenges have in common is, that not a certain algorithm is needed but a certain exercise. The formulated problem with the sensor array doesn't contain of program code nor an algorithm. But is a figure plus a text which formulates a problem. It is up to the opponent (the student) to provide an answer to the problem. The answer is written in a certain proramming language and will contain of an algorithm. In the concrete example, the typical answer will take the requested 6 elements from the underlying physics engine and in case of the distance value it has to be calculated from scratch. Then a print routine is needed to show the result on the screen.

Creating a GUI with Ansi-C


 

The dominant cause for the upraising of object oriented programming language was the introduction of GUI operating systems like Windows. Since the 1990, the amount of dedicated OOP languages like Java, C#, Python and Ruby have grown exponentially and many programmers are convinced that they need the ability to create classes.
But from a technical point it is possible to create a gui app with the imperative C language as well. There are some prerequisites needed for example a tutorial about creating the widgets itself. [1] Also the programmer has to make sure that all the needed libraries are installed and that the correct compiler settings where chosen.
/* 	
  gcc -ansi 2_ansic.c $(pkg-config --cflags --libs gtk+-3.0) && ./a.out

*/
#include <stdio.h>
#include <gtk/gtk.h>

void show_about(GtkWidget *widget, gpointer data) {
  GtkWidget *dialog = gtk_about_dialog_new();
  gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(dialog), "Sample program");
  gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), "0.1");
  gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog),
     "The quick brown fox jumps over the lazy dog");
  gtk_dialog_run(GTK_DIALOG (dialog));
  gtk_widget_destroy(dialog);
}

void button_clicked(GtkWidget *widget, gpointer data) {
  printf("clicked\n");
}

void initwindow() {
  gtk_init(NULL, NULL);

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "Hello World");
  gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);

  GtkWidget *fixed = gtk_fixed_new();
  gtk_container_add(GTK_CONTAINER(window), fixed);

  GtkWidget *btn1 = gtk_button_new_with_label("Button");
  gtk_fixed_put(GTK_FIXED(fixed), btn1, 150, 50);
  gtk_widget_set_size_request(btn1, 80, 30);

  GtkWidget *entry1 = gtk_entry_new();
  gtk_fixed_put(GTK_FIXED(fixed), entry1, 150, 5);

  /* events */
  /*g_signal_connect(G_OBJECT(btn1), "clicked", G_CALLBACK(button_clicked), NULL);*/
  g_signal_connect(G_OBJECT(btn1), "clicked", G_CALLBACK(show_about), NULL);
  g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
  gtk_widget_show_all(window);
  gtk_main();
}

int main() {
  initwindow();
  return 0;
}
Then it is possible to create a simple window on the screen which includes the ability to show a message box.
There are some differences available to a normal python script which is producing the same result. The main difference is, that the C language is working with pointers. The second difference is, that it is not possible to create any sort of classes. In theory there is a workaround available. C has a built in module mechanism, which means to define variables in files and use functions in the same file to get access to the variable. And the pointer arithmetic is some sort of extra effort which has to be done by the programmer to make sure that the source code is working.
The main advantage of the shown ansi-c code in contrast to a python script is, that the program can be executed in a production environment. The created binary file has a size of only 18kb and runs with the maximum performance.
The open question is what will happen if the programs becomes larger. The main cause why OOP languages were introduced is to manage the complexity. In theory the same purpose can be realized with the mentioned module concept of C, but the amount of literature about the topic is very little.

October 01, 2022

Programming languages in a cluster diagram




The amount of programming languages is endless. One suboptimal option to categorize them is by their history. The more elaborated attempt in building clusters is by a two variable model which contains of interpreted vs compiled and procedural vs. objectoriented. The interesting situation is, that all the existing languages can be located at a certain position in the 2d chart.

And secondly it is possible to name only the languages located on the four corner which are: Basic, Python, C++ and C. Each of these languages has in one variable the maximum value. For example, the Basic language is an interpreted language which is working with the procedural paradigm.

Let us determine the best programming languages for professional purposes. The interesting situation is, that even more than 200 different programming languages were invented, most of them are only used in an academic context. At the university lots of languages are taught, e.g. Pascal, Python and of course Prolog. But, most of these languages are not used for writing operating systems which includes applications for operating systems. The concern of expert prorammers against these academic languages is, that they are objectoriented which is equal to rreject them or they are interpreted which also implies to reject them. The only language which is not object oriented and not interpreted is C.

A closer look into the debian repository and into the anecdotal description of what is used for creating MS-Dos and Win16 bit application will show, that 100% of the software in the past was written in Ansi-C. This is especially the case for the early 1990s. According to the programming books of this time, the future is about object oriented programming namely C++, Delphi and Java, But at the same time, these languages were not used to write production ready sourcecode. But the programmers are prefering Ansi-C.

According to the picture it is very easy to explain the reason why. Professional programmers are prefering a language which is compiled and procedural at the same time. The only language available in this category is C. All the other languages like C++, Basic, Prolog, Lua and so on have a different self understanding.

The question which remains open is, why exactly professional software is written with compiled&procedural languages. It seems that only this combination ensures the maximum performance and the ability to maintain a larger amount of codelines. What the Linux sourcecode and the Windows sourcecode have in common is, that the project has over 1 million lines of code and that the binary file is executed very efficient.

September 27, 2022

From a referee based evaluation to parametric cost maps

 A referee is a instance in sports game which evaluates the behavior of the players. The referee isn't part of the game but his task is to judge about how well the player performs in the game. A typical situation is, that the referee decides if the ball has entered the goal.

The limit of a referee is, that his role is static. A referee for soccer is judging with a different ruleset, than the referee for basketball. In one of the game it is allowed to touch the ball with the hand while in the other not. In a more flexible general game, the referee is allowed to modify the rules during the game. In such a hypothetical game the referee is allowed to change the game. He can advice the same players to behave like soccer players, basketball participent or any other sports game.

Such flexible role switch doesn't make sense for real sports game but it might be interesting in the robotics domain. The idea is, that a robot isn't playin a certain game, but the robot has to obey to the referee. And the referee can say that the ball should kicked in the left goal or into the right goal. And which action is correct doesn't depend on the game but on the decision of the referee.

In such a use case, the referee has much more power than in a normal sports game. So it is no longer a classical sports game with fixed rules, but it is some sort of training game in which the coach imagines the rules and the player has to fulfill them.

From a technical perspective such interaction can be modeled with a parametric cost map. The objective for the critic is to provide a cost map which can be adapted while the objective for the actor is to minimize the costs in that map. The natural commands formulated by the coach are translated into a grounded cost map and the cost map judges if the actions of the player are right or wrong. Such universal game is only limited by the ability to imagine a cost map. And the ability of the actor to parse the cost map.

The term actor critic was introduced already and it describes very well the division of tasks. One instance imagines what the cost map is, while the other instance has to provide concrete actions. It is important to know that both instances are needed so the artificial Intelligence can't be realized with a single module but at least two different modules are needed. The easier to realize module is for sure the actor instance. A computer program which gets a cost map as input is a normal numerical solver. The objective function is provided as input and the task is to search for a node in the game tree which minimizes the costs. A concrete algorithm would be a depth first search algorithm which is described in most entry level computer science text books.

The more complicated problem is located in the coach instance. The critic has to invent a cost function in a way, that a computer can understand it. For example a command like "kick the ball into a goal" is too vaque. The average computer doesn't know what kick, ball and goal is about. So a more precise constraints formulation is needed.

Programming in C# on a Linux desktop

Since many years, the Linux community is asking how and when the Linux desktop will become a mainstream ecosystem. The answer is always disappointing, that this is not the case and nobody knows the reason why. The underlying reason isn't located in the technology but it has to do with the Open Source ideology which prevents that Linux will become the default desktop PC.
Let us investigate the subject in detail and ask a simple question: which IDE (programming environment) is available under Linux which allows to program in the C# language? Somebody may argue, that this question is not important because nobody likes to do so, and in addition all the major IDEs are supporting of course all the programming languages. The surprising insight is, that this is not the case. Let us take a look on some major IDE in Linux which are code:lite, code:blocks, kdevelop and netbeans. It is possible to use these IDE for any language e.g. php, python, C/C++, java and even Lisp. So it would be naturally, that the major C# language which in the top 10 of the TIOBE index is supported as well.
According to the forum postings this is not the case.[1][2][3][4] The interesting situation is, that the answer for C# support or maybe a simple third party plugin is always answered very short with something like “nope” and “we don't have it and there is no plan in that direction” without giving a further explanation. The only IDE which is available for Linux is Eclipse which has at least a third party plugin for C# ("aCute"). But it is poor documented and the user is encouraged to not use the language at all.
So the question is, why is C# not liked by Linux enthusiasts? At first, we have to make clear that Linux is open to different programming languages. All the important languages like C/C++, java, php, python, TCL and of course Forth are accepted and it depends on the individual programmer if he likes the language or not. The only exception is the C# language. Here, the user is not allowed to use the language. The only way in doing so is to install a complete different IDE. That means the user has to leave the normal IDE community and search for a visual studio like software which is available for Linux or not.
References
[1] Feature Request - C#, 2016 #1448 https://github.com/eranif/codelite/issues/1448
[2] Does CodeBlocks support C#, 2014 https://forums.codeblocks.org/index.php?topic=18740.0
[3] KDevelop C# Language Support?, 2016 https://forum.kde.org/viewtopic.php?f=218&t=136944
[4] C# in Netbeans?, 2010 https://www.codeproject.com/Questions/85177/C-in-Netbeans

September 20, 2022

How to solve AI problem with a computer?

 

The main problem with today's computer which includes the software as well is the architecture was designed to solve existing problems. This is an advantage for problems from the domain of mathematics and database but it is at the time a bottleneck in the domain of Artificial Intelligence.
Let me give an example. Today's computers are great for storing table with numbers on the hard drive. The reason is that modern computers have an endless amount of hard drive storage and they have operating systems and database program to manage the information. The same technology failed for handling robotics problems. Even very powerful databases which are running on a supercomputer can't control a simple maze robot which has only 2 sensors and 2 motors.
The problem with AI problems is not how to solve these issues, but to formulate first the problem. AI has nothing to do with databases and surprisingly it has nothing to do with algorithms. The consequence is, that it is not possible to use database programs, programming languages are operating systems to address the issues. Unfortunately, the amount of remaining techniques is little or even zero so the question is how to research AI problem at all.
What we can say for sure is, that Artificial Intelligence has mostly to do with the grounding problem. Grounding means how to convert the real world into a computer representation. Some terms in the context of grounding are: cost maps, notation, motion capture, semantic representation.
None of these terms is located in the classical computer science but they are dedicated AI terms. The shared assumption is, that the world is converted into a data structure, and a cost map or motion capture will help in this task. 
The term "Cost map" is very complicated to explain because it bridges the reality with computer science. A cost map can be realized as a data structure and needs some sort of algorithm to process it, and at the same time, it has to do with a robot which is moving in a maze and with obstacle collisions. The same two perspective situation is available for motion capture which is also a computer science topic and something which has to do with the reality.
The symbol grounding problem is an intermediate layer which combines computer science with reality perception. It is a trick how to explain to a computer what the objective is. From a computer science perspective, a cost map or a mocap recording is a trivial task. In both cases it is stored in a integer array which is not very big. Normal database problems are more complicated to realized than a csv file for mocap recording. On the same hand, a mocap recording can be called an advanced technology because it is very new. It makes sense to summarize these efforts under the term Grounding problem. Grounding means usually to convert the reality into computer science. It is about storing costs and other heuristics in a data structure.
The reason why the subject has to do with Artificial Intelligence is because after a domain was grounded it is surprisingly trivial to solve it with a computer. Every computer built in the last 40 years is able to search in a cost map for the lowest costs and the underlying algorithm is the same what is known as A* which is some sort of mainstream algorithm in game programming.