Students need to learn multiple programming languages - Embedded.com

Students need to learn multiple programming languages

College students are sometimes taught only a single programming language in detail. This limits their exposure to different language syntax/semantics, as well as approaches to problem solving. Every programming language was originally designed for a specific purpose, and, as such, tends to promote its own unique way of looking at, and solving, a problem.

Understanding just a single language promotes solutions that only approach a problem from a single perspective. Knowing multiple languages allows the problem to be looked at from a variety of perspectives so that multiple solutions can be compared and the most natural solution for the problem can be selected.

Say, for example, all you have is a hammer. In this case, both nails and screws will be best inserted with a hammer. However, if you also have a screw driver, then there is an alternate solution for inserting the screws, and the best tool can be selected for the task at hand.

Languages to solve problems
Programming languages are designed to either solve a specific class of problems or support a specific methodology, each encouraging students to look at a problem from a particular perspective.

FORTRAN , for example, was designed to help solve mathematical problems. It can be an ideal language to use for purely mathematical problem solving. COBOL was designed to help solve business data or form storage and manipulation.

The C language was designed to aid in operating system implementation and has features that allow for direct mapping to, or manipulation of, the underlying hardware.

C++ was designed to take a problem-specific language, C, and add Object Oriented programming support. It is thus a mix of both problem solving capabilities and methodological support.

The Ada programming language was designed to provide reliable operation with an emphasis on type safety, scalability and maintainability.

The Java language was designed to provide Object Oriented methodological support and portability. Scripting languages are, in general, designed to allow for very quick solutions to small problems. This list of programming languages can go on and on.

Multiple languages allow multiple solutions
Introducing students to a variety of languages helps them see each language’s advantages and disadvantages in helping to solve problems.

The C language can be used to teach how to interface to, and better understand, the underlying hardware that the software will run on. There is an advantage in some cases to being able to directly map a problem to the underlying computer, such as specifying where devices are located, or directly mapping a structure to memory. The student will also learn the disadvantages of such a language. Languages that allow direct mapping to the hardware tend to be loosely typed, permitting integers to be used as pointers and vice versa, making logic errors much harder to detect.

The Ada language can be used to give students an understanding of how to map a problem directly to a corresponding solution. Ada has powerful built-in typing capabilities, separation of specification from implementation, generic templates, and built in concurrency/threading support (tasks), to name just a few features. Powerful type constructs allow the problem entities (objects, control threads, etc.) to be directly modeled in the solution.

Separation of the specification from the implementation allows for information hiding to aid in portability to different computers and maintainability as the implementation changes over time. Ada is also a strongly typed language that will teach a student the advantages of the compiler catching errors (such as treating a pointer as an integer, which is possible in C) so that they do not end up being run-time logic errors later on.

There are of course disadvantages as well. An Ada program may take slightly longer to write, as a student must specify the types of all variables prior to their usage. Thus there is a cost for static error detection, but this tends to reduce the time that would later be spent debugging an application.

Java may be a good language for students to learn for directly mapping an Object Oriented (OO) methodology into a programming solution. Its virtual machine implementation provides some type safety and also portability (it allows the solution to ignore the underlying computer). On the other hand, Java tends to be clumsy for problems that are not naturally object-oriented.

Further, Java’s thread model is low-level and error-prone, and the language’s stated objective to hide machine details is an obstacle for low-level and real-time applications where such details are intrinsic to the problem.

Multiple languages encourage a solution choice
While all programming languages excel in solving problems for which they were specifically designed, they tend to provide less natural solutions for more diverse problem areas.

For example, languages lacking effective dynamic allocation / reclamation facilities will encourage programmers to represent lists by statically-sized arrays. Languages with good dynamic memory control allow these structures to be modeled in a more flexible way, using pointers and linked lists.

The language choice can thus influence whether the programmer views all lists as static objects that must have a fixed number of items or alternatively as dynamic objects that have no bounds. This representation choice may, or may not, be a natural solution for the problem.

For example, the “list” command has specific implementation ramifications. Static lists require that the maximum number of items be known beforehand. If the number of items is a static value, then this is the natural representation. The amount of storage needed and used will be static and reliably available.

If however the number of items is not statically known, or the number changes during program execution, then the programmer will need to select a maximum size that is perhaps much higher than the likely average number of items. Thus storage space may be unnecessarily wasted.

Dynamic lists are created at run time. If the total number of items to be stored is not statically known then this may be the ideal implementation. However, by their very nature, dynamic lists may grow at run-time and thus the resources they need are unknown and will cause an error condition should the available memory be exhausted. It might not be possible to prove, prior to execution, that enough space will be available, especially for embedded systems with limited memory capacity.

Dynamic lists rely on pointers to build and maintain the data structure. Depending on the language features, pointers introduce the possibility for hard-to-detect errors, such as dangling references (pointers to objects that no longer exist).

The above “list” example shows the benefits and detriments of both solutions to the simple task of maintaining a list. The key point is that either may be the best solution to the problem given the requirements, whether it is a static number of items to be stored, or not.

If the solution is selected based solely on a single programming language, then the optimum solution for the problem may not be selected, or even considered.

Figure 1. Matching the world of programming tools to the world of programming applications

Conclusion
The programming languages discussed here and illustrated in Figure 1 should be considered analogous to a tool box. Each language is a tool to help solve a problem. By comparing the solution that each tool offers, a student can then select amongst these solutions and decide which one is best for the problem at hand. The hammer will be used for the nail and the screw driver for the screw.

This ideal of selecting the best solution to the problem is only available if a student has been exposed to multiple ways of looking at the problem and to multiple ways of programming software code. Students must be given an understanding of a wide variety of languages as well as the different problem area solutions and different methodologies for which they were designed, so that they have all the tools they need to succeed in life after college.

Greg Gicca is director of safety and security product marketing at Adacore . He has over 20 years’ experience in designing and implementing software development tools, and has participated in industry and government groups responsible for defining software quality evaluation standards.

7 thoughts on “Students need to learn multiple programming languages

  1. “I always use FORTH when I have a choice, much faster development and the final users love the immense flexibility of having the development system online at all times.”

    Log in to Reply
  2. “I certainly agree.nnCollege/university sghould not be used as training in a language/toolset to get a job. It should be helping the students to open up their thinking. Exposure to multiple different languages helps that.nnThe most valuable course I

    Log in to Reply
  3. “” it should (and is) interesting in its own right!”nnI absolutely agree.nnWhen we take too much effort to make a subject seem fun we're setting up expectations that are not met in the industry.nnI'd rather have a person that is excited about “bor

    Log in to Reply
  4. “Class heirarchies are most certainly available in C. That's excatly how most operating systems (eg. the Linux kernel) are constructed.nnThe Linux kernel also has tasks etc. Just because these things are not language features does not mean they are usefu

    Log in to Reply
  5. “Not enough time?nnProgramming requires life-long learning. You have 50+ years to learn!nnFar too many degrees are structured as download sessions: all the skills you need to get a job. That's surely the wrong way to go about it.nnnA few years back

    Log in to Reply
  6. “If people “get confused” by things like this, then they're REALLY going to get confused when they get out in the real industry.nnWe should not dumb down teaching to make things easy for everyone. We need good programmers, not just piles of useless one

    Log in to Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.