ARM vs. x86 distros for Software Development (specifically C++ and Python) Advice for M1 Macbook

Casanova

New Member
Joined
Aug 26, 2023
Messages
2
Reaction score
0
Credits
26
Hello,
I hope you're doing well!
I'm a university student currently using a M1 MacBook Pro (it's the only machine I have) for school and personal.

I've recently been thinking of using Linux for software development mainly for C++ and Python.
1. I'm curious what are my options for using Linux on an M1 Machine, and
2. Is there anything I should be aware of between ARM vs. x86-64 Linux distributions for software development? I mainly use C++ and Python.
Any help or advice is highly appreciated! Thanks. Let me know if you have any specific questions for me that can better help answer my questions!

Linux experience: Beginner/Novice?
Context: Throughout school, I've occasionally used a Linux environment I SSH into, so I know a few of the basic commands(ie. cd, ls, mkdir, rm, cat, vim, touch, etc.)
Lately, I've also seen various job postings requesting that applicants(like myself) be experienced with C++ in a Linux/Unix Environment. What does that mean exactly and how is that different from a macOS environment? Or windows for that matter?
 


I would say your target device matters more than what you are developing on.
You can cross-compile almost any hard platform these days.

Python generally isn't a compiled language, however different versions of python, on different OS's
(even different versions of Linux) can sometimes behave differently.

C++ is pretty OS specific, it can often require specific versions of runtime libraries in order to run correctly.
Linux itself is not written in C++, but rather C ( rust is making some inroads here ).

Linux is different from Mac in a number of ways, I don't know if I can list all the differences here.
The "kernel" is totally different. ( Yes Windows and Mac have a kernel of sorts )
The file systems are different, the runtime libraries are different, the system calls are different,
the user management is different, the ACL's ( file permissions ) are handled differently.

Something written in C or C++ for a specific version of Linux, will generally not be compatible with all
other versions of Linux. If the processor type, runtime libraries, and Linux kernel are close enough, it
will "probably" run. It definitely will not be compatible with Mac or Windows.

Python is a mixed bag. Some python app's will run on Windows and Mac's with no problems.
Other's do not. In my experience, it's usually system calls that cause incompatibilities.

If you want a truly portable ( cross OS, cross hardware ) language, you might look at Java.
 
Also, your current options for running Linux on M1 architecture are limited to various virtualization methods. Support in the kernel is coming, but it's not there yet. The pundits are saying support will arrive with the 6.2 kernel.
 
I don’t know anything about M1 support in Linux.

But regarding C++ and Python on ARM and x86_64, there are obviously differences between the two processor types. They have completely different instruction sets.

But it makes no difference to C++ and Python. For C++, the ARM version of g++ (or clang++, if using clang) will compile and link executables that will run on ARM. The x86_64 version of g++ will compile and link executables for the x86_64 architecture.

You don’t need to do anything in your C++ code to cater for the different processor architectures. Just pick a standard version of C++ and stick to it rigidly. The compiler will deal with the platform specific stuff.

You can also use cross-compilers to compile and build ARM executables (or windows executables etc) on X86_64.

With Python, the Python interpreter has versions that are built for various platforms/processor architectures.
So you should be able to write Python code and run it on any platform.

The only time you might experience problems on multiple platforms is if you use 3rd party libraries that are only available on certain platforms. So when working on a project, ensure that all libraries you use are available for all of your target platforms.

Also avoid using Python 2.x as it is EOL. Python 2 is no longer being developed/maintained.
 
From chatGPT...

Python programs written on Linux can generally run on Windows, but there might be some considerations and adjustments you need to make due to differences between the two operating systems. Here are a few things to keep in mind:

  1. Line Endings: Windows and Linux use different characters to represent line endings in text files. Linux uses LF (Line Feed, \n), while Windows uses CRLF (Carriage Return + Line Feed, \r\n). Most code editors and Python itself can handle both formats, but you might encounter issues if you're reading or writing files in your code. To ensure compatibility, you might want to stick with LF line endings.
  2. File Paths: Windows and Linux have different conventions for file paths. Linux uses forward slashes (/), while Windows uses backslashes (\). Python's built-in functions can handle both formats, but if you hard-code file paths, you should use the os.path module to handle path construction in a cross-platform way.
  3. Dependencies: If your Python program relies on external libraries or packages, you'll need to make sure they're available on the target system (in this case, Windows). You can use tools like pip to install the required packages on both Linux and Windows.
  4. Shebang Line: If your Python script uses a shebang line (e.g., #!/usr/bin/env python), it won't work on Windows because Windows doesn't use shebang lines to determine how to execute scripts. You might need to explicitly run the script with the Python interpreter (e.g., python script.py) on Windows.
  5. Operating System Differences: Some platform-specific functionality might behave differently on Windows compared to Linux. For example, certain system calls, file permissions, and networking operations could have variations. Make sure to test thoroughly on both platforms to ensure consistent behavior.
  6. Case Sensitivity: Windows file systems are case-insensitive, while many Linux file systems are case-sensitive. This means that if your code relies on file or directory names having specific casing, you might encounter issues when moving between platforms.
  7. Executable Extensions: On Windows, executable files usually have .exe extensions. If you're distributing your Python program as a standalone executable using tools like PyInstaller or cx_Freeze, the generated executable will have a .exe extension on Windows.
  8. User Interfaces: If your program has a graphical user interface (GUI) built with libraries like Tkinter, PyQt, or wxPython, you might need to test and adjust the interface for differences in appearance and behavior between Linux and Windows.
In general, writing cross-platform code involves being aware of the differences between the target platforms and using appropriate libraries and techniques to handle those differences. Proper testing on both Linux and Windows is essential to ensure your program works correctly and consistently across different operating systems.
 


Top