Is Java dead?

To answer this question we must go back in the 1990s and investigate what the idea behind Java was. The assumption was, that C++ is hard to learn because it supports pointers and multiple inheritance and the assumption was, that C++ is not a cross plattform language. Java was introduced as an answer to both problems. The main feature of Java is, that it doesn’t supports pointers, have no multiple inheritance and that the java compiler is controlled by a single company which was SUN in the 1990s and Oracle in the now.

The question can be reformulated into “Do we need an alternative to C++?”. According to Microsoft the alternative is called C#. According to the Linux community the alternative to C++ is plain C. And here we get the reason why Java is maybe dead. If the millions of Microsoft programmers are preferring C# over Java, if the beginners in computers courses are learning Python and if the Linux users have a need for C/C++ but not for Java, where is the target group of people who should learn Java?

I’m very pessimistic what the future of Java will be. Right now, Java can’t be called a dead language. Because the number of published books about the subject is high, and the Java tag at Stackoverflow has around 1.5 million questions. But from a technical perspective the problem is, that Java not really solve a major problem. The idea that software should run on multiple operating systems was common in the 1990s before the upraising of the Internet. Today, most software is written for the internet as a server application. This is done with PHP, ASP.NET or C++. Sure we can use Java for backend server programming too, and many business applications are doing so. That means, Java is used as a better form of PHP. But the more elegant way is to use either C# or C++.

The main reason why I’m skeptical about Java is, that the Microsoft as the largest software company doesn’t support the language. Instead they have their own virtual machine language which is promoted as the successor to C++. That means, Java is in a weaker position on Microsoft Server systems.

On the other hand, Red Hat is known for a strong Java support. Java is sometimes called an open source version of C#. Because the sources are available as open source. So in theory, it makes sense to use for server programming on RHEL clusters. But there are many reasons who are speaking against Java, especially in the Linux world. At first, Java is not C. Writing a library in Java but not in C doesn’t make much sense. Secondly, Java is slower than C. And compared with C++, Java is weaker, because it is a managed language which is hiding most advanced features from the programmer.

I’m not sure, if Java is dying right now. Many people are supporting the language, and according to the TIOBE index, Java is more often used than C++. So it is hard to guess what the future will bring.

Advertisements

The operating system is the virtual machine

In the history of computing there were some attempts to simplify the programming. An early example is the p-code syntax around the first Turbo Pascal implementations. P-Code and the later developed Java virtual machine is a runtime environment which abstracts from hardware. The idea is to write a p-code virtual machine for a new cpu, and then the Pascal compiler converts high-level sourcecode into p-code which can be run in the p-code VM.

What is wrong with this approach, why was p-code and Java not successful? The problem is, that writing a Virtual machine is a demanding task. Because the Virtual machine is equal to an operating system. Now it is easy to explain what UNIX is. UNIX is some kind of virtual machine to execute the high-level language C. The hello world example written in C is converted into binary code, and the binary code is executed by the operating system, in some kind of virtual environment. The idea is to port the UNIX kernel to any cpu architecture.

It make sense to compare the Turbo pascal p-code VM with the unix environment. The difference is, that the p-code VM is not portable. That means, it doesn’t contain a complete operating system but needs addtional drivers. The same is true for the Java environment. But why it is not possible to write a small Virtual machine? In the example of the Java Runtime edition this can be explained easily. At first we have a simple hello world program written in Java. It uses the SWING GUI to paint some lines on the screen. The hello world source is only 100 lines of code long. But if we want to execute the file on real hardware a huge number of virtual machines, libraries and low level hardware drivers are needed. It is not enough to interpret only the Java sourcecode, because a command like “open a window with Swing” needs additional binary code which is precompiled in external libraries. That means, to run the simple hello World program we need a Java runtime VM which contains around 1 GB and additional an operating system like Windows 10 which contains also 5 GB. In the sum, the environment to run a small Java program is around 6 GB.

