DEV Community

Why is everything Javascript?

Rachel Snijders on February 20, 2024

I am not sure if this is the right place and time to ask this question, but there is something I really don't understand. You might have guessed wh...
Collapse
 
lexlohr profile image
Alex Lohr

ECMAscript (also known as JS) is the standard scripting language running inside web browsers. Attempts to change that (VBscript, Java applets, Flash/ActionScript, GWT, Dart) have all failed.

Furthermore, JS succeeded beyond the browser, making its jump to the server (node, deno, bun, llrt) and embedded systems (espruino).

There's no hidden truth that will magically make you love JS. Like any other language, you'll have to get used to it to get comfortable using it. Starting with ES6 which was released 2015, it got a lot better over the years and is still improving. The same applies to the tools around the language.

If every solution feels wrong for, maybe what you need is a mentor to guide you. Or maybe you're just not meant to be a JS Developer and should rely on web assembly to run languages like rust in the browser.

Collapse
 
miketalbot profile image
Mike Talbot ⭐ • Edited

For me, I use JavaScript because it's the closest thing to Write Once, Run Anywhere with no compilation step.

  • JIT compilation, no build scripts to make things work if you go vanilla.
  • A homogenous language between the front end and back end reduces context switching and improves my performance.
  • In recent years it's become a pretty nice language to express yourself in, especially for async code, and its dynamic nature is part of its power, not its pitfall - but it needs embracing, not hiding from.
  • Massive community support, huge numbers of open-source packages
  • It's fast enough for every app I've built and you can easily integrate other things if you need to

I say this as someone who comes from a C, C++, and Java background with a decade-long sojourn into C#

Collapse
 
ingosteinke profile image
Ingo Steinke, web developer

JavaScript used to be very messy and quirky before esllint, JSDoc, ECMAScript, and TypeScript. But it is still far from clean and type-safe. But it used to be the only programming language supported by every web browser, and with Rhino, node, and Webpack, people started using JavaScript for backend and dev-ops, so that they did not have to learn additional languages like Python, Perl, or bash:

Collapse
 
bwca profile image
Volodymyr Yepishev

'cos you can build anything with it 🫣

Image description

Collapse
 
tandrieu profile image
Thibaut Andrieu

In the early 2ks, there were essentially C/C++ and Java. And VB, but we don't talk about VB. These languages were hard to use, and had the unfortunate tendency to crash your whole machine at the slightest mistake. So you needed a lot of courage and pugnacity to write a single working program. This era gave birth to great, high-quality softwares like... Windows Millennium or... Internet Explorer 6.

Then, Web comes into play with its javascript.

Suddenly, every dumb-a** teenager with a keyboard were able to integrate fireworks, animated banner or that kitten that follow your mouse in their web page. javascript, contrary to other langage, was very permissive, and let you create funny annoying stuff very easily, as long as you don't watch the error console. It spread all around the web like a cancer. Years latter, those teenager becames Engineer, then Directors. And they bring with them what they have learned, forcing everyone to use this technology for things it wasn't created for.

Their madness pushed them to create javascript for desktop with electron, or even worst, Node.js, to port javascript where it should never have been: on the backend...

That, Rachel, is the story of the worst creation of mankind...

Collapse
 
peerreynders profile image
peerreynders

Am I missing some universal truth that will make me love the language?

The universal truth is that there is no need to love JavaScript (or TypeScript).

You will never master JavaScript if you cannot learn to respect its idiosyncrasies.

To get into the right frame of mind perhaps watch this:

“Dear Developer, the Web Isn't About You”

… and paraphrasing …

“Dear Developer, JavaScript Isn't About You”—but what you can accomplish with it (in a relatively short amount of time).

The way to get on with JavaScript is to know and respect its faults, recognize its strengths and above all, to not try to make it into something it isn't by shoehorning it into a frame of some programming language you happen to be familiar with or one you would rather be working with—JavaScript is what it is.

Once you get to that level of competency, JavaScript is a non-issue and you can move on to enjoying building whatever you need to build (and whatever value that provides). JavaScript, just like programming, is a means to an end—not an end in itself.

That said, experience in other (Scheme or Lisp flavoured) programming languages will benefit JavaScript competence.


More recently, “why” it's happening:

“… because of the hydration problem … for these declarative Frameworks to work on both sides efficiently, you need to have JavaScript on both sides; I'm not saying your whole back end has to be JavaScript …”

Evolving Isomorphic Data-Fetching - YouTube

