December 29, 2022
From Treepad to Zimwiki – a small history of outliner software
December 22, 2022
Creating a Luhmann style Zettelkasten with the Lyx software
December 19, 2022
How to write an academic paper without taking notes?
December 17, 2022
Comparing C#, Java and Python
Faster citation with the Lyx software
\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
December 01, 2022
Train localization as a software problem
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
Which programming language is the best?
Is C# obsolete?
// 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)
Writing larger programs in Ansi C and Forth
Modular programming with python
The surprising success of the C programming language
The development of the c language after the year 1992
Writing GUI apps with the c language
October 05, 2022
The remarkable success of the C programming language
C vs C++
Creating header files in Ansi C
Why has the C language evolved into C++?
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
/* 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; }
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
September 20, 2022
How to solve AI problem with a computer?