Are programs today easier to understand than the beginning of programming?

1    01 Oct 2016 21:10 by u/FrankyG170

This is something I've been wondering for a while. I've been taking courses and messing around with C++. Most of the courses I take tell me of "established practices" and things that developers absolutely hate (such as using namespaces). They also talk a lot about practicing encapsulation and thinking using abstraction. It seems that this would become more muddled as the language becomes higher level thus making code harder to understand without comments explicitly saying what's happening in a function.

While C++ has gone through several iterations (as well as other languages) I'm wondering that, if in the process of this, if developers have become better at making encapsulated code or if it's gotten worse with progressively more powerful languages and led to code that requires more explanation to understand.

Basically, as languages have become higher level, have we started to see more or less understandable code?

6 comments

3

Kinda both. They're easier to understand because modern programming languages are better defined, more consistent, and less quirky. They're harder to understand because software today is multiple orders of magnitude more complicated so there's more stuff to understand.

1

With each level of abstraction a program becomes less understandable at the hardware level but more understandable at the abstract level.

When languages get a new version, usually new features get added but none removed for backwards compatibility. So one might say the new versions are less understandable based on this. But the new features are usually simplifying things because developers want that, so one might agree with that otherwise.

For deeper insight

0

Yes, my friend, considering an entire generation programmed like, manually, in a hand-punched piece of paper http://ferretronix.com/march/computer_cards/sdcard/micro_sd_tab_card_2.jpg

And then later on like this (assembly language) http://image.slidesharecdn.com/assemblylanguageprogrammingfundamentals-140313050423-phpapp02/95/assembly-language-programmingfundamentals-8086-39-638.jpg?cb=1394687308

I think even as a starting programmer you'll agree that C++ is a lot easier to understand than any of this, right? But I know what you're actually asking: are newer modern languages easier to understand compared to older modern languages? The answer is simple: absolutely! Let me give you two examples.

Safely reading a file with C++ (created 1983):

  fstream file;
  file.exceptions ( ifstream::failbit | ifstream::badbit );
  try {
    file.open ("test.txt");
    while (!file.eof()){
       file.get();
    }
  } catch (const ifstream::failure& e) {
    cout << "Exception opening/reading file";
  }
  file.close();

Safely reading a file in Python (created 1991):

try:
    with open("aFile.csv", 'rb') as f:
        for row in csv.reader(f):
            print(row)
except IOError:
    print "Could not read file:", fName

You can see that the second is roughly half the size of the first (and a lot less "noise")! Since humans deal with the source code and not machine code, this means that half the size is roughly equivalent to taking half the time to read and understand and this translates pretty well to half the number of bugs since it's half the probability of you making mistakes (since you write less code), etc. When this code is converted (compiled) to the ones-and-zeros of the computer code, they'll be probably become the same size (maybe the second one will be bigger even) but unless you need super small and super-duper fast programs it makes no difference, except the advantages I pointed out here already.

This is actually a study field about programming languages. This means that newer languages regularly produce less, cleaner code than older languages. Here is a quick table from Wikipedia (the line ratio is how humans would see it while statement ratio is how computers would see it, kinda; a higher number means more is done with less writing) https://en.wikipedia.org/wiki/Comparison_of_programming_languages#Expressiveness

Since you seem to be a beginning programmer let me give you a heads up: C++ is not easy to understand in my view. I've worked in a few C++ projects and I'd never start a new C++ project myself, I'll always use newer languages if I get to choose. It is a great language to learn the basics of programming but once your course is finished do yourself a favor and learn Python or Java (Java is already a bit dated too) or any newer language that you like. Trust me: once you've learned C++ learning any other major language will be very easy for you!