Skip to main content
illustration of different programming languages

Java is pretty cool .. but there are other options

Karl Viiburg & Silver Jõgi

Java is everywhere. A language, created more than 25 years ago for home appliances, has become one of the most popular programming languages ​​in enterprise systems for its easy-to-understand syntax, cross-platform, and object-oriented style. 

 

Of course, a lot has changed in 25 years. The great success of Java among large corporations has put Oracle (Java's current owner) in a difficult position. Java has not seen new innovative changes for a long time, and business customers expect the most stable and long-term support possible for their systems.

 

We can even say that Java is partially stagnant. At the same time, more innovative and dynamic programming languages ​​have come a long way and are just as capable as Java. Introducing - JavaScript

 

 

JavaScript - Zero to Hero 

Although Java and JavaScript are similar in name, they are not related. JavaScript started way back in Netscape days with the goal of making websites more dynamic. You no longer had to refresh the page to see the changes, it all happened before the users eyes. 

 

Without diving into history too much, JavaScript began to gain traction when Netscape donated JavaScript to the ECMA Foundation to allow different browser vendors to implement it and offer it to its users. The standardized backbone of JavaScript, ECMAScript, began around this time. 

 

Pilt
illustration about JavaScript and TWN

 

Over time, JavaScript has moved from browsers to phones, desktops, cars, as well as back-end systems with the arrival of NodeJS. JavaScript is now the most popular programming language in the world among professional developers. 

 

 

Java and NodeJS back-end 

Since Java is still primarily used in back-end systems, we will focus more on this side of the kitchen and go through essential points in this article. 

 

Easy to learn syntax 

Java has an easy-to-understand syntax that makes it easy to learn. JavaScript is based on Java in many design decisions so there are quite a few similarities syntactically.

 

In addition to the official documentation, there are abundant community resources and articles on JavaScript. You will not have any problems learning JavaScript :)

 

Java:

public class ArrayUtil { 
    public static String[] sortByLength(String[] items) { 
        Arrays.sort(items, (a, b) -> a.length() - b.length()); // Comparator.comparingInt(String::length) 
        return items; 
    } 
} 

 

JavaScript:

export function sortByLength(items: string[]) { 
  return items.sort((a, b) => a.length - b.length); 
} 

 

Asynchrony 

Java allows you to use threads to divide processing and run different operations in parallel.  

 

Threads can be metaphorically equated with the management of voluminous work - the governing body gives work instructions to others (in this case, the threads). When the work is completed and the orders are executed, the body checks how well the branches have done their job.

 

NodeJS is asynchronous by design and uses the JavaScript Promise API, distributing processing to multiple threads. Successful or unsuccessful results can be processed as needed, when needed.

 

The Promise API is also available in browser JavaScript, allowing front-end applications to move demanding activities away from the main User Interface (UI) thread to provide a faster and more user-friendly experience

 

JavaScript can also be run on anything 

A big advantage of Java has been that it works with any device, be it a desktop computer, server, phone, desktop application, etc. The comprehensive user base and the need for alternatives have also guided JavaScript.

 

JS can be implemented in desktop applications through ElectronJS or Cordova / React Native for mobile apps. JavaScript allows you to bring your solution to market on any platform - from smart refrigerators to cars. 

 

Security 

The cornerstone of any large and small application is security. Be it cryptography or code level error correction using strict typing rules. JavaScript also has a solution for this.

 

NodeJS supports several types of cryptography, from securing traffic through TLS encryption to encrypting PKI key-based data.

 

In addition, the NodeJS community has developed several RFC compliant modules to allow implementing any kind of cryptography solution required. The RFC can be seen as a globally recommended and agreed standard. 

 

if (data.signature.algorithm.endsWith('ECEncryption')) { 
  const ec = new EDDSA('ed25519'); 
  const key = ec.keyFromSecret(this.request.hash.raw); 
  if (!key.verify(Buffer.from(data.cert, 'base64'), data.signature.value)) { 
    throw new Error('Invalid EC signature (verification failure)'); 
  } 
} else { 
  const verifier = crypto.createVerify(data.signature.algorithm); 
  verifier.update(this.request.hash.raw); 
  if (!verifier.verify(cert, data.signature.value, 'base64')) { 
    throw new Error('Invalid RSA signature (verification failure)'); 
  } 
} 

 

TypeScript is available for strict typing in the JavaScript ecosystem. It is an open-source superset for JavaScript developed by Microsoft.

 

