June 14, 2018

Using C++ like MS-Excel


Microsoft Excel and the Open Source clone Libreoffice calc are very good programs for developing prototyping spreadsheets. A new Excel file is created fast, and the user can try out some calculations. The major problem is, that the amount of programming inside an Excel sheet is not very high, that means it is impossible to use MS-excel for prototyping GUI games, or simple search algorithm.
What is possible is to use the MS-excel metaphor for describing the workflow in the C++ programming language. Let us imagine, that C++ is like Excel and we want to create a software prototype. How do we do this?
At first, we are creating a working directory and inside the folder we are executing “git init”. In the folder we are creating the project-subfolder called “project1”. In this folder we can store small .cpp files. Every cpp file is equal to an MS-excel tab. That means, the project1 folder is equal to an excel file, and the cpp files are the tabs in the file.
Now we can enter some content. Like in Java, each file can only have one class. file1.cpp has class1, file2.cpp the class2 and so on. As an additional constraint the maximum lines of code for each files is limited to 100 lines of code. That means, the files must be small. And at a last constraint the sum of all files should only have 500 lines of code, otherwise we must create a new project-folder.
The overall idea of this structure is to use C++ as a prototyping programming language for trying out new sourcecode. We can switch between the parts of our program with browsing through the files, and the idea is to use only well known statements like std::string, for loops and if-statements. That means reducing C++ to a Python like language which is not aware of pointers, STL and other complicated stuff. Instead we imagine, that C++ is our MS-excel spreadsheet and the idea is not to write software but doing some trial&error workflow.
A new project folder is not created for writing stable software, but make a new iteration in the software prototype. If the limit of 500 lines of code is reached, the old project will get stopped, instead a new project is created from scratch. The idea is, that if the lines of code is slower, it is easier to understand the code.
Working with git and C++ in such a way is from a technical point of view possible. It is only a question if the user is aware of it. Most users think, that git needs branches and that C++ projects needs to be very complicated and contains a lot of pointers. No, they don't. There is no need for making things complicated. Small is beautiful.
I think, C++ and git were developed for prototyping reasons as a replacement for MS-Excel. The use case is to write new algorithm quickly and throw away everything if the user is bored.