Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

July 28, 2026

Graph traversal with a head up display

The perhaps most simple example for a head up display is a graph traversal problem of a robot. The robot moves inside a graph and should reach a target node.

The AI for the robot works with a head up display. There is a text box at the bottom showing the inner voice of the robot. The inner voice determines at which position the robot is, which nodes are in the near, what the target node is, and which action should be taken next.

A mathematical problem, graph traversal, gets converted into a textual problem. Textual means, that the head up display is using words to describe the reality. possible words are [currentnode, goalnode, nextnode, distance_to_goal]. These words and events are used to describe the game state from a high level perspective. The text box ensures that the inner voice was implemented correctly. That means, the AI isn't solving an optimization problem and its not running an algorithm, but the main task for the AI is to generate textual output in the head up display and talk to the human operator.

May 26, 2026

The failure of AI related programming language part 2

 In addition to a previous blogpost [1] the problem with 5th generation programming languages from the past should be explained in detail.

The initial situation in the mid 1980s was the existence of powerful 4th programming languages like C, Pascal and C++ which have simplified source code development. In contrast to former assembly language these languages offered powerful libraries and were able to compile on different computer hardware. Its pretty easy to write videogames like Pong and jump'n'run games in C and C++.

Unfortunately, these languages were not able to master robot control and AI problems. Some attempts were made to program game AI in the C language but in most cases the source code is hard to read because its a finite state machine, or the algorithm needs a high amount of CPU cycles because its a breadth first search algorithm in computer chess.

The consequence was to rediscover dedicated AI programming languages like Lisp and develop new 5th generation languages like Prolog and KL-one, which allows agent oriented programming. the promise was, that the programmer defines only facts and the reasoner module is able to plan by itself the robot's action.

It should be mentioned that AI related programming languages were a failure from day 1. The problem is, that its hard to utilize Prolog for a concrete example, e.g. to control a robot. 

The main problem with so called 5th generation languages is, that they were designed with a classical programming language paradigm in mind. There is an interpreter which executes the code on a computer and the user is asked to formulate the problem in the syntax of the programming language. This constraints makes sense from a computer science perspective, because every programming language is organized with this principle. Without an interpreter or a compiler the computer can't execute the code. But from a domain specific perspective, its not possible to specify a problem this way.

The working thesis is, that existing 4th programming languages like C/C++ are more than powerful and doesn't need improvement but can be utilized for AI related programming task. What is needed to bridge the gap towards the reality is a user interface, formulated in C/C++.

A GUI interface manages the communication between a computer and the human user. It contains of buttons, text fields and command lines. Such a user interface is the key element to design advanced AI software. In the optimal case, the user interface looks like a head up display for a robot. There is a video camera picture shown on the screen and on top there are multiple text boxes as overlay with additional information formulated in grounded languages. Such kind of futuristic GUI can be programmed in a classical programming language like C.

[1] https://ai-and-robotics.blogspot.com/2026/04/the-failure-of-ai-related-programming.html 

April 15, 2026

The failure of AI related programming language

The promise of 5th generation programming language was to formulate AI related problems on a higher abstraction level. Examples like Prolog, Domain specific language and robot control APIs were invented to simplify the programming. Unfurtunately the concept was never accepted in the reality. The reason is, that a programming language is targetted towards the internal behavior of a robot or a computer, and the internal system has no knowledge about the external world.

Let me give an example. Suppose a domain specific language for robot control is invented which consists of statements like:

robot.move()
robot.stop()
robot.chargebattery()
robot.robotpickup()

In theory this DSL sounds logical the problem is to parse such a language with a computer program. A statement like robot.move() can't be converted into low level actions. Its only a mock up without executable programming code. The reason has to do with the difference between internal structure of a system and external environment. The statement "robot.move()" makes only sense if there is a simulation in which the robot can move, rotate and stop. In a normal robot program written from scratch there is no such simulation available, but the memory aka the RAM of a computer program is empty.

Programming language for high level robot control doesn't work, because a programming language is the wrong tool for such a purpose. Programming language like C, Java, Rust or Python are great for technical implementation of ideas but they can't generate artificial intelligence. What is needed is not a programming language but a communication protocol similar to GUI interface. Typical examples for such an interface are the Maniac Mansion verbs shown on the bottom or the vocabulary of a text adventure. These interfaces are not realized as programming language but they are widgets on the screen created for human to machine interaction.