The problem with Virtual machines is, that the problem of an operating system is ignored. In theory a virtual machine is a nice thing. The lua engine or the Python engine are very short programs which can be implemented efficient. But, the VM needs an operating system to communicate with the hardware. That means, without Windows 10, the Lua VM doesn’t work.

In the area of microcontroller programmer there were invented minimalistic operating systems which work as a virtual machine and as operating system as the same time. The problem is, that the number of features is low. If we increase the complexity for example if the aim is to run Java on a smartphone or on a desktop PC, there is a need for a full blown operating system which takes at least 5 gb for storage space.

Let us describe the problem from a different side: what kind of environment is needed to execute a hello world program written in C? In the early history of the UNIX operating system only a 100 kb assembly file was needed. That was a minimal Unix system which was able to execute a C program on the PDP11 computer. But later iterations increases the operating system. Today a standard Linux installation needs around 10 GB on harddisc space to hold all the drivers and libraries. The question is: can we reduce the complexity of operating system, so that future Linux version needs only 100 kb? No, it is not possible. a short look into real operating systems like Mac OS X or Windows show the trend, that all of them contains million of codelines. The problem is, that the operating system provides lots of features. In theory, a computer doesn’t need an operating system. For example the C-64 runs quite well without any kind of OS. Instead the programmer uses the assembly language to communicate with the hardware. The problem is, that this kind of programming style isn’t very powerful. It is very complicated to write new software for the C-64.

How to fail a software project

In the screenshot the so called git file statistics is shown. Or at least an important part of it. On the top figure it is visible that I’ve added lots of files to the repository, which is equal to lost control. Instead of deleting old files or rewriting them, I’ve simply created new one. On the bottom it is shown what the files have a type. Most of them are written in C++, but some of them are JPEG and PNG graphics files.

Linux for Non-programmers?

The famous Ubuntu Linux distribution was founded with a certain vision about the future. The idea was to use Linux to motivate non-programmers to become programmers. The website ubuntuusers has as a target group the ordinary PC user who is currently running MS-Windows but is interested to do advanced stuff with the command line, with the Python interpreter and with Linux. Ubuntu is some kind of broader movement with the aim to make programming knowledge more attractive for the masses. And with open source software this is an easy going task, because advanced programming environments and Unix like operating systems are distributed for free.

There is only a small problem. Ubuntu wasn’t a success. People who are already programmers have tried the system and they loved it, but non-programmers are not interested in Ubuntu Linux. They preferred their MS-Windows box and stay away from any kind of IDE, texteditor, compiler and make tool.

Ubuntu was attacked from two sides at the same time. Profi programmers from within the Open Source community like Linus Torvalds doesn’t like Ubuntu because it wasn’t possible to compile software with the system. Instead it was an operating system for beginners with a reduced feature set. Newbies and non-programmers also don’t like Ubuntu, because it was too complicated for them and they understand nothing. As a consequence, Ubuntu was not accepted. The aim to attract millions of non-programmers for doing advanced stuff with their computer was not reached. The ubuntu project failed, and the LInux community too.

What can we learn from this experiment? We can learn, that 99% of the PC users are not interested in programming. What they want is using a computer for surfing in the Internet but they don’t want to write any single line of code. Not in Windows, and also not in Linux. They have nothing against Python, Java or C++ in special, they have something against programming in general. Any effort which is trying to educate people in learning programming will fail. That means, Ubuntu fails, Windows subsystem on Linux fails, Microsoft C# fails and so on. The most advanced stuff the mainstream user is doing with a computer is using it like a calculator in MS-Excel. That means, he writes numbers in cells and then calculates the sum. Using MS-Excel is used very often by million of people. But the next logical step after MS-excel, which are bash scripts, Visual Basic, Python or C++ is ignored. Real programming is something which is ignored by the mainstream user.

