r/linuxquestions 23h 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.

9 Upvotes

20 comments sorted by

View all comments

15

u/dgc-8 23h ago edited 22h 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

2

u/WarGiver 23h ago

the reason I was considering c++ was two reasons, first I heard it runs faster, and second is to share something with windows users. I never ran a python script on windows, technically even Linux either before this, so ease of access or running is my worry.

6

u/Azelphur 23h ago

first I heard it runs faster

Pretty much, but it's also much harder to learn, pick your poison.

second is to share something with windows users.

You have exactly the same problem, you still need to compile and distribute. You can use pyInstaller to create a Windows exe. For Linux side, you can package it, but you should also provide the Python file anyway to support Linux distros that you haven't packaged it for. Maybe look into flatpak or open build service. Regardless, this problem is the same whether you use C++ or Python.

6

u/WarGiver 22h ago

huh pyinstaller, that sounds like right path for windows... and it sounds like sharing the py file would be the best linux option.

I think I will stick to py, if c++ is that bad to learn.

6

u/Francis_King 18h ago

Speed doesn't help much if one or more of the following apply

  1. You are interacting with the user - the user is the speed limitation
  2. You are accessing a database - the database is the speed limitation
  3. The code starts, does a few things, and then finishes - you'll only notice the speed difference is you around in a tight loop (most speed tests are a loop)
  4. You are calling out to compiled libraries - the calling program isn't where the time is spent

Python is an excellent language

3

u/RPG_Hacker 22h ago

It's worth noting that sharing executables will not be easy on Linux, anyways, and is often even discouraged by the Linux community. The reason for this is that most Linux distros have a unique environment for running executables, making them compatible with only that specific distro.

There are alternatives and ways around this, but to put things simply, you just won't be sharing EXE files on Linux like you might be on Windows. It isn't typically done. So if you're choosing to make your app a compiled program, you might even end up making things more complicated instead of simpler, since users of the app might now have to compile it from source (unless the specific package manager they use has a compiled version of it available for their specific distro).

So unlike on Windows, sharing a Python script instead of an executable might even be simpler for end users on Linux.

3

u/dgc-8 22h ago

just to add if you want it to run fast you don't have to pick c++, there are other more modern compiled languages that also have zero-cost abstractions which run as fast as c++, say rust for example. but c++ is also fine and still a very good choice

2

u/serge-mv 12h ago

C++ is indeed faster then Python, but in your case, does it matter? If you are just going to work with file system and generate a set of numbers and then use that outside of your script (as in, it's not real time usage), then do you really need the most bestest speed? It's not like you will sit there and wait hours for python script to finish. Also take into account the speed of development and ease of debugging.

1

u/sidusnare Senior Systems Engineer 18h ago

C++ isn't going to make sharing with Windows easier.

You have probably run a lot of Python on Windows without knowing it. A lot of projects just bundle the whole language, modules, and project in an InstallWizzard. Windows is very inefficient around this.