Who the fuck looked at the white paper of this language and said "yeah, this is the future"

>Most JS tutorials show the standard for loop syntax as "for (i = 0; i < someValue; i++)"
It seems this board has a hard on for hating on Java, but honestly, I'd take Objective-C library tier verbosity over the insanity of this language's everything any day of the week. Words can't even describe how pissed off I am right now.

Other urls found in this thread:

w3schools.com/js/js_loop_for.asp
skulpt.org/
dorey.github.io/JavaScript-Equality-Table/
twitter.com/SFWRedditVideos

Explain what's wrong with global variables.

You fucking shitposter, can't you read the rest of the post? Global variable declarations by default is the fucking worst idea ever.

>I didn't use var like I'm supposed to
That's what I read.

Go home Lynx, you are drunk.

javascript was written in one work day, that's under 7 hours of actual work. True story.

Javascript is Lisp in imperative clothing. Once you plebs realize that you'll start appreciating that it's actually a pretty good language.

I wonder.

Also
>>>/g/

As far as I know, Lisp variables aren't opt-out global.

While JS has some pretty nice features, such as first class functions, all the shit details it comes with make the pain of using this simply not worth it. The type system somehow manages to be fucking retarded even for dynamic standards.

Java 8 has some features that make functional programming almost comfortable (much saner than JavaScript, by the way), but if you want to get a taste of Lisp made imperative and crazy, try out Scala.


Your reading comprehension is not very good, is it?

Three languages are mentioned in this sentence: Java, which is used as an example of the universally hated language in Holla Forums; Objective-C, which may have the most verbose libraries ever written; and "this language", which refers to JS, which is implied to be worse than the "worst part of Java made worse".

I'm fairly proficient with Java. I would never confuse Java with anything that's not small C# snippets, much less with JS.

No, reusing single-letter variable names is clearly worse.

Yeah, sure, let me tell all those programmers that the "i is for iterator" convention is wrong and that they should name all their loops after some verbose variable name like "numberOfTimesTheRootNodeChildrenLoopHasExecuted" just so this special snowflake language can not shit itself if you forget the local modifier.

Where the fuck did all these JS suckers come from? Holla Forums has always ridiculed web development and Nodeshit, why is it suddenly acceptable?

Global variables continue to take up space in memory even when they are no longer needed, and they much more difficult to analyze the execution path that leads to their modification.