What is the reason why the normal users resists to learning programming? Because it has something to do, that knowledge about programming is useless. It is changing all the time, and what is right in programming language A is different in programming language B. Let us make an example. Suppose somebody have learned the perl language 20 years before. What can he do with this knowledge in the now? Right, nothing, Perl is called an obsolete language. It is no longer used for writing code. And the same will happen with all the other languages. From a technical perspective it makes absolute sense, that C++11 looks different from C++98 but suppose somebody is familiar with C++98 what can he do next? Learning programming is some kind of dead end and the mainstream users is aware of it. He knows, that if he want’s to program his first hello world example in Python, he will invest many months and as a result he gets an error warning that some library isn’t installed in his computer. So the right decision is to stay aware from the voodoo and let other people become a programming expert. If he can give to these Microsoft programmers a small amount of 50 US$ for the OEM license the customer is happy, because he isn’t force to programing for himself.

On that basis, Microsoft have created a business model and the customer isn’t interested in destroying this model with Linux. Because in the future of LInux, everybody needs to be a programmer.

Let us observe how the communication flow between programmers and non-programmer is. It works not in a way, that programmer will teach to mainstream users how to become programmers itself. That was the idea behind ubuntu and it failed. Instead the interaction works in a way, that the non-programmer is paying 50 US$ into the pockets of software company and they are writing the software for them. The aim is, that the numbers of programmers stays small below 20 million. There is no need, that a huge number of people is able to debug C++ application or can install a webserver in under 5 minutes. Instead the work distribution is organized by capitalism ideas which means with money in the loop. That is the explanation, why Linux failed. Linux is trying to convince the mainstream users to become computer experts and learn to program by it’s own. So that the user no longer needs a software company like MIcrosoft but can create his own operating system. This vision isn’t possible, because the value of learning programming is very small.

Programming isn’t a universal skill which has to be teached to anybody in the internet age and it isn’t the road to understanding robotics. It is some kind of skill which is outdated today. Programming was a major subject in the early 1980s in which the commercial software market didn’t exists. In that time programming was the only way to get new software. Nowadays the situation has changed. To get the latest software nobody needs to learn programming, instead he is visiting a software store and click the buy button.

The most pessimistic outlook is, that learning programming in the now isn’t the best hint. Because even somebody is very good in writing code, his knowledge will be outdated in 5 years. The software industry invents all the time new programming languages and new backend libraries. Some kind of general pattern which remains the same isn’t there. In a worst case scenario somebody is investing many hours in learning a language and if he is an expert in it, the language is outdated and he can learn the next language.

What the user wants

Let us first explain what the mainstream is interested in. He want’t to buy Windows PC, he want’s access to the internet and he want’s to try out different software. That means, the PC and the ecosystem around it can be called a great success. The trend is positive. Right now, more then 2000 million PC are worldwide in use, and the number will grow in the future. On the other hand, the mainstream user isn’t interested in becoming a power user, which includes to learn programming. That means, the students are not motivated to attend a programming course, the elderly do not want to program in old-school language and the mainstream user isn’t interested in give away his Windows operating system and switch to a Linux distribution.

Sure, there is a group out there which is fascinated by Open Source software and by writing it’s own software. But compared to all PC users it is a minority. They are less then 0.3% of all the users which means, the group is too small to talk about it. The problem in the media is, that in the past this small group has reached a high attention and the idea was, that this small group will become a large group. This wasn’t happen.

The mainstream user see the advantage of getting a PC incontrast to get not a PC. With a PC and a working internet connection he can send e-Mail, watch Youtube and write letters in MS-Word. Without a PC he can’t do so. The decision to become interested in PC technology is very easy and it was done by nearly all the people worldwide. But what is the advantage of learning to program and mastering the LInux operating system? Right, there is no advantage, the customer will loose he time and he gets nothing. If he don’t want to learn programming he has made the rational decision. What he can do with his time alternatively is to learn a foreign language, read a book or making sport.

Programming is boring