Of course, there is a need to write a computer program which checks if the user is moving the mouse over a verb and presses the button. But such kind of program can be formulated in classical programming language like C/C++ or Python, Because the task for the program is very low level and has to do with recognizing the mouse position and display text on the screen. These tasks have to do with computer programming the core sense because the program defines how to blit pixels to the screen and which sort of game loop is reacting to the user input.

April 01, 2026

AI without programming

Computer science is mostly organized around programming languages. There are imperative languages like C, there are object oriented language like Java and there are modern languages like Python. A common strategy was to implement artificial intelligence in a programming language. The reason is, that a computer which is running a program is the most powerful and often the only tool available in computer science. So the assumption was, that this workflow can be adapted towards artificial intelligence.

Unfortunately, this concept doesn't work in reality. Even many AI related projects were implemented in C++ and lots of industrial robots were programmed in a robot programming language the concept of implementing AI in a programming language is a dead end. Even high level languages like Python doesn't provide the needed elements or libraries needed for making a computer smart. A computer program will run only in a predefined fashion which is the opposite of adaptive systems which are able to solve complex tasks.

The answer to the challenge is to avoid programming languages at all and imagine Artificial intelligence in a non computer science perspective. Instead of asking how to implement AI on a computer the new question is who can humans communicate with robots. This question goes beyond software engineering but it asks for protocols similar to TCP/IP. Implementing a communication protocol in C or in Python is only a detail problem and can be ignored in most AI related projects.

The computer shouldn't be described as a computational machine but as a message transceiver. There are incoming messages from a human and there are outgoing messages back to the human. Artificial intelligence means to formalize this process with a protocol, with a vocabulary and with a grammar. This task can't be described in classical software paradigm but it has to do with protocol design and inventing a domain specific language.

Let me give an example. Suppose the goal is to create a warehouse robot. Such a robot will needed a list of nouns like "obstacle, path, battery, box, barcode" and the robot will need a list of verbs like "stop, forward, rotate, scan, grasp". These nouns and verbs can be combined into sentences and some adjectives may help to communicate in difficult situations. Computer science and especially software engineering is the wrong discipline to describe the robot's vocabulary but it has more in common with linguistics not related to computing anymore.

February 11, 2026

Computer programming vs. AI programming

 Computer programming is the art of software creation. It has to do converting a real world problem into executable program code like Java or C/C++- A typical example is to program a pong videogame, or improve a database management system.

Modern computer programming since the 2010s does't reinvents the wheel but its using existing operating systems, programming languages and libraries. For example videogames are written with the help of a 2d game library, and database systems are created on top of existing SQL databases.

Programming has always the goal of creating software and modify existing software which is running on a computer. All the modern technology like the Internet, word processing software, and database software is the result of well engineered software applications.

Despite the importance of programming in computer science the discipline has a blind spot because its not possible to program an AI software or write a software for a robot. Many attempts in writting robot software in C/C++ and Java were presented in the past, but most of them have to be called a failure. It seems, that artificial intelligence is working different from classical software engineering principle. Its not possible to reuse existing software libraries or take advantage of existing programming languages. Even the most powerful programming language avaialble which is Python in combination with the latest mathematical libraries is useless for realizing a robot project. The reason is, that software programming describes the world as computer centric. The attention is always directed toward a computer and towards its ability to execute a software. For example the Python interpreter provides a list of commands. Programming means to arrange these commands to a fixed structure which is a computer program, namely in classes in subroutines. Then the program canb e exucuted. The problem is that such a program won't realize artificial intelligence.

There is a single programming excersise available which demonstrates the transition from classical software programming towards artificial intelligence which is activitity recognition in motion capture. This specialized problem has its roots in computer animation and was first mentioned in the 1970s. The task is to annoate the movements of the mocap markers with textual names like sitting, jumping, walking and so forth.

Computer programming is focussed on the CPU of a computer. The computer has to solve a problem, e.g. adding two numbers or search in a database with a search algorithms. In contrast, the activity recogntion task works with a communiation paradigm similar to an internet protocol. The idea is to convert low level data into high level data. Such a communication system is an open system, which is seldom described in the programming literature. The reason is that communication is referenced to external parties located outside of a computer. 

