[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
>mfw people hate javascript just because you dont get it
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 26
Thread images: 5
File: 1325814500865.jpg (7 KB, 251x242) Image search: [Google]
1325814500865.jpg
7 KB, 251x242
>mfw people hate javascript

just because you dont get it doesnt mean its shit
>>
I get it and it's shit.
>>
>javashit
>ever
>>
File: 1325814500865.png (84 KB, 251x242) Image search: [Google]
1325814500865.png
84 KB, 251x242
>>53630345
>mfw people post the reddit frog
>>
>>53630345
>hating something
let go of your attachments friends and seek inner bliss
>>
lmao don't try a river frog boy.
>>
>>53630345
>I'll make it so the page content doesn't show up unless you allow scripts from three different domains
>yeah that makes sense
as expected of a frogposter
>>
I understand it, it's awful, but it's on the verge of being great for what it is(a high level language.) One day. One day.
>>
People hate java too even though it's the best language around
>>
>>53630374
/thread
>>
>>53632433
>people use C to make viruses
>therefore C is a bad language
>>
>>53630345
It is a shit language, and you are a shit programmer.
>>
I hate all languages that aren't easy to read/type.

Ruby and Python I like.
>>
File: 1436200565980s.jpg (3 KB, 125x119) Image search: [Google]
1436200565980s.jpg
3 KB, 125x119
>>53630345
[1,5,10,20].sort() //[1,10,20,5]
typeof NaN === "number" //true

>not shit
>>
>>53632906
>I don't understand lexicographical ordering
>I don't understand IEEE floating point numbers
How's your 67th version of Fizzbuzz going?
>>
javascript is pretty bad

t
b
h

f
a
m
>>
>>53632948
I understand them just fine. They're still awful design paradigms. I'm a web dev and I work with js everyday, it's still a piece of shit though.
>>
>>53632991
How else should sort be implemented? How would you compare a number and a string?
What type should NaN be then? You do realize that in static languages like C and Java NaN is also a float right?
>>
>>53633020
Make it take a comparator as an argument. If none is provided, sort numerically if the first element of the list is a number, lexicographically otherwise.
>>
>>53633081
So how should it sort [1, "a"]?
And you do know that you can specify a comparator as an argument right? Fucking retarded web devs.
>>
>>53633020
I'll give NaN a pass, but sort should really be based on the type of the array. I realize this isn't possible given the way javascript is written, but that's the problem. Since it's untyped it's a bitch to debug and leads to horrible design patterns like === and general unexpected behavior.

Some other fun ones:

var i = "1"; i++; //11
var i = "1"; i+=1; //2
[] == false //true
![] == false //true
!![] == false //false


I would be no means call it a "good" language. It serves it's purpose, nothing more.

>>53633081
sort can take a compare function as an argument
>>
File: 1452303046019.jpg (124 KB, 600x664) Image search: [Google]
1452303046019.jpg
124 KB, 600x664
>implying that there are languages in use today that have no design flaws
>implying that you can't avoid the bad parts of a language
>implying you could design a better language in 10 days (which is what Brendan Eich did it in)
>implying that all other relevant languages didn't get lambdas and other features because Javascript made them popular
>implying that people who "hate" Javascript don't just hate trying to interact with the DOM which is the worst API ever designed
>implying Javascript's inclusion in browsers and the discovery of AJAX in 2005 isn't the reason we're still using the web instead of some abominable Adobe Coldfusion/Flash or Microsoft .NET application delivery system
>implying Javascript is a bad language

Just learn the language and maybe you won't be shit at it.
>>
>>53632906
>[1,5,10,20].sort() //[1,10,20,5]
What the ever-loving fuck??? I can accept most shit in JS but this is straight-out faulty behavior.
>>
File: javascript.jpg (71 KB, 700x500) Image search: [Google]
javascript.jpg
71 KB, 700x500
>>53632906
>>53633278
And yet
['banana', 'melon', 'apple', 'steak'].sort(); 
//[ 'apple', 'banana', 'melon', 'steak' ]

makes perfect sense

The .sort() function defaults to sorting by unicode, and assumes that all array elements are strings.

If you want to sort numerically, you pass a sorting function as a parameter. Yes lambda functions and functions as first class objects are pretty neat language features.

[2,10,20,4].sort(function (a,b) {
return a - b;
});
// [ 2, 4, 10, 20 ]


In terms of examples of why Javascript is shit, this is a pretty dumb example. It just illustrates how people don't know what they're talking about.

Here, at least next time use some decent examples:
https://www.youtube.com/watch?v=2pL28CcEijU
>>
>>53633178
>>53633193

I realize, I was just giving my opinion on what the function should do. If an array has [1, "a"], just let it error unless a comparator was provided.
>>
>>53633629
>lambda functions are a pretty neat language feature

Oh, huh, I never experienced those, except in:

Common Lisp
Scheme
Python
C/C++
Emacs Lisp
Java
...
Thread replies: 26
Thread images: 5

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.