Hacker News new | ask | show | jobs
by jdiez17 3408 days ago
This seems quite similar to LabView. So I imagine it'll have similar pros and cons: LabView is great for putting together quick prototypes for e.g data collection or visualization, but it quickly becomes unmanageable as the complexity increases; you need to 'tidy up' the placement of the various operators or it ends up being a rat's nest.
3 comments

No, they explain that LabVIEW and other visual languages are just different ways of representing the code. The idea here, I think, is that there's far greater coupling between the output of the program and the program itself. It's similar to some of Bret Victor's ideas: https://www.youtube.com/watch?v=PUv66718DII

I'd like to incorporate this coupling idea into my own visual dataflow language (http://web.onetel.com/~hibou/fmj/FMJ.html), but haven't yet decided how to implement it. My approach has been to design the language from the bottom-up, so that simple programs can be simply drawn, and there are higher level programming constructs which simplify more complex code, avoiding the complexity problem (the Deutsch limit) you've seen with LabVIEW.

i have written very large systems in labview, and your viewpoint is simply not accurate for a good labview programmer. just like any coding discipline, you keep your VIs, classes, libraries, etc. small and suited for a single purpose. what you end up with is a collection of VIs that basically have a REPL automatically built in (i.e., just run the VI). and when i say large systems, i mean multiple projects with greater than 1,000 VIs and many tens of classes.

it's a rule amongst good labview programmers that you keep your block diagram to where it fits on a single, reasonably sized/resolution monitor without scrolling. simply adhering to that rule encourages good coding practice. within my large systems, i am able to freely edit pieces with often no unintended consequences. since reference-based data types are really only used for multi-threaded communication and instrument/file communication, you typically are operating on value-based data which makes reliable code development quite easy.

and what you describe is equally applicable to any text-based language. neither labview nor text-based languages have built-in precautions against horrific coding standards.

If it were "only" for the spatial relationship between "variables" and logic, LabVIEW wouldn't be such a pain to use.

What's really annoying about LabVIEW is, that its programming paradigm is kind-of functional, but it doesn't go the full effort and forces you to do things, which one kind of expects are abstracted away, and things become a mess. Let me explain my top pet peeve:

In LabVIEW the main concept are so called VIs: Virtual Instruments. A VI consists of a number of inputs called "Controls", some logic in between and outputs called "Indicators". Inside a VI you have the full range of programming primitives like loops (which interestingly enough can also work like list comprehensions through automatic indexing, but I digress) "variables" (in the form of data flow wires) but no functions. VIs are what you use as function. And if everything happens through VI inputs and outputs and you don't use global variables, feedback nodes or similar impure stuff it's pretty much functional.

Somewhere your program has to start, i.e. there must be some kind of "main" VI. But VIs mostly behave like functions, so if you hit "run" for the main VI it will just follow its data flow until every input has reached what it's wired to and all subVI instances have executed and thats it. That's perfect for a single shot program, like you'd have on the command line or executing to serve a HTTP request, however it's kind of the opposite of what you want for an interactive program that has a visual UI. Sure there is that "run continuously" mode which will just loop VI execution. But all what it does is re-evaluate and execute each and every input and subVI again and again and again. If you're using LabVIEW in a laboratory setting, which is its main use, you probably have some sensors, actuators or even stuff like lasers controlled by this. And then you do not want to have then execute whatever command again and again. There is a solution to this of course, which are called "event structures". Essentially its like a large "switch" statement, that will dispatch exactly once for one event. Of course this caters only toward input manipulation events and some application execution state events. And you can not use it in "run continuously" mode without invoking all the other caveats. So what you do is, you place it in a while loop. How do you stop the while loop? Eh, splat a "STOP" button somewhere on the Front Panel (and don't forget to add a "Value Changed" event handler for the stop button, otherwise you'll click STOP without effect until you manipulate something else).

And then in the Event structure you have to meticulously wire all the data flows not touched by whatever the event does through so called "shift registers" in the while loop to keep the values around. If you forget or miswire one data flow you have a bug.

What seriously annoys me about that is, that in principle the whole dataflow paradigm of LabVIEW would allow for immediate implementation of FRP (functional reactive programming): re-evaluation and execution of only those parts of the program that are affected by the change.

The other thing that seriously annoys me is how poorly polymorphism is implemented in LabVIEW and how limited dynamic typing is. I'd not even go as far as saying that LabVIEW does type inference, although at least for primitive types it covers a surprisingly large set of use cases. Connect numeric type arrays to an arithmetic operation and it does it element wise. Connect a single element numeric type and an array and it again does things element wise. Have an all numeric cluster (LabVIEW equivalent of a struct) and you can do element wise operations just as well. So if we were to look at this like Haskell there's a certain type class to which numeric element arrays, clusters and single elements belong and it's actually great and a huge workload saver! Unfortunately you can't expose that on the inputs/outputs of a VI. VI inputs/outputs always have to be of a specific type. Oh yes, there are variants, but they're about as foolproof to use as `void*` in C/C++. So the proper way to implement polymorphism in LabVIEW is to manually create variants of your VI for each and every combination of types you'd like to input and coalesce them in a polymorphic VI. And since you have to do it with the mouse and VIs are stored in binary this is not something you can easily script away. Gaaahhh…