Why I use JS.

Móricz Gergő on November 18, 2018

My main language is JS. I use it both on the web and running locally with Node. But why is it my main language? Let’s find out! 1. Fast w... [Read Full]
markdown guide
 

I have never seen a better package manager than NPM.

That made me laugh, thank you. Now I wonder what else package manager have you seen.

 

Golang has a really nice package management in my opinion. NPM is kinda bloated and security leaves much to be desired...

Also, my previous office project's node_modules weighted 5 gigabytes...Half of the installed packages were including lodash (different versions), moment.js and other popular js helpers libs. It would be really nice if this can be somehow unified so that I don't have x versions of some packages installed. Most of the package authors are not updating their dependencies, leaving users with security flaws sometimes.

So basically, no, NPM has a long way to go yet to be a really good package management (and JS really need one).

 

AFAIK, both yarn and pnpm keep the only version of each dependency.

I think yarn doesn’t but pnpm works that way for sure.

 

Basically nuget and pip. That’s actually way less than I though I knew... :D

 

Well, maybe there are better package managers, but npm is way better than similiar language’s package managers IMO.

There are not many languages similar to JS. I’d say none :)

There are, but similiar in different aspects: python is similiar, in that it’s both low-and-high-level (ctypes), and is fast to write.

 
 

The x=>x/2 function is a lambda expression, a.k.a. arrow function in case you are wondering. The same feature is also seen in other languages such as Java since Java 8 and C#.

 

Yeah, I know about that, and it is a thing that boosts how fast you can write code IMO. If that's wrong in your opinion, tell me!

 

In JavaScript's case, it helps with some this issues.

// Shamelessly copied code from MDN added with logging
function Person(){
  this.age = 0;

  setInterval(() => {
    console.log(this.age++); // |this| properly refers to the Person object
  }, 1000);
}

var p = new Person();

The callback here in setInterval works fine and well (logging 0,1,2 etc.), yet without using arrow functions (i.e. before ES6), the callback would look like:

setInterval(function() {
  console.log(this.age++); // JS be like, "What's this?"
}, 1000);

The this in the callback function refers to Window (logging NaN) and all hell breaks loose.

