Java, PHP or Kotlin: Which programming language to learn?
Would you like to learn programming but unsure which programming language to start with? This article will help you decide.
Would you like to learn programming but unsure which programming language to start with? This article will help you decide.
Programming languages often have their own purpose for which they are designed, or domain where they have excelled in. It is usually easier to choose a language according to what types of applications are easy to write in it than only according to the features of the given language. Therefore, we will go through various application categories, languages that are suitable for them and also their pros and cons.
1. Mobile applications
The development of mobile applications is moving at a relatively fast pace, since even every small child has a mobile phone. The developer can programme mobile applications in native languages such as Java/Kotlin for Android and Objective-C/Swift for iOS, or in so-called multiplatform frameworks where the developer ideally writes the source text of the application once and the application thus compiles for Android as it would for iOS.
Java is an object-oriented language. It has been a popular language for two decades and in 2018 it was named the 5th most popular technology. It is a multi-platform language in which desktop, server and mobile applications can be developed for all wide-spread operating systems.
It is a very popular and widespread language. Thus, there is enough study material and a huge community that can help if any problems arise. There are also more job offers for this language due to its prevalence. If someone learns Java, he will know how to do more types of applications.
Google, as an Android development company, prefers Kotlin for the development of Android applications. It is probably mainly due to the licence disputes with Oracle, but it is possible that Google will gradually neglect Java.
Also, support for new Java versions comes with delay.
Java also lacks some modern elements of the language, such as immutability or checking that variables are not empty. Some other languages require that variables which can be empty to be marked. This decreases the susceptibility of errors in code.
Kotlin is a statically typed programming language which translates to Java bytecode that runs on Java Virtual Machine. It is a modern object-oriented language that allows you to efficiently write source texts.
Kotlin is designed to be efficient in writing its code. So, if you compare an application written in Java with an application written in Kotlin, the Kotlin application will contain less source text. As you get used to Kotlin, the source text will be easier to read and more comprehensible for you. In Kotlin, you will also be able to use libraries that were written in Java and even use both Java and Kotlin in one project at the same time, since both languages are translated to Java bytecode.
Kotlin has not expanded much since its inception in 2016 and so less study material is available as well as a smaller community which can help in the event of problems. Kotlin is also slower to compile in comparison to Java.
Kotlin has a more complex syntax (code writing) than Java and more effort is required to learn it.
Swift is a compiled programming language from Apple. It is relatively new and serves mainly for the development of applications for Apple platforms (macOS and iOS), but it is also available for Linux and Windows. Apple computers (e.g., MacBook) are required in order to develop iOS applications. The Xcode environment is mainly used for development.
Compared to its successor Objective-C, it contains features of modern programming language and reduces the susceptibility to error by removing some features inherited from the C language.
The language is usable almost exclusively for Apple platforms and it is hard to say if its usability will expand in the future.
2. Multiplatform mobile applications
These are applications that you write once and are then able to configure for several operating systems. There are more tools that can be used to write cross-platform applications, such as Flutter, React Native, Cordova or Xamarin. Flutter is the youngest of them but, in a short time, has probably become the most used of them.
Flutter technologies use Dart as its programming language to create applications. It is an object-oriented language with a number of conveniences that modern languages use. If you want to write an application in Flutter, you just need to learn one language, which is Dart, and know the components that Flutter uses. There is no need to master any other technology.
Dart has a simple syntax reminiscent of C#, Java. It can be learnt easily and, thus, suitable also for beginners. It is intuitive and efficient to write.
The dart language has not extended to other technologies, except the Flutter framework, even though there have been attempts to use it in Angular (apps running in the browser) and it can also be used to write server applications. Therefore, learning it will not give you the same advantage as learning Java, for example, which has a wider use.
3. Applications running in the browser
These are client-server applications where the client part (user interface) runs in the web browser. An example can be an Email client (Gmail) or e-shop. These applications usually require the server side as a provider of data and other services. It is possible, though, to make independent applications. These applications are typically not installed but need to be set on a server with a public URL address. They also have their limitations on that given browser. For example, they cannot simply access files from the user’s disk.
Because the variables are not typed, the difficulty of maintenance is increased as well as developing larger programs.
You have to be especially careful about comparing objects using the “==” operator. This can produce unexpected results (e.g., [ ] == 0). However, instead of that, it is enough to use the alternative operator “===”.
In order to create a larger application, you need to choose and learn a framework such as Angular, React.js, Vue.js.
Neither HTML nor CSS are programming languages but they are technologies that one needs to know in order to create applications for web browsers. HTML is a language for structuring documents or applications. CSS is a language for the visual styling of HTML features. They are easy to learn and at the beginning you just need to know a small part of these languages.
4. Desktop applications and games
Windows with windows
C# was created by Microsoft as its alternative to Java. It is an object-oriented, compiled, typed language. Similar to Java, C# is compiled into IL bytecode format and is converted to native code at startup. It is quite tied to .NET framework and there is also a popular game creation tool for it – Unity.
It is probably the most suitable language for the development of Windows applications where performance is not the most important factor. The language contains several modern features and has a large number of libraries which can be used to create applications.
Developing graphical interface applications in C# is still only for Windows. Their speed is generally lower than if they were written in C++.
C++ developed from C by adding support for classes and objects and by creating a larger standard library. It is a compiled, typed language. Its greatest popularity was in the 90s. Many games are written in C++. The most popular tool for creating games is probably Unreal Engine. It is also possible to write applications for many platforms.
Its main advantage is the possibility to write highly optimised code and also to write applications that can be transferred to other platforms.
The language has many disadvantages of the C language. The main one is the susceptibility to error connected with the management of operational memory and the necessity of creating header files.
This category is quite general and does not have any significant limitations. Programs without graphical environment - most programming languages can be created to run from the command line. Most of the time, these are programs for data processing or the automation of operating system processes.
Python is a scripted, untyped general language. It is often used for mathematical calculations, statistics, machine learning. Its advantage is that there is a large number of libraries for it. Applications written in it can be run on various platforms on which Python is available. It can be also used to create multiplatform desktop applications with a graphical environment (via PyQT).
Bash is a language used mainly as shell (command-line interpreter) in operating systems such as Linux or macOS. It is, therefore, almost always available in these systems, making scripts in it easy to use. Its basic knowledge is very useful for advanced users of these operating systems. The language is able to easily use the functionalities of external programs and combine them. However, it is not suitable for writing general applications.
5. Application servers
These are applications running on servers that are accessed through the network. They mostly have their client applications running in the browser or mobile applications. They are, therefore, a suitable choice for programmers who do not like creating user interfaces.
Java is probably the most widespread language for writing application servers. For about 20 years there has been a large active community developing tools for creating these applications - either a standardised version (now called Jakarta EE) or independent tools (e.g., Spring framework). There are a large number of libraries and technologies for Java which facilitate the creation of even complicated applications.
Java applications are able to run on any platform for which the Java Runtime Environment (JRE) is available. Java as a language is still actively developing and improving, but its development is not wild – there is no danger that an application written today will stop working in a few years because of changes in the language.
Java may not be the completely suitable choice for the development of small private applications because deploying the application usually requires a cloud service, and that could be a complication. However, several providers of these services have simple programs for free.
C# a .NET
C# is used to create application servers with .NET framework. This was created by Microsoft, but today it is an open-source tool available on various platforms.
Comparison with Java
The development of applications on both platforms is very similar since they solve the same problems (request processing, saving to the DB, etc). Both worlds influence each other – they take over features that have proven themselves on the other side. If someone is experienced in creating application servers in Java, it is easy for him to also learn to do them in .NET. and vie-versa. Individual advantages and disadvantages are often subjective – for example, whether it is better to access to databases via JPA/Hibernate in Java or via Entity Framework from Microsoft.
PHP was originally conceived as an option for scripting HTML pages. It was inspired mainly by the language C, from which it adopted syntax and some functions from the standard library. Later, object-oriented elements were added and elements that proved unsuitable were dropped from the language. However, this is an untyped scripting language.
PHP is a very widespread language, mainly because of open source projects for creating websites such as WordPress, Joomla or Drupal, and the fact that PHP is supported by most web hosting companies.
Applications do not run on servers – code is executed on demand (e.g., to create websites), which can be a problem for applications which require a more advanced processing.
Probably the biggest advantage is the ease of deploying the application on regular web hosting . You just need to buy a domain, web hosting and upload files to the server. It is not necessary to create a complicated application at the beginning. It is possible to insert the PHP code directly to HTML. For more serious applications, however, it is better to use some of the frameworks (e.g., Laravel or Yii).
The language itself is not difficult but it changes relatively often and applications need to actively adapt to new versions of the language, otherwise they can stop working. This also applies to frameworks. The language contains some elements which can be confusing and even frustrating. One example is the way to work with pointers (other examples can be easily found on the net).