Sophistication in Web Applications?
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?"
they would write their web app in an object oriented language for maintainability and then have a compiler which produces javascript as output. Of course, at some point we all might wake up and put a virtual machine in the browser that doesn't take 30 seconds to load and enrich the platform.. of course, then we have compatability issues.
How we know is more important than what we know.
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.
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.
This
First Post!!!
Sounds to me like you're spending too much time wondering what google is doing.
1) How the hell would we know?
2) Where did you get "in Python" from?
What I'm listening to now on Pandora...
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
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...
while(1) { fork(); };
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.
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.)
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 try to make us always see things from businesses' points of view; as they try to force us to watch ads; as they try to destroy competative organizations, competative ideas, copetative desires; as they grudgingly accept technologies whose powers WE embrace, only to try to twist them into empty shells of thier possibilities.
Google's claim to not be "evil" is a very relative claim -- they don't have flashing banners and pop-ups, but they do have ads, and lots of them; they don't sell fake search results, but they do play ball with China; they have a bottom line, and they will be motivated by that. They will try to destroy the Wikipedia, for example, should that or something else one day prove to be a true threat.
http://gmail.google.com/gmail/a-1487aa0e66-212dee0 389-dbe349c86a
7 61 c33-86ff8c2092
4 0c 20f-083934da2b
c 84 247-1e80e12f44
http://gmail.google.com/gmail/a-1487aa0e66-2b9f
http://gmail.google.com/gmail/a-1487aa0e66-53c0
http://gmail.google.com/gmail/a-1487aa0e66-2e42
Please take it if you will use it.
MSN's http://webmessenger.msn.com/ is a web-based MSN client implemented using a combination of HTML and Javascript. The source for the javascript is available here. I was looking into how it worked the other day and tidied the source into a more readable form. 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.
Want to improve your Karma? Instead of "Post Anonymously", try the "Post Humously" option.
998 of these functions have one- or two-letter names
Google was always effective with minimalism, which makes sense when you've got all that code. Every letter is still a byte to download and process. So, the Google programmers are really smart with their variable/function names. Just look at the google front page - the id's and classes are all one or two letters, and the name of the text field is 'q'. Why do you need big variable names? They just take up space, are harder to memorize, and you're going to have to look back through the code to see what they do anyway.
I know my life is much easier when I use one-letter variables, although I don't know about one-letter functions. Maybe it partly IS the result of a designer application.
I am NOT a number! I am a - oh wait, I'm number 761710. Look! 761710!
http://gmail.google.com/gmail/a-1487aa0e66-c6fdec5 90f-3dcd265be5
1 31 b55-0a51b018ce
http://gmail.google.com/gmail/a-1487aa0e66-806e
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?
well for starters google is publicly traded now which means the investors have first say on how the technology works, NOT the engineers. More characters = more bandwidth = higher cost of operation = cut in profits = stock prices go down.
Also which has been touched on alot. For a script that size, chances are what we see is probably the product of code optimization and or a front end program that translates human readable code into smaller "optimized" code for the site.
"It's better to be a pirate then join the Navy"
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 support at all.
Yes, this is a nice little feat of JavaScript engineering (or whatever process they used to do it), but in practise, it makes gmail slow and hard to use. I don't see anything they couldn't have done with regular HTML, CSS and minimal JavaScript that would function like people have come to expect a regular web-page to function like.
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.
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.
"Accept that some days you are the pigeon, and some days you are the statue." - David Brent, Wernham Hogg
Dynamic languages are kick ass, I really really like them, but they're for prototyping, not writing maintainable production systems. Static, type checked languages are currently the best way to write maintainable code. In the future we'll have even more formal methods to play with and we can make even more maintainable code.. that doesn't mean we'll leave dynamic languages behind, it just means it will be even more evident that they're not suitable for production systems.
How we know is more important than what we know.
I didn't get here fast enough, but I would just like to commend you for being so honestly nice - you even posted AC, so you can't even be accused of karma-whoring (even though I can see the potential karma hit in seeming like a karma whore)
If there are so many with excess invites, I'd like one too... please?
Pretty please?
It kept me from falling asleep many a day in high school. Curse the unavailability of scalar variables... and only 6 precious, precious lists.
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
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...
My God, it's Full of Source!
OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
Funny, but true. Just to salvage the topic. Maybe people should get out a pad of paper and make a list of things that appear to be simple, but are really complicated upon closer examination. e.g. making a movie the majority will buy.
You insensitive clod, I don't have a gmail account to look at it... :) Unless someone wants to send me one.
Mid-Eastern Pennsylvania Gaming Convention
javascript's type resolution is definition based
. html
this means the execution environment determines the behavior of namespace/module resolution issues (by dynamically loading code from external files or whatever as required with some intrinsic)
This way you can break your project into independant modules, implement test harnesses, etc.
javascript allows you to scope and prototype objects and defintions.
You provide namespace scoping by using nested definitions. And prototypes (i.e. classes, not clonable objects) are created using the prototype keyword.
Also check this out:
http://www.crockford.com/javascript/private
The tools are there. Unfortunately, you won't find many guides anywhere about how to use these properties to write maintainable code or work it in a collaborative environment. Discussions about closures and anonymous functions is also few and far between. But you will find endless discussion about detecting the DOM of various web-browsers (sigh).
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
"And are there any other web apps that are this sophisticated?"
Is this a joke? There are much more sophisticated web apps out there (leaving aside the searching bit). Since client-side seems to impress, check out hushmail.com. That is on the low end of "sophisticated".
Property law should use #'EQ, not #'EQUAL.
Run one of the videos. If you have Plone give it a try. Slick.
A firewall can not protect you from yourself. Turn off what you do not need. Do not use the firewall to do your work.
You consider gmail to be complex? What's your job, notepad to wordpad transcriber?!?!?!
BTW, the short meaningless function names are to save bandwidth. They probably run the real code through sed or perl before deploying.
Javascript, Perl and other interpreted languages have one enormous advantage when it comes to maintenance - particularly when you're trying to maintain a system written by someone else.
Because they're interpreted, you can always find the source code - and because you can copy the source directly from the production deployment, you know that the source you're working with is the correct version. You ever tried to debug or modify a compiled application where the original developer has moved the binaries onto the production systems and then lost the source? Or trawled through ten or twenty near-identical source trees trying to work out which one corresponds to the latest stable release candidate? This will usually be the directory called "Copy (4) of project.0.9.NOT_WORKING" or something similarly intuitive.
With all this talk of open source, it's worth remembering that interpreted script is about as open as source can get.
-- Open Source: It's mad, but you don't have to work here to help.
(emphasis on the stinking)
I think this is really all I have to say about that.
Unfortunately I cannot see the page. Would anyone care sending me a gmail invite ?
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.
Not Cobol but Cadol. In older versions, you saved space in memory by doing
NL
NL
rather than NL 2.
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 write JavaScript: much of the code is redundant - having to deal with browser specific dependencies. This makes JavaScript one of my least favorite languages (and I was one of the authors of an early book on JavaScript)!
...
P.S. If anyone could spare a Gmail invite
[Insert pithy quote here]
Has anyone else noticed that the quality of Google's search results has been droppng over the last year?
This is my sig.
... and 998 of these functions have one- or two-letter names!
... assuming all 2-letter combinations (ignoring case), 26 x 26 = 676.
... it could be that the gmail code has multiple occurances of the same letter combinations, but using different cases, which would be scary. It's also possible that the same function names are appearing multiple times within the code, perhaps in different scopes (does javascript even have scoping?).
I've never seen the gmail code, but let's do some basic math, shall we?
26 letters in the alphabet
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 things
Skiers and Riders -- http://www.snowjournal.com
Who wants the javascript before gmail use obfuscate in code
gmail_script.jsuse save as
Try reading it with a screen reader or on a internet enabled (but no javascript) phone. Crap!
I'm sure we'll start seeing better standardization of XMLHttp across different browsers and more stuff like this.
Scuttlemonkey is a troll
Check the source code for Yahoo's mail. It isn't much better, and their IE-only HTML email editor is awful compared to a popular free textbox editor (that works in Firefox/Netscape).
Trying to use JavaScript to turn web pages into rich text-editing applications with the same level of event capturing is, to put it bluntly, really stupid. It can be done, but the victory is Pyrrhic: clients think it's easy and easy to maintain. A new browser comes out with an incompatibility and you have another code fork to write.
A browser is an application, not a mini-OS with predictable rendering. It's an engine for outputting text, media, and simple form elements not meant to encapsulate the entire host OS's GUI.
This is probably the most overrated, post I've ever read in my life. How many ISPs (ATT, Level3, Above.net, etc.) charge a "per page" fee?
No, you pay for a certain speed (eg 100MBit) and a certain number of gigabytes per month.
It may be obfuscation, but I seriously doubt it. Bandwidth savings are probably part of it, but if you haven't noticed a big thing with google is speed. If there are 1000 functions and they all have short 2 letter names vs. long descriptive names of probably 8 or more characters, they save 6K on the names of their functions alone! That doesn't begin to count the number of times the functions are called within that javascript. They're probably saving upwards of 100K on that script by shortening names of functions.
If I had to guess, it's a combination of bandwidth and, more importantly, speed. Won't someone please think of the dialup users?!
Yes, I am a smart ass; it's better than the alternative.
but the JavaScript that can be used in browsers is a very different beast, with a tangled nightmare of quirks, extensions, and compatibility problems.