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

 



Forgot your password?
typodupeerror
×
Programming Businesses Google The Internet Technology

Sophistication in Web Applications? 197

whit537 asks: "Anyone who uses Gmail for 5 minutes can see that it's a pretty dern sophisticated web application. But just how sophisticated? Well, first of all, the UI is composed of no less than nine iframes (try turning off the page styles in Firefox with View > Page Style). But then consider that these iframes are generated and controlled by a 1149 line javascript. This script includes no less than 1001 functions, and 998 of these functions have one- or two-letter names! They're obviously not maintaining this script by hand in that form. So do they write human-readable javascripts and then run them all together, or have they developed some sort of web app UI toolkit in Python? Does Gmail need to be this complex or is the obfuscation a deliberate attempt to prevent reverse-engineering? And are there any other web apps that are this sophisticated?"
This discussion has been archived. No new comments can be posted.

Sophistication in Web Applications?

Comments Filter:
  • by Glog ( 303500 ) on Saturday December 11, 2004 @10:34PM (#11063783)
    I don't believe that the naming of the functions and variables is simply an effort to obfuscate the code. There is that, of course, but the main reason is probably to save money on bandwidth. When you have millions of people hitting your servers you can scrape quite a few bucks by removing white space and reducing the size of your files the way they have.
    • They might also save a few more bucks by not writing so much javascript and not using so many iframes (think of the requests!). All of gmail's complexity leads it to regularly breaking on my machine and just make the experience more annoying for me (I use tabs for a reason!)
    • Exactly. Shorter function and variable names means smaller code. I thought that much was pretty obvious to even the least experienced programmer. In Google's case, I'm sure this is about saving a few bucks - although it does do that - but about producing smaller and faster web pages.

      • I agree. One webapp I wrote a while back I ended up needing to put the SHA1 hash algorithm on the client-side in javascript and I did the same thing in order to keep things as snappy as possible. I ripped it down to the smallest possible size (by hand) by renaming all the variables and function names as short as possible and eliminating all useless whitespace, etc. As a side effect the source became fairly obfuscated like Google's looks, not that I cared to obfuscate sha1.
    • Exactly.

      I'm amazed that this even made Slashdot; Google often takes care to reduce the bandwidth usage of its pages (view source on google.com sometime....)

      I do a fair amount of JS coding, and I've taken to distributing the majority of my scripts [twinhelix.com] in two separate "commented" and "compressed" JS files for exactly that reason. My guess is that Google in fact has a fully commented and readable copy of their JavaScript code that they run through a preprocessor/compressor; I use my compressor [twinhelix.com] (basically a hacke
    • So, wait. Google is willing to offer dozens of these little free services (blog photo hosting, gigabyte e-mail, etc), and yet it's worried about an extra three to four characters for function names? I don't believe you.
      • They're not worried about it. They just understand that they can save money by minimizing the lenghth of the javascript. Why wouldn't they do this?
        • Well, I figure, of all the things they could do to save money, cutting function names doesn't strike me as the top one on the list. I guess maybe for a low-impact kind of thing, and it couldn't hurt.
          • by eggstasy ( 458692 ) on Sunday December 12, 2004 @06:32AM (#11065312) Journal
            Google serves ads on every page. Assuming they are paid a fixed fee per page, then minimizing their per-page costs is the only way they can increase their revenue. Offering more free services draws in more people, who are served more ads. If they optimize those pages as well, they will earn more profit there.
            BTW... ever noticed how google uses text ads? Do you think the only reason they do that is because it's less intrusive? Wrong again - it also saves a lot of bandwidth compared to an image ad :)
            When you serve billions and billions of pages, shaving off a single byte on each page saves you GIGABYTES of traffic.
          • Well, I figure, of all the things they could do to save money, cutting function names doesn't strike me as the top one on the list. I guess maybe for a low-impact kind of thing, and it couldn't hurt.

            Why don't you and everyone who thinks so send me a nickle a day for the next several years. Chances are there aren't nearly as many of you who think that, as there are people who hit Gmail daily. And chances are still pretty good that a little less than $20/year from each of you would manage to pay off my mo

    • yes.. but it's probably done with some obfuscator/optimizer.

      it's done for size and speed in j2me too(most of the time the obfuscation isn't _that_ hard to dig open if you wish).
    • Similar to what caused the Y2K "problem" for many, only that was saving memory as opposed to bandwidth....
  • It has to be the richest web application I have seen.

    Incredibly well designed, flexible, and scalable.

    They are years ahead of the nearest competition.

  • by Otter ( 3800 )
    So do they write human-readable javascripts and then run them all together, or have they developed some sort of web app UI toolkit in Python?

    1) How the hell would we know?

    2) Where did you get "in Python" from?

    • Re:Huh? (Score:4, Informative)

      by Cecil ( 37810 ) on Saturday December 11, 2004 @10:55PM (#11063892) Homepage
      I think he may have derived "in Python" from the fact that Google has been hiring many Python programmers in the past couple years.

      However, it was completely uncalled for speculation that had no place in a Slashdot article. ... just like the rest of this article.

      I'm with you, "huh?"
      • by bill_mcgonigle ( 4333 ) * on Sunday December 12, 2004 @02:41AM (#11064728) Homepage Journal
        When you sign up to be a Python Programmer you have to promise to evangelize rabidly. At least that's been my experience. Evangelism must include suggesting that python is the best language for every job, trashing every other scripting language, and suggesting that Python is what makes the Holy Grail work. ...and to mod-down any Slashdot post that doesn't beatify Python, I'm sure. There goes some karma...
        • Being the maintainer for a fairly large and complex app written in Python, I can tell you it's a mixed blessing. It's nice and portable, extremely powerful, easy to understand. It also causes me no end of headaches, especially under Windows; engine corruption on some systems causes extremely odd and sometimes funny errors (e.g: TypeError: f() takes exactly 14391 arguments (3 given)). Memory usage, especially with the graphics library, is enormous, though still short of what Java would require. All in al
          • If you've encountered an error like the example you've given, and can confirm that it is due to *Python* (as opposed to a third-party library you're using) the python developers would be *very* anxious to hear about it - especially as Python 2.4 has just been released.

            Please raise a bug report on SourceForge with the Python version, Windows OS and as short a sample script as you can that replicates the problem.

            However, in almost all cases this is caused by a misbehaving third-party library written in C/C+
            • See, that's the problem -- it doesn't occur on any of the machines I use, which seems to indicate it's coming from a non-standard DLL somewhere. I'm not using any libraries aside from wxPython and win32all. I've tried gathering evidence to pin down a suspect DLL but I've gotten nowhere.
    • Re:Huh? (Score:3, Insightful)

      by sethadam1 ( 530629 ) *
      Actually, if you browse around Google and Gmail, you'll find tons of links like this one [google.com] - the file has a .py extension.

      Google writes A LOT in Javascript. It would not surprise me, although I have no evidence of this, if they wrote the code in their choice editor and then ran a python app that condensed the code to remove space, renamed the functions, and replaced all function references. At 1000+ functions, if the function names had just 5 letters each (not much if you're not being terse), that would be
      • Re:Huh? (Score:3, Insightful)

        that would be an extra 3000 characters (3k) PER PAGE LOAD

        Well, that js file would be cached by the browser, hopefully, not reloaded with every single page load.
  • While doing research for an AI project, I found a project that does this, kinda, and is written totally in PHP, etc... its called AIStockBot [aistockbot.com]

    Its nicely obsfrucated, but it's open source... some of their algorithms and predicting phases are quite complex. I decided to do something a little more basic and written in C. mmmmmm C...
  • not obsuring (Score:1, Redundant)

    by blindbat ( 189141 )
    The send out a lot of data and don't waste any bytes. That is why they compress the names. Similarly, look at the google page: no spaces.
  • by Anonymous Coward
    1200 lines of Javascript might seem like an enormous amount to a dreamweaver monkey, but it's hardly any code for anyone who does real programming*. Check out the scripts for Outlook Web Access for example. Or any other intranet/portal type application.

    (*Well, many 'real programmers' are loath to do rich client stuff in JS, perferring their server side frameworks instead. But once you get the hang of it, it's pretty nice.)
    • I don't think it's accurate to say that any arbitrary amount of code defines the line between code grinders and real programmers. After all, there's a world of difference between 1200 verbose, well-commented lines and 1200 highly optimized lines full of obscure tricks to squeeze every bit of performance possible out of the hardware. The first could be cranked out in a few hours by almost anyone with some programming knowledge, and the second might take weeks or even months to get right.

      Looking at the Goog

  • Google became an integral part of the web some years back.

    Lately, to me at least, a similar potential became clear with Suprnova (remember when someone posted the link to Jon Stewart on CNN?).

    But I fear for both of these web apps,for the same reason Real's attempt to own Internet video was bad, Apple's pitch to own web music is bad, and MS's ongoing attempts to own HTML, etc. are bad.

    The ubiquity of MP3s, Bit Torrent, Mozilla, Mplayer and VLC, and Linux in general have held back these bastards as they tr
  • by bdash ( 598142 ) <slashdot DOT org AT bdash DOT net DOT nz> on Saturday December 11, 2004 @11:05PM (#11063934) Homepage

    MSN's http://webmessenger.msn.com/ [msn.com] is a web-based MSN client implemented using a combination of HTML and Javascript. The source for the javascript is available here [msn.com]. I was looking into how it worked the other day and tidied the source into a more readable form [bdash.net.nz]. At least MSN had the decency to leave human-readable function names... this fact alone makes the code reasonably understandable.

  • Do you still need to be sent an invitation to setup a gmail account? I never got around to signing up during the initial wave of hype and I would appreciate it if anybody could send me an invitation.
  • Sure, it's sophisticated, but 1149 lines of javascript isn't rocket science. Anyone worth their salt in javascript programming along with dhtml and css can reproduce this with about a month of solid coding. The trick is getting the cross-browser stuff working correctly, the rest is standard client/server stuff.
    • agreed. the cross-browser issue is the only 'sticky' part of it.. the other part is knowing where and how you are going to actually use the JavaScript. It was very clearly planned and executed very cleanly. JavaScript usually gets a bad rap because of the cross-browser issue, but when it does work it IMO bridges certain usability gaps on the web. I would say the two reasons why the code uses mainly two letter function names- bandwidth, and more difficult to reverse engineer (obfuscation).
  • by Anonymous Coward

    developed some sort of web app UI toolkit in Python?

    This is why I call Python "Java of the open source world".. so many people think all programming begins and ends in Python.

    JavaScript is *already* a sophisticated, object-oriented language. In fact the design of the language is somewhat cleaner than Python. Why do you think they would write it again in Python somehow?

    • My thoughts exactly.

      I'll add that the majority of drawbacks in javascript are deficiencies in the DOM. 'select' objects and the rather inflexible event model come to mind as prime examples of this. Javascript, by itself, is a clean and compact scripting language that gets the job done well. And even those issues are fairly easy to code around thanks to how flexible javascript is.
    • but the JavaScript that can be used in browsers is a very different beast, with a tangled nightmare of quirks, extensions, and compatibility problems.
  • This is the reason for gmail pissing me off so much. It seems that all of this complexity just prevents use of normal browsing, and it regularly breaks down on me (are they ever going to fix that 'Loading...' bug?)

    For example, embedded URLs in emails don't just link to the website, or utilise the 'target' attribute - they use javascript which prevents me from opening them in new tabs (I have to drag them onto the tab bar). Same thing goes for email conversations - but I can't drag those, so there's no tab
  • by sakusha ( 441986 ) on Sunday December 12, 2004 @12:31AM (#11064285)
    People can be fooled into thinking things are sophisticated apps when they're really not. I'm reminded of a famous anecdote from Danny Hillis. He was trying to sell his Connection Machine with WAIS software to a CEO for enterprise-level data mining. He gave the CEO a demo at his shop, the CM1 did its thing, and the CEO was totally unimpressed, and said, "hell, my IBM PC back at the office can do that!" Hillis couldn't believe a 286 could do something that requires a CM1 supercomputer, so he asked the CEO to take him back to his office and show him.
    So they get back to the CEO's office, and he uses his PC to dial up Dow Jones News Retrieval service and runs a monster WAIS search.. which used a CM1 that Hillis sold to Dow Jones.
  • You insensitive clod, I don't have a gmail account to look at it... :) Unless someone wants to send me one.
  • One small extention to Plone; [plone.org]

    1. CPSSkins [chalmers.se]

    Run one of the videos. If you have Plone give it a try. Slick.

  • I'm surprised noone's caught on to this.

    Google's all about HTML/JS compression. I remember reading an article about how Google goes to great lengths to reduce their HTML/JS fingerprint. It ends up resulting in real savings.
  • The biggest problem with programming in JavaScript is the incompatiblity of JavaScript among browsers and even across versions of browsers. If you're writing an application in which the end-user is using one type and version of browser, it's not a problem. If you're writing for the mass market - major headaches. To make matters worse, there are major incompatibilities between versions of IE - IE4 is very different from IE5 and IE6. And you can't count on end-users having the latest browser. When I writ
  • Has anyone else noticed that the quality of Google's search results has been droppng over the last year?
  • ... and 998 of these functions have one- or two-letter names!

    I've never seen the gmail code, but let's do some basic math, shall we?

    26 letters in the alphabet ... assuming all 2-letter combinations (ignoring case), 26 x 26 = 676.

    676 2-letter combinations + 26 possibilities for the function names with 1 letter = 702.

    702 possible function names, as long as we ignore case. BUT, AFAIK, javascript is a case sensative beast -- function "bb" is not the same at "BB".

    998 - 702 = 296.

    296 could be a couple of t
  • I'm sure we'll start seeing better standardization of XMLHttp across different browsers and more stuff like this [theserverside.com].

"What man has done, man can aspire to do." -- Jerry Pournelle, about space flight

Working...