United Business Media EE Times


Search

HOMEMARKET INTELLIGENCE UNITFORUMSDESIGNNEW PRODUCTSCAREERSBLOGSCONTACTEVENTSSIGN UP!RSSMost Popular contentTrusted Sources

 


ESC SV 2009 PREVIEW: Why can't C be more like Java, C# and C++ (or vice versa)?
Print this article Email this article Reprints RSS Digital Edition

Embedded.com


Many embedded developers have long been reluctant to migrate from tried and true C programming to newer programming languages such as C++, Java and C#, which support object-oriented reusable data structures implemented with design patterns to make them more reliable, more portable, and more maintainable.

According to Michel de Champlain, the reason that the linga franca for embedded systems programmers continues to be the C programming language is simple: it is fast and it is compact.

But, he said, there are ways to stay with the well-tested and reliable C language, but still take advantage of some of the advantages of newer languages and without the problems, or the long learning curve. This is the subject of "Small and Reusable Object-Oriented Data Structures in C (ESC-464)" a class that he and Brian G. Patrick are conducting at the Embedded Systems Conference in Silicon Valley.

"The successors of C have extended the language, adding object-orientation in C++ and then a virtual machine in Java and C#," he said. "These features provide additional levels of abstraction which isolate, as much as possible, the programmer from the idiosyncrasies of the underlying architecture. From a software engineering point of view, these features are welcome news.

But from an embedded systems point of view, they are often cumbersome, bloated, and ill-equipped for lower level program development. "This is somewhat ironic since Java was originally conceived as an embedded systems language," he said."Equally ironic, C and C++ do not provide standard support for some basic embedded systems tasks.

"Among these tasks is memory access where embedded systems developers are often forced to incorporate language extensions offered by compiler vendors that permit all kinds of memory accesses or allocations via banks and data/code sections."

In their class, said Champlain, the focus is on the benefits of C object-oriented collections especially designed and optimized for small footprint embedded systems. "These collections also profit from a uniform memory model layer that facilitates porting across different platforms."

"By supporting code reuse, collections not only reduce memory requirements but also shorten the development time and effort for embedded systems applications," he said.

Historically, according to Champlain, modeling and programming small embedded systems has been almost impossible to tackle with an object-oriented approach. "Using classes and objects was simply too demanding for the limited space and processing power of the 8-bit microcontroller, the fundamental building block of embedded systems<" he said.

"For that reason (and a good reason at that), the majority of embedded systems programmers continue to use C as their programming language of choice," he said. "It is compact, it is quick, and it is widely-supported. However, by adopting C, we have no option but to adopt a traditional procedural approach to programming.

Although C is also versatile and allows us to emulate more modern programming paradigms or styles, such as the object-based or object-oriented approach, said Champlain, doing so often requires sophisticated programming techniques. Yet, the motivation for developing collections in an object-oriented (OO) way supports one fundamental advantage: write once for all and reuse often.

Over the last decade or so, the development of software applications has relied more and more heavily on code reuse. However, code reuse depends on two fundamental requisites: a uniform memory model that hides away the details of the underlying architecture and a class structure which encapsulates data and its behavior into a single syntactic unit.

In this class, Champlain and Patrick present the case for using C to successfully to implement abstract data types, an important step forward. But to adopt an object-oriented paradigm, languages such as B# are needed.

Designed with the embedded systems programmer in mind, the B# language is fully object-oriented and has standard support for processor interrupts, device register names, deterministic memory defragmentation, and multi-threading.

To support these features, he said, B# is coupled with its own virtual machine which promotes reusability across different hardware platforms and provides a uniform memory model.

As a result, said Champlain, the embedded systems developer is able to write interrupt handlers and access device registers in a uniform manner, independent of the underlying architecture (memory-mapped or port-mapped). "More importantly, the virtual machine of B# has been purposely designed to work within the computational and memory constraints of small footprint embedded systems," he said.

"Although memory access is a typical embedded systems requirement, it is not standard in programming languages like C, C++, Embedded C++, and Java," he said. "In these languages, conditional compilations or special keywords are often used to support several microcontroller families.

"This makes applications hard to maintain and harder still to port. Our collections submerge hardware differences based on a uniform memory model. The end result is more reusable code which is platform-independent."

The model they use manages the data and the runtime stack of an embedded application as part of a B# embedded virtual machine (VM), dedicated to small footprint embedded systems or more specifically, for 8- or 16- bit microcontrollers with a maximum memory size of 64K bytes. The virtual machine manages all memory allocations, deallocations, and defragmentations and provides an independent memory manager written in ANSI C.

"Code reuse eliminates the re-implementation of common data structures such as stacks and queues," said Champlain. "Although code reuse is possible in C, it is best exploited using an object-oriented approach and a uniform memory model built into a virtual machine.

"Therefore, languages such as B# offer an appealing alternative as code reuse play an increasingly important role in the development of embedded systems applications."






  Free Subscription to EE Times
First Name Last Name
Company Name Title
Email address
  Click here for your Free Subscription to EETimes Europe
 
CAREER CENTER
Looking for a new job?
SEARCH JOBS
SPONSOR

RECENT JOB POSTINGS
CAREER NEWS
Engineers take a bad year in stride
According to the findings of the 2009 EE Times Global Salary & Opinion Survey, generally, engineers are satisfied with their career choices.

For more great jobs, career related news, features and services, please visit EETimes' Career Center.


All White Papers »   

 
Education and
Learning


Learn Now:












Home | About | Editorial Calendar | Feedback | Subscriptions | Newsletter | Media Kit | Contact | Reprints|  RSS|   Digital|  Mobile
Network Websites
International
Network Features




All materials on this site Copyright © 2009 TechInsights, a Division of United Business Media LLC All rights reserved.
Privacy Statement | Terms of Service | About