Classical programming works with the algorithm paradigm as a theoretical understanding. The algorithm is executed on the machine and solves a problem. In contrast, communciation oriented programming works with the sender to receiver paradigm. There is no algorithms needed but there is a message which is delivered over the network. Programming a robot is similar to implementing a communication protocol, there is also a sender, a receiver, a message and a protocol. And the robot never runs an algorithm, but the robot receives a message.

February 03, 2026

Annotating video games

The screenshot left shows a simple random walk in a path with two robots. Even if the picture is provided in maximum resolution it remains unclear what the meaning is of all these pixels. Human can guess that the connected nodes are the allowed path, but computers have no idea how to interpret the image.

The situation becomes much clearer by activated the pause mode shown on the right. There is an additional textual window which explains, that the red circle is robot1 who is moving from node #4 to #5 and has a full battery. These information can't be parsed from the original picture so the text box provides additional meaning. Another feature of a text box is, that computer will understand the information much easier because all the data are formatted in a key value syntax which is the prefered layout for machine understanding.

Such a text box is the core element of Artificial intelligence because it adresses the symbol grounding problem. The text box communicates the current game state to an external instance which is a human observer. Instead of analyzing how the simulation was programmed internally the new question is how to talk about the domain in natural language. Such a task is realized with a user interface in general and with a text box in detail. 

Simple example for a head up display


An entry level example for demonstrating the power of head up displays and grounded language is a route navigation problem which is perhaps the most easiest example for instruction following. The robot gets controlled with a random generator and after pausing the game, a text box with additional information on the screen. This text box contains of the grounded language which is important to provide meaning.

Every head up display is based on a two tier architecture: there is a graphical screen in the background and a textual screen in the foreground. Such kind of text boxes are common design element in videogames, and they are also useful for artificial intelligence. The compact representation in the text box helps a computer to understand a videogame.
Grounding means, that the AI is able to generate and format the content in the text box. 

The text box is updated if the video game status is changing. Both layers are synchronized automatically. Programming such an upto date grounded language is the core problem. In case of the graph traversal robot, the information shown in the text box are easy to format. In case of a kitchen robot or a self driving car the text box contains more complex information which are harder to maintain automatically.

January 29, 2026

Pong AI with internal teacher

 

The game has 2 modes: a) normal videogame instructions are executed by the AI b) internal teacher, game is paused and text overlay is shown. A press on space toggles between the modes. This two mode system emulates a speaker to hearer interaction. So there isn't a single Game AI available which controls the paddle, but there are 2 layers which have different obligations. 

January 26, 2026

Improved chatbot for a kitchen robot

In addition to the previous post, the python script was improved a bit. There are more entries in the database, the amount of informaiton is higher, and very important a telemetry mapping function is available. This allows to monitor a teleoperation robot. The amount of codelines was increased to 80 but the software remains easy to understand.

The core element is a database with words. Every word is described with additional key-value informaiton for example a picture or a position. The AI takes the current sensory data and searches for a match in the database and the AI also searches for a text input from a user. If the AI has found an entry in the database its equal to understand a situation. In short, the AI is a database lookup algorithm. Here is an example interaction and of course the source code written in Python3.

----
gathering telemetry ...
attention near apple
robotpos near table
user: lookat table
search database ...
lookat action inspect object
table {'pos': (0, 0), 'desc': 'place for storing objects', 'word': 'noun'}

gathering telemetry ...
attention near apple
robotpos near table
user: grasp apple
search database ...
grasp action take an object
apple {'pos': (10, 3), 'word': 'noun', 'category': 'fruit', 'desc': 'is food to eat', 'filename': 'apple.jpg'}
----

"""
chatbot kitchen robot
a wordlist is stored as python dictionary, user enters command which is searched in the wordlist
application: Teleoperation monitoring
"""
class Chatbot:
  def __init__(self):
    self.data={
      # verb
      "open": "action open something",
      "grasp": "action take an object",
      "ungrasp": "action place object from hand to world",
      "eat": "action eat food",
      "lookat": "action inspect object",
      "walkto": { 
        "word": "verb",
        "category": "action",
        "desc": "move towards location",
        "motor": "legs",
      },
      # noun
      "apple": {
        "pos": (10,3),
        "word": "noun",
        "category": "fruit",
        "desc": "is food to eat",
        "filename": "apple.jpg",
      },
      "banana": {
        "desc": "noun food",
      },
      "table": { 
        "pos": (0,0),
        "desc": "place for storing objects",
        "word": "noun",
      },
      "fridge": {
        "pos": (1,0),
        "word": "noun",
        "status": "closed",
        "category": "furniture",
      },
      "plate": "noun food is served there",
      "door": "noun entrance to room",
    }
    self.telemetry()
    self.parser()
  def getdist(self,p1,p2): # return: manhattan_distance
    result=abs(p1[0]-p2[0])+abs(p1[1]-p2[1])
    return result
  def telemetry(self):
    self.sensor={
      "robotpos": (0,1),
      "camera": "cam02.jpg",
      "attention": (10,3),
    }
    # search robotpos and attention
    print("gathering telemetry ...")
    for i in self.data:
      if "pos" in self.data[i]:
        dist=self.getdist(self.sensor["robotpos"],self.data[i]["pos"])
        if dist<=1:
          print("robotpos near",i)
        dist=self.getdist(self.sensor["attention"],self.data[i]["pos"])
        if dist<=1:
          print("attention near",i)
  def parser(self):
    line=input("user: ") # manuel input
    line=line.split()
    print("search database ...")
    for i in line:
      if i in self.data:
        print(i,self.data[i])
      else:
        print(i,"not found")
    

if __name__ == '__main__':
  c=Chatbot()

November 01, 2025

Programming effort for Pong videogame for different decades

 

The task is to write a pong clone including two paddles, a ball and a visible score. The constraint is that only tools are allowed which were available in a certain decade of computer history.
year
description
Programming effort
1985
BASIC on 8bit homecomputer without permanent access to the device
40 hours
1985
BASIC on 8bit homecomputer with permanent access to the device
20 hours
1995
C in MS-DOS
15 hours
2010
Python with pygame
5 hours
2025
Javascript generated by Large Language model
1 hours

April 01, 2025

How to navigate in the AI Literature

 

The collected papers and books about artificial intelligence and robotics are the most dominant resource available to investigate the subject in detail. The assumption is, that every subject was described already in the Gutenberg galaxy, the only question is where exactly and how well a certain text was written.
Especially for newbies its important to identify possible entry point to start the journey to AI. Such an entry point are “np hard” and “Np complete” problems which are discussed since the 1990s in common books about algorithms. The idea is that apart from vanilla problems like sorting an array and searching in a string, some advanced challenges are available. These advanced challenges have no known algorithm, or the algorithm is working with so called heuristics.
The good news is, that these np hard problems are a good starting point to investigate the subject of AI. Every AI problem problem is also an np hard problem. That means, AI is trying to solve only the advanced problems not researched in classical computer science, e.g. path planning, motion planning, decision making in games or human to machine communication.
There are some attempts available to solve even np hard problems, e.g. guided search in the state space or evaluation function. Especially evaluation functions are a widely discussed subject within the AI community because they are needed for computer chess. There are hundreds or even thousands of books available which are dedicated only to evaluation functions, so we can say that this subject might be a good starting point to become familiar with AI.

March 22, 2025

np hard problems as terra incognita

Computer science is an academic discipline with a long tradition. Its core elements are programming languages and algorithms. .Endless amount of source code was written in multiple programming languages, there are even esoteric languages available like Intercal and Befunge which are examples for computer art. Unfortunately, computer science consists of a seldom described weakness which are np hard problem.

An np hard problem is a mathematical challenge which can't be solved with existing programming languages nor algorithms. That means, modern languages like C++ in combination with modern 64bit operating systems like Linux isn't powerful enough to determine the shortest route for 15 cities or find the shortest sequence for solving the rubik's cube puzzle. What makes the situation more complicated is, that even after adding more RAM to a computer, np hard problems remain unsolvable.
One possible explanation why computer science is ignoring np hard problems might be, that its useless to invest ressources into problems, which can't be solved. If 100 researchers in the past have independent from each other tried to solve the Traveling salesman problem, and all of them have failed, it doesn't make much sense if additional researchers are trying to solve the same problem. .np hard problems can be compared to the perpetuum mobile in mechanical engineering which is also described as a dead end.
On the other hand there is a discipline available which is devoted to np hard problems. This discipline is called Artificial intelligence and its main problem is to solve all these unsolvable problems like rubik's cube, path planning and motion planning. Its important the difference between computer science which is only about polynomial problems vs. Artificial intelligence which is only about np hard problems. Both disciplines are trying to achieve different goals and they are operating with opposite tools.

