September 18, 2022

Creating GUI apps in Linux

 A common question for programmer newbies is to ask which of the existing GUI frameworks is the most widespread used, or the easiest one to learn. Other users may ask which programming language might fits well for writing large scale GUI apps. The surprising situation is, that none of the existing libraries like Qt, tkinter or WXwidget can be recommended and all the mainstream languages like Python, Java and C++ are an antipattern to develop a GUI app.

With this forward it might be interesting to know what the preferred choice is in writing a GUI app. The working hypothesis is, that not a certain programming language is important but a certain GUI builder software. A gui builder is a WYSIWYG program which allows to drag and drop a GUI interface similar to painting an image, and then the code is generated by the program.

Let us take a closer look what very different software tools like MS-Access, Borland C++ Builder, code:blocks and WXglade have in common. In all these environments, the user isn't asked to write a single line of code, but he has menu with widgets like a button, a textfield and a combo box and then the tool knows how to write the code.

The reason why a gui builder is not optional but mandatory is because a GUI framework like Qt or any other one is a large scale library which contains of thousands of classes. It is not possible to use a small gui library. Even so called lightweight GUI libraries like FLTK will occupy around 4 MB on the hard drive and provides endless amount of options and parameters. The only way to master all the widget is an extra tool which is not working with sourcecode but with a graphical interface.

Let us take a closer look into a smaller but very powerful GUI builder which is wxglade. The amount of features is very low. The user sees in the left pane the list of widget and is asked to drag and drop them into the right pane. The interesting situation is, that in setting menu for the entire application it is possible to specify a concrete programming language:



The menu looks not very impressive,, it is only a dialogue box with the option for C++, python, Perl and Lisp. The interesting situation is, that at least the wxglade software knows how to convert a GUI window into runnable sourcecode.

Let us investigate what will happen after activating the "C++" option. The wxglade software is producing the .cpp and the .h files. Also it is written in the preface in the comment section how to compile the .cpp code into a binary file. The user has to enter the command into the terminal and gets the application. A simple example Hello world windows contains of a text widget and a button occupies around 164 kb in total and can be executed with "./MyApp". It is a normal C++ program written by a machine.

After creating the code, the human programmer is asked to improve the generated code. He can add some events or program the database backend by itself. The interesting situation is, that such a workflow is much easier than writing the app from scratch. The assumption is, that 100% of the C++ GUI apps are written in this programming style. In all the cases, the beginning is always a GUI Builder which produces some code, and this code is improved more or less by a human programmer into an application.

This pipeline makes sense because a simple form which contains of only 3 buttons and some widgets will result into a long class which has 200 lines of code. It is not possible or very complicated to write the code by hand only with a printed manual. This is only possible if the programmer knows already what a concrete programming language and a concrete GUI framework has to offer.

Perhaps it should be mentioned, that all the generated code from Wxglade is using the Wxwidget. Somebody may argue that wxwidget is not the best framework and this assumption is correct. But, suppose a different gui builder will use a different framework, for example Qt. Then the pipeline is the same. At first the programmer starts a GUI builder, the code is generated by the software and then the programmer improves the code a bit or more. So we can say the focus is always on a gui builder which stands in the center and a concrete programming language or a concrete GUI library is less important.



In case of GUI programming the question is not if C++ or Python is the better choice. And the question is not if Wxwidget or Qt makes sense. But the more serious question is, if Visual studio, wxglade or Eclipse is a here to stay. GUIs are developed with a certain GUI builder, the gui builder defines how the sourcecode will look like.

There is some sort of TIOBE Index for gui builder tools. Popular tools are visual studio, eclipse and android studio These programs are not used because of syntax highlighting or other text editor capabilities but the dominant reason why programmers are using Visual studio is because of the GUI builder functionality. It allows them to draw an application similar to draw a picture with a graphics program.

GUI builders
The most interesting feature of a GUI Builder is, that it interprets the world from a certain perspective. There is no need to decide for or against a programming language. For a gui builder the difference between C++ and is low, even both languages are very different from each other. The reason is that a gui builder doesn't asks the user to type in sourcecode, but the user has drag & drop widgets and press the "generate" button.

The reason why most GUI apps are developed for Windows is because the visual studio software is a mature one which is over 20 years old and its core component is the mentioned gui builder. Alternative tools like wxglade have less features and are less well documented.

The interesting situation with visual studio is that the software can be used to create C++ and C# code as well. So the question is not which of the languages is the better one, but the GUI builder works fine with both.

