Science/Engineering programming - Which is easier in extending C? Python/Ruby?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Science/Engineering programming - Which is easier in extending C? Python/Ruby?
I've gotten to learn the basics of both languages (functions, loops, classes), and learned love both. However I have come to a point where I need to know which is easier to write C extensions to do the "heavy lifting" (ie. intensive calculations). I therefore am posting this question here to seek some advice on this.
However I have come to a point where I need to know which is easier to write C extensions to do the "heavy lifting" (ie. intensive calculations). I therefore am posting this question here to seek some advice on this.
I'm not quite sure what you mean by C extensions with regard to intensive calculations. Do you mean extensions like for example OpenMP or the (Open)MPI framework to realize parallel calculations? Or do you just mean libraries which do some intensive stuff like say (solving systems of linear equations) encapsulated within these libraries?
Maybe, you could give some more specific examples what you think about?
What I meant was to write libraries in a different language to the glueing language. In this case I would like to use C libraries or Programs and integrate them to Python per se.
What I meant was to write libraries in a different language to the glueing language. In this case I would like to use C libraries or Programs and integrate them to Python per se.
I've seen too much code written by scientists to trust them with C or C++, and I barely trust them with Python.
I've seen too much code written by scientists to trust them with Python. C++ is safer.
In the moderate size sample of scientists and large sample of code that I have seen:
C and C++ code is written to either look like Fortran code or look like Matlab code. It is outrageously inefficient, defeating the point of coding it in C++ rather than just leaving it in Matlab. But it is organized, understandable and repairable (after profiling).
Python code is outrageously anti structured and scattered. It is incomprehensible and unrepairable.
Obviously, this depends significantly on the individual programmer. But a large part of it is in the language design. Python makes it very easy to violate the "encapsulation" concepts of object oriented programs to levels of disorganization that I don't think you would believe without seeing. Before I saw any Python code, I objected to the level of encapsulation pushed by languages like Java and C++ because sometimes that encapsulation makes the program structure worse and because a competent software engineer would encapsulate when appropriate even if the language doesn't push that. After seeing the abuses common in Python code from total anti encapsulation, I have a better appreciation for language features that recognize most people writing software aren't actually competent at it.
I'm a scientist and I write good C code. Also good Fortran code. And good Matlab code.
Though, I must admit I've run across some really badly written code that was done by scientists.
But, then, I've also run across very badly written code in the FOSS world too, and more than once I've undertaken a project (when the money is right and I was in the mood) to fix a PHP website that had been "programmed" by someone who obviously didn't know what he was doing.
You may wish to go the other direction. That is, start with a higher level language better targeted at task at hand and drop into a lower level language when you need functionality that is not provided by the higher level language.
Octave, developed as free open source software, provides the functionality of MatLab. Like MatLab, Octave permits extension functions written in C. Octave is a higher level language than C better suited to engineering problems.
I concur with your opinion about C written by scientists. I have seen a lot of software written by scientists that did not meet any reasonable standard of good programming practices. That sword cuts both ways. I have also seen software written by good programmers that is weak on the engineering and scientific implementation. The problem is that it takes a lot of time to become a good programmer and a lot of time to become a good scientist and a lot of time to become a good mathematician and a lot of time to become a good engineer. We also do other things in our lives.
I laud your efforts to become one of those rare persons who develop a deep understanding in several of those fields. It is a lofty goal, yet not unattainable. The people who succeed in developing expertise in multiple fields bridge the gaps between those fields. It also could be more than a little frustrating, because the most likely scenario in the work place is that you will end up working in one of your fields of expertise to the neglect of all the others that you have developed, with considerable investment of your resources.
I personally understand ones and zeroes and I also understand poles and zeroes. Yet what I have ended up doing is working on fixing up badly implemented software, digital hardware, and analog circuitry designed by nominal experts in each of those narrower specializations.
This is just my opinion, of course. I can not claim to be any authority on the subject.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.