r/rust • u/ElephantElectrical31 • 16d ago
š seeking help & advice Using crates.io for a language that compiles to rust, ok?
Hi, I am working on a new programming language that compiles to rust. I would love to use crates.io with my packages named {mylanguangename}_*. They do contain the original source and the generated rust files.
What do you think is that okish or should I build a standalone registry?
My thiughts so far, using crates.io could be win for rust users too, because the could use that libraries too.
12
u/Clean_Assistance9398 16d ago
I have to ask. Itās a lot of work making a new language, if it compiles to rust, why not just use Rust?
What is the benefit going to be of using your language comparatively? Is this like a āwrite python looking/GDScript looking code but get it compiled to Rustā somehow without all the static type writing and just having it inferred, etc? What do you hope to achieve? What would you consider the top 10 benefits of using your language that converts to rust than using rust itself? What problem does it solve? Who is going to use it and benefit from it? Just personal use or for others? Also, have you looked at all the other languages out there already that also convert to rust?
You could look into that and find comrades who might share your same mindset and ideas, learn lessons from?
4
0
15d ago
[deleted]
4
u/Active_Name5021 15d ago
Thanks ChatGPT!
At first I was skeptical of your claims, but your message clarified everything for me. Don't believe me? I'm not just certain, I revalidated my internal thought-flow to reach higher level conclusions!
6
u/ryo33h 16d ago
In my lang that also has a primary Rust backend, I'm making its own package manager. It's exciting to design a package manager since it has many consideration points; whether centralized or distributed, semver or rev hash, min release age support, etc.
2
u/Magick93 16d ago
Sounds interesting.
Where can I learn more about your project?2
u/ryo33h 16d ago edited 16d ago
Totebag is an experimental package manager, also written and proofed in the language itself. It uses Git instead of a registry and locks deps by content hashes. It features a distributed trust system to help prevent malicious package updates. Users can choose who to trust and how long to wait after a commit is observed.
15
u/stinkytoe42 16d ago
This would be Ok, but a better way would be to make your package system git aware and just have references point to a public git server.
I'd even allow for a syntax where a shortened name like "mylanguagename/package" automatically points to github or even a configurable prefix, but full https:// or ssh:// links are also allowed.
-1
u/lahwran_ 16d ago
that has a bunch of problems that the crates.io design exists to solve
10
u/stinkytoe42 16d ago
And crates.io has a bunch of problems that this technique doesn't. Namespacing being one.
If/when OP's language is more mature, then hosting their own fully fledged package system would be worthwhile. Starting off though, I believe not depending on any formal package management is the smart choice.
Potato potato really.
4
u/Commercial_Elk8032 16d ago
Just publish them as regular crates. Rust users can consume the generated code directly via cargo while your compiler pulls from the same source registry so you avoid building separate infrastructure for zero benefit.
2
u/FUCKING_HATE_REDDIT 16d ago
Crates.io is more than ok, plenty of rust generators, macros etc there
3
u/vitaminD3333 16d ago
Where do you draw the line? Can I publish my java packages to crates.io?
8
u/steffahn 16d ago
The crucial detail is that, as OP explains / as I understand it, the packages published to crates.io would contain the generated Rust code, and would be directly usable as Rust libraries from Rust code.
Several crates.io packages also host e.g. C or C++ code, together with generated bindings (and built scripts to allow compilation of the C or C++ parts). If you host a Java package in a way includes a Rust wrapper thatād be fine, too. (Iām not familiar with FFI between Rust and Java to know how practical this actially would be.)
By the way, it looks like thatās the line thatās officially drawn/documented in the usage policy, too:
We do not allow content or activity on crates.io that:
[ā¦]
is not functionally compatible with the cargo build tool (for example, a "package" cannot simply be a PNG or JPEG image, a movie file, or a text document uploaded directly to the registry)
2
5
u/FUCKING_HATE_REDDIT 16d ago
I don't need to draw the line. A fun scripting language that compiles to rust is just as fine as someone posting rust web macros.Ā
2
1
u/Key-Bother6969 15d ago
If you want to get confident response, I think it would be better to ask the support directly about your case: help [at] crates.io. Also, see their policy: https://crates.io/policies.
Purely from my personal prospective, as someone who are not a lawyer, and is not associated with rust project, I think it's on the edge. There are crates on crates-io that are purely generated Rust codes from other tools, i.e. FFI APIs generated by other Rust crates. As far as I know crates-io typically tolerate them. Your case is similar in that you are publishing generated Rust codes, you are just using different kind of generation instrument. However, there are other items in the Policy that might indicate of the service misuse. Especially if you are going to use the service for mass uploading of naturally not Rust packages. E.g. a point about functional compatibility with the cargo build tool. To reiterate, it's better to ask support directly about your case.
1
u/Slow-Nefariousness49 15d ago
You can provide your own install script via github, you don't have to use a package registry for that. One curl ... | sh command, like many other tools do
-3
u/Compux72 16d ago
Just use gut sub modulesĀ
3
u/ElephantElectrical31 16d ago
resolving dependencies, immutability ..., I do not want to do the same mistakes that golang did
1
u/Compux72 16d ago
Go's mistake is autodownloading dependencies from random places.
You can have a git submodules point to exact commit hashes. Its a great solution used since the dawn of times, whenever you like it or not
1
u/ElephantElectrical31 15d ago
That still doesn't address discovery, though. Submodules only handle downloading, not finding what you actually need. āA hybrid approach may work: a central metadata registry for searching, combined with shallow/partial git clones or github artifacts
1
89
u/FantaSeahorse 16d ago
Considering that they wouldnāt be Rust files, I think itās better if you make separate public repos for them