Does using Rust eliminate the need to implement garbage collection in a language?
No. The language in which a language is implemented has almost nothing to do with the properties of the implemented language. Rust was originally written in OCaml, for example, but OCaml is garbage collected and Rust is not.
If I am to use Nim, what exactly will I be losing (or gaining) over Rust?
As you noted, Nim is garbage collected (reference counted) and does not use an ownership system for anything other than eliding reference counts. There are some data structures that are difficult to represent in an ownership system like Rust, notably trees. If you use a tree to represent any part of your language - and you likely will - it's probable that you will run into difficulties with the borrow checker, especially starting off, or have to fall back on using Rc
and Arc
to form a reference-counted structure. (a possible alternative is to instead represent trees as Vecs
)
Rust is descended from the ML family of languages, however, and inherited many of their features that make them nice for building languages (ML: literally "Meta Language"). The combination of Rust's struct
and enum
types allow for the modelling of many data structures useful for implementing a language, while its match
statement allows for structurally decomposing them. These are heavily inspired by ML's data
/type
/datatype
and match
/case/of
constructs.
Rust's struct
is directly equivalent to Nim's object
. Rust's enum
has no direct equivalent. Instead, Nim has "object variants": structs that have a tag that can be matched upon to access different fields. This means that fields can be shared across variants, unlike Rust's enum
, but the tag must be explicitly defined separately. This is generally a little harder to work with. Nim also does not have structural pattern matching: its case/of
statement can only match upon ordinal types and strings (though, there are libraries that extend it to work structurally).
There's not a right or wrong choice, of course, and there are many examples of languages implemented in both, but hopefully that provided some exposition as to what language features make a language suitable for implementing other languages in.