Slashdot Mirror


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

137 of 197 comments (clear)

  1. not simply obfuscation by Glog · · Score: 5, Insightful

    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.

    1. Re:not simply obfuscation by __aafkqj3628 · · Score: 1

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

    2. Re:not simply obfuscation by koreaman · · Score: 1

      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)

    3. Re:not simply obfuscation by gusnz · · Score: 1

      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 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 (basically a hacked up bunch of Regexes) in that form. There are numerous other 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.

    4. Re:not simply obfuscation by Rie+Beam · · Score: 1

      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.

    5. Re:not simply obfuscation by recursiv · · Score: 1

      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?

      --
      I used to bulls-eye womp-rats in my pants
    6. Re:not simply obfuscation by Rie+Beam · · Score: 1

      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.

    7. Re:not simply obfuscation by eggstasy · · Score: 3, Informative

      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.

    8. Re:not simply obfuscation by Fweeky · · Score: 1
    9. Re:not simply obfuscation by gl4ss · · Score: 1

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

      --
      world was created 5 seconds before this post as it is.
    10. Re:not simply obfuscation by sporktoast · · Score: 1

      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 mortgage AND buy me that new car AND...
      --
      In a related story, the IRS has recently ruled that the cost of Windows upgrades can NOT be deducted as a gambling loss.
    11. Re:not simply obfuscation by i.r.id10t · · Score: 1

      Similar to what caused the Y2K "problem" for many, only that was saving memory as opposed to bandwidth....

      --
      Don't blame me, I voted for Kodos
  2. Siebel? by cdgod · · Score: 1

    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 .Sig is left intentionally humourless.
  3. One more for sure by Tr0mBoNe- · · Score: 1

    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(); };
  4. not obsuring by blindbat · · Score: 1, Redundant

    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.

  5. Re:Huh? by Cecil · · Score: 3, Informative

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

  6. Gmail not that impressive by Anonymous Coward · · Score: 2, Insightful

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

    1. Re:Gmail not that impressive by PurpleFloyd · · Score: 2, Insightful
      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.

      --

      That's it. I'm no longer part of Team Sanity.
    2. Re:Gmail not that impressive by shaitand · · Score: 1

      Web developers are not dreamweaver monkeys. Web developers are web developers, they write code.

      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.

    3. Re:Gmail not that impressive by LWATCDR · · Score: 1

      But some of your statments are just wrong.
      "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.

      --
      See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
    4. Re:Gmail not that impressive by Malevolyn · · Score: 1

      And most still use tables, too. I like pure CSS layouts.

      --
      Your ad here.
  7. Re:If they are smart, and they are, by I_Love_Pocky! · · Score: 1

    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.

  8. MSN's Web Messenger Is Impressive by bdash · · Score: 2, Interesting

    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.

    1. Re:MSN's Web Messenger Is Impressive by figleaf · · Score: 1

      How did you manage to properly indend the code?

    2. Re:MSN's Web Messenger Is Impressive by bdash · · Score: 1

      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.

    3. Re:MSN's Web Messenger Is Impressive by jpmkm · · Score: 1

      There is also a nice command called 'indent'.

    4. Re:MSN's Web Messenger Is Impressive by bdash · · Score: 1

      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)
      {
      // ...
      }
  9. Gmail accounts by new-black-hand · · Score: 1

    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.

    1. Re:Gmail accounts by new-black-hand · · Score: 1

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

    2. Re:Gmail accounts by technicolor_guru · · Score: 1

      If anyone is still being generous with the invites, I'd like one (johnathan@airbrushguy.com)

  10. Re:If they are smart, and they are, by OmniVector · · Score: 1

    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.

    --
    - tristan
  11. Re:If they are smart, and they are, by T-Ranger · · Score: 3, Insightful

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

  12. Re:If they are smart, and they are, by I_Love_Pocky! · · Score: 3, Informative

    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.

  13. Yes and No by nacturation · · Score: 1

    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.
    1. Re:Yes and No by file+cabinet · · Score: 1

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

    2. Re:Yes and No by nacturation · · Score: 1

      F**k, what country are you from? 1149 lines of code in a month?

      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 fully polished interface in a couple of weeks and they slapped it onto the site because it worked flawlessly the first time. I don't think so.

      --
      Want to improve your Karma? Instead of "Post Anonymously", try the "Post Humously" option.
  14. Re:Huh? by sethadam1 · · Score: 2, Insightful

    Actually, if you browse around Google and Gmail, you'll find tons of links like this one - 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.

  15. Re:If they are smart, and they are, by Anonymous Coward · · Score: 1, Interesting

    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.

  16. Re:Just quick and easy by file+cabinet · · Score: 1

    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.

  17. why Python if you have JavaScript? by Anonymous Coward · · 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?

    1. Re:why Python if you have JavaScript? by pragma_x · · Score: 1

      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.

  18. Re:Just quick and easy by ComputerSlicer23 · · Score: 3, Interesting
    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

  19. there is no spoon by Nykon · · Score: 1

    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"
  20. Re:Just quick and easy by Pig+Hogger · · Score: 1
    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.

  21. Is it at all needed? by __aafkqj3628 · · Score: 1

    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.

    1. Re:Is it at all needed? by Anonymous+Custard · · Score: 1

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

    2. Re:Is it at all needed? by __aafkqj3628 · · Score: 1

      Nope, Safari.

    3. Re:Is it at all needed? by __aafkqj3628 · · Score: 1

      For me, it only happens when I try and load gmail for the first time (ie. http://gmail.com/), not on conversations or anything inside gmail.

      (I also don't have an Adblocker installed)

    4. Re:Is it at all needed? by Anonymous+Custard · · Score: 1

      Oh well :)

    5. Re:Is it at all needed? by __aafkqj3628 · · Score: 1

      Yeah, I've got Apple Mail, why should I take anything less? ;)

  22. Re:Huh? by Anonymous Coward · · Score: 1, Insightful

    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.

  23. Re:Just quick and easy by lupin_sansei · · Score: 1

    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.

  24. Re:Just quick and easy by Karora · · Score: 3, 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...

    --

    ...heellpppp! I've been captured by little green penguins!
  25. It's all a matter of perception by sakusha · · Score: 2, Interesting

    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.

  26. Re:Just quick and easy by JabberWokky · · Score: 2, Interesting
    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

    --
    "$30 for the One True Ring. $10 each additional ring!" -- JRR "Bob" Tolkien
  27. Exactly... by WIAKywbfatw · · Score: 1

    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
    1. Re:Exactly... by photon317 · · Score: 1


      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.

      --
      11*43+456^2
  28. Re:Just quick and easy by ComputerSlicer23 · · Score: 1
    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

  29. Yah, good for Javascript! by QuantumG · · Score: 2, Interesting
    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.

    --
    How we know is more important than what we know.
    1. Re:Yah, good for Javascript! by Earlybird · · Score: 3, Interesting
      • 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, and has been proven false countless of times, such as by these guys, or these guys, or even these guys, or, God forbid, you may have heard of these guys.

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

    2. Re:Yah, good for Javascript! by Earlybird · · Score: 2, Interesting
      • So the fact that there are absolutely no static type checking tools for Javascript has no affect on its maintainability?
      Yes. JavaScript is a poor language, but for other reasons than a lack of a static type system.

      • Get a grip sunsine.

      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-argument to the specific case of typing: Static typing, unless implemented from the bottom up with Ocaml-style type inference (which leads to other interesting problems), adds more metadata to the program, which adds to the amount of text that must be typed, read, digested. Compare:

      int a = 1;
      with
      a = 1
      The intent, in both cases, is absolutely clear. The second syntax is simpler, shorter, and more readable.

      Readability is a huge maintenance consideration. Ease of refactoring is another; if a should be changed to be short, much use of the variable needs to update to accomodate this change -- expressions, function calls, function prototypes and so on. This is why nascent IDEs such as Eclipse focus so much on automatic refactoring, because refactoring is a pain to do in statically-typed languages.

    3. Re:Yah, good for Javascript! by QuantumG · · Score: 2, Interesting
      The reason I'm not taking you seriously is because you don't even seem to be aware of the arguments for and against dynamically types languages. I mean, you havn't even mentioned unit testing yet. People who know what they are talking about understand that you can't do serious programming in a dynamically typed language without a strong unit test framework and then you live and die by that framework. The unit testing consists almost 100% of manual type checking and verification of invariants, pre-conditions and post-conditions. The argument for dynamically typed languages is that the lack of a static type checker forces you to write the unit tests which then encourages you to add this verification of the program to them. Whereas people who use exclusively statically typed languages often don't feel the need for unit tests and therefore let more bugs slip into production.

      That's a good argument for dynamically typed languages which honestly addresses its shortcomings and suggests ways to avoid them. You havn't said anything similar, so I have to assume that you're not aware of the shortcomings of dynamically typed languages and have no idea how to avoid them.

      Now that I've actually made a sensible argument for you, I'll indulge myself with a retort. Unit testing is indeed important and when used with a statically typed language even more effective than a dynamically typed language - because at least half of the bulk of the unit tests can be dropped because it is done with a type checker. As more formal methods become available the bulk of unit tests will become even smaller for statically typed languages but will remain the same for dynamically typed languages. This has already happened for languages like Eiffel where verification of object contracts is now automated. These methods are becoming available for Java too.

      --
      How we know is more important than what we know.
    4. Re:Yah, good for Javascript! by Earlybird · · Score: 2, Interesting
      • The reason I'm not taking you seriously is because you don't even seem to be aware of the arguments for and against dynamically types languages. I mean, you havn't even mentioned unit testing yet.

      Please. I mentioned unit testing in my first reply, where I wrote:

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

      I also linked to an interview with Guido van Rossum where he talks about this very topic, so if you think I'm ignorant of the issues involved, you must be purposely ignoring what I'm writing. Thanks for trolling again.

      • This has already happened for languages like Eiffel where verification of object contracts is now automated. These methods are becoming available for Java too.

      Sorry, but interface contracts have very little to do with static type checking.

      A pre-condition is typically something like whether a value is within a range, or that an argument is not null, or an array has a certain length, or that an instance is of a certain class at runtime; not whether it's an integer or a string.

      Design by contract, being unrelated to static type checking, is therefore a concept that is equally applicable to both statically- and dynamically-typed languages, the main difference being that in a dynamically typed language, the checks may only occur at runtime.

      There is nothing preventing dynamically typed languages from doing automated type checking. This and this make a good start. The latter is similar to Java 5.0's annotation system.

      As for unit tests consisting of type checks, you will probably find that the overlap is larger than you think. Even if a method in Java returns a StringBuffer object, the Java interface can never explain what the contract is: whether it's allowed to return null, whether it always returns a different instance, what that object is supposed to contain.

      You will find that in Python, for example, the checks are more or less the same; if the method returned Fnarg instead of the expected object, your test will fail -- unless Fnarg happens to behave like what you wanted, in which case everything is all right. As for input, regardless of the type of language, throwing garbage at functions is always useful; with dynamically typed languages, you might just end up throwing a little more garbage.

      Unit tests are supposed to be simple and quick to write. Languages like Python are known to support much more rapid development. Even if you add 20% more checks, you'll still come out on top. Ever worked with lists and maps in Java? They're not first-class objects, so they're a nightmare to manipulate. Such structures are extremely common in tests. (I have been writing Java and Python unit tests every day for four years, so I know where the differences are.)

      (As an aside, if in your mention of Eiffel you're referring to design by contract, the concept was invented for Eiffel, so saying it's "now automated" is like saying the Eiffel tower is now made out of steel.)

    5. Re:Yah, good for Javascript! by Anonymous Coward · · Score: 1, Insightful

      God forbid, you may have heard of these guys [slashdot.org].

      It is a well-known fact that the slashdot codebase is so poorly written that it would be a monumental task to make it product valid html. So, I wouldnt go holding slashdot up as an example of how to write maintainable code with perl.

    6. Re:Yah, good for Javascript! by LordMyren · · Score: 1

      i sincerely hope you're trolling if your proposing that dynamic languages are un-usable as production devices.

      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.

  30. Re:If they are smart, and they are, by binary42 · · Score: 1

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

    --
    ruby -le"32.times{|y|print' '*(31-y),(0..y).map{|x|~y&x>0?' .':' A'}}"
  31. OT alert by empaler · · Score: 1

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

    Pretty please?

    1. Re:OT alert by cow+ninja · · Score: 1

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

    2. Re:OT alert by CableModemSniper · · Score: 1

      Try it backwards.

      --
      Why not fork?
  32. Re:Just quick and easy by Pig+Hogger · · Score: 3, 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...
    He was working for a ski resort, you insensitive clod!!!
  33. Ah yes... the TI-83. by Ayanami+Rei · · Score: 1

    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
    1. Re:Ah yes... the TI-83. by koreaman · · Score: 1

      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

  34. Re:Huh? by Anonymous+Custard · · Score: 2, 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.

  35. Python Programmers by bill_mcgonigle · · Score: 3, Funny

    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)
    1. Re:Python Programmers by TheSHAD0W · · Score: 1

      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 all, it's okay, but there's plenty of room for improvement.

    2. Re:Python Programmers by Cecil · · Score: 1

      I'm actually a Python programmer too, and I do believe that it's the best language for every job, and it could in fact be what makes the Holy Grail work.

      I'm not really an evangelist, though. ;)

    3. Re:Python Programmers by tdelaney · · Score: 1

      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++ - usually a wild store, mismatched memory allocation/deallocation, etc. If this is the case, please submit a bug report to the author of the third-party library.

    4. Re:Python Programmers by TheSHAD0W · · Score: 1

      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.

    5. Re:Python Programmers by Malevolyn · · Score: 1

      I'm also a Python programmer. I do believe Python is good for just about everything, but I honestly don't think it was the best language for something like BitTorrent. As stated above, the memory requirements are quite large at times, and shifting as much data around as BitTorrent does, it's not very well suited. Although, Java actually does it quite well, one reason I like Azureus.

      --
      Your ad here.
  36. Re:Huh? by mehu · · Score: 1

    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.

  37. Re:If they are smart, and they are, by bill_mcgonigle · · Score: 1

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

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
  38. GMail Invite by drkich · · Score: 1

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

    1. Re:GMail Invite by drkich · · Score: 1

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

    2. Re:GMail Invite by ehoff · · Score: 1

      Any GMail invites out there for a kid coming late to the party? ehofff_at_covad.net

    3. Re:GMail Invite by pasta_here · · Score: 1

      yeah I too don't have one. Could anyone please send me one invitation for the same ?

    4. Re:GMail Invite by technicolor_guru · · Score: 1

      If there are any other generous souls out there, I'd like one. (johnathan@airbrushguy.com)

  39. It shouldn't be that hard. by Ayanami+Rei · · Score: 1

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

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
  40. This sophisticated? by Wolfkin · · Score: 1

    "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.
  41. Re:Just quick and easy by fiftyfly · · Score: 2, Funny

    *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

    --
    "Sanity is not statistical", George Orwell, "1984"
  42. Re:It's all a matter of perception-Hard Times. by sakusha · · Score: 1

    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.

  43. Re:If they are smart, and they are, by itwerx · · Score: 1

    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?

  44. Plone never ceases to amaze me... by Spoing · · Score: 1
    One small extention to Plone;

    1. CPSSkins

    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.
  45. Re:Just quick and easy by SkunkPussy · · Score: 1

    haha that would get +1 funny if I had any mod points!

    --
    SURELY NOT!!!!!
  46. Re:If they are smart, and they are, by HolyCoitus · · Score: 1
    --
    That's scary.
  47. Re:If they are smart, and they are, by HolyCoitus · · Score: 1

    Amusing proof of writing nightmare code in any language

    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.

    --
    That's scary.
  48. Re:If they are smart, and they are, by backslashdot · · Score: 1

    yup dats q of v.

  49. Re:If they are smart, and they are, by VenTatsu · · Score: 1

    Netscape use to (and may still) offer servers that run JavaScript on the server for CGI and the like, much like mod_perl, PHP, or ASP. And speaking of ASP, you can use ASP to run JScript, which is MS's inplementation of ECMAScript (The ECMA standard name for JavaScript).

  50. Re:If they are smart, and they are, by denthijs · · Score: 1

    Herem Here! Javascript (or at least ecmascript) is the bomb
    Too bad ofcourse every browser has its own implementation witch makes it harder to write clean code.
    No comparison to the Netscape4 IE3 days where they were a 100% different though....

  51. Re:It's all a matter of perception-Hard Times. by fozzmeister · · Score: 1

    Computers?

  52. Re:Just quick and easy by dmayle · · Score: 1

    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.

  53. Re:If they are smart, and they are, by QuantumG · · Score: 1

    :)

    --
    How we know is more important than what we know.
  54. On the subject of code maintenance.... by Sheriff+Fatman · · Score: 1

    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.
  55. Re:Just quick and easy by codeboost · · Score: 1

    Pardon me... But why in the world do you need to search for incremental variables in the first place?
    A source file can contain a dozen for's and while's; isn't it easier to search for the function name and then look inside that function?

    Anyway, since we're on the topic, wouldn't it be nicer to name your inc variables xxx ? It doesn't naturally occur in the english language (unless you write really perverse comments) and it's fun!
    Imagine the pleasure you get from reading a code snipped like:
    for (xxx = 0; xxx < 0xfffffff; xxx++){DrawFrame(xxx);}

  56. Re:Just quick and easy by Zareste · · Score: 1

    Sometimes I wonder why I read replies.

    Y'know if I spent my days debunking every sadistic anonymous moron who wants 'freedom' to be when everyone to suffers and dies at the hands of political masochists, where would I be? I can't reason with people who want to kill every person trapped under a government that will encage all who take a shit without its permission. Please keep in mind that you can go to Hell if you love supporting torture.

    --
    I am NOT a number! I am a - oh wait, I'm number 761710. Look! 761710!
  57. Re:Just quick and easy by Zareste · · Score: 1

    Compiled languages...

    I was talking about Javascript. 1000 lines or so to be specific.

    --
    I am NOT a number! I am a - oh wait, I'm number 761710. Look! 761710!
  58. Re:If they are smart, and they are, by mediaboy · · Score: 1

    The Mozilla project contains a couple of embedable JavaScript engines. http://www.mozilla.org/js/

  59. Re:Just quick and easy by stoborrobots · · Score: 1

    wouldn't it be nicer to name your inc variables xxx ? ... it's fun!

    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/
    http://xxx.arxiv.cornell.edu/
    http://xxx.adelaide.edu.au/
    http://xxx.uni-augsburg.de/

    Yep, folks - Governments and Universities worldwide, hosting xxx sites. And for what it's worth, xxx.lanl.gov was the original!

  60. Re:Just quick and easy by ComputerSlicer23 · · Score: 1
    Have you ever made a mistake in indexing? Ever go looking for an off by one error in a for loop? I'm not looking for the for loop, I'm attempting to find all the places the "i" was used as an index variable (because I'm nesting a new loop where I need to use "jjj" any place close, because I'm removing the loop that has "jjj", I think there is a bug in the indexing, or I think I transposed the use of iii and jjj someplace in some software).
    for( iii = 0 ; iii < sizeof( foo ) / sizeof( foo[0] ) ; ++iii )
    {
    ... 15 lines of code that uses iii twice on every line...
    }
    It's sure a lot easier in vim to hit /iii, and see all of the "iii" highlighted.

    Kirby

  61. Re:big stinking piles of code by Bastian · · Score: 1
  62. Re:Huh? by Ryosen · · Score: 1

    You might as well complain about the logo, too. At 3300 bytes, it could tear down the entire Net! How could Google be so reckless?!!

    --

    Ryosen
    One man's "Troll, +1" is another man's "Insightful, +1".
  63. Can't see the page by nicolas.e · · Score: 1

    Unfortunately I cannot see the page. Would anyone care sending me a gmail invite ?

    1. Re:Can't see the page by nicolas.e · · Score: 1

      Thanks a lot to snipes420 and Joe Pestro for the invites.

      Posting this one back since I only need one ;) :
      http://gmail.google.com/gmail/a-c587d89248-6e8f 2ca 938-6d1f1297e8

  64. Re:Just quick and easy by JabberWokky · · Score: 1
    I'm not complaining about your development methods, merely explaining mine.

    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

    --
    "$30 for the One True Ring. $10 each additional ring!" -- JRR "Bob" Tolkien
  65. Bandwidth Savings by Anthony+Liguori · · Score: 1

    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.

  66. Re:Just quick and easy by russint · · Score: 1

    I wonder how those firewalls treat http://mirrors.playboy.com/ :) (office safe, really)

    --
    ^^
  67. Re:Just quick and easy by LadyLucky · · Score: 1
    That's the best tip you ever got? Not something like 'static is evil'?

    Oh my.

    --
    dominionrd.blogspot.com - Restaurants on
  68. Re:Just quick and easy by ComputerSlicer23 · · Score: 3, Informative
    Well, I'll point out that "static is evil", is a flat out wrong and a statement with no context. At the time I was well aware of the 2 types of things that static can be applied to, and the two different contexts in which you can it on variables. That's not even to discuss the meanings it has in C++.

    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.

  69. Ever hear of CADOL? by /dev/trash · · Score: 1

    Not Cobol but Cadol. In older versions, you saved space in memory by doing

    NL
    NL

    rather than NL 2.

  70. Re:If they are smart, and they are, by dubl-u · · Score: 1

    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.

    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.

  71. Re:Just quick and easy by dubl-u · · Score: 1

    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

    This seems dubious to me. The only time I use a variable like i is in a nice, short loop, so I have no need to search. If a loop is too long to fit conveniently on the screen, I almost always do Extract Method (or I extract a function if it's not OO code). If I can't figure out a way to do that, I give the variable some meaningful name.

    Using three-letter loop variables seems like a very clever solution to the wrong problem entirely.

  72. Re:Just quick and easy by n3k5 · · Score: 1
    /usr/share/dict $ grep -ic ii words 419
    --
    "Sanity is not statistical", George Orwell, "1984"
    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 that's what it is, but the point is that it is only defined within a small block and its function can easily be understood in that context. However, if a variable is used throughout the whole program, so you'd actually like to search for all the places it's used in, giving it a descriptive name is a must. Using 'i', 'j' and 'k' all over the place and doing all kinds of things with and to them is absolutely insane.
    --
    but what do i know, i'm just a model.
  73. Re:Just quick and easy by ComputerSlicer23 · · Score: 1
    Well, just wait until you have an off by one error. Even with just 10 or 15 lines of code, it's still much easier to be able to search for them. I'm not searching for them because they are so far apart, or because they are hard to find. I'm searching for them, so I can ensure I double check each and every single one is correct.

    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 bad habit of saying "find again" in vim if I write a bad regular expression.

    Finally, I'll point out, that if you are iterating over an array, giving it any value but "iii", "jjj" is less idiomatic, and thus in some schools of thought bad (I'm a subscriber, but not sure a full fledged zealot about that). There isn't a better or more meaning full name if what you are doing is iterating over an entire array. Now, if you are skipping around, that's a whole different deal. There you can have a better name.

    Finally: If I can't figure out a way to do that, I give the variable some meaningful name.

    Wait, so what your telling me, is that in complex loop that has a long block of code that you can't figure out how to decompose, you change to use a longer variable name to make the code longer, and have more line breaks and use less idiomatic code? In complex long blocks code, you stop following coding conventions as old as the hills just doesn't sound like as nearly a good idea as making it easy to track down indexing errors. I'll give you the last word if you want it, and just agree to disagree with you.

    Kirby

  74. Re:Just quick and easy by LordMyren · · Score: 1

    i have a week of finals before skiing.
    its that time before hell freezes over,
    and the coder comes out to play.

    hope you've got good conditions,
    its been a crazy "winter" here on the east coast.

  75. Re:Just quick and easy by dubl-u · · Score: 1

    I'm not searching for them because they are so far apart, or because they are hard to find. I'm searching for them, so I can ensure I double check each and every single one is correct.

    I'm glad that works for you. I feel like if a block of code is hard to read, I should make it easier to read. If you'd prefer to search, that's fine by me.

    Wait, so what your telling me, is that [...] you change to use a longer variable name to make the code longer [...] use less idiomatic code [...] you stop following coding conventions as old as the hills

    Yes, you're right, I was trying to say that I'm an idiot. Because there couldn't be any other possible interpretation what I wrote, right?

  76. Browser Incompatibility by rlp · · Score: 1

    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]
  77. Re:Just quick and easy by ComputerSlicer23 · · Score: 1
    Nobody said the code was hard to read. Any time I'd use "i", I use "iii". It's easier to search. Nothing about that has the implication that it's hard to read. I use searching to ensure I got every last instance correct.

    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. What precisely did you mean? What am I misinterpretting? To me that sure looks like your saying you stop using "i" at points as the index variable in a for loop at some points, but not at others based on if you can refactor the for loop.

    It's really hard to understand you've either changed contexts and I didn't notice. Giving variables meaningful names is a wonderful thing. However, how meaningful a name do you have for a variable you are using as an index? Maybe you could give me an example? I'm not trying to be a prick, but I read the words on the screen and took what seemed the most natural interpretation. Maybe there's some small chance you weren't being clear.

    Kirby

  78. Google needs to focus on their search engine by tjstork · · Score: 1

    Has anyone else noticed that the quality of Google's search results has been droppng over the last year?

    --
    This is my sig.
  79. Re:Just quick and easy by dubl-u · · Score: 1

    Well, aren't you clever not bothering to clarify so I could possibly understand what you mean.

    If you're interested, I'm glad to explain. Traditionally, people indicate that by asking questions rather than assuming the worse, but I'll presume you're doing it differently.

    Nobody said the code was hard to read

    It would seem to me that if you're having enough trouble finding the uses of a variable that you need to search, the code is hard to read. Perhaps we work on different sorts of code.

    You start discussing giving variables "meaningful names". In sections you can't refactor.

    Occasionally I'll end up with a complex enough loop that's awkward to eliminate by one of the many ways to get rid of a long loop (extract method, helper object, iterator, closure, foreach, etc).

    Pretty much every time that happens it's because it's clearer with the code in one place because there's some meaning to things. For example, I might loop through a set of customers, pulling out invoices and looking at individual line items. If it were just a single loop of customers, I'd use just 'i'; that's a common idiom in languages without something like a foreach loop. But using arbitrary letters for all three is confusing, so I'd name them more clearly.

    Does that help clarify what I meant?

  80. math & case sensitivity observations by cr@ckwhore · · Score: 1

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

    --
    Skiers and Riders -- http://www.snowjournal.com
  81. gmail script without obfuscate by Denstone · · Score: 1

    Who wants the javascript before gmail use obfuscate in code

    gmail_script.js

    use save as

  82. Re:Gmail, you know what to do by Laerien · · Score: 1

    Links have gone stale! Bloody hell - thought maybe I would join the rest of the world and get a gmail account. Please invite me now before I get stuck with lam3name381382@gmail.com! Fewer and fewer invites these days - checkout http://isnoop.net/gmailomatic.phpGmail Invite Spooler to see my plight. shannonskipper@knology.net (woot - 1meg limit)

  83. Gmail is just the beginning of such apps by FigWig · · Score: 1

    I'm sure we'll start seeing better standardization of XMLHttp across different browsers and more stuff like this.

    --
    Scuttlemonkey is a troll
  84. -1 WTF? by bigtangringo · · Score: 1

    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.
    1. Re:-1 WTF? by eggstasy · · Score: 1

      You misread me. I said they made a certain amount of money per page (by serving ads), and also that each page has an associated per-page cost.
      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 broken servers, you will have a per-server maintenance cost, and indeed a per-page maintenance cost. Your total cost will be $500k/yr, so if you served 500 million pages that year you will have paid $0.001 per page in maintenance. And then there's the cost of acquiring the new servers, etc...

  85. Re:Just quick and easy by LadyLucky · · Score: 1
    Errr, right wow. that was pretty thorough, I'm quite impressed. Actually I am a Java Weenie and that statement is really just not that it should never be used, just so often they are used when they shouldn't be used and they lead to hard to maintain code and bugs. You know, static functions lead to a lack of object oriented code and if-whiff and all that.

    I was poking fun at your tidbit because these days IDEs will find variables for you without text searches.

    --
    dominionrd.blogspot.com - Restaurants on
  86. Re:If they are smart, and they are, by Hognoxious · · Score: 1
    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.
    Ah, but which Javascript - there's the rub.
    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  87. Sure... by Craig+Ringer · · Score: 1

    but the JavaScript that can be used in browsers is a very different beast, with a tangled nightmare of quirks, extensions, and compatibility problems.