Sometimes, programming is called exciting, because the students can do what they want. They can create games, animate characters and write web-application. Others say, that programming is hard, because C++ is so complicated and every year new programming languages are invented for different operating system. But in reality, programming is boring. That means it is too easy and makes no sense. But let us go into the details. The best place to learn programming is stackoverflow. It the right portal for any language, no matter if Python, C++ or Java is the subject. Stackoverlow is based around questions and answers. Somebody needs to know how to write a GUI and an expert or Amateur is answering the question. Somebody may argue, that this kind of game will never be the same, and that every language and every topic is different. But the reality is, that after a while all the languages look the same. They have all to do with open the texteditor, write a for loop, and inside the loop, a function is called. The function gets a parameter and uses an if statement to decide what to do. Sometimes an external library is used to activate higher functions, for example painting on the gui or writing to a textfile, but in general that is everything what programming is about.

Some people are fascinated by this workflow and other are programming code for the last 30 years. But what can we learn from doing so? Right, nothing. That means, programming itself is boring. The only way to increase the level is to program a certain kind of software which is interesting by its domain. For example, if somebody is interested in Sports he can write a app with that topic, or if somebody likes social networks, then he can program a database which connects millions of people. Such a domain is indeed interesting and the programmer will learn a lot.

But let us go back to coding itself. In the past, programming itself was an adventure. If somebody had only a Amiga 500 and want’s to program something in Pascal he has to figure out how to do so. The same was true for the 1970s area if somebody want’s to program a mainframe. In both cases, no tutorials were available and the programmer has to start from scratch. But in modern world, most have changed. Today, all operating systems have a preinstalled compiler which understand any language, and the bookmarket explains in detail how to use the tools. That means the programming process itself is solved. It is documented what the workflow is, and for any problem there is a solution. This makes programming a bit boring, because it is equal to a sandbox without any trap. It is no longer possible, that a beginner, an amateur or an expert programmer come to a situation which was unexplored before. Instead he will make the same experience then hundred guys before him. He will forget the semicolon at the same position, like all beginners and he becomes the same good feeling, if the hello world text is printed to the screen like anybody before.

The problem with today’s programmers is, that most of them didn’t recognized that every thing is repeating over and over again. They belief that their problem with C# is completely new and equal to a scientific problem which has to be handled by university. In reality, programming isn’t a science anymore it is more like building a house. It is done million of times before, and it is impossible that somebody will reinvent the wheel.

Somebody may argue, that building a house is exciting and it is a demanding task. But he ignores, how often and how standardized the procedure is. It can’t be called a scientific work, because it is known how to do it. Programming hasn’t anything to do with computerscience, it is something which should be learned and teached off the campus. In the freetime, in the public library or by friends. Or to make the point clear. A programming course at the university lowers the quality without any need. It slows down the scientific progress and is a waste of time.

Programming a robot

There is one exception to the rule that programming is boring. If the task is to program a robot. With classical programming this task hasn’t much in common. And stackoverflow won’t help in this question. Programming a robot is a scientific task, that means it has nothing to do with C++ or Python, but with papers on Google Scholar. Programming a robot is equal to write a Phd thesis. That means, it isn’t a repetitive task, but it is exciting. At the beginning nobody knows what the result will look like. The reason is, that the subject in unexplored land. That means, probably you will be the first human ever, who has tried out a certain algorithm on a robot and it fails … If you’re asking at Stackoverflow nobody knows why. Even the sourcecode is error free and the code works, it is hard to guess what the problem was. It depends on the domain, that means which type of robot and which kind of algorithm was used. And sometimes it depends even on the student, what he has tried out before. In contrast to normal programming, robot programming is a challenge. It is the core discipline on a good university and is never boring.

Update about GUI programming

The topic of GUI programming seems to be very complicated. In the past there were many frameworks out there, C#, Java, X11, Gnome, Qt, wayland, GTK+, SFML, OpenGL and much more. But which of them is right for creating a gui which runs on any OS? To make things short, the easiest approach for creating a GUI is Python together with GTK+. This works on Linux and Windows, and it is good documented. Here is the link https://python-gtk-3-tutorial.readthedocs.io/en/latest/textview.html to an example texteditor. I’ve copy and pasted the code in Fedora and start the application with “python texteditor.py” and it runs quite well. The sourcecode is very easy to understand, much easier than Java, C with GTK+ or Qt.

