31

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?

6
  • 16
    Also, you forgot Go. Commented Jan 21, 2011 at 11:36
  • 23
    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
    Commented Jan 21, 2011 at 11:52
  • 1
    Saying one language is enough is like saying one type of wood is enough, would you respect a carpenter who had only worked in Pine, but never maple or oak?
    – Zachary K
    Commented Feb 16, 2011 at 16:27
  • Also, you forgot Sawzall labs.google.com/papers/sawzall.html
    – Chiron
    Commented Apr 22, 2011 at 16:41
  • 1
    They used java Check this reddit.com/r/google/comments/3sdx3b/…
    – Elshan
    Commented Jun 17, 2016 at 10:22

6 Answers 6

99

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 that requires less than 30ms latency you can tune C++ code to achieve that performance. In a managed language like Java it is a bit 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.
3
  • From your explanation does it mean that GMail uses GWT? Commented Jan 21, 2011 at 22:37
  • 1
    Google is currently using python for web appplications also.
    – Raphael
    Commented Jan 27, 2011 at 19:50
  • Prominent Googler Alex Martelli explains "Python where we can, C++ where we must" Commented Apr 30, 2018 at 21:16
19
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.

2
  • 4
    +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 :-) Commented Jan 21, 2011 at 12:05
9

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.

1
  • I'd implement complex algorithms - not extremely performance-critical - in Python.
    – user7043
    Commented Jan 21, 2011 at 15:28
3

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

2

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

0

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.

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