Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Sophistication in Web Applications?

Cliff posted more than 9 years ago | from the what's-really-under-the-hood dept.

Programming 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?"

cancel ×

197 comments

Sorry! There are no comments related to the filter you selected.

If they are smart, and they are, (0, Flamebait)

QuantumG (50515) | more than 9 years ago | (#11063780)

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.

Re:If they are smart, and they are, (1)

I_Love_Pocky! (751171) | more than 9 years ago | (#11063921)

Javascript is more-or-less object oriented. Have you ever used it? It is actually a pretty clever little language, with quite a bit of utility.

Re:If they are smart, and they are, (0, Flamebait)

QuantumG (50515) | more than 9 years ago | (#11063944)

and about as maintainable as Perl.

Re:If they are smart, and they are, (3, Informative)

I_Love_Pocky! (751171) | more than 9 years ago | (#11063999)

Both Perl and Javascript can be maintainable if the programmer designs their code with that goal in mind. Besides, Gmail has slightly more than 1000 lines of code. That really isn't really a maintenance nightmare.

Java is an object oriented language, but I could certainly write Java code that would be a major headache to maintain if I chose to do so. I think most maintenance problems come from poor coding habits, and not the language its self.

Re:If they are smart, and they are, (0)

Anonymous Coward | more than 9 years ago | (#11064048)

QuantumG has a point that both Javascript and (especially) Perl have a coding culture that does not encourage maintainable code. Check out some of those html doodad javascripts you can find free on the web -- very obscured terrible code.

One could argue that Perl's language design is not amiable to maintainable code, but Javascript can be programmed almost exactly like Java (nice easy monkey-maintainable stuff.)

The only thing js is really missing is a 'class' keyword (instead of using 'function').

Re:If they are smart, and they are, (1)

binary42 (801099) | more than 9 years ago | (#11064437)

Just remember that Javascript is OO but not via classes. It is a prototype OO language (see others like Self).

Re:If they are smart, and they are, (1)

bill_mcgonigle (4333) | more than 9 years ago | (#11064742)

One could argue that Perl's language design is not amiable to maintainable code

If you mean Perl doesn't force you to write good code the way Java does, yeah. And I'm happy for it when I need to do something hard, like multithreadded servers.

But if you're suggesting Perl doesn't let you write good code you'd be wrong. There are some pretty big, successful, rapid-release perl projects out there that are well done and well maintained. Spamassassin is just one example of a public one. Ticketmaster would be an example of a private one (yes, that Ticketmaster).

Re:If they are smart, and they are, (1)

OmniVector (569062) | more than 9 years ago | (#11063980)

parent poster said pretty much what i was about to. i've written a fairly complex hierarchy menu in OOP javascript. there is also a project that's been around for sometime called dynapi that seeks to make a cross browser OOP javascript system for widgets.

Re:If they are smart, and they are, (3, Insightful)

T-Ranger (10520) | more than 9 years ago | (#11063986)

"pretty clever little language" is the understatement of the year. The entire UI of the browser that I am using now is done in javascript.

Re:If they are smart, and they are, (0)

Anonymous Coward | more than 9 years ago | (#11064186)

Big deal, the whole thing eventually has to execute on the CPU. *That* is the clever part, not some limp wristed software crap.

Re:If they are smart, and they are, (1, Interesting)

Anonymous Coward | more than 9 years ago | (#11064088)

Have you ever used JavaScript outside the browser? It's a very sophisticated object-oriented (prototype-based, like Self.. you can also use prototypes in Perl and Lisp and other "roll-your-own-objects" languages, I've noticed.. this means new objects are made only by copying other objects).

So it's funny when you and the original poster opine that it must be written in some "other" language.. JS is actually more sophisticated than, say, Python!

I recently saw some JS code online that added many Ruby-like dynamic methods to the standard JS objects.. pretty amazing I thought.

JS, along with other "embedded" languages like PostScript and Forth are probably way under-appreciated yet are vital for many functions.

Yah, good for Javascript! (2, Interesting)

QuantumG (50515) | more than 9 years ago | (#11064390)

Every single language you've mentioned there are NOT maintainable. Why? Cause they're all interpreted dynamic languages. It's fun and all to write in these languages and get stuff done with them but as soon as you spot a bug you have a hell of a time to:
  • reproducing the bug
  • debug the problem without changing it
  • convincing yourself you've fixed it
  • looking for the same class of bug elsewhere

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.

Re:Yah, good for Javascript! (3, Interesting)

Earlybird (56426) | more than 9 years ago | (#11064769)

  • Every single language you've mentioned there are NOT maintainable. Why? Cause they're all interpreted dynamic languages. It's fun and all to write in these languages and get stuff done with them but as soon as you spot a bug you have a hell of a time to ... blah blah ... not suitable for production systems.

This is a myth [artima.com] , and has been proven false countless of times, such as by these guys [zope.org] , or these guys [gnu.org] , or even these guys [php.net] , or, God forbid, you may have heard of these guys [slashdot.org] .

First, the term "interpreted dynamic language" is vague and misleading. Interpretation has nothing to do with code maintainability. (You can interpret C, and you can compile putatively interpreted languages such as Java [gnu.org] and Python [sourceforge.net] to native code; indeed Java has been natively compiled for years, and the fact that it is just-in-time compilation is irrelevant).

And what does "dynamic" mean? Do you mean a dynamically, as opposed to statically, typed language? Do you mean runtime introspection? Self-modification and metaprogramming? Runtime name resolution? What? I suspect you mean a combination of these. Python, Perl, Ruby, JavaScript, PHP, Haskell, Lisp and OCaml have these features. C++ can be considered a "dynamic" language, as can Java, C#, etc. So why do you claim that these languages are not maintainable?

These newfangled languages are more rapid to develop in than lower-level languages. Maintenance is simpler because the languages are simpler, higher-level and more easily maintained. For example, the absence of a separate compile/link cycle means I can get from changing a source line to testing the source line quicker.

In many cases, reproducing or debugging a bug is simpler in, say, Python than in C, because the infrastructure itself is simpler. Pure Python, for example, does not have memory access violation errors; there's no way your Python code can read or write an invalid pointer, write beyond the end of a buffer and so on; a whole class of pointer errors, most of which have security repercussions, are annihilated by this feature. Similarly, Python uses exceptions, so nobody can forget to check and propagate a function's error return value.

More often than not, errors that surface in these languages are high-level problems, which is good, because those are simpler than the ones involving someone forgetting to call free() on an allocated buffer or accounting for overflow when shifting a bit mask.

The uncertainty involved in the dynamic typing/late binding model of such languages is compensated for through unit testing.

Oh, and JavaScript, a "dynamic language", is being used by Google in a production system, and Google is known to use Python and Ruby in their systems. I suggest you call them up and tell them their languages aren't suitable.

Re:Yah, good for Javascript! (0, Flamebait)

QuantumG (50515) | more than 9 years ago | (#11065031)

So the fact that there are absolutely no static type checking tools for Javascript has no affect on its maintainability? Get a grip sunshine.

It shouldn't be that hard. (1)

Ayanami Rei (621112) | more than 9 years ago | (#11064863)

javascript's type resolution is definition based
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. html

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).

Re:If they are smart, and they are, (0)

Anonymous Coward | more than 9 years ago | (#11064727)

how do you run JS code w/o a browser?

Re:If they are smart, and they are, (1)

itwerx (165526) | more than 9 years ago | (#11065012)

how do you run JS code w/o a browser?

I second this question!
I'm also wondering why the heck the original post that started this whole thread has been modded Flamebait?

not simply obfuscation (5, Insightful)

Glog (303500) | more than 9 years ago | (#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.

Re:not simply obfuscation (0)

Anonymous Coward | more than 9 years ago | (#11064173)

How about a webmail interface that doesn't have to load 1000 lines of executable code to your browser just to show a web page? I'd think that would save a lot of bandwidth.

Re:not simply obfuscation (0)

Anonymous Coward | more than 9 years ago | (#11064529)

You think roundtrips to the server don't take bandwidth? Javascript is the best thing possible for slow connections.

Re:not simply obfuscation (0)

Anonymous Coward | more than 9 years ago | (#11064199)

Wow, this reminds me of the old days on my VIC-20, where I crammed as much as possible on a single line of BASIC to save a few bytes of memory. I've come full-circle!

Re:not simply obfuscation (1)

PhlegmMaster (596165) | more than 9 years ago | (#11064207)

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... (1)

WIAKywbfatw (307557) | more than 9 years ago | (#11064340)

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.

Re:Exactly... (1)

photon317 (208409) | more than 9 years ago | (#11064402)


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.

Re:not simply obfuscation (1)

koreaman (835838) | more than 9 years ago | (#11064487)

You should see the disgusting code TI-BASIC programmers produce. Anything that the system will let you get away with that saves even 1 byte, people will do.
This includes mismatched quotation marks and parentheses. (The interpreter is not very strict syntactically)

Ah yes... the TI-83. (1)

Ayanami Rei (621112) | more than 9 years ago | (#11064633)

It kept me from falling asleep many a day in high school. Curse the unavailability of scalar variables... and only 6 precious, precious lists.

Re:Ah yes... the TI-83. (1)

koreaman (835838) | more than 9 years ago | (#11064646)

Don't forget using lists and matrixes to fake variables...
run out of your allotted 27 and 100->dim(L1) gets you 100 more :p

Re:not simply obfuscation (1)

gusnz (455113) | more than 9 years ago | (#11064982)

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 hacked up bunch of Regexes) in that form. There are numerous other [dithered.com] script processors out there too.

So in conclusion, this isn't really obfuscation (or at least not primarily obfuscation), just bandwidth saving. I'd be very suprised indeed to learn that they were dynamically generating JavaScript via Python (where did the submitter get that idea?). Writing a JS parser and compressor though is pretty simple regex work, and if you couple it together with a table of variable name replacements, you can easily autogenerate slimmed down script for the web.

Re:not simply obfuscation (1)

Rie Beam (632299) | more than 9 years ago | (#11065038)

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.

Re:not simply obfuscation (1)

recursiv (324497) | more than 9 years ago | (#11065048)

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?

Siebel? (1)

cdgod (132891) | more than 9 years ago | (#11063802)

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.

Re:Siebel? (0)

Anonymous Coward | more than 9 years ago | (#11063941)

Where's the HTML Link you fool?!?!

Gmail... love it... loving it... (0)

Anonymous Coward | more than 9 years ago | (#11063815)

First Post!!!

Sounds to me like you're spending too much time wondering what google is doing.

Re:Gmail... love it... loving it... (0)

Anonymous Coward | more than 9 years ago | (#11064168)

Not first post. Cockstick. Suck it.

Huh? (0)

Otter (3800) | more than 9 years ago | (#11063822)

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? (3, Informative)

Cecil (37810) | more than 9 years ago | (#11063892)

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?"

Re:Huh? (0)

Anonymous Coward | more than 9 years ago | (#11064117)

I am more confused by the fact that your posts imply you are new to slashdot and it's editors, but your UIDs disagree, that is more reason for "huh" then anything

Python Programmers (3, Funny)

bill_mcgonigle (4333) | more than 9 years ago | (#11064728)

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...

Re:Huh? (2, Insightful)

sethadam1 (530629) | more than 9 years ago | (#11064041)

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 an extra 3000 characters (3k) PER PAGE LOAD. Multiply that times thousands (tens of thousands after general release?), and you'll see A LOT of extra bandwidth.

Re:Huh? (1, Insightful)

Anonymous Coward | more than 9 years ago | (#11064256)

At 1000+ functions, if the function names had just 5 letters each (not much if you're not being terse), that would be an extra 3000 characters (3k) PER PAGE LOAD. Multiply that times thousands (tens of thousands after general release?), and you'll see A LOT of extra bandwidth.

You're forgetting the effects of caches. I agree that they probably developed the Javascript the way that they did to minimise bandwidth use, but the impact isn't anywhere near as much as you imply.

Re:Huh? (2, Insightful)

Anonymous Custard (587661) | more than 9 years ago | (#11064650)

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.

Re:Huh? (1)

mehu (92260) | more than 9 years ago | (#11064733)

Well, that js file would be cached by the browser, hopefully, not reloaded with every single page load.

True, but that's only per user. Thousands of different users would still generate thousands of hits, and thus thousands * 3k of unnecessary bandwidth.

One more for sure (1)

Tr0mBoNe- (708581) | more than 9 years ago | (#11063824)

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 (1, Redundant)

blindbat (189141) | more than 9 years ago | (#11063831)

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.

Gmail not that impressive (2, Insightful)

Anonymous Coward | more than 9 years ago | (#11063904)

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.)

Re:Gmail not that impressive (0)

Anonymous Coward | more than 9 years ago | (#11064148)

well before you show your trollmanship off lets compare apples to apples.

For one your use of "real programmer" versus "dreamweaver monkey" is insulting. Most webmasters have more skills then many coders. Application languages may be more complex but web programming and design take much more creativity.

Anyway since we ARE talking about a web app 1200 lines *IS* quite impressive for a web app and use of JS. So before you try posting as AC to either troll or just pat yourself on the back trying to make yourself feel better, remember putting down others to make yourself look better is a sure sign of self doubt. Lets not play down the impressiveness and skill it took to develop gmail. Regardless of your opinion of google, we are all techies here, lets appreciate talent no matter where it is displayed and whom ever displays it.

Re:Gmail not that impressive (0)

Anonymous Coward | more than 9 years ago | (#11064242)

Unwad your panties, It's not my problem that you have a chip on your shoulder because you can't teach yourself to write 1000 lines of code. Maybe you'd be a more useful interface guy if you could.

The point was that there's a stereotype that Javascript = Image Rollovers = 5 line snippets. This misconception is obviously what the story submitter was biased by.

And, no, 1200 lines of interface glue is not that impressive, and neither is the gmail DHTML UI. The backend is probably 100-1000x as many LOC.

Re:Gmail not that impressive (0)

Anonymous Coward | more than 9 years ago | (#11064707)

chip on shoulder?
Weren't you the one bashing web developers saying they were not as good as "real developers" ?

I am a developer and yes have worked on my large scale projects for many gov't contractors, but that does not mean it is okay to talk about about others in the industry because you think they are not as skilled at one thing as you are.

Re:Gmail not that impressive (0)

Anonymous Coward | more than 9 years ago | (#11064228)

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.

What the hell are you talking about? That's like saying "Real car people don't concern themselves with the body, just the engine"

Or to put it another way: how would you implement Gmail with your "server side framework"?

Re:Gmail not that impressive (0)

Anonymous Coward | more than 9 years ago | (#11064274)

> how would you implement Gmail with your "server side framework"?

With post-backs, duh (see most other webmail UIs).

BTW, I actually support doing heavy client-side stuff, just that GMail is not especially complex. You guys just haven't seen this stuff because until recently the public WWW was fixated on Netscape 4 support.

Re:Gmail not that impressive (2, Insightful)

PurpleFloyd (149812) | more than 9 years ago | (#11064673)

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 Google code, we can see that while it appears to be machine generated, it definately tends towards the latter; Google has obviously tuned the code to save bytes and run as quickly as possible. Bandwidth and processor power aren't so important in a corporate environment where everyone has a LAN connection to the server and decent machines to work on, but when you have to deal with customers on dialup links and using old machines, every bit and every instruction counts. In that scenario, 1200 lines can be an enormous amount of code.

Indispensable web applications (0, Troll)

jamienk (62492) | more than 9 years ago | (#11063918)

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.

Free Gmail (0)

Anonymous Coward | more than 9 years ago | (#11063927)

http://gmail.google.com/gmail/a-1487aa0e66-212dee0 389-dbe349c86a

http://gmail.google.com/gmail/a-1487aa0e66-2b9f7 61 c33-86ff8c2092

http://gmail.google.com/gmail/a-1487aa0e66-53c04 0c 20f-083934da2b

http://gmail.google.com/gmail/a-1487aa0e66-2e42c 84 247-1e80e12f44

Please take it if you will use it.

That was very nice of you (0)

Anonymous Coward | more than 9 years ago | (#11064429)

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)

MSN's Web Messenger Is Impressive (2, Interesting)

bdash (598142) | more than 9 years ago | (#11063934)

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.

Re:MSN's Web Messenger Is Impressive (0)

Anonymous Coward | more than 9 years ago | (#11064200)

Pretty interesting for a Microsoft service... the thing works with Firefox.

Re:MSN's Web Messenger Is Impressive (1)

figleaf (672550) | more than 9 years ago | (#11064505)

How did you manage to properly indend the code?

Re:MSN's Web Messenger Is Impressive (1)

bdash (598142) | more than 9 years ago | (#11064570)

A clever combination of regular expressions to add spacing around operators, newlines after semi-colons, braces, etc. combined with Emacs' indent-region to add indentation. :-) The downside is that some of the HTML inside string literals got a bit mangled, but for educational purposes that isn't a big deal.

Re:MSN's Web Messenger Is Impressive (1)

jpmkm (160526) | more than 9 years ago | (#11064999)

There is also a nice command called 'indent'.

Re:MSN's Web Messenger Is Impressive (1)

bdash (598142) | more than 9 years ago | (#11065045)

Sure, that would be an ideal tool to use. Sadly, it is designed for use with C and doesn't work very well with Javascript code. In particular it seems to struggle quite badly (which is understandable) with function definitions of the form:

foo = function(a, b, c)
{
// ...
}

Gmail accounts (1)

new-black-hand (197043) | more than 9 years ago | (#11063979)

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.

Re:Gmail accounts (1)

new-black-hand (197043) | more than 9 years ago | (#11064104)

Thanks to everyone who sent out gmail invites - but they are not required anymore.

OT alert (1)

empaler (130732) | more than 9 years ago | (#11064446)

If there are so many with excess invites, I'd like one too... please?

Pretty please?

Re:OT alert (1)

cow ninja (306125) | more than 9 years ago | (#11064547)

augh.. can't figure out your email.. @avttasihdob ?

Yes and No (1)

nacturation (646836) | more than 9 years ago | (#11064014)

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.

Re:Yes and No (1)

file cabinet (773149) | more than 9 years ago | (#11064072)

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).

Re:Yes and No (0)

Anonymous Coward | more than 9 years ago | (#11064153)

Given that gmail only targets modern browsers, the cross-browser stuff is probably not that big of a deal for anyone who knows their stuff. I wrote about 7K lines of Javascript for IE and only had to change about 5 lines to get it working on Mozilla. The real bitch for them is probably Safari support.

Just quick and easy (0)

Zareste (761710) | more than 9 years ago | (#11064062)

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.

Re:Just quick and easy (1)

file cabinet (773149) | more than 9 years ago | (#11064092)

using one letter variables is a horrible idea in practice(although there is an exception-- for auto incrementing variables, i++). who the fuck wants to maintain an application with 2-letter functions? a word is much easier to remember then 2-letters. Google most likely has a framework of how they do things and having short JS variables/id's/classes is part of that. 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. that's horrible logic.

Re:Just quick and easy (3, Interesting)

ComputerSlicer23 (516509) | more than 9 years ago | (#11064125)

Ironically, the one of the best tips from one the best programmers I've ever known, is use the form "iii" for all incremented variables. Why? Because if you use English Language descriptions, "iii" should never occur when searching except for in the case of your variable. However, if you use i,j,k (the standard loop variables), when you search for them, you constantly have to search, and search again because you find those letters embedded in function names or keywords.

Kirby

Re:Just quick and easy (1)

lupin_sansei (579949) | more than 9 years ago | (#11064272)

Any text editor worth its salt has a option in the search function to match the whole word, and not the text anywhere in another word.

Re:Just quick and easy (0, Offtopic)

ComputerSlicer23 (516509) | more than 9 years ago | (#11064343)

I'm sure I could find a different editor, but "ESC/iii" is how I do searching. I really don't care to figure out how to write a better expression in vim. vim is well worth it's salt, and I could probably map a macro to work for searching for a word. However, by default I'm not aware of any such option short of writting a longer regular expression that I would to search for an increment variable. Every programmer worth their salt I've known uses some vi varient or emacs. Off hand I don't know how to search in emacs, but I'll bet it's a quicker and easier for the hot key for "search", as opposed to "search for full words".

Any editor that I need to use a mouse with is defective. Mice are only good to feed cats and pick the xterm you want to use.

Kirby

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064692)

ESC/\ will search for the whole word "i".

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064716)

Argh. Make that ESC/\<i\> . Forgot I was typing HTML.

Re:Just quick and easy (3, Funny)

Karora (214807) | more than 9 years ago | (#11064277)


For the number of times "ii" occurs in english you could save yourself a character, right there.

Now, I'm off for a bit of skiing...

Re:Just quick and easy (3, Funny)

Pig Hogger (10379) | more than 9 years ago | (#11064512)

For the number of times "ii" occurs in english you could save yourself a character, right there.
Now, I'm off for a bit of skiing...
He was working for a ski resort, you insensitive clod!!!

Re:Just quick and easy (2, Funny)

fiftyfly (516990) | more than 9 years ago | (#11064927)

*correction - a water skiing resort... in hawaii... working on an ascii front end for a diiodide metering device... Just a though: /usr/share/dict $ grep -ic ii words 419

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064290)

But why would you be searching for those variables in the first place? If they are just loop variables, you should easily see where they are used. If you have some gigantic loop with pages of code, then that sounds like a prime target for refactoring.

Re:Just quick and easy (2, Interesting)

JabberWokky (19442) | more than 9 years ago | (#11064291)

Most editors have a search that takes into account the various word breaks. Most programmers editors are smart enough to automatically identify the language and know where "words" break in variables (i.e, car->door is one word, while truck>car is two words split by an operator... although I hate spaceless operators myself). Very helpful when you're using word by word selectors to cut and paste.

Aside: I generally use c for my incrementing variables, and foo for my unknown type variables (common in returns in un- or loosely typed languages.

OnTopic: Looking at the code, Google likely has a more verbose code base and runs it through a stripper that minimizes the code and removes comments and excess whitespace. Since they use Python internally, especially in their GMail site, it would be a likely choice for such an app.

While the one and two letter variable names are not at all unmaintainable, I'd imagine that comments and most importantly, indentation are maintained in the original.

--
Evan

Re:Just quick and easy (1)

ComputerSlicer23 (516509) | more than 9 years ago | (#11064344)

The best editor I've ever seen doesn't, without quite a bit of extra typing. Get used to vi varient sometime, it's generally much faster. I use vim as my development IDE. ":make" will build the software and take you to the next error. ":!" will let you see the console that has all the errors (actually, it will let you see the shell that all your stuff runs it). "cn" will take you to the next error.

I could probably map a macro to something like "search whole word" if I felt like it. However, I've found using "iii" to be an idiom well worth using in conjuction with vim.

Kirby

there is no spoon (1)

Nykon (304003) | more than 9 years ago | (#11064197)

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.

Re:Just quick and easy (1)

Pig Hogger (10379) | more than 9 years ago | (#11064210)

Compiled languages could not care less if your variables names are 1, 2, or 36 characters long, they always compile to the same 16/32/64 bit reference.

The objection may be valid for an interpreted language; however, for this, you can use a pre-processor that will substitute a terse compact name for a long explicit one.

I did that some 15 years ago when I had to maintain 15-20 year old Business-Basic code which did not allow more than 1 letter + 1 digit variables name.
I wrote a pre-compiler that allowed long variable names that you could pre-define (for existing code) and explicit line labels names, as well as permitting do-while and do-until loops (translated as IFs and GOTOs).
The end-code had also plenty of REMarks containing the "source" code so you could see what the program did even by looking at the resulting "object" basic code.

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064862)

Another thing is that on the server side they could be using some sort of program that spews out the JavaScript code on the fly, sort of like what ASP.Net's server-side objects do: they spew out JavaScript functions to the client that do all the callbacks to the server to do the processing.

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064229)

From your .sig:
Remind me why it's NOT cruel and unusual to be thrown into a cage with rapists and murderers

When you have willingly violated the law, knowing the consequences? When you have raped and murdered others?

Do you have a better way to:
Prevent people from breaking the law
Punish them when they do
Prevent them from breaking the law again

Freedom, in the US, is a priveledge that is taken away when you choose not to follow the rules that freedom requires.

I find two other things funny about your statement. First, you imply that there are a lot of rapists and murderers in said cage, but the fact is that they are in the minority. Second, you place yourself above them, when the reality is that if you've broken the law, you are just as bad as they - you followed your lusts and desires and left the bounds society has set for everyone. In the USA, those bounds are increasing day by day, but even if they weren't increasing, they are already exceptionally large. Do you seriously think that you are so confined by these laws and rules that you cannot exist within them? This speaks of a great deal of pride on your part.

Unjust laws and unjust rulers have existed since the dawn of time. Our society has ways and means to change the laws if you feel disenfranchised, but there's always going to be a line (setting aside anarchy for a moment) and someone is always going to be on the wrong side of it. Are you suggesting that you know where that line should be for everyone in our society? How do you answer the person who is on the other side of your line? Or are you so self centered that you don't care what everyone else wants, society's rules should allow for your desires?

Please keep in mind that there's always means to escape to another society if you feel that our society's rules and laws do not suit you.

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064298)

you're an idiot

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064533)

I beg to differ. He's actually a fucktard, and for the crime of posting nonsense, he needs to be sentenced to a good "pound you in the ass" correctional facility.

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064309)

> I know my life is much easier when I use one-letter variables,

That feeling is called Job Security, but don't get addicted to it.

Re:Just quick and easy (0)

Anonymous Coward | more than 9 years ago | (#11064719)

yeah but what about the poor programmers who have to read your code later?

Gmail, you know what to do (0)

Anonymous Coward | more than 9 years ago | (#11064068)

http://gmail.google.com/gmail/a-1487aa0e66-c6fdec5 90f-3dcd265be5

http://gmail.google.com/gmail/a-1487aa0e66-806e1 31 b55-0a51b018ce

why Python if you have JavaScript? (2, Interesting)

Anonymous Coward | more than 9 years ago | (#11064108)

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?

Is it at all needed? (1)

PhlegmMaster (596165) | more than 9 years ago | (#11064240)

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.

Re:Is it at all needed? (1)

Anonymous Custard (587661) | more than 9 years ago | (#11064682)

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).

If you're talking about Firefox tabs, I've had no problem CTRL-clicking and open a link inside an email into a tab...

Re:Is it at all needed? (1)

PhlegmMaster (596165) | more than 9 years ago | (#11064743)

Nope, Safari.

It's all a matter of perception (2, Interesting)

sakusha (441986) | more than 9 years ago | (#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.

It's all a matter of perception-Hard Times. (0)

Anonymous Coward | more than 9 years ago | (#11064792)

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.

Re:It's all a matter of perception-Hard Times. (0)

Anonymous Coward | more than 9 years ago | (#11064870)

Hmm... aren't the mechanics of making a good movie just the same as making a bad movie?

I think most bad movies fall apart on two things: bad script and bad editing, which is indirectly related to bad script.

If you tell a good story, people will tend to like the movie. All the fancy graphics, special effects and big names aren't able to overcome a bad foundation ("Gigli" comes immediately to mind).

Re:It's all a matter of perception-Hard Times. (1)

sakusha (441986) | more than 9 years ago | (#11064997)

Nah, there's not much you can do with a list like that. Instead, how about a list of things that are really simple, but people persistently believe are terribly difficult? Now THAT would have some potential!

I'll start the list:

1. Counting votes.

GMail Invite (1)

drkich (305460) | more than 9 years ago | (#11064852)

You insensitive clod, I don't have a gmail account to look at it... :) Unless someone wants to send me one.

Re:GMail Invite (1)

drkich (305460) | more than 9 years ago | (#11064877)

Thank you all for your invitations, I do appreciate it!

This sophisticated? (1)

Wolfkin (17910) | more than 9 years ago | (#11064881)

"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".
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?