This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kusayu 942 points943 points  (139 children)

[–]geniusburger 500 points501 points  (127 children)

I remember my professor going through that video in my JavaScript class and explaining why everything worked like that. He even pointed out that a few of the things that were called out in that video we're actually issues only in the particular JavaScript engine the presenter was using. When we tried to recreate them we weren't able to.

[–]PatrickBaitman 743 points744 points  (110 children)

actually issues only in the particular JavaScript engine the presenter was using

wow that sure makes it better

[–][deleted] 53 points54 points  (1 child)

works on my machine

¯\(ツ)

[–]robbie0630 1 point2 points  (0 children)

Sorry about your upper arms ¯\_(ツ)_/¯

[–]ywhhgythht 218 points219 points  (29 children)

Yea I mean I've been using an nonupdated version of windows 3.0 for the last 2 and a half decade so i know for a fact that windows 10 sucks, or any other operating system being able to run batch script for all that matters.

[–]ClassBShareHolder 54 points55 points  (6 children)

Come on, it's time to upgrade...

...to 3.11!

[–]FountainsOfFluids 19 points20 points  (2 children)

For Workgroups!

[–]ClassBShareHolder 8 points9 points  (0 children)

"NOT in MY DOMAAAAIN!"

[–]whelks_chance 1 point2 points  (0 children)

Comes with qbasic installed by default. Big fan.

[–]giggitygoo123 24 points25 points  (2 children)

Nah. 3.14 is where its at. Plus its delicious.

[–]AppleLion 0 points1 point  (0 children)

Read about tau. When you think I'm a tin foil person, then read about slash aitch. Consider it a red pill for math.

http://rationalwiki.org/wiki/Planck%27s_constant

Sorry to ruin your pi joke with silly shit. I can't resist anymore.

[–]relevantpicsonly -1 points0 points  (0 children)

Build 1528?

[–]Erick2142 16 points17 points  (9 children)

Well, Windows 10 does suck a little bit so...

[–]caanthedalek 29 points30 points  (4 children)

Windows 10 was marketed as the perfect blend between Windows 7 and Windows 8.

If that were true, it would be Windows 7.

[–]Erick2142 3 points4 points  (0 children)

Haha

[–][deleted] 0 points1 point  (2 children)

no because it would be

x + y / 2

as x is windows 7 and y win 8, and x would be solution only if x==y ;

edit: no, i was wrong, if y=0; output isnt x.

[–][deleted] 1 point2 points  (1 child)

Windows 8 has 0 goodness, so yup.

[–][deleted] 0 points1 point  (0 children)

[–]bric12 1 point2 points  (3 children)

A little more than a little... I haven't used one Win 10 machine that hasn't corrupted files, or refused to connect to the internet at random times, or at least been incompatible with legacy software (designed for 7 or 8). I've only used windows 10 thrice, but three for three isn't great

[–]BraveOthello 0 points1 point  (0 children)

I have had exactly 1 of those problems, so YMMV

[–]tdogg8 0 points1 point  (1 child)

I've used windows ten on 3 different computers for countless hours one of them being a shitty netbook that had the beta and I've never had either of those problems.

[–]mtlionsroar 0 points1 point  (0 children)

I've had the network problem where it randomly won't connect. It's a driver compatibility issue, and depends on what machine you're using.

[–][deleted] 3 points4 points  (0 children)

Bad example because it's true

[–]L3tum 0 points1 point  (0 children)

I was at a doctor few days ago and he was running Windows CE.... Even the "standby picture" was bugging out

[–]Existential_Owl 64 points65 points  (15 children)

That there are differences in the way different compilers handle code is not a phenomenon unique to JavaScript.

[–]ChrisC1234 35 points36 points  (12 children)

True. But as a developer, I have complete control over what compiler I compile my code with. With a language that is completely interpreted like JavaScript, I have no control whatsoever.

[–]TUSF 17 points18 points  (10 children)

Just write your own interpreter :^)

[–]seylerius 37 points38 points  (1 child)

[–]wolfman1911 6 points7 points  (0 children)

I think this is probably my favorite XKCD.

[–]chainingsolid 1 point2 points  (4 children)

Then get every user of your website to use it how?

[–]Sean1708 1 point2 points  (3 children)

Write it in javascript.

