-1

After a while surfing on source code of big projects especially application servers like this, I have understand these projects are not developing by one language. Many of them are using python for secondary language.

Now I have four questions:

  1. Why is used more than one language?
  2. Why python is used for secondary often?
  3. Why python is not used to develop all parts of projects and they still is using c/c++?
  4. And which the parts of projects should be developed with python and which part of projects is using c/c++?

4 Answers4

2

Hard and soft layers

Programming language designs tend to trade off between "high-level" features, which enhance programmer productivity at the cost of speed, and "low-level" features, which require a great deal of programmer effort but produce very fast code.

Therefore it sometimes makes sense to use two languages on a project:

  1. Write 90% of the code in an expressive, high level language which is easy to write and maintain.
  2. Write the 10% of performance-critical code in a low-level language which is harder to write, but allows for comprehensive optimisation.

c2wiki calls this the HardAndSoftLayers pattern:

By virtue of the first rule of optimization, go ahead and write most of your code in the highest level language you can find.

By virtue of the third rule of optimization, when you must, use a profiler and find the slow parts of your program. Take those parts, and write them in a lower-level language.

For reference, the rules of optimisation are:

  1. First Rule Of Optimization - Don't.
  2. Second Rule Of Optimization - Don't... yet.
  3. Profile Before Optimizing
Li-aung Yip
  • 12,320
  • 5
  • 34
  • 49
1

The rule is pretty simple: the developers choose the language(s) based more or less on the following criterias:

  1. their familiarity with it
  2. how easily you can do the task using that language
  3. how well is suited the language to the specific task

Today most of the development done in this multilingual environments are huge solutions, where different components need to communicate, exchange data or simply do work which is comprised of more than one step. It is easier to write the communication/data interpretation/whatever wrapping necessary part in a language such as python and then leave the real time and speed needy work to be done by some lower level language which compiles directly without the need for an interpreter.

Let's dig a little bit deeper.

  1. How familiar are the developers with the programming language depends on the background of each developer. If they are given a free choice, obviously they will pick the language they know the best, unless there is a lobby from someone else... usually higher in the management chain. Python is not necessarily the language of choice, python is simply an easy to use and learn language, which is well suited for most tasks. Our project has no bit of python in it, only tons of ruby code. Because the main developer liked ruby at that time, so we're stuck with it.

  2. If you know more than one programming language you know that each of them is doing the same thing differently. For example, creating a socket, connecting to a server, reading the stuff and printing it out is just a few lines of Erlang code, but it takes a lot more to do it in C++ (for example...) So again, if you have a task you know how to solve easily in a specific language you are going to stuck to it. People are lazy, they don't necessarily learn new stuff unless needed.

  3. Obviously you are not going to write a device driver in python, and it is much easier to create a complete web service with java than with plain C... but you still would need the part of the solution that does the hardware close thing. When you have a task you carefully measure the requirements and implications and wisely choose the language you will do it in. Because it will stuck to it forever.

Ferenc Deak
  • 34,348
  • 17
  • 99
  • 167
0
  1. Sometimes python is not good enough.

    Dealing with computer vision, image or sound processing, calculate tones of data is not really what python is good at. Other language like C or C++ is really good at those fields.

  2. support your primary language is java, and you want to glue other languages into one project. That where we need Python. Python is well known glue language. you can use ctype,SWIG, Jython, ironPython or other method to bind multiple language.

  3. Guess I answered this question at 1.

  4. Need for speed. go for C or C++ . Care more about productivity, go with Python.

Ryan Kim
  • 258
  • 1
  • 6
0

Without referring to the project you sent, I'll give you my 50c for why the company I work for, as to why we use python quite often in our projects.

Primarily, we have no python code relating to the software solution itself. All python code either relates to assist with development, machine set up, common framework tools deployment for testing, and vastly for code generation.

  1. Why is used more than one language?

No project we work on has only one language, when looking at all our enterprise level solutions or large scale implementations.

This is mostly due to the fact that our tiers are written in languages that provide best performance and usability at each level separately.

For instance, C++ for speedy core back-end services, and C#.NET for rapidly developed and provide good UI for the front-end.

  1. Why python is used for secondary often?

Personally, apart for the reasons I explained above, we don't make use of python 'secondary often'. We use C++/C# as the most common pair, but depending on the platform, might be other pairs.

  1. Why python is not used to develop all parts of projects and they still is using c/c++?

Python is great for quick solutions and doing things you wish your shell could do. This largely involves file management, etc.

C++ is perhaps the fastest compiled language, providing optimal usage for core and largely used actions.

Based on that, and the fact that the market has more knowledge and experience in C++ (for many reasons), C++ is the more popular choice.

  1. And which the parts of projects should be developed with python and which part of projects is using c/c++?

I believe I may have already addressed that above.

-

I hope I could help, please remember this is only my personal opinion and by no means should this be taken as a fact.

ericosg
  • 4,926
  • 4
  • 37
  • 59