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?"
not simply obfuscation (Score:5, Insightful)
Re:not simply obfuscation (Score:2)
Exactly... (Score:2)
Re:Exactly... (Score:2)
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 (Score:2)
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
Re:not simply obfuscation (Score:2)
Re:not simply obfuscation (Score:2)
Re:not simply obfuscation (Score:2)
Re:not simply obfuscation (Score:2)
Re:not simply obfuscation (Score:4, Informative)
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.
Re:-1 WTF? (Score:2)
I didnt say that ISPs charged google on a per-page basis, but what google pays for their bandwidth is the sum of all pages served and in there lies your per-page bandwidth cost.
Supermarkets dont charge you by the pea, but if you buy a bag of 500 peas for $5.00, then you have a per-pea cost of $0.01.
Also, if you have 50 part-time monkeys making $10K/year to swap out br
Re:not simply obfuscation (Score:2)
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
Re:not simply obfuscation (Score:2)
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).
Re:not simply obfuscation (Score:2)
Ever hear of CADOL? (Score:2)
NL
NL
rather than NL 2.
Siebel? (Score:1)
Incredibly well designed, flexible, and scalable.
They are years ahead of the nearest competition.
Huh? (Score:1)
1) How the hell would we know?
2) Where did you get "in Python" from?
Re:Huh? (Score:4, Informative)
However, it was completely uncalled for speculation that had no place in a Slashdot article.
I'm with you, "huh?"
Python Programmers (Score:4, Funny)
Re:Python Programmers (Score:2)
Re:Python Programmers (Score:2)
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+
Re:Python Programmers (Score:2)
Re:Huh? (Score:3, Insightful)
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)
Well, that js file would be cached by the browser, hopefully, not reloaded with every single page load.
Re:Huh? (Score:2)
One more for sure (Score:1)
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)
Gmail not that impressive (Score:2, Insightful)
(*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 (Score:3, Insightful)
Looking at the Goog
Re:big stinking piles of code (Score:2)
I think this is really all I have to say about that. [icarus.net]
Re:Gmail not that impressive (Score:2)
Dreamweaver monkey's are web designers. They are visual types who can't handle even a simple code like html (which is why they are using an html editor rather than a text editor). Web developers are programmers who happen to work with web based applications. Two different animals.
Re:Gmail not that impressive (Score:2)
"Most webmasters have more skills then many coders. Application languages may be more complex but web programming and design take much more creativity."
More skills at what? Most "webmasters" are frontpage users. Not saying all but most are just putting up html using a visual editor. Now some are very tallented. As to web design taking much more creativity? How do you figure? I mean an app is an app. None of your statments have any basis in fact.
Indispensable web applications (Score:1, Troll)
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
MSN's Web Messenger Is Impressive (Score:3, Interesting)
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 (Score:2)
Re:MSN's Web Messenger Is Impressive (Score:2)
Re:MSN's Web Messenger Is Impressive (Score:2)
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:
Gmail accounts (Score:2)
Re:Gmail accounts (Score:2)
Yes and No (Score:2)
Re:Yes and No (Score:1)
Re:Yes and No (Score:2)
Of course, 1149 codes is after being condensed without comments. Anyone can probably crank out 1149 lines of javascript in a couple of days. The guesstimate of a month is with full testing, debugging, making it work cleanly and intuitively, creating the user interface, etc. Writing the code isn't always the hardest part of creating a fully functional site. The way you put it, you'd think that a single developer at Google just whipped out a
why Python if you have JavaScript? (Score:2, Interesting)
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?
Re:why Python if you have JavaScript? (Score:2)
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.
Sure... (Score:2)
Is it at all needed? (Score:2)
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
Re:Is it at all needed? (Score:2)
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? (Score:2)
Re:Is it at all needed? (Score:2)
Re:Is it at all needed? (Score:2)
Re:Is it at all needed? (Score:2)
(I also don't have an Adblocker installed)
It's all a matter of perception (Score:3, Interesting)
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.
Re:It's all a matter of perception-Hard Times. (Score:2)
I'll start the list:
1. Counting votes.
Re:It's all a matter of perception-Hard Times. (Score:2)
GMail Invite (Score:2)
Re:GMail Invite (Score:2)
Plone never ceases to amaze me... (Score:2)
Run one of the videos. If you have Plone give it a try. Slick.
Bandwidth Savings (Score:2)
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.
Browser Incompatibility (Score:2)
Google needs to focus on their search engine (Score:2)
math & case sensitivity observations (Score:2)
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 t
Gmail is just the beginning of such apps (Score:2)
Re:If they are smart, and they are, (Score:2)
Re:If they are smart, and they are, (Score:1, Flamebait)
Re:If they are smart, and they are, (Score:4, Informative)
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, (Score:2)
People seem to have it out for Javascript at Slashdot. Heh. A lot of negativity towards the language. I've seen some beautiful javascript, but I guess I'm one of the few.
Re:If they are smart, and they are, (Score:2)
I think this is true, but language is a factor. I have a soft spot in my heart for Perl, but I would much rather get handed 100kloc of badly written Java than badly written Perl.
Re:If they are smart, and they are, (Score:2)
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
On the subject of code maintenance.... (Score:2)
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
Re:If they are smart, and they are, (Score:2)
Re:If they are smart, and they are, (Score:4, Insightful)
Re:If they are smart, and they are, (Score:1, Interesting)
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 dy
Yah, good for Javascript! (Score:3, Interesting)
Dynamic languages are kick ass, I really really like them, but they're for prototyping, not writing maintainable
Re:Yah, good for Javascript! (Score:4, Interesting)
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! (Score:3, Interesting)
Yes. JavaScript is a poor language, but for other reasons than a lack of a static type system.
You're obviously trolling. Present us with arguments supporting to the proposition that dynamic typing decreases maintainability, and we'll have a discussion. Until then, you're just spouting FUD.
I have already given ample explanations for my view, but here's a counter
Re:Yah, good for Javascript! (Score:3, Interesting)
Re:Yah, good for Javascript! (Score:3, Interesting)
Please. I mentioned unit testing in my first reply, where I wrote:
I also linked to an interview with Guido van Rossum where he talks about this very topic, so if you think I'm ignorant
It shouldn't be that hard. (Score:2)
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)
Re:Yah, good for Javascript! (Score:2)
AOP is pretty integral to maintaining dynamic code, but thats yet another can of worms. the situation gets messy, but ultimately it needs to get messy.
dynamic languages are convenient to code in, but essential to the future of web architecture.
system.reflection is pretty juicy stuff.
Re:If they are smart, and they are, (Score:2)
I second this question!
I'm also wondering why the heck the original post that started this whole thread has been modded Flamebait?
Re:If they are smart, and they are, (Score:2)
Re:Just quick and easy (Score:1)
Re:Just quick and easy (Score:4, Interesting)
Kirby
Re:Just quick and easy (Score:4, Funny)
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 (Score:3, Funny)
Re:Just quick and easy (Score:3, Funny)
Re:Just quick and easy (Score:2)
The sig is what makes this post doubleplusfunny.
But to stay on topic: I you wrote proper code, you would never, never ever search/grep or a variable like 'i'. Such a variable name belongs to a small loop (e.g. one that iterates through an array and increments an index) that can be read and understood quickly. It still might be better, depending on the circumstances, to call it 'count', 'xCoord', or 'offset', if
Re:Just quick and easy (Score:3, Interesting)
Aside: I generally use c for my incrementing variables, and foo for my unknown type variables (common in r
Re:Just quick and easy (Score:2)
I could probably map a macro to something like "search whole word" if I felt like it. However, I've fo
Re:Just quick and easy (Score:2)
Without quite a bit of extra typing? You just need to add triangle brackets to signifiy the word break. (Don't forget to escape them.) For instance, if I want to search for words ending in x, I type "/x\>" (the front slash to signify the search). For the word "i" all alone, it's "/\". Simple as that.
Re:Just quick and easy (Score:2)
vi-family editors will certainly edit on a word by word basis - hit right and then 'w' (see above for searching on a word), and I'm fairly certain that vim will allow you to specify what constitutes a word break.
I agree that vi is pretty powerful. I used it for most of a decade when I was on Unix variants.
--
Evan
Re:Just quick and easy (Score:2)
Oh my.
Re:Just quick and easy (Score:4, Informative)
In regular C, for a function, it's actually highly useful, and extremely desirable. Go look in any extremely large body of C code. You'll find out just how desireable C static functions are. They are used all the time inside of the Linux kernel. They guarantee that the linker won't make that symbol available externally. Which is great for avoiding two different functions with the same symbol.
In regular C, using static on a global variable also makes it have no external linkage. It also moves where the memory is actually set aside. Which changes when it gets initialized, and how large your executables are. I believe it's also a very good way to ensure your variables are safe to use in signal handler context. This is common go look at the Linux kernel. Happens all the time. Highly useful application of static.
In regular C, using static on a variable in function scope, can be useful, if it is also a constant. In that case, you can move the space off the stack and into the BSS section (at least under UNIX, I forget the equivilent under a Win32 platform). This again is used all the time in the Linux kernel. It shrinks the stack usage and saves space. As I recall, you want to declare all strings that are constants as:
static const char foo[] = "foobar";
It saves space in the kernel. I forget exactly why it does right off hand, but it has to do with the assembly that GCC outputs. I might have that wrong, you might want to do "*foo" instead of "foo[]", but you get the idea.
Now, in regular C using static on a variable in function scope to store state between function calls is an excellent way to introduce a race condition. So your blanket statement that "static is evil" is blantantly wrong. Whoever or where ever you learned it from was mimicing what they'd heard before without any understanding. Next you'll be telling me there's no good use of "goto's" either. Which isn't the case, they are few and far between, but they do exist. I've never come across one, but I am aware of when they would be useful. I could make use of them, but generally performance, cache coherency, and "the fast path" aren't things I generally have to worry about. Those are the types of problems we just throw more hardware at and keep the code highly maintainable.
I learned about a lot of thinks from my old boss, but the "iii" was one of the truely unique things, I've never seen anywhere else. Any good text on C programming will explain what I just did. The small useful things that you just deal with all the time because you never stop to think of a better solution. Paul didn't have too many of those. He recongized anytime something was difficult, and pondered the problem until it was easy. Just like, he knew when static was a good idea. Although I actually picked that up at school, during the explaination of Ada. You can do something named modules in Ada, that you can somewhat duplicate in C with static and separate translations units.
The truly most useful thing Paul ever taught me was just assume all of your code leaks memory. Assume your code will segfault because there is a bug in it. Assume you'll get crappy data that will lead to pathelogical cases. Design your code so that as much as possible that doesn't make any difference in terms of your ability to process data that doesn't cause a memory leak, a segfault, or isn't malformed. Never get stuck when there is more data to try. If some data elements blow up your code. Timestamp when you tried them and don't retry them for a while so you can work on other data. Any time you are doing batch processing, you should always have a parent that is deathly simple that will spawn children that do the real work.
Re:Just quick and easy (Score:2)
I was poking fun at your tidbit because these days IDEs will find variables for you without text searches.
Re:Just quick and easy (Score:2)
Which reminds me of my favourite sites to visit when my internet access is through monitored firewalls (corporate or university systems)
http://xxx.lanl.gov/ [lanl.gov]
http://xxx.arxiv.cornell.edu/ [cornell.edu]
http://xxx.adelaide.edu.au/ [adelaide.edu.au]
http://xxx.uni-augsburg.de/ [uni-augsburg.de]
Yep, folks - Governments and Universities worldwide, hosting xxx sites. And for what it's worth, xxx.lanl.gov was the original!
Re:Just quick and easy (Score:2)
Re:Just quick and easy (Score:2)
It's much easier then just scanning for them by eye, and more accurate (computers are good at looking for a series of text, my eyes aren't nearly as fast). Plus I won't have the
Re:Just quick and easy (Score:2)
Well, aren't you clever not bothering to clarify so I could possibly understand what you mean. I've never said anything about naming anything besides an "increment" variable used in a for loop. You start discussing giving variables "meaningful names". In sections you can't refactor.
there is no spoon (Score:1)
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 (Score:1)
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 lo