Let us describe the workflow for a real project. THe good news is, that a gui is not very important in an application. It is something which works on top of the software for interacting with the user. That means, normal programs and especially large programs are programmed for the command line and the gui is only the interface. It can be programmed at last if everything else is working.

The above cited example with the Python GUI shows, that GTK+ is a powerful and easy to use framework which is well documented for Python programmers. But using GTK+ together with other languages like C and C++ is very complicated. I would guess because of missing documentation. But at least the Python language works great together with GTK+. For a real project we can learn from it, that a GUI prototype can be created quick and without pain with Python. And then the programmer has to decide. Either he can stay on Python and he connects the gui with the core-program which is hopefully written in C++. Or he can convert the Python sourcecode manually into C++ which is complicated and not documented.

But let us stay for a while on the combination between Python and GTK+. The surprising information is, that this hasn’t anything to do with C# or Qt. Instead the old-school and not very often used GTK+ framework is used, combined with a modern scripting language. The next important information is, that the sourcecode even it was programmed in Python doesn’t look like a real object oriented program. It is more similar to an extended XML file. The reason is, that GUI programming is not real programming but more a layout task. That means, the designer defines rectangles and events. The GUI layer shouldn’t be mistaken by a real program and perhaps this is the reason why Python is great for such a task?

The codedensity of the example texteditor GUI is very low. That means no algorithms are implemented but it looks more like macro / script. Not only because Python was used as the programming language, but also from the statements itself. Every widget has it’s class (searchdialog, Textviewwindow) and the classes have methods which defines interaction with the user. Like I mentioned above the result looks similar to a XML file but is different from a normal program which implements algorithm. Maybe this is the explanation why GUI programming is at the same time too easy and too hard? Because classical languages like C/C++ are too powerful for only create some buttons on the screen, but at the same time it is very complicated to program the GUI with C/C++?

I’m not sure what the answer is. Perhaps the idea software contains of the main program written in C++ and a frontend written in “Python+GTK+”. Or the other option is first to code the GUI with Python and then convert the code into C++. I don’t know. Right now, i would guess, that a GUI can be created more easier with XML+Python then with C++ and without XML. Or let us explain the situation from the other perspective. Suppose, only the GUI should be created and not the whole program. The fastest way in doing so is to use:

– Glade for creating the XML file

– Python for creating the GUI out of the XML file

– Python for specify the event handlers and redraw the buttons

The open problem is how to connect this prototype with the real application which is normally not created in Python but in a more sophisticated language like C/C++.

The bottleneck is called gtkmm

GUI programming is on the first hand complicated, especially under Linux. The good news is, that it is possible to delimit the reason for failure. At first we ignoring all frameworks and all programming languages and only describe what the fastest way is to build a new GUI from scratch. It is the combination of Python, GTK+ and glade. This approach is very well documented in the internet, it works under Linux and Windows and the user needs only a few lines of code to create a nice looking GUI prototype.

With this enclose we have described what a working technology is: GTK+. And now we want to describe something which doesn’t work. Programming in C++ (which is the best programming language) for GTK+. Programming in C++ itself is easy, it is also well documented and the speed is amazing. The connection between C++ and GTK+ is usually done with the interface called gtkmm. And this is the weak point in the formula. GTKmm isn’t documented, the library doesn’t work and it is too complicated to use.

Here the summary right now. A working GUI prototype can be done with Python, GTK+ and Glade. A working software can be created with C++. But bringing all together, that means to write the code in C++ and connect this with GTK+ is a pain.

It is unclear right now, why the Python GTK+ binding works so great and why it is documented quite good, while the gtkmm binding doesn’t work. Or to change the point of view a bit. GUI programming is easy going, if we ignore the C++ language and give Python a chance. Together with glade it is possible to create quick&dirty a nice looking GUI which works everywhere. The problem is, that most programmers are not interesting in writing an app in Python, because the Python interpreter is slow, the Python standard is changing all the time and it is not possible to write a library in Python. They are prefering C++. But if we want to use gtkmm for making a simple GUI it is nearly impossible because it is too complicated and nobody knows why.