Even if GUI builders are highly important in software development they are seldom discussed in the literature. The assumption in the past was that it depends on the individual choice of a programmer if and which gui builder he prefers. Also the tools are nearly invisible in the final sourcecode, because what is available as sourcecode is written in a certain programming like C++ or java. So the assumption was, to focus on the language or maybe on the GUI library but not on the tool which is responsible for the code.



[1] https://visualstudiomagazine.com/articles/2017/08/15/ide-ranking.aspx




C++ is a great programming language

Modern application development works with the attempt to create web applications and use prototyping techniques. Both is supported very well by the C++ programming language. C++ is a scripting language and it was designed for the Internet. C++ runs great in the browser as a GUI Frontend and on a webserver as a database backend.

But c++ has many other features which makes it unique from potential alternatives. C++ doesn't require the user of pointers which are known as a complicated programming tool which even aren't understood by experts. Also it doesn't have header files which are known as error prone in the C language.

IN the sum, C++ is the language of the future which is recommneded for most purposes. It is a beginner friendly prototyping language which fits very well to the needs of newbies.

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.
 

September 04, 2022

Review of the new Version of the Zim wiki

 

The latest version of the Zim desktop wiki is 0.74.3 which is not available in Debian. But the user can download and install the package manual with the dpkg tool. The first impression of the software is very good. The programmers have removed the toolbar, so that it is no longer possible to format something in bold Also the search box was removed The user needs an additional click if he likes to find something.
Some things remain unchanged. The rendering of the link map takes the same huge time like in the stable version. The user is pressing the button, has to wait for 20 seconds, then a popup menu from gnome asks to quit the application at all and then after a while, a messy chart of the nodes is drawn.
One cause of the slow speed is for sure the underlying programming language. Python is known as a beginner friendly programming language which is not recommended for productive software. So it is some sort of luck, if the user doesn't loose all the important information, if the program is crashing.
A closer look into the source code will show, that the Richtext WYSIWYG editor was realized in 600 kb of Python code. Most of the code was written a while ago in the Python language and never changed. This speaks for the zim project. There is no need for using the C++ language or creating a more efficient GUI because this would need too much manpower which would be missing somewhere else, outside the zimwiki project.
Overall the zim wiki is a great improvement over the previous version 0.73.5. If the end user is not satisfied with existing Outliner tools, he will dislike the zimwiki program as well. It is a pleasure to see, that even an ArchLinux package file is provided. This Linux distribution is a great replacement for Debian and other outdated projects because ArchLinux has always the newest version of a program ...
One bug should be mentioned at the end. In contrast to the previous version, the program is asking the user if he really likes to delete a certain page in the list.

September 02, 2022

Writing GUI apps for Linux

 

GUI applications are a major concern in the Linux ecosystem. There are some frameworks available but none of them can be recommended. The following blogpost introduces the topic and compares the major options for programming window based applications.
Roughly spoken the list of gui frameworks consists of: Qt, gtk+, wxwidget, tkinter and FLTK. THe problem is, that the programmer can decide only for one of the frameworks. One the first look, Qt looks like a mature GUI framework. There are some points which are speaking against Qt. First thing is, that it is not only a C++ library but it extends the C++ language. Second problem is, that the amount of commits in the qt project is 5x lower than the amount of commits in the gnome project. And third point is, that larger LInux distributions like Ubuntu are preferring gnome.
Suppose gnome is a here to stay, the next question is how to create a gui. The first assumption is, that the underlying GTK+ library works pretty well to create guis. THe problem is, that gtk is documented poorly and even under python it is complicated to create a gui app. The better choice is to use the wxwidget framework.
Wxwidget looks the same, what PC users are using under Microsoft windows. It is full blown framework to create gui apps. It is working with python and C++ as well. The major concern against wxwidget is, that the size for an executable hello world app is too large. Indeed, a hello world app will need around 140 kb size in the working directory. And the app is doing nothing but showing a window with some pull down menus.
On the other hand it is possible to reduce the filesize with some tricks to around 22 kb:
g++ -Os -s helloworld.cpp `wx-config --libs --cxxflags`
upx a.out
Also it should be mentioned, that under the Windows operating system a much larger file size for hello world apps is common.
Compared to the wxwidget library, the FLTK library looks very outdated. Only a few tutorials are available and it seems, that the development has stopped around 2010. So the best choice for creating in the year 2022 a Linux gui app is wxwidget.
MVC concept
After deciding for one of the existing frameworks the next question is how to create the GUI app itself. Suppose the user has decided for the wxpython framework which allows to create GUI software in python, how exactly should the program look like? The major problem with GUI application is, that the inner principle is different from normal object oriented programming. OOP means basically to create objects for each elements. So the assumption of the newbie is, that he will needs different objects for the menu bar, the text box and the buttons. This is correct but wrong at the same time.
The major problem is gui programming is to connect these elements together. The end user will click on a button whichi activates the script and the script is searching something in the database. The problem is, that these process is executing functions in different parts of the program. So the question is how to arrange the classes.
MVC is a here to stay principle in solving the question Let us describe the concept step by step. The first file which has to be created is gui.py. This file holds the form which is displayed on the screen. It contains of the menu, the entry boxes and the buttons. Such a gui.py file can be created either with a text editor or with a gui designer like wxglade. After executing the file, the user will see the GUI on the screen which is a mockup. It won't do anything but show only the graphical frontend of the program.
In the second step two additional files are created which are controller.py and backend.py. The controller.py file contains of the event handling. It is the same what is known in Visual basic and MS-access as macros. For example, the user clicks on a button, and then the script in controller.py is executed. The script checks if the input is valid and decides which function should be called next. In the easiest case, the user is pressing on a button and then a “print()” statement is executed which displays on the command line that the button was pressed.
It is important to know that the macros, aka the eventhandling is never located in the gui.py file but it is outsourced into the controller class. This is the opposite of normal object oriented programming. Because of this reason the principle is called Model view controller principle. It is a technique how to write GUI code into different classes. The reason why MVC is used by 99% of the software is because it allows to create GUI apps much faster. The idea is, that in the first step only the GUI mockup itself is created. That means, the window on the screen has no functionality. The functionality is added later.