November 15, 2023

Homecomputers until the 1990s

 Before the advent of today's PC technology which is dominated by Windows and Linux operating system there was a much smaller community available of computer enthusiasts. From 1980-1990 most of todays computer hardware and software was invented in the first place and the magazines which were introducing the subject to a readership were sometimes very well informed. In that period two dominant computer systems were available which was the Commodore 64 and the MS DOS PC.

At first it should be mentioned that on IBM PC hardware until the year 1990 the well known Windows operating won't be running fast enough. The only available operating system for early DOS Computers was DOS itself which is a single user, single tasking operating system. In comparison to the Commodore 64 advantage was that it was much easier to write software for MS DOS than for the C64. 8bit homecomputers with 64kb and less main memory and without any harddrive are not capable in running compiled C programs. The only sense making programming technique is the Assembly language. In contrast, early MS DOS PC until 1990s are working fine with c compilers. These large scale programs including the build in libraries can be installed on the small hard drive (less than 100 MB) and it is possible to write and debug software direct on a MS DOS PC.

The reason why this workflow is described in detail is because its working the same like modern programming workflow in the 2020s. That means, in the last decades the programming itself hasn't changed that much. Typing in C code on a 286 PC and compile it into machine code or typing in java code into a mto a more recent 4 core PC is based on the same abstraction mechanism. The human programmer has a set of libraries and combines existing functions into a new software.

Somebody may argue, that the difference between Assembly language and Turbo C is small because both programming language were invented decades ago. This assumption is wrong. Learning assembly from scratch and write larger software is very complicated while the same task in C can be handled easily. The difference is that the C language is a problem oriented language while assembly is hardware oriented. The typical assembly program is written for a certain CPU and a certain adress space in the main memory, while c program are written around a certain domain like a game or a word processing applications.

The only negative point of the C language are the hardware requirement. C assumes that an entry level 286 MS DOS PC is available which has 600 kb of RAM and a harddisc of 10 MB and more. Its not possible to run  a compiler with less RAM and without a harddrive. Even if some C compilers are available for the C64, it can't be used in reality for writing programs. The cause is that a compiled C program is much slower and will need more RAM than a hand coded assembly program.

The main difference between the C64 and the MS DOS PC Is, that C64 programmers claim that Assembly language is a here to stay. This assumption is the result of the lower hardware of the C64 which prevents to use any other programming language than Assembly. Even if its possible to write Assembly program on the MS DOS PC most programmers prefer a c compiler because the language allows to increase the productivity. Especially if a graphics library is available and the programmer is familiar with the computer its possible to write simple games in a short amount of time, very similar to what today's programmer can archive. in other words the existence of a c compiler is the single cause why MS DOS PC have replaced 8bit homecomputers.

October 21, 2022

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

September 06, 2022

Creating a minimal outliner in Linux

 



For creating a 1dArrayoutliner a first mockup is available.It was realized in 200 lines of code in the python language and shows the main window for an outliner. It is using a two pane layout. The user can select in the left menu the page and will see in the right pane the content of a page.
The page content is rendered with a self written parser. A pushdown automaton analyzes a markdown file and translates it into a rich text window. Right now, the GUI framework is wxpython but it seems that it is not powerful enough. So perhaps it makes sense to switch to tkinter?
The bottleneck of the current project is to save the information from the text editor into a markdown file. To realize it the text editor needs the abilty to save something as markdown, or the program needs to parse the information in the window manual. The task is needed because images and text are shown at the same time in the window.
That means, writing a text only outlier program is pretty easy, but if the images are shown inside th text it is much harder to program it.
 
