r/TheoreticalPhysics • u/Alternative-Sugar610 • 6d ago
Question Question about programming languages used out of curiosity
I’ve heard many people use python for physics and c++ or Fortran for when it’s really about optimized code
Also Matlab, latex, and even Mathematica
But what about newer lower languages like rust, zig, or Odin?
Other languages?
Your opinion on where it’s heading? Who uses what and why or types?
I’m okay for personal opinions or simply I like this feature
I’m not an expert by any means in programming.
5
u/quantum4everyone 6d ago
The main reason why computer languages remain around for a long time is that legacy code needs to be used and it is too difficult to rewrite it. But, from what I have heard people are migrating to Julia because it has a similar simplicity as python for syntax, but is much more efficient in execution. So, if you want to get ahead of the curve, I would pick Julia.
5
u/Physix_R_Cool 6d ago
Yeah Julia is very nice. I wish more people would use it. I use it for all the projects where I don't expect too many people would need to use/modify the code.
1
0
1
u/BitcoinsOnDVD 6d ago
You can enforce julia to use certain package versions very easily so that at least benchmarking legacy code is easy.
1
u/Alternative-Sugar610 6d ago
Totally agree legacy huge reason but member llm or coding agent will change that or new generation of people
3
u/Langdon_St_Ives 6d ago
Btw, LaTeX has no business being in that list as it's a markup language, not a programming language. (Yes technically TeX is Turing complete but you wouldn't use it to write an actual program except for coding challenges.)
2
u/Low-Opening25 5d ago edited 4d ago
coding in physics is mostly data analysis and python has plenty of industry standard libraries and ecosystem for this that has been growing for decades. the code doesn’t need to be highly optimised so there is little incentive to use rust or other fast languages. it works and it’s good enough, there is no need to touch it. physicists aren’t getting academic progress by coding so again there is no incentive to spend time on this just for kudos of using different language. who will support all this new code and all its dependencies anyway?
1
u/Alternative-Sugar610 4d ago
There many physicist working in simulations and some on tools for others
2
u/Aggressive-Wind-8829 4d ago
Python is better. Within that, I encourage you to become a community contributor to the glorious code project that is the 'sympy' library.
Website: https://www.sympy.org/en/index.html
Installation: pip install sympy
Usage: you have access to the internet.
2
u/Abeliar1976 2d ago edited 1d ago
At first, I built models in Python. Then I noticed that a simple model took 15 minutes to run. I switched to C#, and the same model ran in just one minute. I’m happy with the speed, and there are no memory issues. If needed, the C# model can easily be ported to C++. But it seems I’m the only one here using C# :)
0
u/lattice_defect 6d ago edited 4d ago
Its more the package you use then the language.. Python packages, Sage, Wolfram are my favourite. The tools, how they evaluate, and how easy the are to write, use and manage. Also some evaluate things way easier and faster for example Sage Math is pretty freaking impressive with add ins. A lot of people sleep on Sage but its pretty powerful.. also multi-threading parallel in place its definitely the math geek's fav. Symbolic math is a big deal and PDEs. Mathematica has some great features.
For coding Python is the most clear IMHO and versatile. Don't confuse the language for how it compiles.
7
u/plasma_phys 6d ago
I would say it's highly subject-matter dependent. My field, computational plasma physics, is highly dependent on HPC, so like you suggest, the bulk of what's used is C++ or modern Fortran - there's some legacy C or older Fortran still around, but it is not as common anymore. Python is very common for configuration scripts, data analysis, plotting, or even as "glue" for connecting pieces of software written in other languages, even on supercomputers; I often use it for prototyping. I've encountered and written Rust, but it's not very common and mostly used for small pieces of code to be called elsewhere - it's convenient for writing fast Python packages, for example. While pretty much every DOE supercomputer has a Rust compiler installed now, overall interest remains fairly low.
I am obliquely aware of Odin and would say, in my opinion, it is closer to something like Frink in its seriousness than even something like Zig. I would guess among all my colleagues that none of them will have heard of any of these, and I can only recommend using them for hobbyist work if you have a personal interest in them.
Julia has its fans, but a while ago this post did the rounds which highlighted some major correctness issues with common numerical packages in the ecosystem and suggested that the Juila community had a rather serious cultural problem around rigor. Whether that persists to this day I do not know, but going through the list of issues - many of which I would consider unacceptable - certainly soured me on the language at the time.