r/linuxquestions • u/WarGiver • 15h ago
Support Noob needs help creating linux programs
I am posting this reluctantly because reddit is a toxic mess most of the time, but two hours of research and I am no closer to an answer. If this is the wrong place to ask please aim me.
I am about 6 months into using Bazzite Linux and decided to make a program for content generation for a game (does not matter for my question but for context its a program to either randomly or psudeo-randomly produce a custom planet for the game space engineers) I want to make this tool available if/when I finish so leaving it a python script (I am well aware the unholy pain converting that to c++ will be) is not going to be a good way to share it.
The problem is that while I know and have compiled stuff to exe files for windows, before I switched, I do not know anything about doing that for linux. Can anyone aim me at the noob resources for that?
I started making it in py half to teach myself py half to see if I could, I got far enough in that I stopped to think and now I need help finding the off ramp.
Edit: Thank you all for the help! I am just going to stick to python and share that when I am done.
5
u/MonsieurCellophane 15h ago
vs code works on linux and supports a host of languages, python and C++ among them.
5
u/vanderaj 14h ago
First things first, you're doing this the way I would learn a new language, so you're already on the right track. I suggest picking up a good Python reference book, like Dead Simple Python by Jason C. McDonald, and watching a few YouTube videos on selected topics if and when you need them.
You can do this. You can do it either by yourself, which will be far more interesting albeit slower, or you can use AI to help. I suggest instead of asking AI to code everything, ask it to help you learn things, and then you implement what you had in mind, rather than let AI do it. This will be far more satisfying to me than just vibe coding something. YMMV.
Looking at the instructions for creating a planet in Space Engineers, it requires a bit of image processing and a fair amount of numerical processing. For the latter, consider using numpy, which has highly optimized routines on most platforms for Python to work with large numbers, vectors, and floating-point numbers, images, and more besides.
I think the majority of your processing time is creating the textures, bump maps, biome maps, height maps, and other assets, which Python would be a good fit alongside finding good image libraries and numpy. You'll also need to find something to export things to XML, which I believe Python has in spades.
Honestly, I'd get something working first before worrying about the compile step. Most Python packagers like py2app or pyc are not really compiling your code, they're packaging it up. You won't see much of a performance boost, it'll just be easier for folks without a Python runtime to use your code. Most Linux distros have Python preinstalled, so a pip -r requirements.txt and so on will be more than sufficient.
If your Python code ends up being too slow, consider parallelization before a rewrite. If you are just starting out and really want a fully compiled language, my favorite language is Go. It's extremely simple to learn, but it doesn't have a rich package library (pip) or numpy, so coding it in Go or Rust might be more difficult than in Python.
2
u/WarGiver 14h ago edited 14h ago
I have gotten some help from Gemini in figuring out the height map, most of rest should be far more reasonable. while I am not a master of making SE Planets I know enough to have a plan. My thoughts on packing it is just a result of something I started on a whim taking form, then realizing I might actually succeed so I had to figure out what success would look like. But your post and others have given me the hints I needed.
edit: to be clear Gemini helped me learn Perlin noise and how to make it line up like sides of a dice. :) I have zero faith or belief it could generate what I want faster then doing it myself.
2
u/razorree 15h ago
programming on linux the same, if you use compiled language (c, c++, rust, go, java/kotlin, flutter) - you have to compile it and create a release.
Do you need GUI? did you decide on your language and stack? (extra libraries for GUI or other features).
I guess Python is still the easiest.
2
u/maty7dub 14h ago
TLDR; Just use python. It is so much easier in every way
I would just say to stick with python if you already started and would tell you to switch to it even if you haven't.
If you want to distribute your utility and wrote it in C++, you would have to make a package for each distribution (package manager) that you want to support. Alternatively you could look into portable package formats like flatpak or appimage, but that is quite overkill.
If you write your app in python, you just need to provide the source file itself and, optionally, a requirements.txt. Though some instructions in a readme go a long way as well.
It feels like almost everyone who starts with programming is concerned about using the fastest language they can (I was as well), but honestly it doesn't matter. I don't know much about what you want to make, but I would assume you will be writing to a file, which is horribly slow regardless of the language.
If you are interested in learning more than in the finished product, I would point you in the direction of go, which seems like the best option you have as far as compiled languages go (no pun intended), because it creates one binary file, which should be portable between Linux distributions (but don't quote me on that) and also the fact that it has a working package manager (don't confuse this with your distribution's package manager) unlike C/C++.
I would also recommend looking into git and it's hosting services (GitHub, GitLab or Codeberg), which is the preferred way to distribute software like this. And if you're sticking with python you might find it's virtual environments, or venvs for short, very useful, since you will likely be installing dependencies with pip.
1
u/Weary-Bowl-3739 14h ago
If you want to have a less toxic experience than reddit over all, you came to the right place. Still toxic, but a lot less. If you prefer even less toxicity, go to the dedicated stack exchange forums and avoid stack overflow AT ALL COSTS.
C runs faster. But is it relevant? Do you have some function based on simple variables and a few operations? Or do you push thousands of array through the CPU or GPU?
Game optimization should focus on the parts, that make a difference.
1
u/erroneousbosh 14h ago
Looking at the web page for Space Engineers (I've never played it), it looks like the game is scripted in C# - so why not learn that? Now you can write your tool and you can write scripts for the game.
If I was going to do that I'd take a look here: https://ubuntu.com/developers/docs/tutorials/dotnet-use/
You might also look into Lua which is kind of designed as a language for scripting other software. It's used I think for Roblox (haven't played that either) but I've used it to script Wireshark, DaVinci Resolve, and a couple of tools I've written myself.
Don't worry about speed for now. If your Python code is too slow, see if you can work out ways to speed it up like moving complex calculations out of loops if possible.
1
u/sidusnare Senior Systems Engineer 10h ago
You don't do that for Linux, punish your source. If you're doing Python, the layout is usually ./src/<module>/files.py . There are different conventions for different languages, have a look around. Creating a project in GitHub often creates some defaults.
1
u/musbur 9h ago
- Do it in Python on Linux, stick to standard packages as much as possible
- If it runs fine, distribute via github. Your sentence "[...] so leaving it a python script [...] is not going to be a good way to share it" has it exactly backwards. It is the best way to share it, hands down.
- If it runs too slow, and if you can prove that it is actually the python execution speed, rewrite in a compiled language like C, C++, Rust
- Endure the endless pain of cross-platform development and packging.
1
u/serge-mv 4h ago
Python is cross-platform, unless you use some very specific things, so you can just use that if you want.
However, if you want to write it in C++, you can do that too. However, you will need to be more careful if you want to deploy it on windows and Linux because some operations will be platform-specific and without checking you might code yourself into a corner.
As for the resources, tyou can start here https://wiki.archlinux.org/title/List_of_applications/Utilities#Development
It's a list of linux tools for development, and you can go through and find out details yourself. But briefly, for Python you usually would pick either VS Code or PyCharm. For C++ there are many IDEs and you can also pick one from JetBrains, or you can just code in Vim and then compile it. IDEs are not really required, especially if you are doing a small project. Code::Blocks is a popular IDE for C++ on Linux, or CLion from JetBrains, or also VS Code.
In Linux you generally will have 2 compilers for your C code, namely GCC or CLang. Any will do for you.
14
u/dgc-8 15h ago edited 14h ago
Every Linux distro has python preinstalled, so it's perfectly fine to keep it in python. There are many big apps in the repos that are written mostly in python.
But if you want a compiled language, I can relieve you, compiling software is way easier than on windows, at least in my opinion. Even when I was on windows I used wsl for my c++ projects.
If you choose a modern language like rust or go just look up the "getting started" pages of these languages. If you want to use C/C++ take a look at gcc/g++ and maybe make, although that is optional. There should be quickstart guides out there, or ask again if you don't know further