Perhaps it makes sense to explain why there is need to program yet another outline editor. Because most of the programs from the past are very big projects It seems, that the average outliner / PKM software has at least a size of 1 MB and there is no upper limit so that current software has 200 MB and more.
The idea is to reduce the requirement to a minimum and write a much smaller outliner program which has 100 kb and less. For doing so there is need to specifiy which features should be implemented and which not. From a database persective an outliner has to implement the CRUD operations which stands for create, retrieve, update and delete. The interesting situation is, that more actions are not needed, if the user can add new pages and modify the existing he is happy. Editing a page means usually to enter text in the richt text window which includes adding images. I think it is not possible to ignore images and assume that a text only outliner will fulfill the needs of a user.
 

November 10, 2021

Modular programming with any programming language

In the past it was some kind of game to compare different languages against each other. C programmers are convinced that their language is the fastest one, python programmers emphasizes how easy it is to write code and Forth programmers are proud of low energy consumption for a single instruction. It is hard or even impossible to bridge these communities.
On the other other hand there is a unique element which have all the programming languages in common. This feature is more powerful than stack based computing, and easier to create than object oriented programs. The single useful feature is the ability to write programs in a modular fashion. The term modular programming is a bit uncommon and sounds outdated so it makes sense to explain it further.
A module is a file which contains of 5-8 procuedures and 5-8 variables. The procedures are allowed to manipulate the variables and the idea has much in common with a class. A module was used in programming before the advent of oop. The pascal language knows the unit statement, the c language can include prototype files, and fortran porgrammer can create modules as well. So we can say that modular programming is the single paradigm which is available in all the languages including forth which has also modular capabilities.
Modular programming looks not very interesting on the first look but it is the key element to write larger program. A larger programs contains of 1000 and more lines of code. Such projects can only be realized in a modular fashion because it allows to structure the program into logical chunks which are programmed independent from each other.
The perhaps most interesting situation is that with modular programming all the languages including forth and C++ are easy to master. What the programmer has to do is to follow strict the rules. That means, if the program gets bigger he has to create a new file and put the procedures into this file. Programming means to manage procedures and variables. This paradigm allows to solve any problem in software.
Let us take a closer look into some larger Forth projects at github. Instead of explaining how a stack based language works let us focus only on modular programming. What we can see in these projects is that some files are there and each file has the same structure. At top there are some variables initialized and in the bottom some functions are written down which are accessing to the variables. So the concept is the same what c programmers are using and java programmers if they are creating new files for a new class. And yes the principle makes sense because it allows to write longer programs which has more features.
The interesting situation is, that modular programming has no limit in the code size. Because newly created submodules can be included in other modules and at the end there are 50 and more files available which have each 100 lines of code. So the overall structure is highly hierarchical. It is less powerful than real object oriented programming but it comes close to the idea.
It sounds a bit trivial to expain this programming style in detail because c programmers are doing so since the 1970s and it is the most common coding style ever. On the other hand the amount of books how are describing the principle is low. Most C introductionary books doesn't even have a chapter about the subject of creating programs with more than a single sourcecode file. Similar to other languages the main focus of a tutorial is to explain the language itself, which includes the statements, but this knowledge doesn't allow to create useful software.
So we can say that an individual programming language is less important. The fact that the for loop in forth works different from a for loop in python can be ignored. What the programmer needs to know instead is how to write programs distributed in units.

November 03, 2021

Object oriented programming without objects

 

The python programming language provides a seldom explained feature which is the ability to use modules. A module is different from the class concept and has much in common with header files in the c language. The idea is to avoid classes in pyton at all and destribute the coder over many files which are included with the import statement.
From a python perspective the advantage is low.. But a python script which is using only modular programming is much easier to convert into normal c code. That means the written program or game can be made faster in the future by translating the python code into c code. The interesting situation is, that using modules instead of classes is working surprisingly well. What the programmer can is to create small files with less than 100 lines of code. Each file consists of some functions and some variables on top. The variables are only getting accessed from the python module but not from the outside.
What modules doesn't allow is inheritance. Also it is not possible to put different modules into the same file. Each module is stored in a different file. This will increase the amount of files drastically. But thanks the ability to import modules hierarchically it is possible to create very complex applications. With dozends of modules which are combined into submodules.
The chance is high that python programmers are using a same technique. The c language has the disadvantage that it is more complicated to create such modules. Because in addition a header file is needed which is an interface to the outside. But in theory, this concept can replace object oriented classes. That means, there is no need to convert c code into c++ classes.
Modular programming has felt out of fashion since the advent of C++. Today the situation is that more complicated programs are mostly realized with the OOP paradigm. Also the UML notation knows only of classes but not of modules. But in theory both ideas allowing to create larger projects with thousands lines of code.
The only thing what is not working is to avoid classes and modules as well. If somebody writes down 20 variables and 40 functions into the same file it is hard to determine which functions gets access to which variable. Such code can't be maintained. So it is important to divide the code into smaller chunks with less than 100 lines of code. Such a file can be analyzed easily by a human programmer.

