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.)
3
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.
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.
1
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.
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.
0