News for hackers. Stuff that matters.
Re:Twitter crashes itself with commas by evilduck on Tuesday July 17, 2012 @10:53AM (#4255893)
Maybe 4mb of memory required in the compilation step, the file mentioned in the article, "t1-more" is only 355kb over the wire.
Re:Twitter crashes itself with commas by falcolas on Tuesday July 17, 2012 @11:22AM (#4256052)
> that "bundle/t1-more" file is a whopping 4 129 653 characters.

I'd have to imagine that 355kb is the compressed size, but that character count (assuming one byte characters, not UTF8) works out to be 3.938 megabytes.

That's a lot of code. Even more when you consider it's been minified.

Re:Twitter crashes itself with commas by evilduck on Tuesday July 17, 2012 @03:17PM (#4257345)
Why do we have to imagine and then speculate from there? This is trivial to inspect.

It's 1.34mb on disk uncompressed but still minified. The copy Twitter is hosting right now is 1409121 characters minified but uncompressed. I have to assume the 4mb mentioned is output from some middle step (closure compiler output?) I'm not arguing the merits of that filesize, just that it's definitely not 4mb.

Re:Twitter crashes itself with commas by unfasten on Tuesday July 17, 2012 @04:06PM (#4257605)
I ran into this problem last night and ended up looking at the script. File size is 4,129,653 bytes, on a single line. I had it saved to check out what the problem was, so here it is if you want to check it out yourself: https://dl.dropbox.com/u/24903613/hn/twitter-4MB-line.js

Link to it on Twitter's servers (I uploaded to dropbox just in case the file expires or is changed): http://a0.twimg.com/c/phoenix/en/bundle/t1-more.5d72926b7850...

Re:Twitter crashes itself with commas by evilduck on Tuesday July 17, 2012 @05:04PM (#4257877)
This was what I was served and was referencing when I wrote that: https://dl.dropbox.com/u/21496507/t1-more.f1f23c393561.js

I don't feel like digging through minified javascript though, so I have no clue what the discrepency is.

Re:Twitter crashes itself with commas by unfasten on Tuesday July 17, 2012 @05:22PM (#4257966)
Interesting. The difference could be A/B testing or serving up different scripts to different browsers.

At a quick glance you can definitely see some differences between the different scripts we were served. For instance, in the one you were served there are some unminified portions that include the license notice for some of the code (easyXDM). In the script served to me there are no unminified portions, with everything being served on a single line.

Re:Twitter crashes itself with commas by polarix on Wednesday July 18, 2012 @01:54AM (#4259549)
Ugh, look at all the whitespace from the compiled mustache. Embarrassing.
Re:Twitter crashes itself with commas by slig on Tuesday July 17, 2012 @11:35AM (#4256133)
Does anyone have the numbers of Gmail JS size?
Re:Twitter crashes itself with commas by bgarbiak on Tuesday July 17, 2012 @12:04PM (#4256310)
According to Firebug: roughly 250 KB is transferred, half of that is lazy loaded (after DOMready, I suppose) and it looks like the biggest file (75KB) is from Google+. All scripts uncompressed (not un-minimized) weigh about 740 KB.
Re:Twitter crashes itself with commas by falcolas on Tuesday July 17, 2012 @12:51PM (#4256572)
Makes me wonder if it's the difference between a different language being compiled to minified Javascript vs. minified Javascript.
Re:Twitter crashes itself with commas by n-gauge on Tuesday July 17, 2012 @12:12PM (#4256355)
~790k (min) in IE8
Re:Twitter crashes itself with commas by debacle on Tuesday July 17, 2012 @11:21AM (#4256046)
350kb of JS is still a ton of JS. I remember deploying YUI almost five years ago now, and 130kb was 'too much' JS.
Re:Twitter crashes itself with commas by awj on Tuesday July 17, 2012 @01:16PM (#4256690)
The main page for the site I work on makes extensive use of jquery, jquery ui, backbone, a crapton of custom javascript, and more of the OpenLayers library than most places I've seen. It weighs in at 330kb and has a decent bit of fat to trim.

What on earth are the people at twitter doing that warrants that much code? Maybe their single page app -> dedicated page transition was more about disabling some things and rewiring urls with the plan of taking advantage of the dedicated setup later?

Re:Twitter crashes itself with commas by jlarocco on Tuesday July 17, 2012 @03:01PM (#4257267)
It's been a long time since I looked at the Twitter API, but I remember some of their API responses being hilariously inefficient. I don't remember the specifics, but something like retrieving a user's tweets the JSON would include a user "object" with every tweet message. The response would be something like this:

    [{user:  {name: 'jlarocco', userid: 1, /* 50 other attributes */}, message: 'my first tweet', id: 1, time: 123456},
     {user:  {name: 'jlarocco', userid: 1, /* 50 other attributes */}, message: 'my second tweet', id: 2, time: 123498},
     /* similar thing 18 more times */]
If the rest of their stuff is like that, a 4MB Javascript file doesn't surprise me at all.
Re:Twitter crashes itself with commas by shock3naw on Tuesday July 17, 2012 @05:51PM (#4258127)
Now that Twitter is 'stable,' the API is being overhauled and they are moving away from being a single page application.

You forget Twitter has been dealing with technical debt for years. The fact that Twitter still runs on Rails and serves as much traffic as it does is testament to what the engineers there have built.

Re:Twitter crashes itself with commas by riffraff on Tuesday July 17, 2012 @06:24PM (#4258244)
I think recently they added some options to omit nested informations in apis. OTOH, duplicated data _is_ easier to handle and produce and probably on the wire efficiency wasn't a big concern in the original twitter app.
Re:Twitter crashes itself with commas by vacri on Tuesday July 17, 2012 @08:29PM (#4258690)
It reminds me back in the day of the 'to html' converter in Microsoft Word. If you had a table in the original document, the converter would needlessly specify all the typeface information in each individual cell...
Re:Twitter crashes itself with commas by notatoad on Tuesday July 17, 2012 @01:33PM (#4256767)
most of twitter is still on single page app. they announced the change back to dedicated pages, but only rolled it out to user pages so far, afaik.