The correct answer to the problem is to rewrite the gtkmm interface and make document the result. That means, create a gtkmm interface which looks the same like Python binding for GTK+. Not GTK+ is the problem (it works great), not C++ is the problem (it works also great), the problem is the connection between both.

Is Java obsolete?

Not yet, in contrast to Turbo Pascal it is used by many millions of programmers. But the question is: why? Usually, a Java project is initiated by people not by the language itself. If Java advocates are out there who think that a programming language without pointers which runs in a virtual machine is easier to use and to teach then C++, then Java will life forever. And exactly this is the problem. The problem is, that most Java fans never tried out C++11. They are not familiar with SFML and they are not aware, that C++ is a portable language which runs on any operating system.

A prediction about the different programming language is easy to make. Python, Java, C#, Rust and Rust will die while only C/C++ will life forever. The reason is, that the most important software (operating systems, libraries, database applications) are all written in C/C++ and that no other language was successful in that domain. Different languages from C/C++ only add functionality to the existing C/C++ ecosystem and in case of doubt they are superfluous.

Let us compare C++ with Java direct. Suppose the aim is to teach programming in a beginner course. The combination of C++11 plus SFML graphics library is the best advice in doing so. The syntax looks exactly like a hello world Python application, but it is pure C++. That means, the game will run as fast as possible and 500 frames per second inclucing threading are no problem. If the aim is to run the software on Linux, Mac OS and Windows at the same time it is also no problem. Either the user can start the binary file with an emulator, or the programmer creates a os-independent make-file which means that after compiling he gets three binary versions of the game. The additional time for procedure is around 5 minutes. So what is the advantage of Java over C++? There is no improvement, Java is a step back behind the power of C++. It is a dead end.

Sure, from a certain point of view, also the combination of C++11 with SFML is complicated and that he isn’t interested in writing sourcecode at all. But then the only option is to not stay away from any programmning language and install only software written before. That means, if C++ isn’t the right choice, what else? There is no easier to learn and more powerful language available. IF somebody has problems with C++ he will also fail with Python, Java and matlab.

Let us compare the major programming language in the example of a for-loop:

for (auto i=0;i<10;i++) // C++
statement();
for x in range(0,10): // Python
statement()
for (int i=0;i<10;i++) { // Java
statement();
}

What is the difference? Right, it looks very equal. And if we add a class, a subfunction and a graphics painting routine we will notice, that the syntax remains the same. The only difference is, that C/C++ has a superior performance and that it is used by system programmers. So what is the motivation to prefer Java over C++? Perhaps the ideology is, that programming is hard, and only with a new language it will be successful? But what is more realistic is, that Java was invented by a company called SUN with a specific aim in mind. If somebody is in control of a programming language he can earn money with it, and he controls the ecosystem.

Limits of C++

Let us observe what C++ means in reality. The first what beginner will try out is how to write a command-line software. They are defining classes and use the std::cout keyword for printing out the result to the screen. What they will notice is, that C++ itself will not make any troubles. Instead all the language features like for loops, if then statements and classes are tested well. If the user is more experienced he can switch to SFML. SFML allows him to paint 2D graphics and animation to the screen. Also games with sprites are possible. Again the user will not recognize any problems with C++ itself, instead he will read a lot in the SFML description about the details of how to put a circle on the screen.

If the user has no higher goals, he can stay for the next 10 years only on command-line level and on SFML. He can write lots of programs with hundred of lines of code. I wouldn’t call it classical C++ programming, because it has more in common with Python programming. But it is done with the C++ compiler. All the other aspects of the language for example pointers, templates, libraries and so on can be ignored. The user is not forced to understand these aspects, he can stay in his comfort zone.

And yes, programming a robot in SFML is as easy as in Squeak or in logo. That means it is programming for beginners and non-experts. There is no need to introduce C++ as a complicated language.