I side with OP on this one, placing variables in the global scope by default is pure insanity (though I've never personally used Javascript).

Lua is often praised by Holla Forums and I think by default its variables are global unless affixed with `local`.

yeah OP is 100% right

js is an abomination

Well, sort of. How it works in Lua 5.3 is, any access to a non-local is actually an access to a member of another local named _ENV. By default, _ENV is set as a reference to this one global table, so in that way it does have implicit globals.

You don't generally write shit in lua anyway, it's more of a scripting language for you to embed into your program, and in that case you just don't fucking do that global table shit there done.

Besides, the system is radically flexible in a way that this isn't a problem. You can use metatables to prevent setting/getting table members which don't already exist, and apply that concept to _ENV since it's just a table anyway. Unless it's not a table, since it doesn't actually need to be. It can be anything. It can be an integer. It can be nil. It can be an opaque pointer. Do whatever the fuck you want, it's lua.

Brendan Eich famously coded JavaScript in 10 days with no design whatsoever.

And yes, you have to be a retard to use it unless you positively have no other option (i.e. for anything but client-side web development)

...

I use "i" all the time then "j" if in it, then "n", then "u". You can clear variables if you are so afraid.

We can rebuild this thread. We have the Holla Forumsnology.

You don't understand the problem. I had three nested loops, named i, j and k. I was in full control of my side of the program, but I was using a library object pulled from another file as a black box (the way objects are intended to be used) and calling its functions inside my loop, which is a pretty fucking normal thing to do in any language.

Thing is, the library was using a loop in the form of "for (i = 0; i < something; i++)", and so was I because every fucking JS tutorial on the web uses i without var ( w3schools.com/js/js_loop_for.asp ), and I just assumed variables declared inside the description of a for loop defaulted to local because there is no fucking reason to make them global implicitly. Turns out they are indeed global, and they are global BY DEFAULT, which means a bugged library can pollute your environment, and that calling a function with a loop inside a loop can reset the original loop, which causes the program to go on a lockdown. This problem is very hard to debug since infinite loops don't really break at a single determinate point, and basically, you are fucked.

Turns out that JavaScript, like Lua (not that I defend Lua; it looks comfy, but so do all other scripting languages until you start having fun with type fuckery and scopes), has a Strict Mode that prevents you from fucking up like this by forcing you to declare variables before using them or preventing you from overriding keywords and special variables. The question is, why the fuck isn't this the default?


I bet you are a Blinkbabby webdev. I have good news for you, though: Chrome also crashed hard.

By the way, do tell what's so bad about Java that makes it worse than JS other than "my fingers hurt because it is too verbose and I am too used to just write 'import program'".

Don't use javascript, javascript is harmful.

Don't code it. Don't use it. By doing so you only perpetuate it. Push your fellow devs towards python for frontend. Python fullstack. Promote it as allowing a more seamless, easier to maintain stack that provides a better user experience.

The only reason javascript continues growing is due to the san francisco "devs" clique that can't code for shit. This is why when that guy removed his "pad-left" it broke everyone else's projects. Shitty coders promote shitty languages.

Transition from javascript to python and you raise the barrier to entry ever so slightly and kick out socjus javascript clique not that python isn't also pozzed. If they object then you should come up with some shitty statistics showing that more women and minorities use python and by refusing to transition to python from javascript they are exercising their coding privilege in an exclusionary and extremely sexist and racist manner.

"See here (points to statistic lies), more women and minorities use python than javascript - by transitioning to python we remove barriers to entry for women and minorities :))))) We need more of that diversity! You're not a racist, sexist bro-grammer are you??"

Are you literally retarded?

People use JS because it's the only scripting language that normally works on browsers.

pajeet, my son

Prove me wrong. Pro tip: you can't because you're too busy shitting on the street.

You've misunderstood what he's saying. He's saying you're not supposed to use scripting in the browser.

>for (i = 0; i < someValue; i++)
ES6:
for (let i = 0; i < someValue; i++)

really.

Wow, you're right, he's just a retarded faggot. I just skimmed across the post entirely.

This meme needs to end. The author tries to add some Lisp features lest he end up with a BASIC clone ≠ language is Lisp.

No, Javascript is not Lisp. Neither is Ruby, you worthless hipster "coding rock stars".

Yeah. There's no namespaces in the one language that really needs them. That's why programmers compensate by using closures.

var namespace = (function(){// private variables var x = 1, y = 2, z = 3;// private functions function foo() { return x + y; } function getZ() { return z; }//public API return { foo: foo, getZ: getZ };}());

Sorry about using spaces instead of tabs. I'm using a phone.

Fact is, scoping variables is a dumb idea. If someone uses a variable, they should be able to access it anywhere by using the name they chose for it. It's like if you had a language where words could mean different things depending on context. Makes no sense.

Have you ever programmed anything beside a hello world in Java?

all the scoping problems are gone if you stick to declaring with the var keyword.

yes, it sucks, but it was rather an accident. there was no whitepaper. javascript was invented in a hurry, and its popularity is also an accident


he just did. it's not the existence of global variables per se, but the fact that all variables are global by default.


that's a bit of a stretch. Javascript's got the first-class functions (so does Python and other imperative languages), but Lisp's homoiconicity is kind of a deal-breaker.
Javascript very dynamic and flexible for a language with C-like syntax, but that doesn't automatically make it "pretty good".


why not?
skulpt.org/


is this sarcasm?

Javascript is meh-tier at best, but the SF hipsters at least improving it somewhat with ES{5,6,7} and whatnot.

While JavaScript will always be shit, ES6 and later are at least a little bit better. And at least you can write in ES6 and transpile to JS with Babel then bundle with Webpack.

That said, the whole trend where pages are now 2 MB and the whole one page app bullshit bundling 5 MB of code + React.js + 20 other libraries is fucking harmful and insane. Shit is fucking cancerous.

Ergo, you have three options: (1) write no JS (2) write minimal vanilla JS and (3) write some in a language like Dart or ES6 and convert to ES6 and commit sudoku .

That said, JavaScript a shit and anyone who uses it server-side should an hero. Avoid the cancer as much as you can.


pic related you faggot

Lua is kind of shit too other than the interpreter and jit being written by inhuman compiler gods.

>Most JS tutorials show the standard for loop syntax as "for (i = 0; i < someValue; i++)"
This is absolutely terrifying! Our browsers run this on a daily basis.

===

dorey.github.io/JavaScript-Equality-Table/

Yes I realize that cross-browser Meme 2.0 shit usually depends on at least jQuery, but that doesn't make the concept of libraries for fucking JavaScript any less abhorrent.

dumb frogposter

dumb tripcancer

RED TEXT TEST
how do i upload pictures with links2 or lynx

Funny, literally every other language on earth has no issue with == and !=.

Honestly, I blame early web devs. Having only one language to do *anything* is a terrible idea and I don't really understand why we needed a new language in the first place. I think something like an embedded Python/Perl/Ruby interpreter with an API would have been a better idea.

...

try { throw 69; }catch(value) { alert(value); } // 69alert(value); // undefined

Yeah.
The project I'm working on disables most of this fuckery by making us use 'use strict'
Still not strict enough for me, but it avoids the global var fuckery
Also we wrap controllers and modules in parentheses to prevent then from staining the global scope.
Basically, the problems you've described have been solved.
But I agree they shouldn't even have existed in the first place

Read a book nigger

It was never meant for big programs. Was only really designed for embedding small scripts into web pages. For full size cross platform applications, Java or Python is what you're supposed to use.

Just because modern web designers are retards and have extended JS beyond anything it was ever supposed to be isn't the fault of the language.

wow no wonder webdevs are so retarded. they were fucked from the start

Thats skulp is kind of interesting. Can you do ajax with that?

Exactly. Javascript doesn't really give a fuck about which data types you're using.

Holy shit quads.

They pretty much are. And there's absolutely nothing wrong with that. Just don't be a retard and bind dynamically when a lexical binding will do the trick.

For a language literally designed in a week, it's STILL FUCKING AWFUL

Who the fuck thought having a language that can't handle recursion without hand-holding to parse a tree-based structure (like HTML, or any form of XML) was a good idea?

...

It was (poorly) designed as a language to add some neat, convenient functionality to websites.

The Web became kind of a big thing so a lot of people learned JavaScript, including a lot of people with no other programming background.

When all you have is a hammer, everything looks like a nail. Add onto that a huge need for developers since proper devs are this expensive thing no one wants to pay for, add a few years, and you have the current status-quo.

Not in strict mode. If you use anything else, you're the problem.

Wrong. Also, not in strict mode. A variable declaration without the var/const/let statement is invalid and leads to an implicit declaration.

True, but in the way MVCs usually work, anything else would be a nightmare. If you want to restrict namespaces properly, use classes, or closures pre-ES6.

False, unless you do it wrong and don't use strict mode.

>>Most JS tutorials show the standard for loop syntax as "for (i = 0; i < someValue; i++)"
I don't know what kind of shit tutorials you are reading, but tutorials don't have anything to do with the quality of the language in the first place. Also, see strict mode.

Use strict mode and stop reading shit tutorials.

TL;DR op can't into using 'var' before initializing a variable. JS has a lot of problems, but none of the ones you listed are among them.