How many lines of code does it take to create the Android OS?
This is a report done on all the projects that make up for the android project, my copy of it is synced as of May 23rd 2010, 6pm
-------------------------------------------------------------------------------- Language files blank comment code -------------------------------------------------------------------------------- XML 4130 26919 62996 3044624 C 7191 494387 685731 2826741 Java 16473 423278 986294 2084883 C++ 5623 349754 385625 1754053 C/C++ Header 12278 300773 653608 1153456 HTML 2325 13539 14681 348935 Bourne Shell 501 45684 46947 317410 Javascript 1717 41901 76306 208012 Assembly 1704 18732 51392 96700 D 2181 16936 24 59142 m4 116 6026 1813 49502 Perl 221 8189 8246 40058 Python 236 9805 14225 38852 make 381 6844 3837 37059 IDL 421 3128 0 24181 Objective C 93 2804 3371 10032 yacc 15 1300 742 9660 CSS 42 1760 617 8566 Teamcenter def 41 631 95 5430 C# 93 863 537 5283 Bourne Again Shell 99 569 1643 3784 lex 21 776 754 3492 Expect 20 105 168 2170 Ada 10 599 560 1681 Ruby 14 393 228 1433 XSLT 8 105 110 1328 XSD 7 182 359 1048 Pascal 4 218 200 985 DOS Batch 34 252 399 911 awk 14 92 198 899 DTD 9 66 42 289 sed 9 32 143 277 Korn Shell 1 39 46 223 Lisp 2 32 5 144 MSBuild scripts 1 1 0 140 NAnt scripts 2 10 0 89 ASP.Net 3 5 0 76 YAML 6 27 42 66 SQL 1 5 0 21 PHP 1 0 0 3 -------------------------------------------------------------------------------- SUM: 56048 1776761 3001984 12141638 --------------------------------------------------------------------------------
Update
It seems like this post got some attention on Reddit, YCombinator news and other sites on monday. I hadn’t noticed until today, so here are some answers to many of the FAQs about the post.
Yes it was done using cloc. Don’t shoot me I’m just the messenger.
It was run at the base folder of the entire Android OS source checkout, so yes it will include sample and tests I suppose.
C#, Ada, Objective-C? I also thought the same… It’s probably worth the try doing a few finds and greps to see if this is true, again I just posted the output of cloc, I didn’t intend to make this a scientific paper, just a fun and curious post to get a rough number on the lines of code, that breakdown was just icing on the cake for me (as inaccurate as it maybe)
Update
This post is now being referenced in Wikipedia! on the “Android (operating system)” article.
About Gubatron & Android
Ever since the iPhone OS handicapped millions of smartphone devices with its draconian laws, I started looking more and more seriously at Android as THE platform for every non-iPhone device coming to the mobile and TV space. Now I’m part of the developer team of FrostWire for Android, an application that exploits all the power of the device and the freedoms of the platform to allow people to connect and share.













