java-logo.jpg
java-logo.jpg
java-logo.jpg
java-logo.jpg
java-logo.jpg

Java Turns 20—So What Else is New?

June 13, 2015
New programming languages come and go, but Java and C/C++ may not be the only ones to keep an eye on.
Oracle’s Java turns 20 this year. C++ hit the big 3-5 last year, while C is over 40. Microsoft’s C#, the baby of the group, is 15 years old. All of these continue to command a significant following even in the embedded space. All have significant corporate support that helps with their staying power and they have been continually updated with new features. For example C++14 allows units (see "Bjarne Stroustrup Talks about C++14" ), and lambda expressions are now part of Java, C#, and C++.

Of course, new programming languages keep cropping up, including ones designed for embedded applications. Many look to displace existing programming languages, with others targeting new or emerging platforms like IoT or mobile devices. In theory, they try to simplify the programmer’s job and help make applications safer and more secure.

For example, Google Go is a new language from Ken Thompson, Rob Pike, and Robert Griesemer. Ken, as you may know, helped create C. (See "Thompson, Ritchie, And Kernighan: The Fathers Of C".)

Apple’s Swift looks to replace Objective-C, the company’s current programming language. Objective-C has primarily been used for Apple platforms, and Swift is following suit—so if you aren’t interested in those platforms, Swift won’t be, either. This is very similar to Microsoft’s approach for C#, although C# has found some open-source, third-party support.

Swift does not expose pointers and its syntax has moved towards languages like C++ and Java. Object-ive-C syntax was closer to Smalltalk. It supports named parameters for methods, while espousing features like protocols (think Java interfaces), categories, and closures.

Mozilla’s Rust is another general-purpose programming language that targets highly concurrent and safety critical applications. It has a syntax similar to C/C++, but it guarantees memory and thread safety. While Rust uses manual memory management, its control of pointers is worth looking at—especially for embedded applications. Its “boxed pointers” have a unique reference to a heap object that will be deleted when the pointer goes out of scope. There also are “borrowed pointers” designed to prevent dangling references. Data referenced using these pointers cannot be deleted, while a borrowed pointer references it. A “borrow checker” provides compile time checking.

Of course, like almost any practical programming language these days, it has C bindings. What I find interesting are Rust’s trait-based generics and pattern matching support. The latter is not unique, as Scala (see "If Your Programming Language Doesn’t Work, Give Scala A Try" ) and other programming languages have this feature.

Go, Swift, and Rust still have to prove themselves. The bottom line: These and other languages will not have a lot of impact on C, C++, C# and Java in the near term.

C, C++ and Java are still the primary languages for embedded applications, with C leading the charge. The reason is simple: Every processor coming out of the foundry has a set of development tools with a C compiler. Assemblers have essentially disappeared; they still exist, true, but board support packages (BSP) and runtime support are almost always in C these days. Even if a developer uses another programming language, it will need a C interface to gain access to base services.

There are other tried-and-true languages available without needing to try out a new language. Dynamic scripting languages like Python and Lua are already used in embedded applications from robot control to wireless Internet-of-Things (IoT) sensor devices. Then, of course, we have JavaScript. While primarily used in web browsers, it also works as a standalone platform.

Duktape is just one open-source C implementation of JavaScript that can be embedded. JavaScript, like Lua and Python, will run on many Cortex-M microcontrollers. The Google Chrome V8 JavaScript engine is written in C++.

Sometimes I wonder if we should not give Ada or Lisp a chance. Ada is 35 years old and has built-in multitasking, plus contracts that make most languages look lame when it comes to safety. (See "Ada 2012: The Joy of Contracts".) Its object-oriented support matches that of the newer languages. Lisp has been around for 60 years and is where a lot of the “borrowed” ideas for these other languages came from. Think lambda.

Sponsored Recommendations

Board-Mount DC/DC Converters in Medical Applications

March 27, 2024
AC/DC or board-mount DC/DC converters provide power for medical devices. This article explains why isolation might be needed and which safety standards apply.

Use Rugged Multiband Antennas to Solve the Mobile Connectivity Challenge

March 27, 2024
Selecting and using antennas for mobile applications requires attention to electrical, mechanical, and environmental characteristics: TE modules can help.

Out-of-the-box Cellular and Wi-Fi connectivity with AWS IoT ExpressLink

March 27, 2024
This demo shows how to enroll LTE-M and Wi-Fi evaluation boards with AWS IoT Core, set up a Connected Health Solution as well as AWS AT commands and AWS IoT ExpressLink security...

How to Quickly Leverage Bluetooth AoA and AoD for Indoor Logistics Tracking

March 27, 2024
Real-time asset tracking is an important aspect of Industry 4.0. Various technologies are available for deploying Real-Time Location.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!