r/linuxquestions • u/Eruner_SK • 14d ago
Advice Ideal programming language on linux for me?
I am planning to code some simulations, which usually mean that pc runs for hours, calculating numbers, and then I want to see various numerical results on screen, and I need advice on what way would be both more efficient (than what I did before) and enough comfortable for me write code.
Previously, I wrote JavaScript in HTML file, and therefore ran the simulation on browser. Drawback is that JS is single-threaded by default, and I haven't get hands on experience on JS multithreading.
Currently, I have linux (fedora-based), text editor, and nothing more, no IDE, no (coding) app, just pc ready for coding by hand.
Apart from JS, I got past experience with Java and C++, and I know that I would hate Assembly, so please don't suggest Assembly to me, or similar very-low-level coding language. And I need something more than Console/Terminal-based coding, some simple ways to show results on screen.
Hmm, I expect to gain more performance from coding in something else than JavaScript, while at same time I don't have much time to deeply learn new stuff, so therefore I am asking for a min-max ideas on what language/setup should I use to just focus on writing methods and letting PC doing the calculation?
13
u/feinorgh 14d ago
Python has great libraries for maths and science, and is easy to get started with. Use "uv" and "ruff" for creating specialized environments if the official Fedora packages does not provide what you need.
Rust is a solid option but has a much higher threshold to get started. Expect potential performance to be much higher than Python in general, but writing source code and handling the tooling around Rust is more complex.
C is a solid choice with a low(er) bar of entry, but requires you to have deeper knowledge about data structures and memory management, although there are LOTS of libraries that you can use to solve a lot of problems.
C++ is more complex than C, but a lot of simulation software is already written in C++. It's got less handholding than Rust, which enables you to shoot you in the foot earlier and much harder, but the potential is enormous.
These languages are all first-class citizens on Linux-based systems, and on Fedora in particular.
There's also other languages that may be interesting depending on your use case: Elixir/Erlang, Julia, NodeJS if you already know JavaScript, Fortran if you have academic maths background.
You can try out the syntax of many of them first, but Python is probably the easiest to get started with.
3
u/Zandegok 14d ago
Depending on your attachment for nice GUI, you can make an html or a full web server that would show you infinitely intercative results in real time.
This makes you less dependent on specific language's GUI capabilities.
You can even save calculation from script to a file/db, and read this file with the html/server for full independency
4
u/ap0r 14d ago
"simulations" is so broad as to be meaningless.
You are asking "hey I am planning to work on a car, what service manual and special tools should I get" And the answer is "depends on which car and what specific work you want to do".
Please give more detail.
9
u/pelofr 14d ago
That screams python/numpy at me or even R
6
u/ipsirc 14d ago
6
u/KlutzyCompetition937 14d ago
For simulations do python. Easy syntax you'll be able to prototype faster but python is inherently single threaded but you can write code to be multi threaded. If it's scientific work you're doing and absolute correctness is a must I would suggest R. Otherwise c++, rust or any low level programming language will work if you're willing to code for it.
4
u/Xia_Nightshade 14d ago
I’d love to give a different answer, though Python seems like what you’re looking for
2
u/EcstaticAssumption80 14d ago
GoLang
2
u/Klapperatismus 14d ago edited 14d ago
Tcl then. It’s multi-threaded by default and there’s a thread management package that makes using threads super simple:
Tcl has coroutines as another means of concurrency as well. Those are very lightweight and they are executed in the same interpreter instance which means you have access to all its namespaces. While threads are better separated from each other. Which one is better suited you have to decide yourself. You can even combine both.
A GUI? Use Tk with Tcl then.
If you want to combine both, you can for example have one thread manage the GUI and the other threads sending it scripts on what to do in the GUI.
3
u/anjumkaiser 14d ago
Learn rust.
1
u/Cactoos 14d ago
Python + wasm, maybe. You can still work with a browser that way.
1
u/pohart 14d ago
Numpy or R is probably what you're looking for.
If you're sure you want parallel & concurrent programming i'd look to rust or modern Java, though.Â
1
u/Excellent-Love-6943 14d ago
I'm pretty MATLAB+simulink pilled from school. If you have it, I'd consider it. But I know there are other free ways to do what MATLAB does.
Not knowing what kind of simulation, it's hard to say, though.
1
u/Novero95 14d ago
Python. If you want to show charts use matplotlib, for results just save them a file and format it nicely.
1
u/Wally-Gator-1 14d ago
- Simulation: Python + NumPy + extensions in C (if you need the core algo to run faster).
- Alternative: Julia
- If you need close to metal: C or Rust
1
u/max_wen 14d ago
You strike me as a python person
1
u/AwesomePhoenix_ 14d ago
If you want something fast go for C or C++ or Rust or Go (or asm if you're crazy) but not an interpreted language like python or js.
1
u/sockertoppenlabs 14d ago
Fortran
1
u/Leather_Flan5071 14d ago
Python or Bash but bash won't get you that far
1
u/DryRAlN 14d ago
Haskell. But you should probably use a combination of languages
1
u/Sol33t303 14d ago
Basically any language has Linux compilers/interpreters.
I suggest Python, easy to write and popular for this sort of thing.
1
u/Glum-Building4593 14d ago
R is built for math. It can be multithreaded in code.
1
u/dutchman76 14d ago
You can use any language that works best with the type of simulation you're trying to write.
Java, Go, Rust, Python, C/C++, Perl, PHP
They can all do it, it's pure preference
1
u/That-Frank-Guy 14d ago
Imo python with numerical library is the easiest. If you're on CPU, numba, if you're on GPU, Jax is pretty good
1
u/mikef5410 14d ago
With common lisp, you'd be able to connect into the running code at any point and inspect with the debugger intermediate results. Likewise your be able to modify the running code on the fly.
1
u/Open-Adhesiveness-86 14d ago
You already know C++, so just use it with OpenMP. Stick #pragma omp parallel for on the hot loop, compile with -O2 -fopenmp -march=native, and you've got all your cores with basically no new language to learn. For the output, dump CSV from the sim and plot it separately with gnuplot or a tiny python script, way less hassle than wiring up a GUI.
1
u/Particular_Ant7977 14d ago
Cool kids use Julia nowadays.
0
u/basilrwx 13d ago
Go; thank me later. 🙂
0
u/ylluminate 14d ago
You should really give V a try. It’s a really fantastic language. I’m working on the py2v transpiler atm to convert some large code bases and it’s coming along nicely.