May 24th, 2010 at 5:21 am
ASP.Net ? Objective C? Ada?
How bizarre.
May 24th, 2010 at 10:45 am
Answer: 1 line of Ruby? Hahaha, just kidding. ;)
May 24th, 2010 at 1:48 pm
Are you including the sample code and data in this count? 3 million lines of XML code seems a bit high unless you’re counting sample data.
May 24th, 2010 at 4:03 pm
C# ?????
May 24th, 2010 at 5:27 pm
[...] http://www.gubatron.com/blog/2010/05/23/how-many-lines-of-code-does-it-take-to-create-the-android-os... [...]
May 29th, 2010 at 11:07 am
[...] How many lines of code does it take to create the Android OS? – Gubatron.com – Quite a nice way to show, in one table, how complex a project actually is. Wonder what the Objective-C is for? [...]
July 26th, 2010 at 3:18 pm
Did you measure only the part of Android that is downloaded via the repo tool, or all 242 git projects? My count using cloc for the latter was substantially higher:
SUM: 380827 14403252 19160933 77345274
October 13th, 2010 at 1:56 pm
[...] meanwhile, uses just over 12 million lines of code. To get Windows 7 down to the same size as Android, you’d have to hack off approximately 98% [...]
October 24th, 2010 at 12:40 pm
XML is not a programming language.
October 25th, 2010 at 12:10 pm
XML can be used as a programming language. It’s all how you interpret it. The fact that most people use it as data or metadata doesn’t mean you can’t create a programming language using tags.
In platforms like Android it’s used plenty as a support in the programming of your user interfaces. You define a set of steps on how your UI layout will be, that to me is a program. If you’ve ever used stuff like ant, then you will also consider XML as a programming language.
October 26th, 2010 at 1:16 pm
“Ever since the iPhone OS handicapped millions of smartphone devices with its draconian laws, I started looking more and more seriously at Android as THE platform for every non-iPhone device coming to the mobile and TV space. Now I’m part of the developer team of FrostWire for Android, an application that exploits all the power of the device and the freedoms of the platform to allow people to connect and share.”
Handicapped millions of smartphones? Draconian laws? Freedom to connect and share? You sound like every left-wing, head-in-the-clouds Google fanboy who ignores how fragmented and buggy Android is because you think it’s “open” and not controlled by carriers.
October 29th, 2010 at 4:31 pm
You tell me if you want to spend 6 months of your life developing an app that could be rejected. Screw that.
Buggy? Fragmented?
My apps are running fine on thousands of phones and tablets, if there’s an issue it can easily be fixed.
I rather have freedom of choice and deal with it’s costs than be hand tied and have an overly expensive hardware that can’t do much.
Apple is on it’s way to repeat its doom of the 80s, it’s going to divide the camp of developers for MacOSX with the Market. Now you’ll get the same Fart App, Cookie cutter One App that gets counted a thousand times as different app type of developer to come and pollude the MacOSX pristine environment which got to succeed because it embraced freedom and standards. If they’re lucky, they’ll get the same Trigger-buyAnApp-happy customers to buy the same shit they got on their iPhone this time on the desktop.
There’s thousands of existing apps that will never fit the Draconian restrictions.
And hell to the no, “god” save me from being a left-wing Google fan boy. I just tell it like it is, I’m immune to Apple’s Reality Distortion Field. I like what makes sense from them and google, and I hate what doesn’t.
November 9th, 2010 at 10:40 pm
php just 3 code ??? very interesting
February 3rd, 2011 at 10:13 am
[...] Gubatron.com (23 de maio de 2010). How many lines of code does it take to create the Android OS?. Página visitada em [...]
July 7th, 2011 at 3:38 am
3 lines of PHP !!!!
I suppose it’s something like that:
This (the report above) is an excellent example how the information we get in net can be totally useless e wrong.
July 7th, 2011 at 3:40 am
In my last post the 3 lines of php are missing.
I’m try to write again.
1:
July 7th, 2011 at 9:11 am
[...] infringing Microsoft’s patents, but that’s not how software patents work. Android has roughly 10 million lines of code. Auditing 10 million lines of code for compliance with 18,000 patents is an impossible [...]
July 7th, 2011 at 11:09 am
[...] infringing Microsoft’s patents, though that’s not how program patents work. Android has roughly 10 million lines of code. Auditing 10 million lines of formula for correspondence with 18,000 patents is an unfit [...]
July 7th, 2011 at 12:03 pm
[...] Microsoft’s patents, but that’s not how software patents work. Android has roughly 10 million lines of code. Auditing 10 million lines of code for compliance with 18,000 patents is an impossible [...]
July 21st, 2011 at 1:33 am
[...] infringing Microsoft’s patents, but that’s not how software patents work. Android has roughly 10 million lines of code. Auditing 10 million lines of code for compliance with 18,000 patents is an impossible [...]