New constraints have been leading to a complete rethinking of how we handle isomorphic data-fetching in JavaScript frameworks. Truthfully I don't have the fu...

favicon youtube.com

“… if you're not using JavaScript on the server, you're doing it wrong … but if you care about end-user experience, you can make more significant improvements by running JavaScript on the server [compared to any other server language «you» prefer] …”

Evolving Isomorphic Data-Fetching - YouTube

New constraints have been leading to a complete rethinking of how we handle isomorphic data-fetching in JavaScript frameworks. Truthfully I don't have the fu...

favicon youtube.com
Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

My take, just keep doing what your doing your job security is far greater in rust or go or any lower level.

The idea of a scripting language as a backend is appealing I suppose for ecosystem and speed and you know what they say, go where the money is.

Personally I’m learning C# and python lately

Collapse
 
mrlinxed profile image
Mr. Linxed

A lot of the things are done with the web browser nowadays. And Javascript happens to be what runs in browsers.

If you're already hiring javascript developers you might as well make your backend in JS as well.

Aside from that, if something is popular enough, it'll fuel itself. It's hip. It's easily talked about. It creates lots of views and interaction. Other languages are viewed as dusty.


That being said, you do what you want to do. You shouldn't be writing code in a language you don't like, you'll burn out. There are still plenty of jobs out there using other languages. And no, I don't think you'd be shooting yourself in the foot with it.

Collapse
 
alvaromontoro profile image
Alvaro Montoro

There seems to be many developers that think if you are not doing JavaScript, you are not really developing. Based on that (mis)conception, it is natural to use JavaScript to simplify (more like "JavaScriptify") what other languages like HTML, CSS, or a server side language can (and should) do.

Don't take me wrong, JavaScript is essential nowadays. It is convenient being able to do many things in a single language, but many times it's at the cost of performance and complexity –even when the solution claims to remove complexity, what it ultimately does is adding a new layer of abstraction... which leads to more complexity.

If you enjoy Go, do Go. If you enjoy Rust, do Rust. And remember: you don't need to love a language or marry it (although specializing in a language will give your career a nice boost), just to work with it.

Collapse
 
seandinan profile image
Sean Dinan

In my opinion, I would say it's because the world runs on the internet and JavaScript is essentially the only programming language available in-browser.

That does seem to be changing as WebAssembly gains momentum. Not sure if you're already familiar with it, but it might be of interest if you want to branch out into other languages (e.g. Rust, C/C++, C#) while still developing web applications.

Collapse
 
benuuts profile image
Ben

My take is that the browser has become the universal operating system. Developers made the most of the only available language and became expert at it. Then started using it outside of browsers to have one and only codebase on the same technology.

Collapse
 
elsewares profile image
Brian Hollenbeck • Edited

I remember the day when I had to make a decision: either I was going to really commit myself to Ruby on Rails, or I was going to dive beyond jQuery and REALLY understand Javascript. I haven't regretted the choice for a day since.

Yeah, Javascript isn't perfect - but then no language is. The reason why Javascript is everywhere is because it became the lingua franca of the Web, and the Web,l far and away, represents the largest opportunity for employment or derivative income as a developer.

Yes, it's slower than Rust. Yes, its not as safe or ironclad as C#, yes, the Math library stinks when compared to Python. But! It's fast ENOUGH, TypeScript is safe ENOUGH, and with a Node/Deno/Bun runtime, I can bang together a server that binds to a Python or R or MatLab library that'll do the floating-point math FOR me. And I can have it done, tested and public-facing in a weekend.

Collapse
 
fyodorio profile image
Fyodor

Unpopular opinion: JS (and TS too, consequently) is a beautiful and simple functional programming language. Once you know it and get to work with something else (including Go, Rust, Zig, whatnot), everything seems so bloody overcomplicated. And I don't mean the code, rather the mental concepts.

