Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share compiled Nim libs #518

Open
EchoPouet opened this issue Apr 12, 2023 · 10 comments
Open

Share compiled Nim libs #518

EchoPouet opened this issue Apr 12, 2023 · 10 comments

Comments

@EchoPouet
Copy link

EchoPouet commented Apr 12, 2023

Abstract

I am very interested in lots of small languages ​​and I wonder if companies can use them. Often with this language (open source) to share a library there is a package manager based on Git to get sources.

Motivation

The problem is that you must share your code. It’s not a problem when you work on open source project or if your business model is compatible with that. For a companie that would like to share a librairie to a customer without the code it’s a big problem. One solution is to generate C librarie and reinport it. Not realy ideal and why the customer would use Nim ?

Description

The idea will be to add a new type of file like JAR for Java. This file, nimca for Nim Compiled Archive (it’s an example), contains some information.

  • List of all exposed functions and types,
  • the compiled code
  • others things to build with.

Of course this file can only work on the plateforme where the library was built. It’s not a problem at all. I really think this feature can encourage companies to use Nim.

To be clear, it’s not a judgement on business model or the open source philosophy. But the open source isn’t the unique model for lot of reason more or less justified and a language that force you to share your code limit your business.

Thank for your attention.

@Araq
Copy link
Member

Araq commented Apr 13, 2023

We have that in the form of .rod files which are generated for "incremental compilations" (IC) to work. Unfortunately only now work on IC has begun to continue now that ORC is reasaonably stable. But still.

@Clonkk
Copy link

Clonkk commented Apr 13, 2023

Is installing rod files instead of source code a planned evolution for installing package ?

@EchoPouet
Copy link
Author

Great.
To make it simple, this feature will replace this steps:
Nim->C Header + DLL + Nim C binding -> Nim

@Araq
Copy link
Member

Araq commented Apr 13, 2023

Is installing rod files instead of source code a planned evolution for installing package?

Yes. But it's quite far away and needs a mechanism like module_linux_arm64.rod because the rod-file resolved when statements and platform specific code.

@EchoPouet
Copy link
Author

A last point, to be easy to use, nimble should allow to download or use local nimca file and build with this.

@mratsim
Copy link
Collaborator

mratsim commented May 21, 2023

The problem is that you must share your code. It’s not a problem when you work on open source project or if your business model is compatible with that. For a companie that would like to share a librairie to a customer without the code it’s a big problem. One solution is to generate C librarie and reinport it. Not realy ideal and why the customer would use Nim ?

The industry standard is a .dll or .so or .a and a header file. I don't see what nimca brings compared to that.

It's nice to allow the customer of that company to use any language as they see fit. Being interoperable is a strength, not a weakness. Forcing/contaminating all downstream to force them to use Nim, i.e. trying to do vendor lock-in, will be a negative.

@EchoPouet
Copy link
Author

The industry standard is a .dll or .so or .a and a header file. I don't see what nimca brings compared to that.

It's nice to allow the customer of that company to use any language as they see fit. Being interoperable is a strength, not a weakness. Forcing/contaminating all downstream to force them to use Nim, i.e. trying to do vendor lock-in, will be a negative.

nimca is useful for Nim, it is always possible to produce .dll and header files for other languages. The goal is to share Nim libraries without giving the code in a simple way. It must be seen as for the JAR files in Java.

@mratsim
Copy link
Collaborator

mratsim commented May 21, 2023

I don't see the benefits compared to a .dll and header. Can you list them?

@Araq
Copy link
Member

Araq commented May 21, 2023

A .dll + header doesn't support anything with inlining semantics such as:

  • generics
  • templates
  • macros
  • iterators

Also a DLL is fundamentally type-unsafe and kinda the lowest common denominator.

@EchoPouet
Copy link
Author

I also add that currently you have to create a Nim wrapper to use the C header and the dll previously generated by Nim. I think this is a ridiculous situation if on top of that you lose the advantages of the language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants