|
Re: LabVIEW for C/C++/Java Programmers
The description about data flow is pretty accurate, but since LV includes some control structures, there are a few additional descriptions that are useful to know about.
A LV program is made of one or more VIs (Virtual Instruments).
A VI is made up of a panel, a diagram, and descriptive info such as the name, icon, and description.
The panel allows the user to view and interact with data.
A diagram contains nodes and wires and is used to describe how the computer interacts with data.
All control flow structures are nodes that contain diagrams.
*Loops are control flow nodes that contain a diagram and run it as many times as specified.
*Cases and other conditional statements execute only one of their diagrams based on the selector input.
*Sequences execute each diagram, one after the other.
*A subVI call is a node that updates the panel and executes the diagram of the VI referenced by the subVI node.
A diagram executes by propagating data already available on wires, followed by executing nodes that do not need any additional inputs. Each and every node on a diagram is executed once and only once as its data becomes available. When all nodes on the diagram are complete, the diagram completes and propagates data to its outputs wires.
Other things worth noting:
Nodes are functions, but they don't necessarily return immediately -- especially when they are I/O related -- and can be used to regulate or signal downstream or owning code.
Wires are special unnamed variables useful for safe parallel programming. The wire guarantees that the variable is only written to one place in the diagram, then it guarantees that each reader receives the same value -- no uninitialized variables and lightweight synchronization between write and reads.
Global and local variables and other state data can introduce race conditions, but all data accesses are atomic. When reading a global, all writes are locked out, etc.
A subVI can be marked as reentrant or not. By default it is not, and it automatically mutexes so that only one caller is in the code at a time. This is particularly useful to protect global resources to avoid race conditions. If marked reentrant, simultaneous callers will proceed in parallel.
Loops are an easy way to execute code in parallel, but without something to slow down their execution, they will run as fast as possible and can starve out parallel tasks.
Many LV operations are polymorphic -- they operate on many datatypes -- and this can allow for very concise syntax.
LV doesn't support recursion, at least not very well.
LV does have the ability to create objects, protect data fields and methods, and do dynamic dispatching, but it is generally treated as an advanced architectural feature. And the objects are not referenced, but have by-value semantics to work well in a parallel language.
These are the sorts of things I usually try to point out to experienced programmers new to LV. I know some of the lingo is technical, but you have to start somewhere.
Greg McKaskle
|