July 12, 2021
Will Microsoft take over Debian?
July 11, 2021
Dictionary in C++ and in Python in comparison
The C++ version is faster, of course.
map.py
#########
d={
"A":{"one":0, "two":0, "three": 0,},
"B":{"one":0, "two":0, "three": 0,},
}
for i in range(20000000):
d["A"]["two"]=5
a=d["A"]["two"]
#print(a)
map.cpp
###########
#include <iostream>
#include <map>
#include <string>
#include <string_view>
// g++ -O3 -std=c++2a map.cpp
int main()
{
std::map<std::string, std::map<std::string, int>> d;
d["A"]["one"]=0;
d["A"]["two"]=0;
d["A"]["three"]=0;
d["B"]["one"]=0;
d["B"]["two"]=0;
d["B"]["three"]=0;
for (int i=0;i<20000000;i++) {
d["A"]["two"]=5;
int a=d["A"]["two"];
//std::cout<<a<<"\n";
}
}
July 10, 2021
Simpler programming with groovy and python
The programming community consists of two opposing group. The first one are old school programmer who have learned programming in the 1980. This group is familiar with Assembly language, C and sometimes the C++ language is used for creating modern desktop applications. This approach to writing software can be called a professional one because it garantees the maximum performance and is used to create large scale productive programs.
On the other hand, there are programmers who are not calling themself developers because they have never learnt to write code in C or Assembly language. The difference between both groups can be made visible by the different understanding of a pointer. Only the real programmers can explain what a pointer is, and they have used them all the time. Pointers are used for creating faster games and handle lot of data in a program.
The interesting situation is, that it is not possible to learn C/C++ or assembly without understanding pointers. They are a fundamental part of these language. To write anyhow a program a different sort of programming language is used. Typical examples for recent programming languages are groovy, python, matlab, javascript and Autoit. What these languages have in common the user has to enter only a little amount of code, and the written code reads easier.
A typical example is to compare a swing gui written in java, with a GTK+ gui written in C. The c code needs 4x more lines of code, and ofcourse the pointer operator * is used everwhere. In contrast, Groovy and especially python are much easier to read.
There is a reason why the scripting languages haven't replace real programming languages. Because a scripting language is using a lot overhead to reach the same goal. They are not a minimalist language like Assembly, but before groovy can be executed lots of programs have to installed first. And all of the underlying programs like operating systems, Virtual machines are written not in groovy but in powerful languages like C, C++ and Java.
July 08, 2021
Describing LaTeX from the workflow perspective
Instead of explaining what the LaTeX software itself is, it shoud be mentioned that without third party programs, the user can't create anything. Before the latex command line tool can be started, the text has to be created in a text editor. There are not a single but a lot of external text editors available:
How to avoid pointers in programming
July 05, 2021
How to learn C/C++ as fast as possible
Sometimes it was mentioned, that C and especially C++ are complicated languages which are hard to learn. The reason is, that C++ allows to write low level code which includes pointers. In addition the amount of possible C++ commands is high and the chance is high that the newbie won't understanding anything.
So the logical choice is to avoid the C++ language at all and take a look for a programming language which works better. Potential candidates are Python (very beginner friendly) and Java (works great for writing productive code).
Sure the Python language works great for creating a prototype. But it fails for creating a productive application. So the question which language would combine the strength of python with a fast runtime performance?
The main problem with potential alternatives to C/C++ is that all these languages are seen as a second choice. Sure it is possible to write code in freepascal, C#, swift or ruby. But the default compiler on all the operating system remains c/c++ and most programs in the world were realized in C/C++. It seems, that from a technical perspective the language is great and the bottleneck is the programmer who doesn't understand it?
The interesting situation with C/C++ is, that the perceived complexity depends greatly on the manual. This is a contradiction to the Python universe in which the language is described in most manuals the same way. There are two sorts of C/C++ manuals available. Older one which are focussed on the language itself and are some sort of reference book. These sort of manuals have created the perception that C/C++ is hard to understand. And there are more recent tutorials available which are describing how to use C/C++ for writing games and apps.
A prominent example for a recent handbook is “SFML Game Development By Example”. The interesting thing is, that this book explains more things than only the language itself and at the same time it is easy to read. The difficulty is not harder than a python book about the pygame envirionment. The newbie learns how to write a small game in under 500 lines of code with the usage of a graphics library and some self defined classes.
The interesting point is, that according to this (and many similar books) C++ is some sort of python like programming language, but it runs much faster.
Let me summarize the situation a bit. First thing to mention is, that C/C++ remains technically the best programming language in the world and secondly it depends largely on the tutorial if the newbie is able to master the language.
Understanding the role of LaTeX
Most introductions into LaTeX are trying to describe what the software itself is about. But this won't answer the question which role LaTeX is playing in a more general workflow. The interesting point is that most authors are not creating their text with latex itself but they are using external software like Emacs, texniccenter and vim. But, if LaTeX is so great why it is not used for writing the text?
To understand this mismatch we have to take a closer look how the programs are interacting with each other. What LaTeX needs as input text is a highly structured longer text, for example a 100 kb long markdown file, a 50 kb .tex file or a 300 kb long ascii text which contains of sections and subsections. in the next step, LaTeX is rendering this file into a pdf file similar to the ps2ascii utility.
In contrast to the MS-Word software the user never creates something in LaTeX but he creates the textfile for LaTeX. The text is written in additional software like the texnic center. And this explain what the idea behind LaTeX is. The user has to prepare the text in an outliner software and then it gets rendered into the pdf format.
Bascially spoken, creating something in LaTeX is not about the formatting itself but the more interesting point is, which sort of functionality is needed outside the latex software. The functionality is provided by so called outliner programs. That is a sort of software which makes it easy to create a longer text in structured way. Structured means that the contains of hierarchical sections, tables and references.
To understand how the process works let us imagine a world in which latex is not available. The idea is the user creates the text in the emacs org mode, then exports it into the markdown format and then renders the markdown textfile into the pdf format with an external program whcih is not latex but a different tool. The user will spend most of the text for creating the text in emacs. That means, the org mode environment is the software in which the text was created. Similar to other outliner programs like cherrytree, the user won't miss a page oriented layout, but outline means that a draft of the text is created.
There is a reason why apart from the famous ms word software, even under Windows and MacOS many external outliner programs like citavi, scrivener or omnioutliner are available. These programs are calling themself authoring tools. The idea is, that in the first phase of writing a document only the content is important and the layout gets ignored. For example, the cherrytree outline isn't able to format a simple two column layout or create the hyphens for a paragraph. That means, cherrytree is a poor choice for formatting the text on the screen and it was never created for this purpose.
Let us describe in general what outliner software is about. These programs were become famous for it's pane on the left screen which shows the document structure. The user can navigate in the document tree and shuffle the sections. Many features or even all features of a desktop publishing software are missing in an outliner program. Cherry tree doesn't even know what kerning is or how to embedded a type1 font. That means all the important features used for creating a book are not there. How can it be that the software is used in the reality if it has a low amount of features? Because cherrytree and other outliner programs are focused on the text itself. There is a distinction between creating the raw text and formatting the text into a pdf document.
From an authors perspective, a book or journal is not created with a desktop publishing software but with a normal text editor aka an outliner software. What an author is doing is not to create a pdf file but the author creates a 300 kb long plain ascii file. The interesting situation is, that even in the world of MS-Word and Indesign there is a clear distinction between creating the text itself and rendering the text into a pdf file. For example the indesign software has an often used function to import plain ascii files. That means, somebody else has to create the .txt file before and then it can be imported.
The relationship of LaTeX to outliner software
The LaTeX software is known as a powerful typesetting program used since decades for creating academic writing. From an outside perspective the LaTeX community prefer it's own program over potential alternatives like Framemaker or MS-Word. But the community struggles in explaining the reason why. How can it be, that a complex software like LaTeX which contains of thousands of macros has found so many advocates?
The reason is not located in the software itself but with the workflow in which LaTeX makes sense. What the average student, researcher or book author is doing can be summarized in the following workflow:
1. makes notes in an outliner
2. aggregate the notes into prose text
3. convert the prose text into a readable pdf paper
This workflow divides the task into two subtasks: creating the text and rendering the text. And both tasks can be realized with different software packages. There are on the one hand programs available for creating an outline which are Omnioutliner, a text editor or the notecase software. And on the other hand there is software available for converting the text into a pdf document.
Let us imagine how the workflow can be mastered without the famous LaTeX software in the loop. First step is to create the outline with a program like notecase which is an open source outliner for Linux. And then the text gets exported into the markdown format and converted in to a pdf paper.
This workflow comes close to what LaTeX users are doing with their software. They are using two different programs for the workflow. A typical combination is to combine the emacs editor for creating the outline, and the pdftex backend for creating the pdf file. Another frequently used combination is to use the texniccenter editor as the editor and the luatex engine for creating the pdf file.
The interesting situation is, that an outliner software doesn't need a preview how the text will be shown in the pdf format. During the outline subtask, the user doesn't care about the size of the font, or if the output is rendered in one column or twocolumn. This missing capabilitites of an outliner software is described by the latex community as an advantage. And they are right. The outline of a text which contains of sections, subsections, intext references and bibliograühic references has enough complexity. There is no need to render the information like it will be printed later.
Even if somebody doesn't prefer the latex software, the chance is high that he will use a divided workflow which contains of creating the text and formatting the text. Or let me explain it the situation from a different perspective. Classical WYSIWYG software like MS-Word, indesign or scribus are a poor choice if the idea is to use them as outliner tools. In theory it is possible, but this is not the purpose of these programs.
Perhaps we have to a go a step backward and answer the question what desktop publishing is in general? Has it something to do with printing out a text or rendering the text in the pdf format? No, the core task is to create the text in an outliner software. The interesting situation is, that the LaTeX program wasn't designed as an outliner software, but latex assumes that the outline is provided as input. That means, the user needs the structured text, and then he can run the latex program.