Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Programming

JavaScript and the Netflix User Interface 195

CowboyRobot writes Alex Liu is a senior UI engineer at Netflix and part of the core team leading the migration of Netflix.com to Node.js. He has an article at ACM's Queue in which he describes how JavaScript is used at Netflix. "With increasingly more application logic being shifted to the browser, developers have begun to push the boundaries of what JavaScript was originally intended for. Entire desktop applications are now being rebuilt entirely in JavaScript—the Google Docs office suite is one example. Such large applications require creative solutions to manage the complexity of loading the required JavaScript files and their dependencies. The problem can be compounded when introducing multivariate A/B testing, a concept that is at the core of the Netflix DNA. Multivariate testing introduces a number of problems that JavaScript cannot handle using native constructs, one of which is the focus of this article: managing conditional dependencies."
This discussion has been archived. No new comments can be posted.

JavaScript and the Netflix User Interface

Comments Filter:
  • by dotwhynot ( 938895 ) on Saturday October 18, 2014 @04:26PM (#48177553)
    ..is to not have a backspace ruin everything you just did just because you didn't have the focus you thought you had (Chrome!). And to work offline as good as online. Take email as an example. I really like using travel time to catch up on, reply to and delete email. But often travel time does not have internet access (train, plane). For now, email clients are superior to web email because of this.
    • by Georules ( 655379 ) on Saturday October 18, 2014 @04:35PM (#48177581)
      Or maybe just unhook backspace from "Back in History". Who the hell actually uses backspace to go back in history on a website?
      • It's the default action for the backspace key for basically every browser ever on Windows, as well as in Explorer windows. I used it that way for a long time, but since switching to Linux where using backspace to go back in history isn't the default, I was annoyed for a little while and then just stopped using it. I have no idea why it's the default on Windows, though.

        I did lose a lot of forums posts back in the Windows days due to backspacing while not having the text box focused.

        • I used it that way for a long time, but since switching to Linux where using backspace to go back in history isn't the default, I was annoyed for a little while and then just stopped using it.

          FYI, it's still the default behaviour of backspace on Firefox on Linux Mint.

      • by Saffaya ( 702234 )

        Who the hell actually uses backspace to go back in history on a website?

        Maybe people who navigate windows with the keyboard ?
        That's what backspace does in windows explorer.
        Go back to the folder you came from.

      • You can thank Microsoft for that moronic decision. It's also in e.g. Outlook. Why you would want to map a key that's universally used to delete stuff, to act as "go to the previous view" (and worse, swap between the two behaviors depending on focus) is beyond me.

    • by tlhIngan ( 30335 )

      ..is to not have a backspace ruin everything you just did just because you didn't have the focus you thought you had (Chrome!)

      The big problem is the javascript "rich" editors that mess with browser state saving.

      Backspace is a non-issue a lot of the time if you're using standard HTML widgets - every browser I've used from IE, Firefox and I think even Chrome save the state so if you accidentally backspace, you can hit Forward and boom, everything is restored. It's useful if you want to multi-quote Slashdot, f

  • Golden Hammer (Score:5, Insightful)

    by Anonymous Coward on Saturday October 18, 2014 @04:44PM (#48177605)
    It's unfortunate that Javascript has become the embodiment of the Golden Hammer in the programming world. And, just like a hammer made of gold, it doesn't even work that well as a hammer. It is only so widespread because when it comes to the web, it's the only tool you have.
    • by gweihir ( 88907 )

      And in addition, those using it do not understand how they should actually doing things. Browser-side application logic is a nightmare and cannot ever be reliable or secure. If you really need client-side processing, do a real piece of software for it. A browser is just a glorified terminal, _not_ processing infrastructure.

      • by Jeremi ( 14640 )

        Browser-side application logic is a nightmare and cannot ever be reliable or secure. If you really need client-side processing, do a real piece of software for it.

        I don't see why a browser-base app could not, at least in principle, be as reliable and secure as "real software". As an example, say I write the real application you recommend, and then I also find a way for it to run inside a web page. Will it become insecure simply because there is now a web-browser window wrapped around it?

        • by gweihir ( 88907 )

          You are right in principle. All it takes is to make the browser a real VM environment with security guarantees, a standardized interface, etc. But that is not going to happen anytime soon, because virtualization technology is not there yet and pretty complicated, and a browser does not have VM isolation and reliable execution as primary tasks. In fact, if you remember, a browser's primary task is rendering HTML.

          I do expect that some day, many browsers will come with a standardized sand-box that does fulfill

          • You are right in principle. All it takes is to make the browser a real VM environment with security guarantees, a standardized interface, etc. But that is not going to happen anytime soon,

            ... because the standardized interface has already happened, or is happening: https://wiki.mozilla.org/WebAP... [mozilla.org]

            The fact that browsers have such a large userbase, and its incredibly easy to make browsers execute potentially evil javascript, js is one of the most secure and best sandboxed languages that exist, that is still powerful. OK there are things as canvas tracking, and webgl shaders. But show me something that supports truly secure accelerated graphics.

            When I run my browser, I choose which file to upl

            • by gweihir ( 88907 )

              Somebody has standardized some interface, but that is vastly different from having a generally accepted "standard interface". Seriously, some insight required in this discussion.

              • That "somebody" is W3C. And if Microsoft doesn't implement it in their internet explorer, the fact that it is a "standard interface" is not the fault of "browser vendors", but of microsoft. and browser vendors (even microsoft) have aligned their js implementations.

                So yes, there is no "generally accepted" standard interface, when you define "generally accepted" as being runnable on IE8. But when you can afford to say to your users "get a modern browser" (still don't understand why google discontinued their c

      • by tepples ( 727027 ) <.tepples. .at. .gmail.com.> on Saturday October 18, 2014 @10:17PM (#48178721) Homepage Journal

        If you really need client-side processing, do a real piece of software for it.

        For which platform shall this "real piece of software" be developed? Windows (desktop), X11/Linux, OS X, Windows Phone, iOS, Android, Windows Store, or something else?

      • Browser-side application logic is a nightmare and cannot ever be reliable or secure. If you really need client-side processing, do a real piece of software for it.

        There's no way in which a non-browser client-side application is more reliable or secure than a client-side application in the browser. That is, unless you deliver it as some kind of tamper-proofed USB dongle with its own processing resources (and perhaps even then).

        • by gweihir ( 88907 )

          That is just not true at all. Maybe look at what secure software engineering can do these days?

  • Why the hell... (Score:5, Insightful)

    by beelsebob ( 529313 ) on Saturday October 18, 2014 @04:45PM (#48177609)

    Why the hell are we still stuck using Javascript for the web? Why have we not got some virtual machine (not a language specific one like the JVM), that we can compile any language we like to? Half the world is trying to hack around javascript's shortcomings. If even half that effort was directed at making PNaCl viable on all browsers, we would be so much further forward.

    • Re:Why the hell... (Score:5, Insightful)

      by NotInHere ( 3654617 ) on Saturday October 18, 2014 @04:58PM (#48177647)

      First JVM is not language-specific: http://en.wikipedia.org/wiki/L... [wikipedia.org]
      Second, javascript can be the compile target of LLVM bytecode. You can compile your favourite C program to js. See emscripten: https://github.com/kripken/ems... [github.com]
      Third, javascript has a very fast but still backwards compatible bytecode like subset called asm.js: http://en.wikipedia.org/wiki/A... [wikipedia.org]
      asm.js can be set as target for emscripten. The browsers supporting asm.js simply JIT it to bytecode, and those which don't still can run asm.js, but way slower.

      • First JVM is not language-specific:

        Meaning that it easily supports (without unreasonable overhead) execution of pointer-based languages such as C, or multiple-inheritance languages such as C++, or dynamic languages (with hash-like objects) like Javascript or Python, or multiple-dispatch languages such as Common Lisp/CLOS, or languages with restartable exceptions such as (again) Common Lisp, or languages with lazy evaluation strategies such as Haskell or Scheme, or languages with continuations such as Scheme, right? Oh, wait, it doesn't - it

    • Re: (Score:3, Funny)

      by gweihir ( 88907 )

      Simple: Client-side executable content in web-pages is an exceedingly stupid idea, so all the bright language designers stay away from it. Hence it is JavaScript for all those that do not understand how to do a web application right.

      • Re:Why the hell... (Score:5, Insightful)

        by Intrepid imaginaut ( 1970940 ) on Saturday October 18, 2014 @06:08PM (#48177887)

        It has a lot of merit, especially if you're trying to do anything fancy. Getting the needed processing power from the client, especially in this day and age of overpowered commodity hardware, rather than the server frees up the server to do more important jobs, and really as long as you're sanitising properly inputs why not. What's really needed is a proper push routine but that comes with its own tangled web of problems.

        • by gweihir ( 88907 )

          Oh, I do understand the arguments for it, but it still causes a lot more problems than it solves, and hence should not be done, ever. Reliability and security are critical. If you do not have them, stop right there. Wanting "fancy" is not a valid excuse to mess up. And lets face it, most modern web applications have pretty low actual processing needs. An inefficient implementation on the server-side is not a valid excuse to do processing on the client. It is an often used one though.

          • You will be sitting in the corner holding to your best practices and ideals while the world uses Facebook, Twitter, Google Mail, Office 365, Google search with autocomplete, Netflix, Youtube, Hulu Plus, Ebay, Amazon, and a hundred other websites that make extensive use of Javascript.
            • by gweihir ( 88907 )

              Well, since of all these sites I use only Amazon and Google, it seems that JavaScript is primary a tool for wasting people's time. No surprise. But who says I refuse to use JavaScript? That is entirely in your mind. I will just call trash trash, even if I use it because there is no good alternative.

      • Actually, the "non-bright" person who came up with Javascript based it on Self and Scheme. If only we had more such "non-bright" programmers! The problem was that the design had to be fleshed out basically over a weekend or two, thus causing virtually all the mistakes that were basically impossible to fix since then.
        • by gweihir ( 88907 )

          I know that. That person has the valid excuse that JavaScript was never intended to be used for anything large or security-critical. It was a quickly hacked-together tool to do small things like changing the color of a button on mouse-over. The problem is all the utterly clueless morons that think JavaScript and the browser are suitable for real computing.

    • by Tablizer ( 95088 )

      Why the hell are we still stuck using Javascript...

      Because it would take a large group of organizations to cooperate and work together, which rarely happens. Closed source wants to lock out competitors and open source wants to each be their own kings of their own little hills for bragging rights. (Almost nobody really works for "free", they all want either money or credit/status.)

      I'd loooove to see a GUI-friendly markup language that is either far less dependent on any scripting or application code for the

    • Re:Why the hell... (Score:5, Informative)

      by Jeremi ( 14640 ) on Saturday October 18, 2014 @06:53PM (#48178105) Homepage

      Why the hell are we still stuck using Javascript for the web? Why have we not got some virtual machine (not a language specific one like the JVM), that we can compile any language we like to?

      JavaScript is [github.com] the 'bytecode' to compile to these days.

      Not saying that's optimal, but if JavaScript is what the world's web browsers run, then JavaScript is what people will target to get onto those web browsers. At least you can still use your language of choice to do so...

      • Thank you for that link. Interesting. I was aware of about ten projects that compile to or enhance Javascript, but that list is enormous.
    • Totally agree with that.

      The only problem seems to be the acceptance of NaCl by the other big browser vendors (Microsoft, Mozilla).

      Here's what wikipedia says:
      (warning: could be outdated)

      Reception
      Some groups of browser developers support the Native Client technology, but others do not.

      Supporters: Chad Austin (of IMVU) praised the way Native Client can bring high-performance applications to the web (with about 5% penalty compared to native code) in a secure way, while also accelerating the evolution of client-side applications by giving a choice of the programming language used (besides JavaScript).[30]

      Id Software's John Carmack praised Native Client at QuakeCon 2012, saying: "if you have to do something inside a browser, Native Client is much more interesting as something that started out as a really pretty darn clever x86 hack in the way that they could sandbox all of this in user mode interestingly. It's now dynamic recompilation, but something that you program in C or C++ and it compiles down to something that's going to be not your -O4 optimization level for completely native code but pretty damn close to native code. You could do all of your evil pointer chasings, and whatever you want to do as a to-the-metal game developer."[31]

      Detractors: Other IT professionals are more critical of this sandboxing technology as it has substantial or substantive interoperability issues.

      Mozilla's vice president of products, Jay Sullivan, said that Mozilla has no intention of running native code inside the browser, as "These native apps are just little black boxes in a webpage. [...] We really believe in HTML, and this is where we want to focus."[32]

      Mozilla's Christopher Blizzard criticized NaCl, claiming that native code cannot evolve in the same way that the source code-driven web can. He also compared NaCl to Microsoft's ActiveX technology, plagued with DLL hell.[4]

      Håkon Wium Lie, Opera's CTO, believes that "NaCl seems to be 'yearning for the bad old days, before the web'", and that "Native Client is about building a new platform – or porting an old platform into the web [...] it will bring in complexity and security issues, and it will take away focus from the web platform."[4]

      See http://en.wikipedia.org/wiki/G... [wikipedia.org]

    • Why the hell are we still stuck using Javascript for the web? Why have we not got some virtual machine...

      asm.js is a subset of javascript that is easily translated to low-level instructions... And runs at near native speed in browsers that optimize asm.js.
      Don't get me wrong, I totally agree that asm.js is a messed up construction... One can think of it as a bytecode encoding in Javascript...
      But it works, it's fast, and it's backwards compatible... Though anyone trying to use large asm.js programs in browsers with a poor javascript engine will get an extraordinary poor performance :) In in practice it might n

  • I hate it. Makes browser loading/transitions slower than just loading a JVM or Flash(and that's saying a lot), fucks with mobile, fucks with NoScript, screws up common hotkeys like backspace which loses what you've written Google Docs unless you're smart enough to run Lazarus(which you shouldn't have to), etc etc etc. Trying to be slick just makes it worse.
    • The delayed transitions are just shitty resource management from lazy hacks, that's a bunch of plugins loading from hither and yon, and it grinds my gears too.

  • Do your damn application logic on the server, as it is indented to. Everything else is insecure and unreliable. Really, that something is possible to do does not mean it is by any means a good idea.

    • by Frankie70 ( 803801 ) on Saturday October 18, 2014 @07:20PM (#48178199)

      Do your damn application logic on the server, as it is indented to.

      And use spaces not tabs.

  • by kervin ( 64171 ) on Saturday October 18, 2014 @05:41PM (#48177799)

    Browsers should not standardize on a particular programming language, but rather on bytecode. But no one wants to use the other's Bytecode solution ( although we have sever great bytecode standards to choose from ) so we're stuck with Javascript.

    • I'm pretty sure that's what Java was supposed to be.

      In any event, the problem they're discussing isn't unique to JavaScript/ECMAScript, it would plague a bytecode solution too... They're deciding to send all the dependencies they could possibly need over the wire before they know they'll need them, instead of deciding which ones to send on the server-side when the page is requested.

  • Ah Javascript. The language we all love to hate, but isn't going anywhere. It seems like a good portion of all development will be Javascript in the not-too-distant future as legions of low paid programmers take up code writing and maintenance.

  • by BitZtream ( 692029 ) on Saturday October 18, 2014 @06:27PM (#48177985)

    Lets stop pretending they are anything close.

    Google docs/sheets/whatever is a really crappy imitation of a full fledge office suite ... from 15-20 years ago. It doesn't even compare to Office 95 other than it has online sharing and collaboration, which is great, except thats a tiny subset of what its actually used for.

    Just because you can make a half assed, no where near feature complete but looks pretty and does the first 3 things that come to mind look-a-like of an desktop app doesn't mean its a desktop replacement.

    There are no desktop applications 'written entirely in javascript' unless you redefine what a desktop application is to fit a narrow subset of what everyone else does.

    Learn to use the right tool for the job and stop thinking just because you can make something look-a-like and emulate a few basic functions that it is the same thing. A screwdriver can be used as a hammer, but it makes a shitty hammer. Google docs CAN be used in place of a full fledge office suite, but it makes a shitty office suite when you replace one entirely. Most geeks who use 'office suites' don't actually use office suites, they occasionally type a few pages into a word processor, sure but they don't do the same things as your full time paper pusher.

    • by StripedCow ( 776465 ) on Saturday October 18, 2014 @07:33PM (#48178239)

      Lets stop pretending they are anything close.
      Google docs/sheets/whatever is a really crappy imitation of a full fledge office suite ...

      The real underlying reason these apps feel flimsy is probably that Javascript is a single-threaded language. It's like going back to the 80s.
      This means that when processing one action of the user (especially if it is a complicated action), the user interface will temporarily freeze.
      In this day and age, this is totally unacceptable.

      • by Fwipp ( 1473271 )

        Most browsers actually support web-workers: http://caniuse.com/#feat=webwo... [caniuse.com]

        And there are a bunch of wrappers to make them feel more like regular threads. Easy-peasy.

        • by StripedCow ( 776465 ) on Saturday October 18, 2014 @08:21PM (#48178371)

          Web-workers are not cutting it. For the following reason.
          Real multi-threaded programs have a shared address space. Web-workers do not.

          Example: suppose your GUI runs on a 1 megabyte long text-file.
          The data-structure that models the text-file is 2 megabytes long.
          Now you want a web-worker to do something with this text-file in the background (e.g., count the number of words).
          So you start a web-worker thread. But then you need to send the text-file as a message to the thread (since there is no other way the thread can reach the data).
          Sending this 2 megabyte chunk of data will surely freeze your GUI for a while, and so the whole point of multiple-threads is mostly lost.

          • by Fwipp ( 1473271 )

            Oh no, you've invented a contrived scenario in which you assert there will "surely" be a performance penalty, therefore the model is entirely unacceptable.

            Maybe you should just, you know, leave the text in the non-GUI worker to start with? Or you can incrementally update the background thread as the data changes. I'm not even positive that postMessage() doesn't execute concurrently with the calling thread, as I'm sure the JIT could do.

            • Maybe you should just, you know, leave the text in the non-GUI worker to start with?

              Let me get this straight. This means that when the user scrolls the document, the web-worker would feed the GUI with lines of text incrementally (?)
              However, if, at the time of scrolling, the web-worker would be busy counting words in the document, I don't see how the GUI would not *effectively* freeze just as well (the main thread would be waiting for new lines from the web-worker which is busy counting words).

              Or you can incrementally update the background thread as the data changes.

              This is like splitting up the task of counting words into smaller tasks that execute incrementally

              • by Fwipp ( 1473271 )

                Sure bud, you have one central non-gui worker, which the GUI thread communicates with and dispatches shit to other workers that need to process stuff. You store a bit of "extra" text (probably 50 pages would easily fit) in the GUI and make requests when it gets closer to the end.

                Just because you can't think of a way to solve a particular problem you've just thought of, doesn't mean that high-quality performant programs can't be written in the language. You haven't worked with any other message-passing model

                • A customer just called. He pressed "Ctrl+End" to go to the end of the document, while it was counting words. He complains that the user interface is frozen.

                  Just because you can't think of a way to solve a particular problem you've just thought of, doesn't mean that high-quality performant programs can't be written in the language.

                  Yes. But because of this problem of the (fictituous) customer, I now have to rewrite my 30.000 lines of code from web-worker style to single-threaded asynchronous style. Unless you have a better idea :S

      • by Shados ( 741919 )

        A lot of AAA videogames have been done single threaded. Web apps can be done the same way.

        Have the action change the state, and use requestAnimationFrame to update the UI nicely, v synced. 60 frames per second is enough to feel snappy. Of course, all I/O is already happening asynchronously, and for the very few cases that are left, you can use workers.

    • by Mr. Mikey ( 17567 ) on Saturday October 18, 2014 @10:17PM (#48178723)
      And yet, I use Google Docs on a regular basis... and find it sufficiently powerful, reliable, free, and with the features I need. If you'd like to create a competing product, please do... otherwise, just what are you bringing to the table?
    • by Shados ( 741919 )

      Atom editor isn't as good as more mature equivalents, but its close.

      Adobe has a tool to create responsive website mockups thats also all in javascript/html while still being a desktop app, I forget its name.

      A lot of stuff is done in Node-Webkit, and in many cases you probably don't even know.

    • Agreed. They're very basic and don't work offline. The only reason I could see that someone would prefer web apps is because they want the NSA to have their data.
  • Man, web apps are so early 2000s. We're all running local apps on tablets and phones now, dudes.

  • As an old-school back end specialist, I hated the spaghetti runtime error aspect of Javascript -- until I started decoupling various aspects using, for instance, AngularJs. Lack of compile-time checking is an increasing part of even compiled languages like C# (dynamic, reflection), but since AngularJs supplies dependency injection, sanity has returned to the logic that needs to be in the front end. As I've increasingly shifted page loads to Ajax calls, my pages have become sweetly responsive even on slow (m

  • Oh, wait. I'm trapped seven years in the past.

    JavaScript is wicked fast, has first class treatment of functions, JSON and the object model are beautiful, and its duck-typing supports great mixins patterns. JavaScript is now outside the browser with Node.js. The Node people made some awesome wise design decisions and Node is awesome. In spite of stupid haters, JavaScript just keeps getting bigger and bigger and racking up more successes. It beat Applets, Flash, VBScript, and challengers not worth mentio

    • by Jaime2 ( 824950 )
      JavaScript has lots of good features. But, it also has automatic semicolon insertion, strange type coercion, eval, and no block scope variables. All of these features entice those who don't know any better to write really bad code. It's like pointers in C - not an inherently bad thing, but out of place in business code where reliability is more important than speed. Because of JavaScript's position as "the default language of the web", these features would be incredibly difficult to fix without losing that

A committee takes root and grows, it flowers, wilts and dies, scattering the seed from which other committees will bloom. -- Parkinson

Working...