Your point of writing faster is true, but it has other benefits depending on the language too 😉 (in Java's case, a more compact code and easier code tracing, plus introducing functional programming to its OOP world).

 
  1. Fast writing You can write JS really fast. You don’t need to use semicolons

You mean Node.js, almost all modern languages doesn't use semicolons,
even COBOL.

Speaking of functions, you can do x => x / 2

Many languages already can do this with almost the same syntax.

So instead of "Hi {}!".format(name), you can do:
Hi ${name}!

You can do

f"Hello {name}!"

which is shorter or equal. For example

Python

f"Hello, {name}! You're {age} years old, I {someword}"

Js

"Hello, ${name}! You're ${age} years old, I ${someword}"

Do not speak or teach without any knowledge.

  1. Types and Equality
'2' - 1 // 1
'2' + 1 // '21'

Perfect type conversion.

  1. Packages

Because you haven't used any language or know any language.
There is much more perfect and awesome package managers than npm.
node_modules, yeah.


The post is completely wrong. Python has much more features than JS
such as optional static typing (without using a new language), Erlang
has great concurrency, Elixir has a simpler syntax and better concurrency,
OCaml has great performance (compiles to native code), can compile to JS (Just for the web, not a real app).

You have to learn new things.

 

This isn't a comprehensive review of JS with pros and cons. This is an article about why I like using JS.

Do not speak or teach without any knowledge.

Here are the languages I know decently:

  • JS (React, Cordova/Ionic, and vanilla JS)
  • Ruby (and Ruby on Rails)
  • C#
  • C++ (on Linux/Arduino)
  • C (on Linux)
  • GBASM
  • Python

I think I know a decent amount of stuff about programming and other languages.

You don't have to like JS, but have some respect please.

 

This isn't a comprehensive review of JS with pros and cons. This is an > article about why I like using JS

This is an article of "pros of JS, this is why I use JS" or I'm such an idiot.

Knowing many languages doesn't matter. The only thing matters how do you write your code. Knowing a language is not just knowing how to print, loop or format. Knowing a language means you know what is exactly it is and what features it gives to you. You can not say you know Python decent, you can say I know JS because it's a language you exactly know.
I just said there is a shorter way and you said JS is shorter while you don't know there is a shorter way in Python. You have to a little bit Google about it. I'm 12yo dude, that's not a big age difference.

tbh

Do not speak or teach without any knowledge.

was a pretty strong statement and that's why i wrote the reply but ok

 

Hey! Thanks for sharing your opinion with us. I dont agree on some points but I respect your preferences. Dont listen to people who think they are better or "true" devs just cuz they dont like it or desagree. Keep the good work, keep learning and stay humble c:

(Sorry my english is not perfect)

 
 

Nice, It's a good post. I also like very much JS.

Just a note. On the point 3. Types and Equality you said...

However, if I know that 123 is a string, and I want to check equality, I can just use strict equality if I want. (===)

But actually is not exactly that way

The difference between == and === is usually characterized that == checks for value equality and === checks for both value and type equality. However, this is inaccurate. The proper way to characterize them is that == checks for value equality with coercion allowed, and === checks for value equality without allowing coercion; === is often called "strict equality" for this reason.

Source => You-Dont-Know-JS (BTW this is maybe the best book out there to learn JS I really recommend it.

So when you use '==' you are allowing coercion. So if the types are not the same. The interpreter will follow a very specific set of rules to change the types of the values. This rules are defined in chapter 11.9.3 of the ecma specification => ecma-international.org/ecma-262/5.1/

 

Yeah, I meant to make the same point in the article. Maybe it was misunderstandable? Maybe I’ll change it. Thanks!

 
Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

I thought you are joking, but I just checked out your site and looks like you are serious.

Bootstrap + JQuery to render 4 f***ing buttons using a table!

"True" frontend developer.

 

Okay, that site is literally something I threw together on my phone at 22:00 and forgot about it lol

I’m going to extract the button styles from the CSS and just use that :D

 

Also, saying that based on a random 5 minute trash project that I’m a “true frontend developer”, means that any shitty project you’ve done makes you a trash deverloper too.

Eats Popcorn 🍿🍿🍿

Your opinion has reached many angery devs. Good luck kid.

On-Topic: I liked JavaScript to be as a script kiddie(not 12 yr old btw). This was like the best language for newbies because it is lightweight and moved to even harder statically typed languages like C++, Kotlin,Java,Dart, and etc.

Still, you really don't want to jump to any bandwagon or having a single hammer that you liked the most to fit for the job just because it is famous/popular, active community, and job salary.

A nice answer finally! Most of the answers look like nowadays responses on stackoverflow. This is not off topic this is actually on topic: the guy is 13 years old ( if I got this right: document.write(new Date().getFullYear() - 2005); year old programmer.) and is giving a short post on why he likes something were it's ok to point other solutions or negative parts of something that he likes but the trashing ugghhh... It's a nice feature to have on this page "Comment marked as low quality/non-constructive by the community" I like it and hope it prevents dev.to becoming like bsoverflow :D

 
 
Sloan, the sloth mascot Comment marked as low quality/non-constructive by the community View code of conduct

You are joking, right? You need to put a "" tag somewhere in your post... that, or your sense of humor should be really dark, considering the fact, that every single item in your list is just wrong.

 

If you really think “every single item in your list is just wrong”, tell me what is wrong so I can know...

 

Is the "" thing the only thing that you could bring up? Did you dismiss every single item in my post because it’s “just wrong”? What hole does this mindless commenting fullfill in your heart? smh

Writing “just wrong” is literally like taking a shit. It’s nasty, and it has no value. If you try to criticise, do it constructively. Thanks.

Funny, that instead of quotes it should be a tag: sarcasm.

Yes it's just plain wrong - a language that has only floating point numbers and no integers (heck, you have no idea what type a variable is until you check it) and you call it "low level"

The most controversial parts - types and equality you call that strengths. Especially the comparison produces so many "funny" results, that people are laughing at JS for ages about that. Objects and inheritance in JS can be called weird at least. Seriously - are you suffering from Stockholm syndrome?

NPM - this is by far the worst package manager available with so many issues it's not even funny and you say "I have never seen a better package manager than NPM". Unless NPM is the only package manager you have seen... because it's literally the worst one around (universe is inventing bigger idiots all the time, so pointing to one that is worse will not surprise me at all).

  1. It can in fact be low level, because you can use it along with C/C++ code with node-gyp.
  2. This is a "why I use" article. Not a "comprehensive review" article. This article lists the pros of JS, and not the cons.
  3. See the thing I've added to the article:

I have never seen a better package manager than NPM. (Not saying that there isn’t but I’ve not seen it/my experience was bad with it.)

If you have any recommendations of a great package manager to check out, tell me!

Literally ANY package manager for any other language is better than NPM. The level of entropy in JS Is just ridiculous. The amount of disks space, used by NPM is insane. The packages have crazy dependencies and the chaos there is beyond comprehension: you have packages for is-even and is-odd - one depending on the other, which on it's turn depends on is-number: npmjs.com/package/is-even

Lets talk a bit about types - dates in JS are a total joke and the only package solving this issue correctly "moment.js" is just too big to be used in front-end projects (react, vue, angular) so you have to stick to date-utils. Such a joke - this should be part of the language itself.

You have no integers, oh yes, there are some tricks but most are such insane hacks, that it's fun to see such code.

Having no static typing also makes it hard to catch spelling errors in code, when you accidentally spell a property slightly different.

Low level - please stop this. Via interop you can call C/C++ code in nearly all languages. This does not make your language low-level at all.


Now let me explain why I reacted like this - it may be a bit too harsh as reaction and I'm sorry to hurt your feelings, but you have to be objective. You may like any language and use it anyway you like. As long as it gets the job done - it's good. However you cannot put the biggest cons as pros without saying "yes this is sarcasm"

code of conduct - report abuse