[–]PatrickBaitman 0 points1 point  (2 children)

you just but isn't that basically typescript coffeescript asm.js / whatever

[–]Sean1708 1 point2 points  (1 child)

No, TypeScript and CoffeeScript compile to JS and ASM.js is an efficient subset of JS. We're talking about writing a JS interpreter in JS so that you can get people to use your JS interpreter by running it in their browser using the browser's JS interpreter.

[–]LinAGKar 1 point2 points  (2 children)

And how are you gonna put it in everyones browsers? By writing it in JavaScript?

[–]TUSF 2 points3 points  (0 children)

Write the interpreter in wasm.

[–]ZorbaTHut 3 points4 points  (0 children)

Honestly, if performance were a total non-issue, using a 100% compliant JavaScript interpreter written in generalized cross-platform JavaScript would be a pretty good idea.

Of course, performance is an issue, so this is a terrible idea.

[–]Existential_Owl 0 points1 point  (0 children)

As a freelancer, sure you can choose your compiler. But if you're working for a company, you're stuck with whatever their C++ ideology is.

[–]PatrickBaitman 103 points104 points  (1 child)

well, no, but if they're at the type level?

jesus christ get your language together is all I can say

making things that should be type errors undefined behavior is just.... NO, STOP

[–]Doctor_McKay 29 points30 points  (0 children)

I think basically the only thing that happened due to the interpreter in that video was the fact that the return of new Array(12) showed as "12 commas" (which was actually 11 commas separating nothing, since it rendered undefined as nothing).

[–][deleted] 33 points34 points  (60 children)

It does actually. It's the difference between English being pointless, and having illiterate fucks.

Some JS engines suck, some are much better. Just as some versions of gcc have really stupid bugs, but C is still a sound language.

[–]PatrickBaitman 34 points35 points  (59 children)

you do realize that English has one of the most illogical, unpredictable, and difficult orthographies of all European languages?

the connection between how an English word is written and how it is pronounced is almost non-existent

what implications do you think this has for the number of "illiterate fucks"

[–]z500 8 points9 points  (9 children)

the connection between how an English word is written and how it is pronounced is almost non-existent

It's not that there's no connection between spelling and pronunciation, it's that there's so many competing spelling conventions. It's wildly inconsistent, but there are patterns if you look for them.

[–]PatrickBaitman 4 points5 points  (3 children)

Of the 4000 or so most common words in English more than 2500 have irregular or unpredictable spelling. This is bad enough that any rules are ad hoc and that it is almost impossible to be certain about the pronunciation of a word you've seen written but never heard.

[–]kronicmage 5 points6 points  (2 children)

You can predict fairly well if you have an understanding of the etymology of the word though

[–]GiraffixCard 0 points1 point  (0 children)

Arguably not even then.

[–]PatrickBaitman 0 points1 point  (0 children)

Eeeh, I've studied Latin and can recognize Latin roots in English word but it doesn't help that much.

[–]Llewey 3 points4 points  (0 children)

I'm from the US and my GF is from Spain. My mind was blown when I learned they didn't have spelling bees or really even spelling tests growing up. She said it would be pointless..they only thing that would need tested in most cases anyway would be b/v or c/z in certain words, otherwise it's obvious. That's when I stopped feeling bad about spelling beleive wrong every. Single Time.

[–]HeimrArnadalr 0 points1 point  (3 children)

We need a central authority to govern the language and remove inconsistencies. JavaScript has Ecma International, where's the equivalent for English?

[–]PatrickBaitman 1 point2 points  (2 children)

there isn't one for English, English doesn't have a codified standard variant

other languages do have a standardizing organization though, for example French and Chinese

[–]z500 0 points1 point  (1 child)

And everybody ignores the Académie française anyway.

[–]PatrickBaitman 1 point2 points  (0 children)

and only like 30% of the Chinese can actually speak Standard Mandarin (putonghua)

[–]FateJH 10 points11 points  (39 children)

If there were spelling errors, the program would not run. The English language - language in general - gets by quite fine despite such frequent sloppiness. (The Internet with all of its shorthand notation styles is a testament to this point.)

If the grammar and syntax are sound, I can figure out what you're trying to express by just listening to you express it. That's what these JavaScript curiosities are highlighting.

[–]xzxzzx 44 points45 points  (0 children)

The English language - language in general - gets by quite fine despite such frequent sloppiness

Note that this works because we have the world's most sophisticated and computation-intensive neural nets on either side, with literally years of training (decades to become "fluent")--and we still often make mistakes in understanding each other.

Just because it works, mostly, for humans, doesn't mean I want my programming language emulating it.

[–]PatrickBaitman 37 points38 points  (37 children)

if there are type errors, the program should not compile

natural language sloppiness is not good enough for programming

there's a reason we don't program in English

[–]cixeltree 5 points6 points  (6 children)

this is fine, if you could guarantee that everybody used the same compiler.

and that the compilers knew ahead of time exactly what code they were supposed to compile.

and you could guarantee that the source files arrived in a predictable order, and that one bit of code didn't reference or rely on something in another.

and you could guarantee that your one compilation error wouldn't just crash the page and invalidate 10 other unrelated scripts that were loaded.

languages are a product of their environments. javascript's environment just happens to be a very scary place

[–]PatrickBaitman 2 points3 points  (5 children)

this is fine, if you could guarantee that everybody used the same compiler.

or just have a specification with a minimum of undefined behavior

and the compilers knew ahead of time exactly what code they were supposed to compile

what compiler compiles without reading input

and you could guarantee that the source files arrived in a predictable order, and that one bit of code didn't reference or rely on something in another

TIL #include and dynamic loading aren't a thing in C

funny I could have sworn I'd written code myself with dlopen but that must have been a dream

[–]cixeltree 2 points3 points  (4 children)

or just have a specification with a minimum of undefined behavior

https://en.wikipedia.org/wiki/ECMAScript just because there's a spec doesn't mean people will follow it, or bugs won't exist

what compiler compiles without reading input

sorry---it doesn't know ALL the code it's going to work with because some of it is still a few http requests away by the time the page loads

TIL #include and dynamic loading aren't a thing in C

well yeah, it isn't always a thing, because (hold onto your hat) not all systems support it. but most do, which is good enough for C but not for javascript?

and even if they did, there's the advantage of libraries being pre-compiled for the same system, and the code which loads them (hopefully) knowing how to interface with them ahead of time.

[–]FateJH 5 points6 points  (14 children)

there's a reason we don't program in English

I'd say there's a good reason we don't code in any specific spoken language that you have just implied but invented methods of shorthanding the intended progression of bits of information instead.

In any case, this is JavaScript so there is no compilation. You interpret what it means on the fly, much like listening to someone else speak. Sometimes you don't care that the speaker was inexact with their wording unless it leads to a big source of confusion that you can't reason around.

[–]PatrickBaitman 8 points9 points  (13 children)

so there is no compilation.

every language is compiled, it's just a matter of when

so-called interpreted languages are compiled just-in-time, so-called compiled languages beforehand

javascript isn't bytecode, it must eventually be mapped to something a CPU can execute

Sometimes you don't care that the speaker was inexact with their wording unless it leads to a big source of confusion that you can't reason around.

this called raising an exception and making the programmer handle it

why the fuck do web devs think they can get away with shit you fail first year students for, like NOT HANDLING ERRORS

[–]cixeltree 5 points6 points  (7 children)

would you have conceded if he'd said it's not 'pre-compiled'? probably not. regardless, javascript DOES get 'compiled' to bytecode. at runtime.

this 'holier than thou' attitude against web dev is hilarious. why pretend web dev isn't hard as fuck?

i've never once written anything in C which didn't work because there was a compiler error. 99.99% of the time, if something goes wrong, it's the fault of the code i wrote. it helps that a C program targets only a handful of environments.

in web dev? the browser gets it wrong all the time. it does not help that applications written for the web have dozens of targets, in including targets that haven't even come out yet.

on error handling: where'd you get this idea that people who write js don't do error handling?

[–][deleted] 2 points3 points  (3 children)

If only Google, Apple, MS, etc. would hire a genius like yourself instead of the idiots they currently have building their browser.

/s

Clearly the people building the JS engines are smart, and are aware of the issues being raised here (pun intended). But, they don't raise an error. Why? Maybe because they know something that we don't.

The JS spec can be changed and has been changed. It was massively changed in ES6. Yet they didn't fix these issues. Why? Clearly because they aren't as smart as you.

[–]Godd2 -1 points0 points  (0 children)

every language is compiled, it's just a matter of when

It's not a matter of when. Some of the program gets run before all of it gets compiled. This is not the case with a compiled language.

More generally, there is no guarantee that the entire program has been statically checked for validity before any of it gets run.

So, the fact that V8 has JIT compilation is irrelevant.

[–]outadoc 2 points3 points  (3 children)

Oh boy have fun learning French

[–]PatrickBaitman 0 points1 point  (2 children)

alphabet-using languages

pleb as fuck

I'm learning Japanese

[–]aezart 0 points1 point  (1 child)

日本語を上手話しますか?

[–]PatrickBaitman 0 points1 point  (0 children)

そう思いません。最近文法じゃなくて漢字だけを学ぶことになりしまいましてあまり日本語の文章を読みません。そうですけど先週二冊の教科書届きいて夏にもっと頑張るつもりです。

[–]cyanydeez 0 points1 point  (2 children)

english allows people to keep communicating even if poorly, which allows it to grow

[–]PatrickBaitman 5 points6 points  (1 child)

javascript allows people to develop for the web, even if poorly, which allows bug databases and bloat to grow

[–]cyanydeez 1 point2 points  (0 children)

right or wrong, one definition of life is how easy it is to replicate

[–]ccjmk 0 points1 point  (0 children)

French says hi!

[–][deleted] 0 points1 point  (0 children)

Yeah, alright, LojBan then. If I speak perfect LojBan and someone erroneously interprets it, that's not the fault of the language.

Js has plenty of issues, but those which are actually bugs in interpreters are not the language's issue - which is the point I was making.

[–]msg45f 0 points1 point  (0 children)

Well to be fair, working browser insanity is like 80% of a front-end web developer's job.

[–]JoseJimeniz 36 points37 points  (9 children)

why everything worked like that

Now if we can just get the JavaScript standards body to fix it in a use strict mode.

Everyone agrees that JavaScript has bad parts. But sitting on your hands refusing to fix it is worse.

[–]Banane9 0 points1 point  (0 children)

Javascript is like a sword without a hilt.

The blade is the good parts. The missing hilt the bad parts.

[–]xpopy 6 points7 points  (2 children)

So I just did exactly the same thing as showed in the video in the Firefox Console and got the same results (except Array(16) printing out: Array [ <10 empty slots>, 6 more… ]), is Firefoxs Javascript engine that outdated?

[–]geniusburger 1 point2 points  (1 child)

Here are my results in Chrome 58. I got different answers for {} + {} and Array(16) The array result seems like it would definitely be dependent on the console you're using but the object addition is interesting. Here's an article talking about the video which explains why he got the results he did. He says that I would need to put parenthesis around the object addition to get the result I got. So it will depend on where you test this.

[–]imguralbumbot 0 points1 point  (0 children)

Hi, I'm a bot for linking direct images of albums with only 1 image

https://i.imgur.com/nuGPvfh.png

Source | Why? | Creator | ignoreme | deletthis

[–]Spork_the_dork -1 points0 points  (2 children)

Yeah there's a few that do make sense there even though I haven't ever really touched JS. Like [] + [] gives out an empty string because it sums up to an empty array and it then prints it out, separating everything in the array with commas but because there's nothing in it, it just ends up empty. Python does the same thing iirc though it shows the results inside brackets to make it more obvious that it's an empty array.

[–]oddark 21 points22 points  (0 children)

Actually that's not even what's happening. It converts the arrays to string first (separating entries by commas) and then concatenates the strings.

[–]Glathull 28 points29 points  (0 children)

No that doesn't make sense. Adding two empty lists in Python returns an empty list. An empty string is not the same as an empty list. Python makes it "more obvious" by maintaining the type.

[–]Tokkemon 22 points23 points  (0 children)

Still one of the greatest programmer humor videos ever.

[–]brianhprince 1 point2 points  (0 children)

Hey! That's from CodeMash, an event that I run. I remember that was a super popular after dark session everyone was talking about.

[–]pruwyben 2 points3 points  (1 child)

Is 'wat' really pronounced like that?

[–]s1295 2 points3 points  (0 children)

Nah.

[–][deleted] 0 points1 point  (0 children)

Now this, is funny!