It allows strict typing like Java, enabling you to spot bugs during development that might only occur during operation. The direct value is measurable in a significant increase in system quality.  

 

export default function debounce<T extends unknown[], U>(callback: (...args: T) => PromiseLike<U> | U, wait: number) { 
  let timer: NodeJS.Timer; 
 
  return (...args: T): Promise<U> => { 
    clearTimeout(timer); 
    return new Promise((resolve) => { 
      timer = setTimeout(() => resolve(callback(...args)), wait); 
    }); 
  }; 
} 

 

For applications with stringent requirements for accessing different system components (file system, networking, environments), there is Deno, created by the creator of NodeJS.

 

Deno is centered around security, which means that the application cannot access any system components without explicit permission. In addition, Deno has a select list of third-party modules that have been separately audited by Deno to ensure maximum support and security. 

 

Multi-platform 

Java achieves its cross-platform capability through virtualization using the Java Virtual Machine (JVM). NodeJS doesn’t have any built-in virtualization, but it doesn't have to. Like Java, NodeJS solutions based on JavaScript can be moved between systems with different architectures. 

 

NodeJS is based on the JavaScript V8 engine developed by Google. "V8" is a familiar term to both supercar fans and developers so you can guess it packs quite a punch. NodeJS supports x86, ARM and even IBM server architectures (32 and 64-bit). 

 

In addition to the support for the various architectures above, NodeJS applications can be containerized and virtualized through tools such as Docker.

 

In short, any system that supports virtualization also supports Docker. With it, you can move your NodeJS application wherever you desire and scalability as an added bonus. 

 

Open source 

When designing or developing functionalities, there might be the need to go a little deeper with either a library or a framework to understand how they work. Or to learn how different developers have handled a specific challenge. 

 

Both JavaScript and all common frameworks - including NodeJS - are open source, allowing you to look at the code to see how it is written and what decisions have been made regarding functionality, design, etc. 

 

As an added value, many experienced developers can both contribute improvements to either new features or fix issues, as well as audit code to increase security. 

 

Unlike Java, you do not require an expensive license to use it for commercial use. Luckily, there are projects like OpenJDK that allow a more cost-effective implementation of Java at the expense of enterprise support. 

 

 

Why prefer JavaScript and NodeJS on your next system? 

Expense 

It is not easy to find experienced Java developers and even if you find them, they don’t come cheap. Java is resource hungry. As a result, the use of different technologies and the need for larger hardware requirements add to the complexity, both mentally and financially. 

 

With limitless possibilities of implementing JavaScript, there are more developers that work with it (it is the most popular programming language for a reason) so finding someone to work with JS is much easier, faster, and often cheaper. 

 

Simplicity 

NodeJS and JavaScript reduce complexity because the entire technology stack is based on a single programming language - reducing resource requirements and allowing to create large, integrated solutions faster

 

Speed 

 

Pilt
Java vs modern programming languages fighting each other

 

Developers deliberately do not use such excuses, but Java is something that needs to be compiled before it can be actually run. For larger and more complex systems (when using Java), the average compilation time is 5-6 minutes. 

 

At first, 5-6 minutes doesn't seem like a lot but given that there could be six developers compiling the code several times a day, the project's total cost is already tens of "development-free" hours. 

 

JavaScript engines have JIT (Just In Time) compilation logic, where the code is compiled and run at the time of execution, which takes milliseconds (thousands of times faster than Java). 

 

NodeJS is also up there in terms of application speed. NodeJS takes less time per request cycle (from query to response) than Java, allowing Node to service more requests per second with lower resource usage

 

 

Is Java dying out as a development language? 

The simple answer now is "No". Different developers may give you different answers to this question depending on their opinion or views. However, there will undoubtedly be more talk and discussion in the coming years, and Java is and will remain a compelling programming language. 

 

There are pros and cons to all programming languages. Unlike 25 years ago, you aren’t forced to use a specific language to solve a particular problem. Java has historically played a significant role in solutions for comprehensive and cross-platform systems.

 

Today, Java is no longer unique, and due to speed, simplicity, and cost, software development preferences have shifted to alternative languages ​​(JavaScript; Python; Golang, etc.). 

 

In summary, alternative programming languages ​​can solve all the problems previously addressed by Java. Nevertheless, the decision must be made based on a specific project, but the balance is increasingly shifting to more modern languages. 

 

Here are some examples of applications developed for NodeJS: 

 

 

 

 

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.