in Android, Code, Geeklife

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

[bash]
——————————————————————————–
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
——————————————————————————–
[/bash]

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.

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

12 Comments

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

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

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

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

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

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

Webmentions

  • VMs – The New Infrastructure Anachronism (2/2) End User Computing | A Collection of Bromides on Infrastructure July 7, 2011

    […] own latent vulnerability: Their kernels offer a vast attack surface (~50 MLOC for Windows, and ~10 MLOCfor Android).   Rich feature sets appeal to users, but introduce […]

  • Android: Microsoft’s most profitable mobile OS. | Driftvalley July 7, 2011

    […] Android has over 10,000 lines of code. Android, like every large software product on the planet, infringes numerous Microsoft patents. And Microsoft is taking full advantage. They’re visiting Android licensees and giving the same sales pitch the IBM team gave Sun in the 1980s. […]

  • All the world is made of faith, and trust, and pixie dust « A Collection of Bromides on Infrastructure July 7, 2011

    […] OSes offer a vast attack surface (About 50 MLOC for Windows, and about 10 MLOC for Android).   Complex specifications, buggy coding, and incomplete testing mean they ship with about 1 […]

  • Microsoft’s Android Shakedown – Forbes (blog) | Information and Technology Blog July 7, 2011

    […] 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 […]

  • Patently Absurd: America’s Bizarre Intellectual Property Laws July 7, 2011

    […] 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 […]

  • Microsoft’s Android Shakedown July 7, 2011

    […] 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 […]

  • Microsoft’s Android Shakedown – Forbes (blog) | IT Blog July 7, 2011

    […] 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 […]

  • Android 3.0 Honeycomb « Júnior MSDN July 7, 2011

    […] Gubatron.com (23 de maio de 2010). How many lines of code does it take to create the Android OS?. Página visitada em […]

  • Five Theories Why Microsoft Won't Support Windows Phone 7 for Tablets | ZDNet July 7, 2011

    […] 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% […]

  • Bookmarks for May 28th through May 29th | PHPkitchen July 7, 2011

    […] 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? […]

  • How many lines of code does it take to create the Android OS? « Metawave Blog July 7, 2011

    […] http://www.gubatron.com/blog/2010/05/23/how-many-lines-of-code-does-it-take-to-create-the-android-os… […]