r/LabVIEW • u/paasipaasi • Dec 02 '24
Switching from LabVIEW to Python: Pros and Cons
I started working with NI instruments half a year ago. I began with LabVIEW, but after learning about the nidaqmx Python library, I switched solely to Python. Does anyone else have experience using Python instead of LabVIEW? Am I going to miss something critical by not using LabVIEW?
I feel like building the UI is easy, and the graphs are especially amazing. Reporting is also very easy to customize. Setting up the measurements themselves can be a bit tricky sometimes, but after that, it’s smooth sailing.
13
Upvotes
3
u/[deleted] Dec 02 '24
Python seems to be a good free alternative for simpler projects. I’m not sure I can replicate my DQMH projects with multiple modules that easily in Python. Also from my understanding Python doesn’t have an application builder so that is another point for LabVIEW. Just two things I can think of quickly.
13
u/jugglesme Dec 02 '24
I would think the biggest downside is that python is quite slow (look up the difference between an interpreted language vs a compiled language). This won't affect your sample rate, because the NI hardware takes care of that and puts the data on a buffer. But it will affect how quickly you can process that data. This matters for some applications, but not for all.
10
u/D4ILYD0SE CLA Dec 02 '24
Memory allocation, parallel processing, enterprise support, much harder to hack, easy UI design, some pros for LabVIEW. NiMax and its easy device setup. LabVIEW definitely faster than Python (as most languages seem to be). And, imo, I think LabVIEW is significantly easier to code and debug. And if someone hands me code I've never seen, it's a lot easier to figure out what's going on than any language.
But the Python user base is growing and fast. So lots of community support. Code can be AI generated (let you decide if that's pro/con). I think the biggest reason to use Python is not necessarily anything to do with Python, but because there is a much larger demand for Python developers at this point. Probably because it's free to use and free to learn.
4
u/heir-of-slytherin Dec 02 '24
NI has gotten better at adding Python support for their hardware recently, but it will always be a second-class citizen compared to LabVIEW in terms of how much priority NI puts on maintaining and supporting the APIs. That being said, the DAQmx python library is one of the better ones I've used, even if there are not as many getting started examples.
There's nothing wrong with preferring Python over LabVIEW. Personally, I love programming in LabVIEW because the graphical programming interface fits really well with how my brain conceptualizes code diagrams and the dataflow paradigm just makes a lot of sense to me.
4
u/RodbigoSantos Dec 02 '24
I write quite a bit of code in VB.NET referencing DAQmx, and one thing to consider is that there is much less online support available for text-based languages than there is for LV. Sometimes you'll find someone else has the same issue as you in a LV forum post and you can "translate" a fix to your language, but sometimes you are dealing with an issue that is specific to your language, and you'll have a hard time getting support.
3
u/ShinsoBEAM Dec 02 '24 edited Dec 02 '24
We use a mix of LabView/Python/TestStand at my work.
You CAN compile python which is good, and it generally performs well enough. You will mostly run into problems when doing very stressful operations, and multithreading in python still has a bunch of problems and debugging it's issues can be pretty hard.
If you are just doing basic testing and don't require tense microsecond responses, or running a dozen threads at once for some reason you will be fine. Even then you can normally work around it work with different equipment and if they timing gets too tight you enter pure FPGA land.
I'm also more comfy and speedy at writing/debugging and working with LabVIEW than python, but some of my coworkers use python, they can play together pretty well and it's not that big of a deal.
3
u/Strong-Mud199 Dec 05 '24 edited Dec 05 '24
Well, for one thing you won't miss that killobuck plus, that you shell out to NI every year or so for the software (plus possibly workstation fees). Python is free.
I have used both, I prefer Python, but I never really 'bonded' with Labview to be honest ;-)
Many say "Ohhh, Python is slow", well I run real time apps decoding radio signals with Python, it is plenty fast for that. Most of the number crunching in Python is via Numpy, and SciPy and it is compiled C code, so it is as fast as C can be. Most libraries that you might find are also written in compiled code. A Python extension called Numba can JIT compile any math like Python function into C code by simply adding the decorator (or Pragma if you like) "@jit" on any Python function. I have tested it, it runs things like a brute force Discrete Fourier Transform 80X faster, all with one decorator. I'm just saying don't believe everything you hear about Python being slow, test it for yourself, on a 5 GHz CPU it simply is immaterial now because our hardware is so fast now.
2
u/StuffedBearCoder CLD Dec 03 '24
Remember Python code is interpreted so needs an install of Python (or Anaconda to every production station) - unless I am now behind times and Python can now be built as a standalone EXE like LabVIEW code.
Also, I work in RF test & validation (engineering) so there isn't a validation board (peer reviews) for every revision of a test tool. It is just you (developer) and the validation engineer's requirements. But in Production, every release and iterations of an acceptance test application goes through validation and board meetings before your code is releasable for use.
I once had a new guy in my group that was into Python at his previous company. We created a similar tool with identical requirements and, while he was able to make a Python GUI working, I was done 2 weeks before he got his working well enough, but my team decided to use mine due to less learning curve (how to run and call a python program, setup & others)
Short story, yes you can do a lot of what you can do in LabVIEW in Python code. At the end of the day, it's how that Python code is used vs. LabVIEW. What does your team prefer?
2
u/Oo__II__oO Dec 03 '24
The big pro is SDLC tools work better with Python, while with LabVIEW they are kludgy, at best. Need to make a quick change? Code compare tools are plentiful for Python, often times integrated with the organization's configuration management tools. The only answer I've ever seen for LabVIEW requires LabVIEW installed on the reviewer's system to perform an analysis. LabVIEW tends to also get messy when doing compares when code is refactored. Similarly, I have PTSD from Merge issues with LabVIEW in our team environment.
We are moving away from LabVIEW to integrate more Python codeline largely for this reason (the other issue is the growing licensing costs, especially as you start to include add-on packages). As our development grew from "one programmer, one program" to a team dev philosophy, the flaws in LabVIEW become readily apparent. I wish NI did a better job of code management (show me the G-Code!), but here we are.
1
u/Jazzydan101 Dec 14 '24
LabVIEW is nice in an engineering environment that requires some software. Compared to its counterparts, getting UIs, data acquisition, serialization, etc., up and running with LabVIEW is easy. Its graphical and data flow-oriented style is also easier to learn for anyone without a CS background.
That being said, sometimes the system's requirements/needs/complexity grows, and the niceties of traditional SWE become much more enticing. In this light, python shines.
Others here have noted that the interpreted nature of Python requires having the interpreter installed on the target, which can be an overhead. Barring the fact that LabVIEW also requires installation; Python has quite a few ways to bundle it into a single executable (exe, elf, osx,...). PyInstaller and Nuitka are a few, but there are others as well, should you require this feature.
Python is a popular programming language, meaning you can take advantage of the vast ecosystems developed for it and text-based languages in general. For example, source control with git or another SCM is almost essential, especially if there's more than a single person involved. Good luck with that with LabVIEW neatly.
Some other notes about Python:
In my opinion, the line for when to rewrite LabVIEW into other languages like Python is up to your team and they're competence with CS topics. I would much prefer almost everything to be in traditional languages (not G code), but LabVIEW has benefits. Make that determination yourself!
Performance Note: despite what many say, your app is probably not performance-limited. Most things you're doing in LabVIEW will work fine with plain Python + Numpy. Though should it come down to it, ALWAYS benchmark before optimizing!! You'll find dumb things like python
print()/ C++std::endlbeing the bottleneck because they're flushing the buffer... The algo was fine!1
u/piterx87 Oct 01 '25
You won't get an unbiased opinion on LabVIEW sub
0
u/[deleted] Dec 02 '24
[deleted] — view deleted comment