Interested in optimization for scientific computing, where to start?

AI Thread Summary
The discussion centers on the journey of a beginner Python programmer interested in deepening their understanding of computer science concepts, particularly in relation to computational physics. Key points highlight the distinction between high-level and low-level programming languages, explaining that high-level languages like Python are easier to write but generally slower due to multiple translation steps to machine code. The importance of understanding low-level programming is emphasized, particularly for troubleshooting and optimizing code when using scientific libraries like NumPy and SciPy. Learning C is recommended as a foundational step to grasp low-level operations and memory management, which can enhance coding efficiency in Python. Additionally, alternatives like C++, Fortran, and Julia are suggested for scientific computing, each with its own strengths and weaknesses. Understanding these concepts is crucial for effectively leveraging Python in scientific applications.
rem1618
Messages
14
Reaction score
0
I've just started programming with Python this summer, and I'm taking a course in computational physics this semester. I've been really enjoying it and programming in general, but I don't have much knowledge in computer science save for intro stuff (string/list methods, functions/classes, precision digits, a bit of dynamic programming), and I'm interested in learning more. Basically, I don't even know what I don't know. For example, what should I look into in order to understand something like this?

(top answer)
http://stackoverflow.com/questions/...-slower-than-builtin-in-arithmetic-operations
 
Technology news on Phys.org
You should know that there are different programming languages (bummer!).

A computer doesn't directly understand those strings of commands you're giving him, it's not smart enough, and for that you need another program(s) that translates those strings into something the computer understands, what we call machine code. For some languages you only need one program or two to get from human code to machine code, we call these languages "low-level languages", because they're closer to the string of 1's and 0's. For others you need several jumps, and we call them "high-level languages". As a result of those jumps, high-level languages tend to produce code that's easier to understand/write while being slower overall, while low-level languages tend to be the opposite.

Where does Python come? Python is a high-level language, and most of the under-the-hood stuff is hidden from the coder unless you use specific libraries. Those stuff are taken care-of for you by a translating program that's called an "interpreter", and you won't need to understand all those "blocks" and "bytes" stuff to code in Python at all!

However, while many Python coders don't even try to understand those, I think everyone should, as sometimes the interpreter (which gives you the errors) gives you weird low-level unintelligible errors, and you need to understand them to use the Python scientific libraries (numpy,scipy...etc) to their fullest.Which is why I recommend you learn a low-level language, and I recommend you learn C specifically. (fun fact: Python is made using C! And that stackoverflow question is about CPython, a Python library for calling pseudo-C code into Python) You shouldn't really "learn" it, you're not supposed to write everything you do in Python in C, just learn how things work. Learning C is by far the best way to learn how low-level stuff works, and it will enable you to write faster code in Numpy once you understand how computer memory works.

Also you might want to properly learn a low-level language for scientific computing, since you've probably noticed that Python is slow, while C is great, it's not at all user-friendly and it lacks scientific libraries as it's intended for use for CS specialists. And here I can recommend C++ (C with object oriented stuff), Fortran (I hate it, but it's incredible as it's intended for scientists) or Julia ( a "high-level" language with low-level performance, a bit biased here since I develop libraries in it!).
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top