Linux gives you much more freedom when selecting development tools. Although C is still a reasonable choice, it shouldn't be the default choice; Linux offers an incredible selection of tools, from shell scripting to C. With that in mind, the primary dividing point is interpreted versus compiled languages. Compiled languages perform better and are generally smaller that interpreted languages. The most commonly used compiled language, C, is used because a C compiler is available-it was used to build the kernel. This article brings to light other tools and languages that embedded engineers frequently overlook. But first, C and C++.
The C language and Linux go hand in hand (going further back, Unix and C were developed at the same time, with Unix being a platform for C while C was one of the development tool for Unix). Because the Gnu C compiler (GCC) is necessary to compile the kernel, this tool is already running and known to be in a working state. This takes much of the technical risk out of using C, which usually makes managers and engineers happy. C is a language where you have a great deal of control over the machine's resources via high-level constructs. When used properly, the type checking available in C results in code that can be checked at compile time for a vast array of errors that aren't found until much later with other languages. Because C is one step removed from assembler language, it makes working directly with the underlying hardware and processor as easy as possible. The variables in C map directly to the word length of the machine where it's running, and an array is nothing more than an alias for a block of memory. With C, you have the most direct access to the functionality supplied by Linux: file handling, interprocess communication, threading, and process control. For example, other languages have the notion of starting a thread, but with C you can control the thread‘s stack size, its scheduling policy, whether the thread starts running after it's created, and even whether the parent process is able to wait on the thread to finish.
But the C language has limits for application development. It's a low-level, procedural language that gives you just enoughto shoot yourself in the foot. Type checking can be circumvented though type casts, and directly accessing the computer's memory can result in defects that aren't immediately obvious. The threading and process control can result in race conditions (a defect where the order of execution matters) and deadlocks (where threads are waiting on each other to complete an operation). The procedural nature of C also makes interacting with databases and other higher-level data structures difficult. C's direct-access, laissez faire memory access can also result in the dreaded memory leak, where a program allocates memory and doesn't release it. Memory leaks can cause a system to fail at unpredictable times in very unpredictable ways.
If you need low-level control and performance, C is an excellent choice. However, if the application spends most of its time moving data around or querying a database and presenting the data to you, other choices can reduce the amount of time you spend in development and debugging.
C++ is more than C with classes, but the object-oriented features in C++ are hugely differentiating. The C++ language has the notion of a class. A class is a data structure for which you define properties and methods. The properties in a C++ class look much like the members of a struct in C. Methods are function declarations that are also members of the class and that have as their scope the other members and properties of the class. Working with classes are templates, which are language constructs that let you specify the type of something as a parameter. A C library uses typecasts (usually to void*) for handling arbitrary types, whereas a C++ library uses a template. The advantage of using the template is type-checking at compile time. The code can't add a real to a list of integers without generating an error. Type checking goes beyond templates. As far as C++ is concerned, there‘s a difference between a char and an int, and trying to use these interchangeably results in an error at compile time. Using C++ means using the C++ standard library, which is much more extensive than C‘s. C++ has the standard collection of I/O and math routines and adds features like containers and iterators. For all of C++'s advantages, it still has some of the disadvantages of C in that you can have direct control over memory resources and can write programs that leak memory. Although the type checking is substantially better than C's, you can still use type casting to circumvent the type checking. C++ code also runs a little slower than C code, and the templates result in a larger image size. In addition to the technical reasons for using C++, you have a learning curve if you've spent years working in C: the similarities in syntax may lull you into thinking the languages are more similar than they really are.
Java (neé Oak, as it was called by its inventors) is a language created with the idea of freeing you from the hardware platform. It's a combination of language, runtime environment, and standard library. As a language, Java has a syntax similar to C++ and many of the same constructs. Java is completely object oriented. To start a program, for instance, you need to create a class with an entry point; C++ still starts by calling a procedural entry point. Java is a compiled language that is strongly typed. The compilation process, in all cases, produces code called byte code that executes on a Java Virtual Machine (JVM). At a stretch, this process can be thought of a cross-compilation. As long as the target hardware is a JVM, it's able to run Java byte code. Strong typing means the language requires variables to be declared before use and there is very little automatic conversion between types. For example, Java allows an assignment of an integer to a long integer, but it doesn't allow the assignment of an integer to a character variable. With the addition of generics in Java 1.6, the language has functionality similar to that of templates in C++. This is a welcome addition, because, for example, the code for handling arbitrary list objects required you to cast objects into Object types (the base type for all objects in Java), reducing the ability to check for type problems at compilation time.
Our website is not responsible for the information contained by this article. Articleinput.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.
Note: This article was sent to us by: Roger J. Erwand at 01302010
1. Explanation of the Embedded Linux development process
All articles are property of their respective authors. Please read our Privacy Policy!
© 2009 ArticleInput.com.