DEV Community

Cover image for Why Are Programming Languages Looking More Like JavaScript?
Alex Howez
Alex Howez

Posted on

Why Are Programming Languages Looking More Like JavaScript?

In 2023 I started testing a lot of new languages and saw newer languages copying JS syntax, and for good reason! JavaScript is one of the most popular and widely used programming languages.

While initially I thought I was biased to the JavaScript syntax, apparently more and more languages are copying it's style.

Did JavaScript prove it's readability and visual scalability?

JavasScript logo

**

The New Languages

**

Take a look at Carbon, Google's new programming language that aims to be a modern and expressive successor to C++, designed to be compatible with existing C++ code and libraries.

Carbon Code Example

The use of arrow functions, the way to declare variables and for loops, you can always confuse this with Typescript!

As a reminder on JavaScript's plasticity, bracket "{}" symbols are optional, same for arrow functions and the same goes for spacing (4 space vs 2 space vs tab spacing).

Below is the same function, written in different ways.

JS code example

**

It's also Kotlin

**
Another example is Kotlin, a programming language that targets the Java Virtual Machine (JVM) and can interoperate with Java code while being more concise and expressive.

It's a language that I'm interested in, and looking at it's documentation I couldn't help but notice the JavaScript similarities again. Curly braces for blocks, semicolons for statements, and var/val for variables.

Kotlin on left, Java on right

Looking at the Kotlin/Java comparison, you can see how Kotlin drops the variable declaration in the "public final int id" in favour of "val id: Int".

**

And also Rust?

**

I'll leave the same example in Rust for fun, another one of the newer languages with this same syntax look.

Rust ChatGPT generated example

Final Thoughts
In my opinion, Python's ease of writing shortcuts make it harder to read on larger codebases, while Java's intricacies make it harder to read line by line.
On the other hand JS/TS or strike a great balance in the middle.

What do think?

Top comments (2)

Collapse
 
ervin_szilagyi profile image
Ervin Szilagyi • Edited

From Wikipedia - History of mathematical notation:

The arrow, e.g., →, was developed for function notation in 1936 by Øystein Ore to denote images of specific elements. Later, in 1940, it took its present form, e.g., f: X → Y, through the work of Witold Hurewicz.

The so called arrow syntax is not something invented by JavaScript people, it is a well know notation for a function. In fact, JavaScript is one of the languages that adopted it lately with ES6. I'm pretty sure, Haskell is the language that made this notation popular. Probably this inspired also the JavaScript people to adopt it.

My takeaway is this: not everything revolves around JavaScript. Having the same notation for concepts is a good thing. Moreover, having a little bit of common syntactical sugar does not mean that languages are the same; there is a whole bunch of other stuff behind the curtains.

Collapse
 
webjose profile image
José Pablo Ramírez Vargas
  1. That is more TypeScript than JavaScript.
  2. The reality is that languages model after C, including JavaScript.
  3. Do you think arrow functions are an invention of JavaScript? No, sir. I first met them in C#, and C# might have ported this from somewhere else.