October 27, 2021

Groups for programming languages

 

The amount of programming languages is endless. Instead of describing a single one it makes sense to put them into baskets and compare the entire category. A modern programming language works with an interpreter and is easy to learn. A typical example is python. Compared to ruby and javascript (which are in the same category) the python language is more widespread used.
The next group of languages consists of classical compiled language. These languages are used by experts to create full blown desktop applications. C++ is the most dominant language in this group. The language is very powerful and much harder to learn than python. Other examples for classical large scale programming languages are C#, Java, C and rust.
The third groups contains esoteric languages which are working quite different from the previously mentioned category. Typical examples in this group are Lisp and Forth. it doesn't make much sense to compare languages from different groups with each other because they are very different. The better idea is to select one category first and then ask which of the languages is working fine.

August 17, 2021

What is the unix philosophy?

 

Instead of a common myth Unix is not about pipes or the kernel but it is a programming style created around the C language. The idea is to create software with the high level C language instead of using assembly language. This allows to writer larger programs which will need lots of RAM and disc space.
Some examples for typical Unix programs are gnuplot which has 150k lines of code in C and lyx which contains of 350k lines of code in C++. Both programs have a long tradition, are typical Unix programs and they are fulfilling lots of requirements.
There is a difference between writing a small piece of software in Assembly language which runs on a home computer and writing a larger program whcih is running on a mainframe computer. The obvious difference is, that a program like gnuplot can't be created by a single person in a weekend but it is long term effort done by a programmer's team.
Perhaps it sounds a bit unusual to ask, but why exactly are larger programs needed? Wouldn't it be ok to paint a chart with a software which needs only 100kb for the sourcecode? This has to do with the unix philosophy. The idea behind Unix is to write large scale programs which are fulling requirements from the end user. The typical program written in C has lots of parameters. It is not because the program itself is so complex but because the task which is textprocessing, graphics drawing or whatever is so complicated. The assumption is, that it is not possible to rewrite the gnuplot software in assembly language and compress it into 10k lines of code. Such a program would be run much faster, but it won't provide all the features of the original gnuplot software.
It is not a coincidence that 90% of the unix software is written in C/C++. Because this programming was designed for creating large programs. In contrast to Assembly language it wasn't invented for hardware needs, but C/C++ is a programmer friendly language. It supports functions, variables, and structs. The result is, that the programmers can write software which has lots of lines of code. Let us take a look what the typical Linux user will see after the first installation of a distribution. He will see that the operating system has occupied many gigabytes of his harddrive. In case of Debian a default installation will need 15 GB. And if the user installs additional software the requirement is much higher.
Somebody has written all the code in the past. This was done by Unix programmers who are familiar with the C language. They have created software packages for database management, text processing, image manipulation, mathematics needs and of course for networking demands. Programming itself is easy, but these applications are hard. A basic tutorial for the c language will fit on a single sheet of paper. C consists only if-then-statements, function declaration and some case switches. But programming a concrete application is very different from programming itself.

July 15, 2021

What is object oriented programming?

It seems, that object oriented programming has so many advantages and it is used so frequently that it has become hard to explain what the idea is. Especially non programmers find it difficult to get the advantages of the C++ language over existing paradigm which is structured programming.
In a single sentence, object oriented programming allows to use of global variables.
A global variable is a memory adress used by more than a single function. The same variable can be accessed from different subroutines of the program without sending the variable as a parameter to the function. A typical example consists of one or two struct variables which are accessed by three upto four different methods. The combination of the variables and the methods is creating a program within the program called class.
So the logical next question is, what should somebody need a global variable? In the classical structured programming technique global variables are not recommended. They are perceived as a wrong idea. The more likely paradigm is to provide the variable as a parameter to the function header. So the function can only manipulate objects they were provided in the heading.