Teaching & Learning February 2, 2018 2

The role of abstraction in learning new languages

Abstraction is a fundamental concept in computer science and influences almost all aspects of how and what we program. Most academic courses focus on how abstraction is applied to writing code or designing a software system. But, abstraction impacts another important aspect of programming: how programmers learn and understand a new framework or language. Ove the past few months I’ve had the opportunity to assist in lower-division college class teaching students who are often brand new to programming. The focus of the class is to teach both programming concepts as well as the specifics of a common language such as Java. Assisting with the course has been an interesting experience. One that has let me look more closely at how I myself learn new languages and paradigms, and how abstraction plays a role. One of the takeaways from the experience has been how well languages such as Java, C#, Python, and others seamlessly abstract out the complexities involved in building and running a program; especially when compared to learning a Javascript framework.

The “Hello World” program is almost a cliche. It is used, for good reason, as the first pages of books and documentation, and IDE’s commonly support a “Hello World” template. For many programmers, creating a Hello World app is the first experience they have with new language and these types of applications serve several very important purposes. First, they show a developer the minimum amount of code needed for a working program. Second, they provide a valuable look at how a language and its libraries are organized; both in terms of structure and in terms of dependencies on other resources. Finally, these apps provide a base foundation on which additional learning can develop. All of these purposes result from the use of abstraction in various ways. However, without a similar type of abstraction in the underlying file and organizational structure of a language, many benefits of the Hello World app are lost.

Take the Java programming language for instance.

public class HelloWorld {
   public static void main( String[] args ) {
      System.out.println( "Hello World!" );
   }
}

While even a simple Hello World program relies on hundreds of files in the Java library, this fact is wonderfully abstracted away. Developers new to the language often never get even a glimpse of the details underlying the JDK. Their exposure is limited to a (hopefully) simple download and install process. When a program is created, for all intents and purposes, the entirety of the program is contained in a single file, which is then turned into another single file that can be executed. It isn’t until the import statement that the picture changes. And even here the abstraction is largely intact. Perhaps we intellectually know better, but using an import statement is so conceptually akin to adding a single file to our program that the abstraction holds true. Other languages such as Python and C# follow a similar pattern. A single or small number of files conceptually contains everything needed to code and run an app.

Compare this to a similar Hello World app in React, a popular Javascript framework for front-end (client-sided) web development.

ReactDOM.render(
   <h1>Hello, world!</h1>,
   document.getElementById('root')
);

On the surface, the amount of code needed is less than that for Java and appears to have an even simpler structure. Depending on the process being followed, setting up a React environment is initially only moderately more difficult than for Java. It seems that the same level of abstraction (and the corresponding benefits) are present. However, the illusion is shattered as soon as a developer tries to run the app or takes even a tiny look behind the curtain. That small amount of code, like Java, relies on a complex framework and the dizzying number of libraries. But unlike Java, these libraries and frameworks lie right next to the application. For instance, creating and running the Java app causes only two files to be made: one for the source code and one for the binary output. The React app, on the other hand, will often generate thousands of files (22,357 the last time I tried) the first time the app is built. These files are only a directory or two away from the Hello World code and are very visible to the developer. The complexity of the files, along with the multiple options for how the app can be built, break the abstraction and make it more difficult for new developers to focus on learning the concepts and syntax of the framework. While this loss is partly the result of the way in which JavaScript is used, it seems to also stem from a lack of cohesion amongst other frameworks as well as specific design choices made when the framework was being developed.

React is not alone in this: almost all of the modern web development languages and frameworks have similar failures of abstraction. This failure can impose a significant barrier on new developers looking to learn or expand into new skills. Full stack development roles are the most common type of position being offered by companies, and in order to train the next generation of developers, tools that can bring about this abstraction need to be created. While some progress is being made towards this front (such as the excellent NodeSchool), more tools and resources are needed.

Sources:

About the author

Brian Houle: (blog owner)  I'm a computer science senior at the Metropolitan University of Denver. I love technology of all kinds and have recently become interested in expanding my knowledge of web frameworks.

2 Comments

  1. Anonymous Panda

    April 26, 2018
    Reply

    Very nice article. It was very easy to understand and I like that you used more than one programming language as an example. Could you maybe give an example of abstraction in a non-programming context?

  2. Brandon

    December 20, 2018
    Reply

    Interesting article

Would you like to share your thoughts?

Your email address will not be published. Required fields are marked *

Leave a Reply

%d bloggers like this: