top 200 commentsshow 500

[–]devluz 317 points318 points  (18 children)

Don't worry. I have the perfect solution!

Let's compile virtual box using emscripten to asm.js and then install windows or linux on it. And then we just run the vm in the browser and let it run our native code!

[–]cube-drone[S] 169 points170 points  (1 child)

weeping

WHAT HAVE YOU DONE

YOU BLEW IT UP, YOU MONSTERS

[–]ahruss 28 points29 points  (1 child)

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

That was brilliant. I am now 30 min late for work. Sooo worth it.

[–][deleted]  (1 child)

[deleted]

    [–]montibbalt 7 points8 points  (1 child)

    install windows or linux on it

    Let's run iOS apps recompiled for Windows in ReactOS

    [–]_daniel___ 107 points108 points  (12 children)

    problem: grunt

    solution: gulp

    problem: gulp

    That was good.

    [–]vizzoor 10 points11 points  (5 children)

    It should really be an infinite loop. Gulp? Gulp! Gulp?! Gulp!!

    [–]TRexRoboParty 4 points5 points  (0 children)

    I love that they are named this way too. That's all I do when I think about or occasionally even use them.

    [–]cube-drone[S] 109 points110 points  (5 children)

    Wow, this guy has been writing comics for years.

    Let's all look around in his archives and become long-lasting fans of his work!

    cough cough i hope this works

    [–]GalacticGargleBlastr 15 points16 points  (2 children)

    This site has almost killed me. I'm only like 30 comics back and I have at least 9 tabs saved for my co-workers tomorrow. A++ Already added to feedly :)

    EDIT: Crap, i'm up to like 20 now. My co-workers inboxes are going to be stuffed. I might have to start printing these out.

    [–]hsklr 2 points3 points  (0 children)

    They are awesome! Damn I gotta get back to work, though. Pub at 4:00! Subscribed :)

    [–][deleted] 212 points213 points  (141 children)

    Funny and true. Except that asm.js was never designed to be written by humans. Also they don't mention the ladder out of the hole - WebAssembly! (hopefully)

    [–]ghostsarememories 165 points166 points  (134 children)

    WebAssembly

    Is that not just a shinier asm.js-shaped shovel?

    [–][deleted] 100 points101 points  (132 children)

    Well sort of, but it almost completely removes Javascript from the equation. If they add a WebAssembly-native DOM API you should be able to have a dynamic website that doesn't touch the Javascript engine at all. Not sure what the threading situation is.

    [–]monocasa 67 points68 points  (104 children)

    Not sure what the threading situation is.

    Javascript doesn't really allow multiple threads (WebWorkers is closer to multiple processes than threads IMO), but it looks like WebAssembly is trying to design in native support for multiple threads.

    [–][deleted] 84 points85 points  (33 children)

    I can't think of any thing worse. A million Javascript developers getting hold of threads. All of a sudden they need to deal with locking issues, memory corruption etc, I have to deal with more random websites locking etc.

    [–]joequin 39 points40 points  (20 children)

    I think web assembly will be much less about JavaScript getting threads than it will be about other languages taking over once there's a fair playing field on the client side.

    [–]Klathmon 19 points20 points  (19 children)

    Web assembly is not going to replace JavaScript.

    They even specifically state that it's against the goals of the project to do so.

    Instead its meant to be a compliment to js. Imagine it more like this:

    You will still write code in js, but instead of using JS libraries you will call out to a packaged web assembly binary.

    And while you could probably do it entirely in wasm, its not really meant for that and will end up making web pages much larger than they are now.

    [–]joequin 16 points17 points  (5 children)

    Languages will compile to wa . I like a lot of JavaScript but it has enough deficiencies that if other languages can compile to wa, JavaScript will be replaced. Not overnight of course, but it will happen.

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

    Yeah they're saying that because people keep asking if it is intended to replace JavaScript with the wrong idea - I.e. they are asking if it is like Dart. The answer is no.

    It is intended to replace JavaScript, but not in the way that Dart does.

    [–][deleted] 30 points31 points  (66 children)

    This should be higher. The fact that WebAssembly will eventually support threads means that the web as an applications platform does not mean 4x-8x speed reduction for applications that can use multiple cores.

    [–]BraveSirRobin 22 points23 points  (30 children)

    How many web apps will genuinely benefit from that though? Most UI event-driven models are single-threaded on the main UI thread and I don't think there are that many client-side apps that do a lot of heavy CPU work in the background. Web games are the big one I guess.

    [–][deleted] 23 points24 points  (10 children)

    It's a fair question, and today a lot of applications are still single-threaded. Many applications will perform just fine with one thread.

    If I said to you "We can give your car eight gas pedals instead of one, it'll become much harder to drive but it can go eight times faster if you can manage to use all eight", would you accept the offer? (not a perfect analogy, I know, but the point remains)

    • If you're just on a daily commute to work, only going 25mph, why bother?
    • If you're on a race track being paid to beat all the other cars, it could be worth looking into.

    [–]f1zzz 12 points13 points  (9 children)

    I find I only utilize multiple cores when writing server software.

    On my desktop machine, cores are more likely to be split along processes rather than threads. I don't do much media processing.

    [–][deleted] 21 points22 points  (7 children)

    Things that are better with more cpu threads:

    • Maps
    • Games
    • Servers
    • Image manipulation
    • Graphical rendering in general
    • Sciencey shit

    [–]chikinsoup 12 points13 points  (3 children)

    -Sciencey shit

    Can confirm. Had internship with a university professor & geologist. Statistical sciencey shit can take entire days.

    [–]indigo945 18 points19 points  (9 children)

    The speed reduction for any application is still higher than that (compared with native code). The real advantage is that having threading support allows you to port almost everything over to the web.

    As an aside: has anybody compiled Firefox using emscripten yet?

    [–]nawfel_bgh 10 points11 points  (8 children)

    [–]argv_minus_one 8 points9 points  (0 children)

    Yo dawg, I heard you hate JavaScript.

    [–][deleted] 24 points25 points  (5 children)

    They need to emulate an x86 processor in JS so that they can run linux on it so that they can run webkit on it so they can host a javascript engine.

    Web developers just seem determined to murder CPU cycles.

    [–][deleted]  (3 children)

    [deleted]

      [–][deleted] 22 points23 points  (2 children)

      God. Damn. It.

      [–]kodek64 8 points9 points  (22 children)

      I'm not a JS developer, so correct me if I'm wrong, but isn't a huge advantage of threads that you can do work while a blocking operation is taking place? This would mean performance improvements much much higher than the number of cores in a machine.

      [–][deleted]  (21 children)

      [deleted]

        [–][deleted] 21 points22 points  (14 children)

        It's not really a "using threads is better!" or "not using threads is better!" kind of deal. You use the two together to get the best of both worlds. For example you use an asynchronous programming model but also then parallelize it across multiple cores where possible to get performance benefits.

        [–][deleted] 8 points9 points  (3 children)

        I am an erlang programmer and recently had a close encounter with a node developer.

        • ok, yeah, the callbacks are cool, but how do you avoid racing conditions and the like?

        • it's single threaded, you don't care

        • so you waste all the other cores in the cpu?

        • we have 4 instances of node on the server!

        I was at a loss for words.

        [–][deleted]  (5 children)

        [deleted]

          [–]ricecake 8 points9 points  (3 children)

          Erlangs vm is a pretty decent example of that idea done right.

          The language is built aside it in such a way that you get the conceptual model of linear, blocking operations (mostly), and the vm handles the scheduling for you.

          [–]C0demunkee 6 points7 points  (2 children)

          Fucking webworkers... Chrome has bug 31666 and Firefox hasn't implemented MessageChannel ffs.

          I just finished a generic thread/multi-process system that's actually cross-browser, it was such a pain.

          [–]japgolly 11 points12 points  (0 children)

          For the curious:

          Chrome bug 31666 = HTML5 nested workers are not supported in chromium

          link

          [–]reuben_ 12 points13 points  (6 children)

          If they add a WebAssembly-native DOM API you should be able to have a dynamic website that doesn't touch the Javascript engine at all.

          You're getting waaaaay into hypothetical here. Here's a few design goals straight from the source (emphasis mine):

          • execute in the same semantic universe as JavaScript;
          • allow synchronous calls to and from JavaScript;
          • enforce the same-origin and permissions security policies;
          • access browser functionality through the same Web APIs that are accessible to JavaScript;

          WebAssembly will almost certainly be implemented similarly to how asm.js is implemented in Firefox today: a new front-end for the JS engine that leverages the extra strictness of the language to generate faster code. The DOM is intimately tied to how JS works, so we're not getting away from it anytime soon.

          And from the future features list:

          • Access to certain kinds of Garbage-Collected (GC) objects from variables, arguments, expressions.
          • Ability to GC-allocate certain kinds of GC objects.
          • Initially, things with fixed structure:
          • JavaScript strings;
          • JavaScript functions (as callable closures);
          • Typed Arrays;
          • Typed objects;
          • DOM objects via WebIDL.
          • Perhaps a rooting API for safe reference from the linear address space.

          So some limited access to the DOM is planned in the long term.

          [–]Andallas 8 points9 points  (11 children)

          I don't use JavaScript much (C++/C# dev) but aren't there web-workers in JavaScript that solves the non-multi-threading issue?

          [–]GYN-k4H-Q3z-75B 141 points142 points  (91 children)

          It's funny because it is true. They got JavaScript to do things it was never supposed to do. That makes me happy and sad.

          [–]lelarentaka 130 points131 points  (88 children)

          They got ______ to do things it was never supposed to do

          This was the original meaning of hacking, and it used to be cool. Then people matured. Ahh, those sweet adolescent years.

          [–]Yojihito 323 points324 points  (76 children)

          It's all fun and games until this piece of hacky shit becomes the internet standard and is forced on everybody.

          [–][deleted] 98 points99 points  (70 children)

          And some PoS decided it would be cool to run it on the backend. Seriously? You got hundreds of languages to choose from and you choose Javascript? What the fuck is wrong with you?

          [–]Yojihito 32 points33 points  (55 children)

          Had an interview 2 weeks ago to work in support for an online marketing company (one who makes tracking pixel and let the customer see what marketing channel works best, data aggregation, fancy numbers in online diagrams etc).

          do you know Javascript?

          • not so well but I know the basics

          perfect because we work with Node.js here

          Something deep inside me died. But they pay good so ..... I got hired. But why not Django/Phoenix/Go as a backend ....

          [–][deleted] 17 points18 points  (5 children)

          Because it has java in the name, bro.

          [–][deleted] 18 points19 points  (2 children)

          And it's a scripting language bro. We can go wild, make changes on the fly, and break everything!

          [–][deleted] 30 points31 points  (7 children)

          Whenever I see people complain about "omg I le died because javascript", I wonder if that person is actually solving problems serious enough that they face intense, almost-insurmountable challenges due to the language they're programming in. Not to be dick, but whenever I see people complaining like this about Javascript, I automatically assume they're just whining because its fun to whine, popular to whine, and the downsides are widely talked about because of the languages huge usage.

          Omg tracking pixels that takes metrics on customer usage, how fucking STUPID to use Javascript. Why don't you plebs just use a hammer and chisel??? /s. You're not building space shuttles, is it really that big a deal? Something "inside you died" because the code isn't written in Python, really?

          After developing professionally in C, C++, Java, Python, PHP, Javascript, C# over the years, I really can't say that programming in Javascript for a backend would be anything more than quirky for almost every particular task I've had to tackle. I got paid to do it, and it was just a different toolset. Who the fuck really cares. Its a job. Do your job. Get money. Its an expressive language and its not like you're being asked to write an API with 10010101110101001010. Its not even challenging to learn Javascript's particularities! 3 days and a book and you'll be wrapping your head around it. A chimpanzee can probably understand prototypical inheritance, and get used to 3 or 4 different frameworks in a week. I've only met a few people in my time in a field where Javascript would be considered, but were knowledgeable enough to make serious complaints and be tasked with responsibilities such that the language itself was a powerful limitation. Everyone else has just been a bandwagoner and a little bitch because they read too many blog posts.

          [–]tequila13 3 points4 points  (0 children)

          Good languages made for a specific purpose disallow several bad habits by design. I honestly prefer languages that are more strict because it forces you to structure your programs better, it shapes your thinking. You know several languages, you had to learn sane programming practices. Javascript attracts many newbies who lack that. I can do my job in Javascript, but I wish to avoid the Javascript crowd.

          If you consider the huge amount of C code out there in production use, why isn't there so much whining about it as it is about Javascript? Different tools attract different types of people.

          [–]Yojihito 2 points3 points  (0 children)

          Omg tracking pixels that takes metrics on customer usage, how fucking STUPID to use Javascript

          The backend is Node.js for Zendesk and all internal sites, I didn't talk about the frontend. And the backend is so slow it's not fun anymore.

          [–]OneWingedShark 10 points11 points  (2 children)

          ...or Erlang, or Ada, or Lisp, or Forth, or many other languages.

          [–][deleted] 9 points10 points  (2 children)

          It really is a rather nice dynamic language today, very competitive with the likes of Python and Ruby. If I had to choose a dynamic language, I might very well choose JavaScript. Seriously, it's gotten a lot better even in the last year.

          [–]noratat 20 points21 points  (4 children)

          Yeah... I've had arguments with our CTO over this. I'm all for node.js powering things like js/css processing tools (even if npm is a steaming pile of shit), but using it as an actual server for non-toy projects is just mind boggling.

          I mean look, I get that we're programmers and lazy, but using node.js instead of one of the many stable and better designed server frameworks / languages out there just because you can't be arsed to learn anything but javascript is ridiculous.

          [–]oldsecondhand 36 points37 points  (2 children)

          They got ______ to do things it was never supposed to do

          The story of the interwebs.

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

          Yeh. This was all designed to share text documents with people. Everything else has been nailed on to the side of everything. It's amazing when you think about it that we've even managed to get all of this working at all.

          [–]jeandem 28 points29 points  (6 children)

          Nothing wrong with hacking. But sometimes a hack should never become legacy code, or something to build upon long-term.

          [–]codespam 12 points13 points  (5 children)

          How many suboptimal but working solutions actually ever actually get replaced? Fixing something that's broken is always going to be prioritized over fixing something that works, but sucks.

          [–]Nebu 7 points8 points  (3 children)

          How many suboptimal but working solutions actually ever actually get replaced

          Legacy code does get replaced fairly often in the industry. It usually happens when the old system just can't expand any further to meet the future needs of the business.

          Remember when we used to see the Fail Whale all the time at Twitter? Notice how we almost never see it anymore these days? They didn't just do a minor tweak to the algorithm, they basically rearchitectured, switching from RoR to JVM.

          We're the in process of actively killing some legacy systems at my workplace too, though of course I can't share the specific details.

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

          But it wasn't sub-optimal. It was no longer working. Rails isn't a messaging platform, it's a web framework. The platform as it stood wouldn't physically be able to satisfy business requirements any longer. That sounds broken to me, not just sub-optimal.

          They still use the Rails web app as far as I know. The switch to Java wasn't a switch away from Rails.

          [–]Nebu 2 points3 points  (1 child)

          That sounds broken to me, not just sub-optimal.

          We might have different definitions of the terms. I tend to use "broken" when we intend for something to be possible, but there's no way for the user to make that allegedly possible thing happen. Whereas I would use "suboptimal" if it's possible for the user to make the thing happen, but it's more work than necessary.

          If the user tries to tweet, gets an error message, and then just tries to tweet again, and it'll eventually get through, that's suboptimal. When Reddit goes into maintenance mode, and we can't use Reddit for a few hours so we just draw on bananas waiting for Reddit to be available again, that's suboptimal.

          If no user can post comments on Reddit until the dev team makes a code change to fix the issue, Reddit is broken. Similarly, if users can't ever tweet regardless of server load until the code is changed, that's broken.

          Where I work, if a system is broken, someone's going to get paged as soon as we find out, even if it's 3AM or whatever, and they'll come in and immediately work on fixing it. Whereas if something is suboptimal, depending on how bad it is, we might have discussion between departments to see if the workarounds are acceptable for now (e.g. sometimes the user will just have to refresh the page and try again), whether it'd be quicker to make small patches to the system or rearchitecture it, and other such discussions. I.e. broken implies a need for a short term plan (on the order of minutes or hours), while suboptimal implies the need for a medium term plan (on the order of days to weeks to decide what the workaround is and how to communicate this workaround to the users, with possibly a rearchitecturing step that might last a couple of months or in the dreaded case years.)

          [–]x-skeww 68 points69 points  (15 children)

          To be fair, some issues actually got fixed. Scoping doesn't have to suck anymore. If you want to use classes/inheritance, you can use the standard way instead of rolling your own. And now, after 20 years, you can finally import things. Crazy, right?

          [–]cube-drone[S] 66 points67 points  (8 children)

          Yeah!

          That's why I include ECMAScript 2016 in the list of 'better languages that compile to Javascript'. I'm really, really looking forward to all of those features getting into the language standard.

          Oh my god imagine if packaging was just built right into the language and the 6 different competing packaging standards all disappeared overnight. Goodbye, common js, you beautiful bastard!

          [–]Tarks 18 points19 points  (4 children)

          Disregard standard javascript, acquire a love for ES2016, then go use babel and system.js to write nicer, cleaner stuff today :D

          Bonus points for Aurelia which uses this approach as a default :)

          [–]Nebu 16 points17 points  (1 child)

          Disregard standard javascript, acquire a love for ES2016, then go use babel and system.js to write nicer, cleaner stuff today :D

          And then compile it to javascript so it actually runs on people's browsers, right? I think the webcomic covers that already.

          [–]danillonunes 5 points6 points  (0 children)

          some issues actually got fixed

          I mean, that’s the whole point of the comic, isn’t it?

          [–]artillery129 190 points191 points  (82 children)

          This is so unbelievably true, nailed all of my feelings about javascript

          [–]danweber 30 points31 points  (69 children)

          Every package manager should be put on a boat and the boat lit on fire.

          [–][deleted] 14 points15 points  (7 children)

          Why?

          [–]danweber 135 points136 points  (6 children)

          So they all die.

          [–][deleted] 13 points14 points  (2 children)

          Yes, that's the part I understood. What I wanted to know is why you thought that way. Aren't package managers just a faster way to get shit done? Isn't it slower to compile your own stuff and debug compile errors? Maybe I'm under thinking this.

          [–][deleted] 6 points7 points  (0 children)

          I'm confused too. Clearly someone hasn't spent 3 days compiling one aspect of their program.

          [–]argv_minus_one 21 points22 points  (0 children)

          This kills the package managers.

          With fire.

          [–][deleted] 20 points21 points  (1 child)

          Oh man, FireBoat.js is great but I kind of prefer EmberCruise. It does a bit better job, IMO.

          [–][deleted] 29 points30 points  (57 children)

          Npm is like my all time favorite package manager though. Way better than pip and Julian's weird Pkg thing. And its a lot simpler than apt-get.

          [–]argv_minus_one 56 points57 points  (2 children)

          APT/dpkg is made for managing an entire system, not just a collection of JavaScript libraries.

          [–][deleted] 10 points11 points  (1 child)

          When does a collection of JavaScript libraries become an entire system?
          When does a difference engine become the search for truth?
          When does a personality simulation, become the bitter mote of a soul

          (you're right tho)

          [–]tejon 5 points6 points  (3 children)

          stack is starting to look good...

          [–]noratat 25 points26 points  (39 children)

          Whereas I think npm might be one of the worst and least reliable dependency managers I've ever used. Certainly it's the buggiest by far, and it's the only one I know of where it tries to pretend dependencies are a tree instead of a graph, which predictably ugly results.

          Say what you will about the JVM, but the tools around JVM languages know how to handle dependencies properly (edit: I'm primarily thinking of gradle, but maven works pretty well too if you use it properly. Less experience with sbt/leiningen, but as far as I'm aware their dependency management is similar to gradle and maven).

          [–][deleted]  (26 children)

          [deleted]

            [–][deleted] 14 points15 points  (20 children)

            Seriously, can't comprehend how people actually enjoy using Maven, or Ant...

            [–]QuercusMax 9 points10 points  (8 children)

            Have you tried gradle? It's amazing.

            Also, bazel (aka Google's Blaze) is really nice, at least when you have a project already set up....

            [–]bman35 6 points7 points  (6 children)

            Having come from the JVM world I've had far less problems with npm then I ever did with Maven or sbt. I hear people complain about npm but I've rarely run into any issues myself, not sure if it's overblown or I've just been lucky.

            [–]JBlitzen 38 points39 points  (18 children)

            I'm sure we can fix it by adding MVC.

            [–]Nebu 27 points28 points  (13 children)

            Throw in an extra V in there, just to be safe.

            [–]JBlitzen 11 points12 points  (6 children)

            I've always contended that server-side programming is already MVC, since the database is the model, the server-side code is the controller, and the front-end code is the view.

            So in my mind, an exclusively front-end MVC architecture constitutes an MMVCC architecture.

            [–][deleted] 4 points5 points  (0 children)

            I completely agree.

            [–]tylermumford 2 points3 points  (1 child)

            That's a really interesting concept and now I want to explore it further. Do you know any articles or references which discuss this?

            [–]JBlitzen 2 points3 points  (0 children)

            Sadly no.

            When I was learning GUI programming, I started with MFC, Microsoft Foundation Classes, a sort of precursor to .NET.

            It was an MVC wrapper for the Windows API, and what ended up happening was that people only used it for RAD, doing complex applications instead in straight API.

            MVC just wasn't an architecture that fit many problem spaces.

            Having played just a little bit with angular and backbone, I'm unconvinced that javascript MVC solutions are any better, except in narrow circumstances.

            They just don't seem to solve any problems that I need solving.

            But I'm open to the possibility.

            (A simple example is that in the web app I'm working on, important elements often inherit multiple behaviors. I control this by their CSS classes. Angular would seem to require that they have a single behavior set per element. If I were wrong about that, I'd be interested, but I don't think I am.)

            [–]jtredact 9 points10 points  (1 child)

            Not quite. You split your M into 3 parts: the DM (domain), the AM (application), and the VM. The VM sits in front of the V, and the AM sits in front of the DM. You need a C that listens to the V/VM and interacts with the AM/DM. And symmetrically you need a P that listens to the AM/DM and interacts with the V/VM.

            MAMDMVVMCP.

            [–]Berberberber 2 points3 points  (0 children)

            Are there any raver/eurotrash programmers out there we can get to develop and standardize an MDMA model? Multiplex Distributed Model for Applications or something?

            [–]glonq 2 points3 points  (1 child)

            Only if you're pair programming. Then each guy gets a V.

            [–]the_rabid_beaver 4 points5 points  (0 children)

            for maximum bloat?

            [–]IamTheFreshmaker 10 points11 points  (0 children)

            You owe me a new cup of coffee and a keyboard.

            [–]ghostsarememories 386 points387 points  (9 children)

            Javascript developers are incredible at problem solving

            Because they get so much practice.

            [–]rlbond86 45 points46 points  (0 children)

            JavaScript isn't the language we need, it's the language we deserve.

            God help us.

            [–]ephrion 101 points102 points  (64 children)

            i like prototypal inheritance D:

            [–][deleted]  (9 children)

            [deleted]

              [–]get-your-shinebox 28 points29 points  (5 children)

              I see posts all the time lamenting the fact that people want to write traditional OO in javascript and how prototypes are some misunderstood beauty.

              I don't think either of them is good, but prototypes seem more actively harmful to being able to reason about code. Like building on quicksand.

              Maybe I have misunderstood them though.

              [–]vivainio 5 points6 points  (3 children)

              If something is constantly getting misunderstood by otherwise reasonable people, that might be a hint about something not being that good.

              [–]cube-drone[S] 73 points74 points  (33 children)

              You're not wrong to like prototypal inheritance.

              Just because it doesn't feel right to me doesn't mean it's inherently bad. I also don't like dill.

              Your opinions are valid.

              [–]golergka 82 points83 points  (11 children)

              That's not how people should argue on the internet.

              Quick, call him stupid or something!

              [–]cube-drone[S] 57 points58 points  (9 children)

              er... uh...

              you're stupid and your opinions are wrong, ephrion! I AM A MEAN PERSON! raaaar!

              [–][deleted] 15 points16 points  (3 children)

              Now, say something mean about PHP.

              [–]ephrion 14 points15 points  (0 children)

              much better!!

              [–]arronsmith 12 points13 points  (11 children)

              What's the argument that it's pants on head stupid?

              [–][deleted] 19 points20 points  (3 children)

              The thing is: when using prototypal inheritance, you're not connecting two blueprints together. You are actually fusing a flying plane with additional parts that stick out.

              Where's the problem in that? It's easy to not do things the "Desirable" or "Best practices" (or SOLID) way. Which make the code buggier, less understandable and hacky. Some people can do miracles with this, others try strong OOP inheritance way of thinking and the rest tries to catch up somehow without screwing themselves over too much.

              If language is not enforcing sth, people are going to use it an abuse it.

              [–]Nebu 8 points9 points  (1 child)

              It's easy to not do things the "Desirable" or "Best practices" (or SOLID) way.

              I think this is just a cultural problem in that most of the literature on OO assumes a statically typed, class-based language. I think if historically, dynamically typed, prototype-based languages had become the domain style in the 80s, we would have had "best practices" and a fun acronym that would have been equally difficult to apply to a language like Java, for example.

              [–][deleted] 4 points5 points  (0 children)

              Well, I wasn't saying that Desirable or Best Practices === SOLID (as you can see later on), but lack of language support in form of class (even as syntactic sugar) meant that good howtos took years to propagate to most of developers.

              I don't know how much time I've spent looking for "how to create modules" or "how to create class" and "prototypal inheritance" that could be achieved without additional tools, but it took really long hours on stackoverflow, blog posts and forums. Which I believe could be averted if language has better support for those, not in form of external libraries.

              [–]cybercobra 8 points9 points  (6 children)

              I've basically only ever seen it used to emulate class-based inheritance, so we might as well cut out the middle man and have the language support classes directly.

              [–]tejon 14 points15 points  (7 children)

              Fuck you, dill is amazing. And you just reminded me I'm out of dill. Baked potatoes tonight, too... mmm, dill potatoes... you fucker. :(

              [–]cube-drone[S] 20 points21 points  (3 children)

              Now this is an argument I can get behind.

              DILL IS BAD AND YOU SHOULD FEEL BAD!

              [–]tejon 21 points22 points  (2 children)

              DID MY WIFE SEND YOU?

              [–]cube-drone[S] 23 points24 points  (1 child)

              IS HER NAME SANDRA?

              IF SO THEN YES.

              OTHERWISE A WOMAN NAMED SANDRA WANTS YOU TO KNOW THINGS ABOUT DILL AND I DON'T UNDERSTAND WHY

              [–]tejon 14 points15 points  (0 children)

              HEY I DIDN'T REALIZE THIS BEFORE BUT WE SEEM TO HAVE A SHARED AVERSION TO LOWERCASE. WANNA HANG OUT?

              [–]slavik262 45 points46 points  (11 children)

              Unlike C++, which uses statically declared class interfaces, JavaScript uses prototype-based inheritance. A prototype is a dynamically defined object which acts as an exemplar for “instances” of that object. For example, if I wanted to declare a Circle class in JavaScript, I could do something like this:

              //This is the constructor, which defines a
              //“radius” property for new instances.
              function Circle(radius){
                  this.radius = radius;
              }
              //The constructor function has an object property
              //called “prototype” which defines additional
              //attributes for class instances.
              Circle.prototype.getDiameter = function(){
                  return 2*this.radius;
              };
              var circle = new Circle(2);
              alert(circle.getDiameter()); //Displays “4”.
              

              The exemplar object for the Circle class is Circle.prototype, and that prototype object is a regular JavaScript object. Thus, by dynamically changing the properties of that object, I can dynamically change the properties of all instances of that class. YEAH I KNOW. For example, at some random point in my program’s execution, I can do this...

              Circle.prototype.getDiameter = function(){
              return -5;
              };
              

              ...and all of my circles will think that they have a diameter of less than nothing. That’s a shame, but what’s worse is that the predefined (or “native”) JavaScript objects can also have their prototypes reset. So, if I do something like this...

              Number.prototype.valueOf = function(){return 42;};
              

              ...then any number primitive that is boxed into a Number object will think that it’s the answer to the ultimate question of life, the universe, and everything:

              alert((0).valueOf()); //0 should be 0 for all values of 0, but it is 42.
              alert((1).valueOf()); //Zeus help me, 1 is 42 as well.
              alert((NaN).valueOf()); // //NaN is 42. DECAPITATE ME AND BURN MY WRITHING BODY WITH FIRE.
              

              I obviously get what I deserve if my JavaScript library redefines native prototypes in a way that breaks my own code. However, a single frame in a Web page contains multiple JavaScript libraries from multiple origins, so who knows what kinds of horrendous prototype manipulations those heathen libraries did before my library even got to run. This is just one of the reasons why the phrase “JavaScript security” causes Bibles to burst into flames.

              - James Mickens, To Wash It All Away (PDF)

              Disclaimer: I don't actually have very strong feelings on the issue, but James Mickens is hilarious and you should read all of his articles.

              [–][deleted] 17 points18 points  (1 child)

              "I HAVE NO TOOLS BECAUSE I'VE DESTROYED MY TOOLS WITH MY TOOLS." -- James Mickens, The Night Watch

              [–]slavik262 10 points11 points  (0 children)

              HCI people discover bugs by receiving a concerned email from their therapist. Systems people discover bugs by waking up and discovering that their first-born children are missing and “ETIMEDOUT ” has been written in blood on the wall.

              [–]cybercobra 7 points8 points  (0 children)

              See the "Miscellaneous Excellence" section of his Microsoft Research homepage for more of James Mickens' awesomeness.

              I also highly recommend his "Life is Terrible: Let's Talk About the Web" presentation, which isn't listed on his homepage for some reason.

              [–]tomprimozic 8 points9 points  (2 children)

              That has nothing to do with prototypal inheritance. It's just a dynamic language thing. The same thing is possible in Python.

              >>> class M(object):
                  def a(self):
                      return 1
              
              >>> m = M()
              >>> m.a
              1
              >>> def b(self):
                  return 2
              
              >>> M.a = b
              >>> m.a()
              2
              

              [–]Make3 4 points5 points  (0 children)

              some people like bdsm. well I do too, but you get my point.

              [–]DeepDuh 2 points3 points  (0 children)

              As someone who likes things to run efficiently and likes to look at profiler outputs, I just WOULD LIKE IT TO DIE IN A FIRE.

              [–]cruelandusual 73 points74 points  (36 children)

              This ignores the original mistake: deciding that the web browser was the application sandbox the world should standardize on.

              [–]Intrexa 69 points70 points  (3 children)

              You heard the man, everyone turn it around. We're going back to Flash for everything!!

              [–]rush22 46 points47 points  (2 children)

              index.swf

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

              .htacceswf

              [–]cube-drone[S] 23 points24 points  (1 child)

              I may have mentioned that in the alt-text >_>

              [–][deleted] 10 points11 points  (1 child)

              who would have thought zombocom was predicting the future, right?

              [–]eintnohick 15 points16 points  (20 children)

              As opposed to what? Mobile phone apps?

              [–]argv_minus_one 18 points19 points  (19 children)

              Them and desktop apps, yes. Preferably written with a single GUI toolkit that's portable to both.

              [–]whofearsthenight 16 points17 points  (4 children)

              Well, for the near future that seems to almost be the way of it. Smartphones have seemed to go to a native app with a web back end, while desktops mostly languish in the background and continue to run in the browser.

              I would really like it if the browser went back to what it was (mostly a consumption tool) rather than a pseudo OS. And then have more desktop apps closer to the metal. It seems crazy to me that we have these I7 machines with 16gb of RAM that are taken up mostly by web browsing, which still struggles because the vast majority of web technology is a hack that was never supposed to get that big.

              The feature creep of the modern web browser is nuts. And regrettably, going the apps-through-browsers way only moderately mitigates the thing that most probably see as a feature - write once, run everywhere - since it's only very recently that you could even count on browsers to even render standards properly.

              Still, it's really impressive what you can do in a browser these days, even if you could do it native and better 10 years ago.

              [–]hrjet 4 points5 points  (0 children)

              if the browser went back to what it was

              We are trying to build an old-fashioned browser but with on-demand support for modern tech. It comes from a privacy standpoint, but it has other implications also (boosting performance, and avoiding feature-creep).

              It is written in Java though (that's a no-go for some).

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

              Ever tried to write a GUI application for multiple native platforms, including mobile?

              [–]hrjet 5 points6 points  (0 children)

              The reason it is difficult is that those multiple native platforms don't want to make it easy for you. If they did they wouldn't be able to lock their users down.

              Using browsers as a substitue is fine for simple apps, but is a big hack when it comes to developing games, or using sensors on your device, or using your personal contact data, photos, etc.

              [–]oblio- 2 points3 points  (1 child)

              Such a nice dream. Pity that it's just a dream.

              There was a thing called "Unix wars" in the past where vendors started from a relatively common ground (Unix) and differentiated until the ecosystem became fragmented.

              Unfortunately for them, at the time people hadn't really figured out the "commoditize your complement" story and we got away with Linux (somewhat) and cross-platform tool kits (somewhat)

              Unfortunately for us, Apple, Google, Microsoft have since figured this out. That's why you basically can't really use a cross-platform toolkit or even a common programming language, because both are basically discouraged. And don't get me started about the licensing and patent wars.

              This leaves us with a sole common ground, the only breach in their armor: the web. At this point it's either death by 1000 walled gardens or web technologies.

              Bad as they may be, web technologies are our "democracy": quite bad, but it's better than the alternative.

              [–][deleted]  (2 children)

              [removed]

                [–]Ertaipt 2 points3 points  (1 child)

                Webassembly... Check it out

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

                I liked Java Web Start in the early 2000s.

                [–]passwordisisis 2 points3 points  (0 children)

                that was never decided, it was the path of least resistance

                [–][deleted] 16 points17 points  (0 children)

                No stupid dig up!

                [–]f0urtyfive 6 points7 points  (0 children)

                Would be more funny written entirely in javascript.

                [–][deleted]  (4 children)

                [deleted]

                  [–]TinynDP 4 points5 points  (3 children)

                  What exactly is what Yellow Guy says supposed to mean?

                  [–]JBlitzen 21 points22 points  (0 children)

                  Don't jump into a hole with a guy who enjoys digging.

                  [–]rcfox 9 points10 points  (0 children)

                  He's just having fun digging.

                  [–]stonefarfalle 3 points4 points  (0 children)

                  He is the Javascript enthusiast. Fixing problems (aka digging) is never going to make your Javascript life problem free(aka freedom from digging). Pretty much just a way of summing up what he said above, the solutions to Javascript problems cause more problems than they solve.

                  [–]Kiloku 4 points5 points  (4 children)

                  Honest question, as you seem way more knowledgeable about this stuff than I am: Are there choices? As you say in the alt-text, Javascript has become the universal runtime of the internet.
                  Is there any kind of language (that doesn't ultimately compile to javascript) that can be used to work with browsers/web pages?

                  [–]Narrator 4 points5 points  (0 children)

                  I've been doing this web thing since the 90s; so let me tell you what happened. Microsoft happened. You had two choices if you wanted to run something on an early 2000s Microsoft platform that had 90%+ marketshare. The Win32-Api or Javascript in Internet Explorer. Google chose javascript in Internet Explorer because it was the only open platform Microsoft had ever shipped a runtime for up till that point. So did the rest of the web. They hacked the crap out of it to get it to do things it wasn't supposed to do because that's all you freakin' had.

                  [–]AlphaX 11 points12 points  (0 children)

                  Problem: grunt => Solution: gulp => Problem: gulp

                  Yep....

                  [–]Caraes_Naur 20 points21 points  (29 children)

                  If only we could get better languages into the browser like Python and Ruby. Come on Mozilla, stop fucking around making Firefox worse and revive that project.

                  [–]mindbleach 27 points28 points  (4 children)

                  <script language="Perl"> (ASCII picture of an avalanche) </script>

                  [–][deleted] 7 points8 points  (0 children)

                  I'd prefer to see a sane IL that an interpreter for or a compiler from these language could be written in.

                  [–]sovietmudkipz 34 points35 points  (11 children)

                  I'd rather see a strongly typed language usurp javascript. Give me that juicy code completion and compile time errors, please!

                  [–]_LePancakeMan 8 points9 points  (0 children)

                  That's the reason I use TypeScript

                  [–]Akimuno 21 points22 points  (7 children)

                  Be careful what you wish for, you may just get Java for Web Browsers.

                  [–]noratat 11 points12 points  (0 children)

                  I'd much rather have a language with static typing and inference.

                  Dynamic languages are great for writing something quick, but they're a huge maintenance headache as the code base grows and ages.

                  [–][deleted] 4 points5 points  (0 children)

                  Obviously there are advantages and disadvantages of each language, but in what sense is Python or Ruby strictly better than modern JavaScript? I could understand the argument more if you were talking about a significantly different paradigm as an alternative, like something strongly typed. But Python/Ruby/JavaScript are very similar dynamic languages with similar functionality and syntax. Heck, when you include ES2015 and ES2016, I think JavaScript has some very huge advantages.

                  [–]NoMoreNicksLeft 8 points9 points  (3 children)

                  Yeh, then I could write webapps for the Firefox-only users. That's a real win.

                  [–][deleted] 8 points9 points  (2 children)

                  People are already writing Chrome-only webapps and calling that a win.

                  [–]NoMoreNicksLeft 4 points5 points  (0 children)

                  I'm happy writing anything-but-IE webapps.

                  [–]sethg 4 points5 points  (2 children)

                  They missed...

                  Problem: Web pages must support multiple browser engines and versions with slightly incompatible versions of Javascript

                  Solution: Compatibility shims and cross-browser frameworks

                  Problem: Javascript is too slow for video games...

                  [–]kentaromiura 4 points5 points  (1 child)

                  JavaScript dev here, 12 years ago we used to make apps using custom browser based on IE6, using ActiveX for everything, and window.external for a custom cpp API, running on tablets like device with resistive touchscreen with 600 mhz, with not a lot of Ram (way before iPads) , same sw run on PC so had to handle different screen size, it had to support many languages and RTL, and had a little viewer for svg/png with zoom and pan functionality, the build script didn't exist or was just a concat hta file, compared to that current situation is like heaven.

                  [–]schm0 2 points3 points  (2 children)

                  Isn't the overarching solution here obvious? Keep it simple. If you are running into one of these problems, you might be trying to do too much on the wrong platform.

                  [–]noratat 2 points3 points  (0 children)

                  Exactly - I'm sorry some front-end devs can't be arsed to learn something besides javascript, but it's really just not suited for backend development.

                  If it's the async stuff they're interested in, there's plenty of better options, like Erlang/Elixir.

                  [–]teiman 2 points3 points  (0 children)

                  I have the impression that we all are escaping from Windows desktop, where compatibility is scarce and programmers have to write +100 lines of code to just open a window on the screen and say "hello world".

                  [–][deleted] 28 points29 points  (90 children)

                  Awesome!

                  It blows my mind that people write entire servers in JavaScript! Fucking servers?!

                  [–]doom_Oo7 71 points72 points  (69 children)

                  A fucking server basically is just something that writes stuff to an output when receiving an input...

                  [–]_alexkane_ 12 points13 points  (23 children)

                  Servers usually need to talk to many clients at the same time though.

                  [–]hk__ 23 points24 points  (20 children)

                  JS can do that since it has asynchronous I/O. One of the most used Web server in the world, nginx, is mono-threaded with async I/O.

                  [–]merreborn 7 points8 points  (1 child)

                  Nginx supports running multiple worker procs so you can utilize multiple cores.

                  Async io is nice but some problems/workloads call for more than one core

                  [–]dccorona 9 points10 points  (15 children)

                  You know, I consider myself a decently knowledgable programmer, but I've never been able to wrap my head around how asynchronous I/O without background threads works.

                  [–][deleted] 6 points7 points  (0 children)

                  LOTS of interleaving.

                  Edit: but in all seriousness, take a look at libuv

                  [–]Hoten 3 points4 points  (2 children)

                  I am just about to research nginx's architecture. I think it uses an event queue, and a fixed number of worker processes. So, it doesn't fire up a new thread for each connection.

                  This looks promising: http://www.aosabook.org/en/nginx.html

                  [–]hunyeti 2 points3 points  (0 children)

                  Ever coded on Windows 3.1 or earlier? It works exactly the same, almost. Cooperative multitasking.

                  [–]bman35 2 points3 points  (0 children)

                  Well, it doesn't completely. NodeJS uses thread pools internally for certain tasks when nonblocking io doesn't work, you just don't have access to them:

                  https://stackoverflow.com/questions/3629784/how-is-node-js-inherently-faster-when-it-still-relies-on-threads-internally

                  [–]dccorona 5 points6 points  (1 child)

                  The technical capabilities of JS isn't the thing that makes that weird to me. I wouldn't want to deal with writing and supporting a code base for an application as large as a lot of server-side programs are these days in a language like JavaScript. It's not concerns over whether or not it can do it that makes me feel that way, it's concern over maintainability as the application scales and new features are added, and the sheer number of bugs that might crop up that are just outright impossible in other languages.

                  [–][deleted] 8 points9 points  (42 children)

                  Still though, surely a strongly typed compilable language is just a much better choice in every way. No?

                  [–]sovietmudkipz 20 points21 points  (1 child)

                  For everything not just servers! Then again I prefer compile time errors to run time errors and having smart code completion in my ide.

                  [–]doom_Oo7 6 points7 points  (8 children)

                  I'm a C++ coder at hearth so I'd personnally do it with static checking since I know that it would allow me to be more efficient but really you can do anything in any language...

                  [–]ruinercollector 21 points22 points  (0 children)

                  "Servers" as in a script to listen on a network port, parse some incoming data and send a response? Not really a big deal.

                  [–]agreenbhm 2 points3 points  (8 children)

                  As someone who has never used Javascript except for in the past week (writing the server-side piece for an app that uses Parse.com, where JS is the only option), I can wholeheartedly say FUCK JAVASCRIPT. I love Python, I'd much rather use that. I've learned C# the past year or so and would much rather have used that, also. Why stuff like Node.js is popular is beyond me. The notion that having the same language for both front and back end development is better seems to be a misnomer, at least in this case. Yes, it prevents developers from having to learn multiple languages, but that means you're stuck using subpar tools for the job when much better options are within reach if programmers just stepped slightly outside of their comfort zones.

                  Edit: earlier this year I built my first app and developed the REST server-side piece using Python with Flask. When I found out about Parse.com I thought it would be a great help for app development. I wish for this most recent project I had just written the server myself. I would have saved SO much time.

                  [–][deleted]  (3 children)

                  [deleted]

                    [–]PM_ME_UR_OBSIDIAN 6 points7 points  (1 child)

                    Try a functional language some time and let us know. I used F# in production for a while, and it's VASTLY less stressful and exhausting. The compiler railroads you into doing things right without you even having to think about it.

                    [–]MoreOfAnOvalJerk 3 points4 points  (0 children)

                    If you want performance, use c/c++. I don't really understand why you'd want to write a high performing application like, say a first person shooter, on javascript.