6 ms·
Each programming language has its purpose. C code is performant and that is a fact. Python code is not. When building mission critical systems why don't progr
by OulaX 5y ago
Each programming language has its purpose.
C code is performant and that is a fact.
Python code is not.
When building mission critical systems why don't programmers just use C itself instead of coding in another programming language and having it transpiled for them? Why introduce such tools all the time?
I am against this because the tools programmers use are becoming too bloated compared to 10-20 years ago.
Want to build an Android App? Use Java/Kotlin.
Want to build an iOS App? Use Swift.
Want to build a Web App? Use a Single JS Framework (Why millions of frameworks?)
Want to build a Windows Desktop App? Use C#.NET Either with WinForms or WPF.
I really see tools and technologies coming up all the time to solve a problem that most of the time doesn't exist.
- klyrs 5y agoThe problem that this language solves is that it automatically sorts out the memory usage for you. That isn't a problem for me; I've been programming in C for decades. But it is a problem for most python programmers who don't have a lick of C experience, but want to get C performance. It drastically lowers the barrier of entry.
- GekkePrutser 5y agoYes and it will also prevent common memory management bugs that can lead to code injection.
- zanellia 5y agoFor what it counts, I have developed code for this kind of applications exclusively in C for ~5 years (let's say 20% of my working time). I still think that debugging a segfault that you could have avoided is not very productive and that motivated me to look into possible alternatives.
- kevin_thibedeau 5y ago99% of the time a stack trace shows the culprit for a segfault straight away. No different than debugging Python.
- zanellia 5y agoif we are arguing that implementing a numerical algorithm in C is as easy as implementing it in Python - I would disagree. But maybe I am just wrong :)
- kevin_thibedeau 5y agoThe issue is debugging crashes, not productivity.
- klyrs 5y agoFWIW, I almost always use valgrind before a debugger, when tracking down segfaults. It doesn't catch everything, but 90% of the time, it gets me to the right region of code in a single run.
- zanellia 5y agosure I use valgrind and gdb too - still hard to argue that a segfault is pleasant to debug though?
- klyrs 5y agoGood good, just wanted to advocate for my favorite tool there. But, in my experience, segfaults are usually the easiest bugs to resolve. Unlike a sign error in my math, they're impossible to miss! That said, tooling to get rid of them entirely is not to be sneezed at :)
- GekkePrutser 5y agoIt doesn't have to be production. Maybe it's for a research project where you just need the extra performance. Everything has a cost. This may not be ideal but learning to do C properly as an experienced Python dev will have a time cost as well. This may just be the best way to get from A to B. I remember when I did a one-off project with a PIC microcontroller. I only had an assembler and I spent 2 days getting nowhere. Then i found a C compiler and I had the whole thing running in 2 hours. The compiler turned out to much more efficient in speed as well as code size than my hand-written assembler.
- packetlost 5y agoYou've never been near a lab environment clearly. Python is a dominant language in university labs and runs of lot more real-time systems than you think. Grad students rarely have industry experience and don't necessarily have the know-how to write C code effectively, so it's a question of resources and ecosystem. Numpy, matplotlib, pandas, scikit, TensorFlow, etc. are all huge draws for the scientific and ML communities.
- PaulDavisThe1st 5y ago> runs of lot more real-time systems than you think soft real time systems, for sure. if it runs any hard real time systems, get out of the lab. We could of course debate the boundary between hard and soft, but I'd rather not.
- deleted 5y ago[deleted]
- 4w4s 5y agoWe can talk instead about how the requirements to run slightly less simple near-hard real-time controllers are really heavy in terms of money, effort and .. weight. This tool may actually help to streamline the software part, potentially being a substitution in certain cases to i.e. Matlab Coder or similar tools.
- zanellia 5y agoRight, MATLAB Coder is a very related tool.
- packetlost 5y agoNo, I mean nanosecond precision real-time systems. Exhibit A: https://github.com/m-labs/artiq https://github.com/m-labs/artiq To save some reading, this uses a combination of an FPGA and kernel (which I think is in Rust) to generate a realtime buffer that is programmed using a mix of compiled-realtime python and plain python via a RPC system.
- Zababa 5y ago> When building mission critical systems why don't programmers just use C itself instead of coding in another programming language and having it transpiled for them? Why C and not assembler? > Why introduce such tools all the time? C compilers are one of those tools.
- zanellia 5y agoI think many people who have at least once first prototyped a numerical algorithm in a high-level language (say Python, Julia, MATLAB?) and then implemented it in C, can relate to the experience of transitioning from error messages of the type: "dimension mismatch for XYZ" to "segmentation fault". That's in my opinion a strong motivation to build tools that can automate certain parts of the development process. Writing C code directly is as a good option, as long as your code is not too complex to develop, maintain and extend. And, again, Python here is intended to be the host language for an embedded domain specific language that gets compiled into C. It does not need to be efficient it needs to be expressive and easy to analyse and transpile.
- adgjlsfhk1 5y agoNote that the whole point of Julia is that it saves you the rewrite. There is Julia code running on top supercomputers that gives speed competitive to C/C++/Fortran. You will have to put in some work to get Julia code to be that fast, but it is usually dramatically easier than a rewrite in a different language.
- fault1 5y agoyes, but "speed" in 'top supercomputers' is not "speed" in 'embedded systems'. I do think Julia potentially can crack this space, but the runtime at least historically has not been tailored for it. It does seem like Julia has become more modular lately especially being able to disconnect the JIT (or LLVM ORC). H Hopefully you'll either being able to either defatten or completely remove the runtime dependencies (ala Rust in no-std mode). Each of these is important for different use cases.
- zanellia 5y agoIt's not so easy deploy an algorithm written in Julia on an embedded platform though, is it?
- adgjlsfhk1 5y agoProbably not :)