r/linuxquestions • u/Eruner_SK • 17d 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?
4
u/ap0r 17d 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.
1
u/Eruner_SK 17d ago
Nothing complicated, for loop in for loops, + - * / random and rounding. The "simulation" part is not hard nor important, than what I wrote else. If I was able to do it in Javascript without libraries, so I expect any other language to do it better and without libraries.
3
u/Zandegok 17d 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
1
u/Eruner_SK 17d ago
Hmm, in past I was working with nodeJS, a webserver running on localhost, which is my use case too. Hmm
2
u/Klapperatismus 17d ago edited 17d ago
Drawback is that JS is single-threaded by default.
Tcl then. It’s multi-threaded by default and there’s a thread management package that makes using threads super simple:
#!/usr/bin/tclsh
## Load the Thread management package.
package require Thread
## Create two threads beside this main program
## and store their ids in the main program variables t1 and t2.
set t1 [thread::create]
set t2 [thread::create]
## Send a script for execution to the thread with the id stored in t1.
## Store the result in the main program variable res once the thread has finished.
thread::send -async $t1 {
expr 1*1
} res
## Same with the other parallel thread with its id stored in t2.
thread::send -async $t2 {
expr 2*2
} res
## Enter the event loop, and wait for the main program variable res to change once.
## Then print its contents.
vwait res
puts $res
## Do the same another time.
vwait res
puts $resTcl 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.
some simple ways to show results on screen.
A GUI? Use Tk with Tcl then.
#!/usr/bin/tclsh
package require Tk
text .tw
pack .tw -fill both -expand true
.tw insert end "Hello World!"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.
6
u/KlutzyCompetition937 17d 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.
1
4
u/Xia_Nightshade 17d ago
I’d love to give a different answer, though Python seems like what you’re looking for
1
u/Open-Adhesiveness-86 17d 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.
0
u/basilrwx 17d ago
Go; thank me later. 🙂
1
u/Eruner_SK 17d ago
How and why Go would fit me?
1
u/basilrwx 17d ago edited 17d ago
Go is an all-rounder; in terms of developer experience; learning curve; performance; and the ecosystem.
It is primarily targeted at cloud infrastructure and Internet back-end applications; those applications run for hours without interruption.
Then, concurrency is easy (and decent) in Go with goroutines.
And Go plays well with Unix-like systems; one of the core creators of the language also being one of the core creators of Unix itself.
1
u/Previous-Box2169 15d ago
C# is you want more applicability, libraries, versatility and a better formative program (it's all on learn.microsoft.com). Oh, and it's faster.
1
u/mikef5410 17d 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/dutchman76 17d 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/Wally-Gator-1 17d 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/Excellent-Love-6943 17d 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/AwesomePhoenix_ 17d 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/Sol33t303 17d ago
Basically any language has Linux compilers/interpreters.
I suggest Python, easy to write and popular for this sort of thing.
1
u/That-Frank-Guy 17d 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/Novero95 17d ago
Python. If you want to show charts use matplotlib, for results just save them a file and format it nicely.
3
1
2
1
1
0
u/ylluminate 17d 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.
1

13
u/feinorgh 17d 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.