...
And this shit is the most popular language nowdays?
Other urls found in this thread:
Guerrilla Advertising Agent, Get out Sup Forums
>be developer on Sup Forums
>pass in string into a .sort()
>JS sorts string as expected
>complain
[1,12,5].sort((a,b)=>a-b)
//>(3) [1, 5, 12]
//
nigga, don't hate it just because you don't understand it.
>Be a retard on Sup Forums
>Think that passing list of ints to a sort function turns them into strings and then lex sorting is OK
...
lul saved
>Autists approve using an horrible hack to fix their shitty language
> no quotes around ints
> calls it a string
k.
>using any language with non-strict typing
You're literally doing this to yourself.
>providing an ordering function as an argument to sort
>horrible hack
lol u n00b
Javashit is for retarded manlet appers.
Would ECMAScript's List.sort() do any better?
I hope for a Fourth Reich, but instead of jews they'll try to eradicate indians that unironically like and defend JS. People like you, Rajesh.
>Pass an array of integers to a sort function
>Expect to get an array of said integers, sorted
>Instead it converts them to strings
Zero excuse for this.
import std.stdio, std.algorithm;
void main()
{
[12, 1, 5].sort.writeln;
}
This is D. It does exactly what is expected.
>[1, 5, 12]
every other language does it that way
JS is the special guy in class
It is popular because you can run applications on any system without installing anything.
I mean the sort makes sense if it were strings, but no quotes means numbers right?
I know everything is a string in javascript but why would a sort not use the internal < operator relevant to the class?
niggers
do you understand the concept of types
do you know how javascript types work?
how is your shitty program gonna sort [2,5, "apples", {race:'nigger', gender:'trap'}]?
the same way the JS interpreter/JIT compiler works, you dumbass
>muh types
there is a reason some people avoid weak-typed langs
Sorting should use natural ordering by default, not some shitty "lets cast everything to string and do a lexical sort" hack.
RTFM
>It is popular because you can run applications on any system without installing anything.
You mean aside from a js interpreter, sure. But you can say that about a lot of languages.
This
you seem lost I agree
Indian hate is not racism, is common sense
because they can't handle the power
50 extends and 200 overloads later you have the same functionality, but if you can't grasp it and/or define and follow specs then yeah, you need to stay shackled to your stronk typez.
Don't worry, I understand.
traccy needs a stronk chadd to fugg her in her boypuzzi.
>jaw drops
>quickly try it out in node 4.2.6
>it's true
cool, but not tech-related
It treats these as strings, JS is retarded like that.
JS has some legitimate weaknesses, but if you think that image is a valid criticism of JS, you are fucking retarded.
considering the fact that 80% of 12k people thought it would do the logical thing, which it doesn't, yeah, i guess i'm retarded.
Judging a language based on small arbitrary characteristics of its standard functions is brainlet tier.
Languages should be judged based on their essential, core characteristics.
Cont. Anyone who actually has more than a week's worth of experience writing JS and isn't a moron literally never experiences any problems as a result of the way the array sort works by default. All languages have small quirks like this.
That's not a hack, that's the way it's meant to be used
>How a language compares variables is a small arbitrary characteristic
Hmmm...
The array sort isn't "how the language compares variables". In JS, you compare variables using , ==, ===, and so on.
The sort is just a method attached to Array objects.
I write JS almost every day and I only find myself using array sort once every few weeks, anyway. It doesn't come up that often. And when I do use it, the way it works poses zero problems.
You sound like you don't know what you're talking about.
If you ever use an array like that I hope you die
forgot my pic
How do you think sorting happens? Sorting is just a series of comparisons and memory operations in order to get data in the order you want. Javascript implicitly converting stuff to string while sorting is unacceptable, and it doesn't happen only while sorting. It makes programmers have to take extra steps to prevent JS from being retarded, and that's what makes it a bad language.
Looks like you're the one who doesn't know what you're talking about.
ITT
> muh C , D ,insert shit lang here
> Butthurts fgts who can get a grasp of reality
I'm a professional web developer. I write JS almost every day. I work with dozens of other people who write JS.
The conversion to string issue doesn't cause any of us problems.
It's something you get used to when you're one week or so into learning JS, and then never even consciously think about again.
If you don't want to deal with automatic type conversion, just always use === to compare values.
This is not a problem anywhere outside of your mind and the minds of others like you.
You know how I know you don't know what the fuck you're talking about?
If you did, you'd be able to criticize JS for things that actually matter.
The fact that you criticize it for trivial things tells me you don't understand JS.
Says the frog poster using a program written in C, inside another program written in C inside another program written in C.
This is why I hate Sup Forums. Yeah sure, a D program has slightly better, more sensical sorting.
Can you fucking find ONE job posting looking for a D develoer?
Use the tech for the job. Ideological purity over practicality makes a NEET. JS isn't perfect, but it's the most used programming language in the world. The Web runs on it (easiest way to make cross platform), there are great transpilers like Typescript, it can run on server, etc.
Only one who actually has brought up good points in this thread is
>This is why I hate Sup Forums.
well yeah... Sup Forums is a consumerist shithole, if you want real discussion of a language you're better off on irc or in some language specific forum. you can't expect much from a bunch of unemployable shitlords memeing about their deprecated/obscure languages that nobody wants.
I can dig for a job posting for D and guarantee it pays well and will probably be secure thanks to its niche. I can find you a million JS jobs scraping the bottom of the barrel on salary, job security, and employer quality. It'll all be shitty curry sweat shops or stupid hipster startups that will all be gone before 5 years are up.
Anyone who's actually good at one language can become good at any other language in weeks. People who write good JS can go write good C, D, Haskell, or whatever.
>not tech related
Yes, it is. India is literally shitting on software development
only a handful of third world countries has this problem (us and india). either move or kill yourself you whining cuck
>what is a browser
And that's not true for any language
>compiled languages need to link to the correct syscalls so that's out of the question (not portable from Linux to Windows)
>interpreted languages need a interpreter preinstalled, and since Windows is a shit platform, doesn't include python, but does include internet explorer
this is why you need types god damit.
IS IT AN INT OR A STRING?!?
fuck dynamic
This is not true. JS does not prepare you for C. C does not prepare you for Haskell.
If you're trying to weed out complete retards, ok. but someone that knows C is not going to pick up Haskell any faster than an educated individual starting from scratch.
I have been writing Java and C for like 10 years now, and JS still fucks me up. I can write it, but I'm nowhere near good.
>how is your shitty program gonna sort [2,5, "apples", {race:'nigger', gender:'trap'}]?
what the fuck is that meant to sort?
>Anyone who's actually good at one language can become good at any other language in weeks. People who write good JS can go write good C, D, Haskell, or whatever.
holy fuck.
no.
Agreed. Static typing with good type inference is best, fuck every other approach.
Somebody who's "good" at js probably knows how to write production grade code on c.
And implicit type conversion like this isn't a pleasant experience for anybody and should be avoided as much as possible.
This abomination shouldn't be sorted at all.
If you need to sort an array with multiple types, you did something wrong
It's not enclosed in quotes so it must be int.
Unless you are talking about the output.
shhh, it's a javascript """developer""", be sensitive to him pls.
>People who write good JS can go write good C, D, Haskell, or whatever.
lmao jscucks actually believe this
No one can be this dense.
Yes, an expert C programmer can pick up PHP in a day. But a JavaScript ""developer"" will have a hard time learning any real language.
may i point you to paulgraham.com
C isn't hard to learn, although of course it takes time to become an expert. I learned C before I learned Javascript. I don't know why Sup Forums always assumes that any JS programmer is a drooling retard who doesn't know low level stuff.
When I said that any good JS developer can get good at another language fast, I meant what I said - a *good* JS developer. Not just a code monkey, but an actually legitimately good JS developer.
JS is popular because it runs in browsers, it has a huge ecosystem, it's multi-paradigm, it's decently fast for a high-level interpreted language, and so on.
Also, it's basically the C of the web, for better or worse, in the sense that there are other languages that treat it is a compilation target or tap into it for its huge ecosystem.
JS is far from perfect, but by restricting oneself to certain subsets of it one can achieve at least an approximation of elegance.
Typescript is pretty boss.
how are there people actually defending javascript. sure you might use it and rarely have any problems but this doesn't mean you have to lie to the thread and say it's good. this must be stockholm syndrome
The type conversion weirdness doesn't come up in real development.
If I wanted to for some reason be extremely careful, like if I was building life-critical stuff, I'd use a subset of JS (maybe TypedArrays) or a language that compiles to JS.
It's a minor, easily avoided problem.
I want to see all the complainers in this thread offer some REAL criticisms of JS, rather than talk about type conversion weirdness over and over.
The type conversion weirdness is literally the first thing you find on the Internet when you search for JS flaws, yet it's not a problem for real JS developers. This makes me think that this thread is full of people who don't know JS and are just complaining about a "popular" flaw that it has.
That's what you get from weakly typed languages.
And that's not even a valid excuse, you could be weakly typed and still distinguish between numerics and strings by the absence of fucking quotes.
If you find yourself in a situation where implicit type conversion is happening, and you aren't using the === operator, you are a fag and shouldn't write software.
>strings don't necessarily have to be instantiated by double quotes
What a nigger tier, ghetto ass, hacked together, shit language.
>do you know how javascript types work?
They don't?
The power to have your program behave unexpectedly because of runtime type checking (if that)? Sign me up
Then there should NEVER have been a default implementation.
This is nothing but a trap. You can't see that coming.
They do. You didn't understand the problem right. The default comparison method the sort function uses just converts all arguments to strings.
>expecting a weakly typed language to sort
At the very least you get dubs for effort
Complaining about sort() in javascript really tells how much they know about the language and you don't even need to be an expert to realize that. Fanboyism for a language is plain stupid and probably just a thing among beginners or NEETs.
I just find it weird that its standard library is so tiny when it's the one language that would benefit from a huge standard library as it decreases the amount of code you'd need to ship.
Every shitty little thing in js requires adding 10 kb more.
Javascript isn't a language meant for any real math or logic. It's a language which was originally created for small client side scripts, but was adopted by borderline retards which turned it into what it is today. With javascript, do not expect things to "make sense", they don't. Just as this guy says, you need to spend weeks on javascript to identify every little retarded thing that is wrong with the language so that you can steer clear of every pot hole and then go "well the road looked fine to me".
Knowning Javascript does not prepare you to learn Haskell, actually learning Javascript makes it harder to learn Haskell. How can you expect a programmer who spends years learning a language void of any logic (javascript) to learn Haskell, a language that makes logic its core, in weeks? I can only imagine a javascripter staring in aww when he sees that 1+1=2 and not "11". A javashitter will never ever be able to handle haskell. Just as a Haskell programmer has too high of an IQ to be able to learn javascript.
It makes sense, but it is counterintuitive. If you call sort without passing in a compare function, the function has to have some sort of fallback comparator that will work with any type, which means comparing them as strings.
>blaspheming like a retard just to make a point
Kill yourself moron
>web dev
>calling a Number 'int'
your tiny brain just can't handle dynamic typing
>Knowning Javascript does not prepare you to learn Haskell
Which is why I said "being good at JS", not "knowing JS".
>Just as a Haskell programmer has too high of an IQ to be able to learn javascript.
Masturbation
...
But it's javascript communicating to php thru a c++ browser under an objC os. Get over it grandpa.
Did you just assume that variable's type?
>Just as this guy says, you need to spend weeks on javascript to identify every little retarded thing that is wrong with the language so that you can steer clear of every pot hole and then go "well the road looked fine to me".
There are some quirks that take a few hours to get used to it you're a good coder. Nothing like "weeks".
What are these things that are wrong with the language, according to you? Should be easy to list them, right?
...
Creator should've copied Java language specification. Never understood why script people consider types evil
JS has types, though. Booleans, numbers, strings, objects, functions, and (in typed arrays) various sort of specific numeric types. And you can easily add a more advanced type system to JS if you want one.
I know jackshit about javascript but it's logical. It can sort integers too, based on pic.
I don't want to get left in the dust, so I started learning javascript to write a webapp.
How do JS developers actually wrap their head around writing their entire application in JS?
Before ES6, all variables were global, anything more than a few hundred lines would turn into a mess, surely.
How did they deal with this before const and let variables?
Ints are strings by default
>Before ES6, all variables were global, anything more than a few hundred lines would turn into a mess, surely.
Not at all. Variables were only global if you didn't declare them with a "var " statement. If you declared a variable with "var", the variable would be scoped to the function it was declared in, and visible only from inside that function and any functions defined inside that function.
JavaScript is not even a fucking programming language, it's a fucking scripting language. Java is also shit, but that's not my point.
GTFO
>Java is also shit, but that's not my point.
Atleast it uses basic fucking datatypes correctly.
How the fuck are you even supposed to sort that? Who the fuck decided that apple comes before 5? Jesus what the fuck JavaScript