August 31, 2022

Making notes on the computer

 

The reason why so many software programs are available is because the subject isn't understood very well. Well known programs for making notes are a plain text file, Onenote, asksam, jabref, endnote and many other programs. To summarize the information we have to introduce the software category of a two pane outliner.
A two pane outliner is some sort of defacto standard for creating notes. If a certain program tries to reinvent the wheel the tool has to explain why it is not an outliner but something else. Most existing programs like Obsidian or onenote are indeed normal outliner programs which are extended by additional features. So let us first investigate a typical outliner program in detail. The Treepad outliner is a good example program. The program is no longer available but for historical reason it can be seen as a good example.
Treepad was available for the windows and the Linux ecosystem as well. It is showing a gui to the screen which contains of the two pane layout. In the left window the structure of the document is shown, while in the right pane the text itself is presented.
It should be mentioned, that an outliner is different from a text editor, from a database and from a word processing application. It has little or no layout features, and has a strong focus on full text search. In contrast to a text editor, the user is investigating a very long document which contains of hundreds of subsections.
The outliner concept is so powerful, that it is hard to imagine a possible alternative. The same outliner program can be used to store different sort of information like source code, notes, and even bibliographic information. At the same time, the term outliner is seldom used in the PIM and note taking community. Why?
One possible explanation is, that most note taking apps doesn't see themself as an outliner but as something else. The paradox situation is, that this self awareness doesn't match to the reality. A closer look into note taking tools in the now and from the past have shown that most of them are outliner programs. Let me give an example. The asksam software which was very popular in the 1980s and early 1990s has described themself as a full text database. The reason was, that asksam was able to search in the content at very fast speed. This was the unique feature of the software. BUt a closer look into asksam will show, that before the content can be searched it has to be created. Ant his is done in a hierarchical fashion.
The inofficial successor of Asksam is the myinfo software. Myinfo looks similar to the mentioned treepad software. It is a normal outline editor which includes the ability to search in the text. It is the same sfotware category like Cherrytree or notecase.
Another interesting situation is, that larger programs like Obsidian and Onenote are avoiding the term outliner. THese programs are looking different from an outliner, because there is no left pane with the outline available. It needs some extra clicks in the GUI and in case of Obsidian the user has to install a plugin to make the outline visible. But, all these programs are asking the user to create sections. Otherwise the content can't be stored. So it is an outliner for sure, only the left pane is not visible.
The Treepad software was available from 1995-2019 and then the project was terminated. The major advantage over other note taking software was, that treepad defines themself as a two pane outliner. It was described in the manual what the inner working is. The user has to create sections which are visible and then he can enter text. This is the core principle of a note taking software. And the concept is so powerful that other programs apart from Treepad are working with the same idea in mind.
It is important to understand that note taking is equal to use an outliner program. No matter how the software title is and what the self understanding of a certain program is, all these tools are nothing else but ordinary two pane outline editors.

A short history of outliner programs

 

