Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have heard Google uses Python, Java and C++. But what I don't know is how is each of those programming language is used. I mean what is Python, Java and C++ is used for at Google. Why would they used upto 3 programming languages when 1 language is enough. Does anybody know?

share|improve this question
2  
Google have various applications, which one you are pointing? –  Abimaran Kugathasan Jan 21 '11 at 11:31
9  
Also, you forgot Go. –  cbrandolino Jan 21 '11 at 11:36
17  
If one language is enough, why is there Python, C++ or Java at all? We could all just use the Assembly language for the processor our systems are running. –  Lazarus Jan 21 '11 at 11:52
2  
@cbrandolino: any evidence that Google uses Go? I know they wrote it, but do they use it? So much Sun code was written in C and C++ despite them having written Java. –  user4051 Jan 21 '11 at 12:27
2  
@Graham Lee: no evidence, but a quite convincing testimony - theregister.co.uk/2010/05/20/go_in_production_at_google –  cbrandolino Jan 21 '11 at 12:34
show 3 more comments

6 Answers

up vote 71 down vote accepted

The correct answer "because different languages have different strengths " has already been stated. But let me provide some more detail on why:

C++

C++ has the main advantage of being the fastest of the lot. Not necessary because Java and Python are slow, but because in C++ you have more control about how things get executed.

For example, if you are writing a web services frontend and require less than 30ms latency you can tune C++ code to get that performance. In a managed language like Java it is a big harder to get the GC to cooperate perfectly.

C++ is used for a lot of 'Google magic' such as BigTable, MapReduce, and search goo.

Java

For most standard applications, Java is a perfectly fine language. It features great tools, lots of existing libraries, and not a lot of time spent debugging.

Java is used for a lot of bigger websites that would be much more difficult to maintain in a lower-level language like C or C++. For example, my understanding is that GMail is written in Java.

Also, note that you can use Google's Web Toolkit to compile Java code into JavaScript. So that awesome webpage or widget you see might have began life as a Java class.

Python

Python is a fantastic general purpose language, but doesn't offer as much fine-grained control as even Java. (For example, there are all sorts of crazy JVM arguments for things -- does python offer similar configuration?)

However, with Python is perfectly suited for simple websites and applications that would otherwise be horrible shell scripts. For example, if you wanted to write a simple testcase to gather data from some sources, process them, and upload them to App Engine Python would be a good choice. (If you needed to distribute that processing across 1,000 machines however, perhaps you could use a different language...)

JavaScript

Obviously Google uses a lot of JavaScript. However, the type of JavaScript written at Google is different than what you see in the wild. Google has developed an optimizing JavaScript compiler that allows you to construct annotations in comments in exchange for better optimizations and static checking. See Google Closure.

Language Doesn't Matter (interop)

Another reason why Google doesn't use just one language is that it doesn't need to. There are facilities in almost every modern programming language to call into external libraries, libraries which may be written in a different language. (See swig.)

Also, since App Engine runs the JVM you can run any language that compiles to Java byte code. (At Google we primarily stick to the languages mentioned here, but this isn't a hard requirement.) If you want to use Closure, Groovy, or Scala on App Engine if you include the right JAR files everything should just work.

Open-Source

Also, Google uses and contributes to a lot of Open-Source where possible. These projects usually are written in one of the above languages and requires it to be 'used' at Google.

The bottom line is two things:

  • Every programming language has its own strengths. To not take situationally take advantage of these strengths would be a shame.
  • The available of interop toolkits and compatibile runtimes means that it is less painful to use multiple languages within the same runtime environment.
share|improve this answer
    
Superb answer. I wish that I could upvote it again. –  Adam Crossland Jan 21 '11 at 17:23
1  
I did for you :) Great answer Chris. –  StuperUser Jan 21 '11 at 17:58
    
Thanks for the explanation. Very informative. –  jpartogi Jan 21 '11 at 22:34
    
From your explanation does it mean that GMail uses GWT? –  jpartogi Jan 21 '11 at 22:37
    
Google is currently using python for web appplications also. –  Raphael Jan 27 '11 at 19:50
show 2 more comments

"1 language is enough" can only be true if every project you do is of a specific kind. And for some projects, even C++ Java and Python are not the best tools. Furthermore, knowing only one language is a distinguishing feature of the poor programmer.

share|improve this answer
add comment

Python is used for their support website,you can see that This page is generated by a python script,they use java libraries for web applications,hence the GWT and java support in the app engine

I think they use C++ for google earth,or for desktop applications in general

share|improve this answer
add comment

They write native Mac and iPhone applications too, and those are in Objective-C. The reason they do that is simple: the APIs are in Objective-C.

share|improve this answer
add comment

These three languages are used for different purposes.

Python might be used for writing automation scripts.
C++ for implementing complex algorithms.(Indexer, Crawler, Map-Reduce, Big Table)
Java for web services, web apps, etc.

These are my assumptions only.

share|improve this answer
    
I'd implement complex algorithms - not extremely performance-critical - in Python. –  delnan Jan 21 '11 at 15:28
add comment
1 language is enough

Maybe one language is enough to complete a number of different tasks adequately, but different languages have different strengths, weaknesses and abilities.

Since google most probably program for a large number of different situations it's a case of horses for courses, the best tool for the job.

share|improve this answer
3  
+1, Using the best tool for the job. I'm currently working on a single desktop application that uses 3 programming languages (plus various markup and database languages). Close to metal stuff with C++, main application with Java, and some Jython here and there for easy customization. It makes sense to take the best of all three worlds, IMO :-) –  Joonas Pulakka Jan 21 '11 at 12:05
    
Was OP making a joke about JQuery ? (Its a meme on StackOverflow) –  Reno Jan 21 '11 at 13:37
    
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.