[original] comparison between Nim and trust

Time:2021-10-21

Comparison of characteristics between Nim and trust

At present, these two languages are minority languages. I have done some research for some time, written something and gained some experience

Similarities:

  1. There is a health macro. It is different from the (unsanitary) macro of C + +
  2. Define functions outside the class (struct or object) definition body
  3. The code is not divided into header and implementation body
    For example, ADA header (ads) and Implementation (ADB), C / C + + header(.h/. HPP) and definitions(.c/. CC / *. CPP), Java’s interface definition and implementation definition are separated, while trust and Nim are not separated
  4. Using functional programming. High order functions are now standard for emerging languages
    Of course, trust is more used and more convenient
  5. Built in asynchronous execution function (such as goroutine / Lua coroutine)
    Rust: through Mio + Tokio (the de facto standard), Nim has built-in asyncdespatch + async series library, which brings lighter multitasking capability
  6. Built in system level threads, easy to use
    The use of C / C + + threads is really a tear
  7. The type definition of variable / constant is different from that of C / C + + / Java and is postpositive. This is similar to scale / kotlin
  8. Type automatic derivation capability
    This function also appears in C + + 11 / Ocaml / Haskell
  9. It can be compiled into C or ASM or JS code
  10. It can be compiled into wasm and executed in the browser
    So far, Nim works more closely with browsers
  11. There is no Gil limit and multithreading capability is not limited
  12. There are integrated package (module) management tools
    nim:nimble; rust:cargo
    It is used to initialize the project directory, create basic code, download necessary modules (packages), etc
    Nimble started late and its functions are not perfect

Differences:

  1. Nim has GC, but trust doesn’t
    Nim is said to be able to manage memory manually without GC. At present, we haven’t found out how to do it
    Trust relies on ownship + lifetime + raii resource management, which is closely analyzed by the compiler
  2. The executable file compiled by trust is huge, and the NIM executable file is quite small
  3. Nim syntax is similar to the mixture of Pascal and python. Trust is close to C, and it feels like a small part of Python + go
  4. Nim’s OOP is very mainstream, and trust’s OOP is very alternative. It requires rich experience in middle-level (framework level) design
    The concept of trust is very difficult (different ownership / border leads to lifetime), and the entry threshold is very high. In addition, it is difficult for developers who are used to other languages to implement method overload with macros and templates. The most difficult thing is that trust can not inherit, and can only combine and implement polymorphism with traits similar to interfaces
    PS: the macro system of trust is not yet stable. It is currently developing from macro 1.1 to macro 2.0
  5. Nim has a slightly more backend
    There are C, C + +, JS and llvm backend
  6. community
    At present, the community of trust is large and active, and the community of NIM is small
  7. Maturity
    The version of trust is above 1.0, and the version is upgraded every six months
    The NIM version is still at 0.19 and has not officially reached 1.0
  8. FFI (external interface)
    Trust can be easily combined with the C standard interface (called or called), but not with the C + + interface (the ABI of C + + itself is chaotic)
    Nim features: as a serious compiler language, it can be combined with C / C + + / Object C, which is the only one I know so far
    PS: in other words, you can make a QT adapter, so you can use the existing powerful QT to do a lot of things

Other summary:

  1. Trust’s [security first, bare metal] concept, high performance and high entry difficulty make it seem to be used in the same basic software / underlying software as C / C + +. It is very suitable as a secure upgrade version of C / C + +
  2. Nim, which is close to the concept of python, Pascal syntax, easy-to-use built-in library, and easy to combine with C or C + + or object C, seems to be a very suitable upgraded version of Python. Non large-scale rapid development is also applicable to NIM, such as prototype development / auxiliary tools / data ETL processing / text processing / web crawler

The fifth wave Programming Language Division

It is not purely based on the timeline

The first batch is FORTRAN / COBOL / ADA / Pascal / C. features: pure process, compilation language, applied to numerical calculation, transaction processing is different from the basic software. PS: ADA
The second batch of C + + / Object Pascal, features: OOP genre and compilation language characterized by inheritance, which are applied to framework / game / GUI software
The third batch is Java /. Net. Features: the design and syntax are similar to those of the second batch, but the middle code and VM runtime are introduced and applied to Web / Web2.0
The fourth batch is represented by Perl / Python / PHP / ruby. Features: scripting, rapid development, simple framework and perfect scaffold. It is used in operation and maintenance, text processing, data ETL, non high concurrency and large flow Web / Web2.0. PS: Python has AI bias
The fifth batch is represented by scale / kotlin / SWIFT / trust / NIM, which has the following characteristics: (except for trust) in the original OOP pattern, a large number of functional programming methods are combined with LISP / ml / Haskell functional programming language; (except scale) it can be run directly in native mode or with JS, wasm and middle code as the back end; Trust introduces another school of OOP and completely abandons the mainstream OOP characterized by inheritance and uses OOP centered on trait

The concept of trust is very difficult. The unique ownship / arrow leads to lifetime, and the entry threshold is very high. In addition, it is difficult for developers who are used to other languages to implement method overload with macros and templates. The most difficult thing is that trust can not inherit, and can only combine and implement polymorphism with traits similar to interfaces