Monday, November 27, 2017
Learning a new Language: LabVIEW
Every once in a while we have the opportunity to learn a programming language. With each new language comes the challenges of learning new "vocabulary" as well as the various things that make each language unique. As with any new language, habits from our "native" language carry over. For example as someone who learned to program in Java and C++, leaving types off variables is still hard in Python!
LabVIEW, unlike most programming languages is a visual language, much like drawing a circuit diagram. Each component is wired to the next, but instead of electricity you pass data. While at large this is very intuitive, LabVIEW has a few of its own quirks.
Clusters are one of the unique quirks in LabVIEW. The need for them stems from the pass by value nature of LabVIEW. Imagine if you needed a wire for every small piece of data that you were going to use in your program! Clusters are a way to bundle this data all onto a single wire, greatly simplifying the visual complexity of your code. However, this often comes at the cost of readability because in general the user can't easily see what a cluster contains. As a newcomer, sometimes a cluster feels like a cheap way to avoid using classes and class private data.
One thing that still blows my mind as a new LabVIEW developer is how easy it is to implement parallel code. In text based languages parallel code can be a pain to write and debug. In LabVIEW it is as simple as dropping two separate pieces of code in the same vi. No allocating of threads or trying to figure out where to place a barrier/mutex etc... LabVIEW does most of this behind the scenes, just drop two loops (or two of anything) wire them to what you need an let the compiler take care of the rest!
Tab Completion → QuickDrop
Most IDEs for text-based languages supply the user with some form of tab completion to speed up development times. Some IDEs go as far as providing a list of suitable choices for the user to select. Since LabVIEW isn't a text-based language, traditional tab completion doesn't really have a place in LabVIEW. In my eyes, QuickDrop is essentially LabVIEW's tab completion. It lets the user preform a text search all of the available functions/components and drop those components into their block diagram. One of the features that I like about QuickDrop is the ability to write your own plugin that, instead of dropping in new code, modifies the existing code you have already placed.
Because of LabVIEW's visual nature I personally feel like code written by other developers is easier to digest and understand than most text based languages. LabVIEW also interacts seamlessly with countless pieces of hardware, which is something that you can't say about most other languages. These are just a few reasons why LabVIEW is a great language to have in your arsenal. National Instruments has great tools to learn LabVIEW that can be found at ni.com/self-based-training. The Core modules (Core 1 and Core 2) are interactive and provide a great overview of LabVIEW especially to someone who has some prior experience with other programming languages. Upon completion make sure you schedule and take the CLAD and become a certified LabVIEW associate developer!