lone-lang / lone

The standalone Linux Lisp
GNU Affero General Public License v3.0
305 stars 8 forks source link

Build on Mac and Windows too (using APE hacks) #5

Closed aartaka closed 7 months ago

aartaka commented 7 months ago

Hi! I haven't used the project yet, so feel free to dismiss the ideas. But here goes nothing: what about supporting Windows and Mac too, using the techniques from https://justine.lol/ape.html ?

matheusmoreira commented 7 months ago

Hello! Thanks for your interest.

I targeted Linux directly for the reasons I've written about in this article:

Programs usually interface with the kernel through libraries provided by the operating system, most commonly libc. Through these libraries, they have access to system functions. POSIX-compliant operating systems provide read, write and numerous others. Windows has the Win32 API and its many DLLs and functions.

These operating systems consist of strongly connected kernel and user space components, developed and distributed as one unit. The user space libraries are the only supported means of using the system. User space programs are not meant to talk to the kernel directly, they're meant to use the provided system libraries. This forces them to depend on and link against such libraries.

While it is perfectly possible to port lone to Windows, macOS, the BSDs or any other system, it would not be freestanding if I did since I would be required to link against their libraries. Only Linux lets me build upon the kernel directly. My goal with lone was to build a freestanding programming language so portability to other operating systems is out of scope for this project.

I currently do not have any plans to implement or maintain such functionality. I don't have the technical means to develop and test such ports either: I haven't used Windows for over a decade, and I don't own any Apple computers that can run macOS. With that said, I'm not opposed to any forks. If it's something people want, they are absolutely free to take my code and improve it.

The article you linked had a huge influence on me but for different reasons:

x86-64 Linux ABI Makes a Pretty Good Lingua Franca

Instead of porting lone to other operating systems, I will take advantage of the fact other operating systems are implementing the Linux interfaces. Windows introduced the Windows Subsystem for Linux almost a decade ago and now it's backed by a real Linux kernel. FreeBSD provides binary compatibility with Linux programs via the Linuxulator which is an implementation of a subset of the Linux system call interface.

I haven't tested either of these but I'd be really if someone tried it and told me it worked. I expect lone to work on both of them. I'll consider it a bug if it doesn't work. I'll also accept patches and pull requests that improve compatibility with other Linux implementations.

aartaka commented 7 months ago

All makes sense, thanks for explaining it!