Outliner programs are a seldom analyzed software category. On the same time, lots of these programs are available. So it seems that outliner are interesting for a larger amount of users. What makes the situation difficult to explain is the huge amount of different software programs. A rough estimation is that at least 300 different software programs were programmed since the 1980s and the amount is growing.
Let us explain the situation from a chronological perspective. The good news is, that over the decades only a few larger applications were popular. The 1980s was the decaded of the MS-DOS operating system. Outliner programs like Asksam, Grandview and MORE for the Apple system were created. The interesting situation is, that for the 1980s these programs had a large size. The more software was around 200 kb on a floppy disc. An outliner program was similar to a database and a word processing a complex application. There was even law case started around the PC-Outline program which looks similar to the grandview software from Symantec.
In the 1990s, nearly all the existing MS-DOS based outliner programs lost it's marketshare. Instead new applications like Treepad and Myinfo were programmed. This pattern is visible in the 2000s as well. New software was programmed from scratch like Notecase, Onenote and keynote. It seems, that the avarage lifespan of an outliner program is lower than 10 years.
Even larger software companies like Microsoft are not able to dominate the market. The Onenote software for example is not the market leader but stands in competition to evernote obsidian and of course the older outliners from the 2000s.
If so many different outliner programs are available it should be estimated that it is clear what an outliner is. This is not the case. Most programs are defining the software category slightly different. Some programs are referencing itself as a two pane outliner program, while other are prefering the term PIM or knowledge base. Other programs are calling themself note-taking app.
From a programming perspective an outliner is a combination between a text editor and a file browser. In the manual of the first popular Windows based outliner “treepad” there was a good description given. Treepad is according to the self understanding a combination of the Windows file explorer with the notepad application. That means, an outliner can be replaced by these single tools. In a minimal case it is equal to use the Linux command line for showing a directory and use a text editor to change the content of one of the files. The outliner program simplifies this task and in most cases an additional full text search engine is provided.
Let us take this explanation as a starting point to get a better understanding what an outliner is about. All the operating systems like Windows, unix and Apple have a directory structure on the harddrive. The user can create folders and store text files in these folders. Such a structure is some sort of knowledge base and most user will store information this way. An outliner program makes this use case more explicit and provides a well looking GUI interface which allows to create more complex folder structures.
Even if around 300 different outliner programs are available, most of these programs are working completely different from each other. So it makes sense that so many software was created. What the programmers have done in the last 40 years is to experiment with different GUI layout and program features. For example, in the years of the grandview and asksam, a left pane was missing. Most of the early outliner programs are working with a single pane window. Since the mentioned treepad program from 1995 the situation has changed. Nearly all the programs since the year 2000 are working with a two pane layout. Some programs have more features while other are very minimalist.
Under the LInux operating system there are text only outliner plugins available for the VIM and the emacs editor. These tools are not able to render images because the assumption is / was that images are not needed.
One possible reason why outliner are a seldom explained software category is, that most users think they have no need for such tools. They are using either the folder structure of the operating system or they are storing the outline into a MS-Word document. And indeed, MS-Word can show on the left side an outline window which allows to navigate in larger documents easily.
On the other hand, lots of users are not satisfied with a simple Word document. They have a need for a dedicated note taking app.

A minimalist outliner software

 

The amount of different outliner programs is huge. Around 400 software projects were written in the last 30 years. The interesting situation is that most of these programs are very huge in terms of codesize. Even the minmalist cherrytree program which is available as Debian package has a footprint of 650 kb. More complex project like the Zettlr app needs around 75 MB on the harddrive.
According to the famous outliner forum, the smallest possible outliner today are Mempad (210 kb), Theguide (1 MB) and Treepad light (450 kb). Especially the treepad light software is the unofficial champion in outliners because it was created very early and was available over many years. So it seems, that even lightweight outliners have a size of around 200 kb upto 600 kb.
This codesize can't be called lightweight. Creating a 500 kb softwareproject can't be realized in a short amount of time. So the dominant question is how to reduce the code size. Is it possible to write an outliner in 10% of the treepad light size which is 45 kb and less? This is perhaps the core question for modern outliner software. What most outliners available have in common is, that they are the opposite of a small software.
It is unclear how big a project like OneNote or scrivener is, but a rough estimation is, that such projects will occupy 10 MB and more on the harddrive. It is a typical example for a typical heavyweight PC software which is created in thousands and even million of codelines.
[1] lightweight 2-pane outliner for breaking up text quickly https://www.outlinersoftware.com/topics/viewt/4707/