Linux Compatibility For Javascript.NET: A Discussion
Hey everyone! 👋 Let's dive into some exciting discussions about bringing Javascript.NET to the Linux world. My company is heavily invested in this library, and we're looking to expand our horizons. We've been super thankful for the recent work by @bwinsley and @oliverbock in modernizing the project for .NET 8. Now, we're setting our sights on Linux compatibility, which isn't currently supported.
The Challenge: Bringing Javascript.NET to Linux
The Hurdles We Face
First off, the current repository is heavily reliant on C++/CLI. Unfortunately, this is pretty much a Windows-only game. Secondly, the C++ code is deeply intertwined with C++/CLI. This means it directly uses .NET System:: types within the C++ code. The biggest challenge? A Linux-compatible version would likely mean a complete code rewrite. It's a big undertaking, but we're up for it!
Our Proposed Solution
Our plan is to use this repository as inspiration. We're thinking of building new code, featuring a pure C++ library and a .NET library. The .NET library will interface using LibraryImport/PInvoke on the C# side. To make the transition smoother, we'll aim to keep the public method signatures and interfaces on the C# side similar. Plus, we'll port the existing test suite to ensure everything works correctly. This approach should allow us to keep the core functionality of Javascript.NET while adding support for Linux.
Asking for Your Thoughts
We're here to chat, gather ideas, and see what the community thinks. We'd love to hear from the existing contributors and maintainers.
Questions for the Community
We've got a few questions we're hoping you can help us with:
- Would a cross-platform implementation of this library be useful to you? Would this benefit your projects?
- Should a cross-platform project replace the existing one, or be separate? Would you like to see a new repository? Or should the new project integrate with the current one?
- Do you have any other thoughts/concerns that are worth bringing up? Is there anything we might be missing? Any potential issues?
Your insights are super valuable to us.
Separating the Projects
My take is that because this is basically a full rewrite, it makes more sense for it to live in a new, separate repository. We wouldn't be able to provide .NET Framework compatibility because we're focusing on cross-platform builds. There could be some performance implications when moving from C++/CLI to PInvoke interop. We believe these should be minimal (and potentially overridden by the .NET 8+ improvements on the C# side), but given the differences, it's worth noting. And of course, as a rewrite, it wouldn't be the battle-tested, established code we have now. So, Javascript.NET in its current form would still be worth keeping and maintaining even after the new project is done.
Potential Performance and Compatibility
Performance Considerations
One area we're keeping an eye on is performance. The shift from C++/CLI to PInvoke interop could potentially introduce some overhead. However, .NET 8 and later versions have brought significant improvements to C#, which may mitigate any performance hits. We'll be conducting thorough testing to ensure the performance remains at an acceptable level. We aim to keep things snappy and responsive, maintaining the high standards of the current implementation.
Compatibility Focus
Another significant point is the project's focus on cross-platform builds. The new project will be primarily designed for .NET Core and later versions, enabling it to run on a wider range of platforms, including Linux, macOS, and Windows. This shift means that it will not be compatible with .NET Framework, which is a major design decision. This is necessary to maximize portability and take advantage of the latest .NET features. This also simplifies the build process, enabling quicker and easier development across different operating systems. We're prioritizing flexibility and future-proofing the library for modern development environments.
The Value of the Existing Repository
Despite the proposed new project, the original Javascript.NET repository remains incredibly valuable. It is a proven, battle-tested codebase that has served as an essential tool for many developers. While the new project offers cross-platform support, the current implementation will continue to be maintained and used. It is worth remembering that a rewrite, no matter how carefully planned, always carries risks. The established codebase is mature and provides a stable foundation for projects that rely on it. We're aiming for a smooth transition, allowing developers to choose the version that best suits their needs and development environment.
Preserving Current Functionality
Our aim is to retain the existing functionality and maintain the API where possible. We are keen on a smooth transition with minimal disruption to the existing ecosystem. We are committed to making sure that the new project not only adds Linux compatibility but also preserves the quality and reliability of the current Javascript.NET implementation.
Transition Strategy
Our strategy will focus on providing clear documentation. We're dedicated to a smooth transition to the new cross-platform version. This includes detailed documentation, migration guides, and support for the existing codebase. We will aim for a phased rollout to give developers time to update their projects. This will provide reassurance and support to everyone using Javascript.NET.
Community Input is Key
We welcome any thoughts or discussions from anyone watching this repository. Specifically, we're especially interested in hearing from @spahnke, one of the most active recent contributors to Javascript.NET. Your experiences and insights are invaluable. Please, share your thoughts, concerns, and suggestions. Together, we can make Javascript.NET even better! 🚀