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.

Are there any serious studies on how well an experienced programmer who knows language X can understand code written by a competent programmer using language Y, for a good range of widely used languages as X and Y?

Of course the real world isn't so simple as a programmers knows just one language. What we'd like to know is: if we do our project in, say, C#, and someday some old physicists who know only Fortran and Algol look at it, to what extent would it make sense to them? Mathematical parts of it might read fine to them, if they ignore what to them are some random-ish punctuation marks. Or, would a Python expert be able to find flaws in my clever Ruby script?

There could be issues from the level of superficial syntax to the level of grand concepts such as objects, template metaprogramming, functional and so on. I'm not expecting the one programmer to fully understand every syntax detail of code in a "foreign language" or to follow the religion of some grand concept, but wondering to what extent they'd get the main flow of control, find the spot where something is drawn on the screen and what determines its color or size, verify that a robot programmed to drive a car will turn off the engine when it's done, those sorts of things.

A good quality study would include published academic research, an official report from some industry group or major software company, though I'll take systematic unbiased observations by experienced leaders of workshops and classes or other sources. Not interested in short blogs, single-case examples, or anecdotes. (Well, maybe a few anecdotes if they make for a good read.)

share|improve this question

closed as off-topic by MichaelT, user61852, Robert Harvey, gnat, Martijn Pieters Feb 18 at 8:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – MichaelT, user61852, Robert Harvey, gnat, Martijn Pieters
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
I don't know if there are any studies, but from my personal experience, I say Yes, I managed to understand a program without knowing the language. –  superM Aug 4 '12 at 7:56
2  
This would depend on a pair of languages: pick C# vs. Java - and you will get a nearly instant familiarity; pick Algol vs. C - and you will get familiarity wit a single-page cheatsheet. Good luck picking C vs. Prolog or Whitespace vs. Ada - it is going to be frustrating. By the way, language is not the only thing that plays into understanding a program: a C expert specializing in embedded designs trying to understand MFC code written in C is a rather sorry sight (this is first-hand experience). –  dasblinkenlight Aug 4 '12 at 11:40
    
How easy is it for somebody who understands Algebra for them to pick up Trigonometry vs somebody who understands Calculus? It depends on the language and paradigm. Detecting and isolating the differences across languages is hard enough, especially since the languages are constantly evolving. I seriously doubt anybody could assess understanding with any reasonable amount of accuracy. –  Evan Plaice Feb 18 at 20:23

4 Answers 4

It obviously depends on the degree how related the languages are to each other. For example, if you have a C or C++ background and have either done some C# or Java programming, it should be easy for you to read and understand the other of the that two languages (Java or C#). If you know Lisp well, Scheme should not be much of a problem. I once debugged a PHP program without having any knowledge about PHP, just with my knowledge from C, C++ and Perl. I am pretty sure when that program would have been written in Haskell or Smalltalk, that would have been immense harder next to impossible for me.

In fact, I don't think an academic research on this topic would make any sense (at least, not a serious one). There is no such thing like a "standard experienced programmer who knows language X", so any study would miss assured basis data. People have different knowledge, and even if they have run through the same schools, they are differently talented and motivated.

but wondering to what extent they'd get the main flow of control, find the spot where something is drawn on the screen

That may be hard even when you are very familiar with the language, either because the code quality is so low, or the used framework is so complex, or the code base is very big.

share|improve this answer

Not sure about an academic conducted study reference, however well self-explanatory naming of methods, classes and functions in C#/C++/Java/Python or etc. languages should provide ease to understand the code base as well as business process flow.

Naming convention within the project and generally in software development is a very important aspect. However, its importance and relevance to building quality software is often overlooked or ignored all together.

Naming Guidelines used in .NET Framework and General Naming Conventions used in .NET are good references to look as well.

share|improve this answer
    
Good API design and naming conventions help but even language-based naming conventions are often 'opinionated' in a way that only applies to that language. Beside C#/Java (which are nearly identical) most languages operate on different principles that have unique workflows and implementations specific to that language. For instance, in languages that don't follow the mega-monolithic core framework model you'll usually find a huge ecosystem of packages that tie together using a common package manager. –  Evan Plaice Feb 18 at 20:32

It depends tremendously on the individual programmer, and how they internalize languages. I have absolutely no trouble working in a dozen languages, while I have a friend that only knows C++. He is no worse at programming than me, he just learned a different way.

Personally, I find a related question more interesting: when there is a bug in the code (i.e. programmer X thought he wrote someFunction(x, y) but he really wrote something else), how hard is it for the second developer to identify the bug. A good programmer X would make it exceedingly obvious what he WANTED the computer to do, and that would be easy to read. However, if he made a mistake, it can be a big deal. Things like the following C++ bug:

int x = getCorrectValueForX();
if (x = 2)
   doSomethingWhenXIsTwo();

Can be NOTORIOUSLY difficult to detect unless you know the language.

share|improve this answer

It not only depends on the programmer as other people have said, but also on the similarities between languages, both in syntax, philosophy and implementation.

Many different languages use a C derivative syntax, and so following the control flow will be easier if you're familiar with that type of syntax. The same goes for strongly typed and loosely typed languages, languages with higher order function support, level of abstraction and programmatic philosophies. It not only depends on you being able to read the syntax but also be familiar with the languages concepts and philosophies.

If you learned C for example, I think it would be reasonable to expect you to be able to derive the control flow from C#, Java, or C++ etc. It would be a little harder to decipher VB because of the difference in syntax, or JavaScript because of closures, weak typing and higher-order functions (I know you can do this in C but it's a little wonky). I would not expect you, however, to be able to debug Lisp, F#, R or, god forbid, assembly because these use a completely different programming paradigm.

TL;DR It's not only important to be able to recognize the syntax, most the time you can decipher a declaration or method call but being able to comprehend the reason behind why a program is written a certain way is the crux of understanding and reading code.

share|improve this answer

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