Again, I believe every programmer has such a langulage in mind (most probably some other than JS), that's totally the matter of opinions. But looks like there's just more folks that feel productive with JS (until they get stuck with performance implications, which to be fair happens not really often or doesn't happen at all for the majority of software products).

Collapse
 
alexsherekin profile image
Oleksandr Sherekin

JS is not a functional language

Collapse
 
tinkermakar profile image
Makar
  1. On one hand, JavaScript has the monopoly over the web browser -- the single largest avenue to most eyeballs in the world. Therefore, most web developers have to know it to some extent anyways.
  2. On the other hand, switching between multiple programming languages is pretty inconvenient -- it's annoying for developers and has a transition cost for the business.

Therefore, everybody is happy to make everything JavaScript.

JS is inevitable 😈

Collapse
 
brihaspati profile image
Brihaspati Bharani

Its because companies want to grow rapidly and there are tons of Javascript developers around to hire, also articles to build things in JS is way higher than any other technologies. Its important to build things fast, but the developers are at the receiving end to not go deep in programming in general. This affects in the long run. But I would suggest to move away from JS once you are good at it to other tech such as Elixir, Go, Rust etc to really love programming and expand the knowledge. Else its all another framework in front end or Nodejs.

Collapse
 
alexmario74 profile image
Mario Santini

You don't have to use JavaScript, you can pick whatever language you feel comfortable with, and just learn it and start writing code with that language.

The only constraint you have, with JavaScript, is that you have to know it, if you work on the web apps world.

But working on web apps is not mandatory either, just like using JavaScript.

I think to learn another programming language will be beneficial for you in any case, and can help you to have some degree of comparison.

Collapse
 
ukw profile image
ukw

In my personal opinion Javascript doesn't rule the world, but it does run natively in browsers, so its only natural there are many developers that are inclined to use it more, partly because of the fact that most of the apps are now web apps and partly because of the familiarity. Its always easy to start with something like Javascript that doesn't need a compiler to run and its easy to catch up being so unrestricted and chaotic like you said. I think there are many developers as well. I started as a Flash ActionScript developer and since Flash died guess what came natural. Given the fact of the popularity of the Flash I can only guess I'm one of the many developers that ended up in Javascript land because of the familiarity of the language (since ActionScript is similar to Javascript) and of course the fact that they are both web apps.

Collapse
 
calebfrieze profile image
Caleb Frieze

The barrier of entry to JavaScript is fairly low and it's easy to learn. I think since so many people start out learning JS, they naturally have a bias towards it, especially because you can do just about anything with it. I agree JS seems to run the world for now, but who knows what will happen in the coming years!

Collapse
 
nigel447 profile image
nigel447

If you dont like Javascript your going to hate VBScript

Collapse
 
efpage profile image
Eckehard

If Microsoft had succeeded in the browser war, everybody would use VBscript today.

It is really interesting to know, how Javascript was created. If we take into account that Brendan Eich only had ten days to create the language, the result was remarkable. But compared to languages ​​that have been developed and refined over decades, it could also be seen as a step backwards.
In any case, Eich admitted conceptual errors that he still regrets today

But we can learn one rule from this: What´s on the internet is going to stay, regardless if it is good or bad.

Collapse
 
shinyvision profile image
Rachel Snijders

True... 😂

Collapse
 
610470416 profile image
NotFound404

because it is the only language can be used in every platform.

Collapse
 
aralroca profile image
Aral Roca

JavaScript is like "English", it can be executed on every device, every browser, etc.

Collapse
 
groovenectar profile image
Daniel Upshaw

We need to bring back VBScript before WASM takes over

Normalize VBScript

Collapse
 
muhyilmaz profile image
MUHAMMED YILMAZ

You have to ask why everythink is C ?

Collapse
 
johndunlap profile image
John Dunlap

Simply put, it's they only language that's supported by web browsers. If a viable alternative was available, half of the world would drop JavaScript like a hot rock.

Collapse
 
shahab987 profile image
Shahab Mosaleh

History!!! ... Ask the same question about "English" and you will find your answer.

Collapse
 
bobfrankston profile image
Bob Frankston

I wrote JavaScript EcoSystem to explain the power of the JS Ecosystem.

Collapse
 
valvonvorn profile image
val von vorn

Nice, but why is everything JavaScript? WHat is the answer?

Collapse
 
tidoo profile image
Arslan Aziz

Because this world is destined to be destroyed by JS sooner or later

Collapse
 
xet7 profile image
Lauri Ojansivu

I'm developing a web framework that does not use Javascript at all:

github.com/wekan/wekanstudio

Collapse
 
stojakovic99 profile image
Nikola Stojaković

Not really. On the front-end you don't have much choice - there is WASM but it's still not widely adopted. On the back-end, Node.js doesn't have a big market share compared to other platforms.

Collapse
 
woanversace profile image
WoanVersace

Easy to use. Easy to adopt.

Collapse
 
saundersdev1 profile image
saundersDev1

Thanks for sharing this piece of information with us