c2nim VS tinycc

Compare c2nim vs tinycc and see what are their differences.

c2nim

c2nim is a tool to translate Ansi C code to Nim. The output is human-readable Nim code that is meant to be tweaked by hand before and after the translation process. (by nim-lang)

tinycc

Unofficial mirror of mob development branch (by TinyCC)
Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
c2nim tinycc
7 15
490 1,794
0.4% 2.8%
4.1 8.9
6 months ago 8 days ago
Nim C
MIT License GNU Lesser General Public License v3.0 only
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

c2nim

Posts with mentions or reviews of c2nim. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-02-12.
  • I learned 7 programming languages so you don't have to
    8 projects | news.ycombinator.com | 12 Feb 2023
    Also on the game development front, I maintain a raylib wrapper https://github.com/planetis-m/naylib As long utilities like c2nim https://github.com/nim-lang/c2nim exist, it's trivial to create bindings of C/C++ libraries. One thing I want to experiment more is making it more automatic by writing a callback exposed by c2nim that transform the generated code using Nim's AST. But regardless in that project I was able to write safe language abstractions on top of the bindings that provide a more native experience. It has scope-based memory management, generics and ... function overloading.
  • The way integrate Rust into Nim
    2 projects | dev.to | 21 Jan 2023
    Rust also has a library called safer_ffi that makes FFI easier, and I tried to use that, but the library seems to be immature, and I could not get arguments in Rust functions. If this library can be used properly, it will be possible to output C header files from Rust functions and automatically generate Nim interface functions from C header files using c2nim. We look forward to further development of this feature.
  • Checked C
    14 projects | news.ycombinator.com | 21 Dec 2022
    Well I'm 99.5% certain at least. Even now I'm uncertain of the C syntax. And I've not been bold enough to test 3rd order C function pointers. I figure that's probably C code you don't wanna touch if possible.

    https://github.com/nim-lang/c2nim/blob/11f2c5363dfe7e8c7c8ce...

    The other annoying one is that "signed" and "unsigned" are basically adjectives, but "long" can be both a type and a modifier. So it's difficult to parse unless you're the target C compiler. Technically you can, but you have to use backtracking.

  • Nim -- a modern "glue" language like Python
    9 projects | dev.to | 11 Oct 2021
    c2nim is a tool to translate ANSI C code to Nim. The output is human-readable Nim code that is meant to be tweaked by hand after the translation process. If you are tired of wrapping C library, you can try futhark which supports "simply import C header files directly into Nim". Similar to futhark, cinterop allows one to interop with C/C++ code without having to create wrappers. nimLUA is a glue code generator to bind Nim and Lua together using Nim's powerful macro. nimpy and nimporter is a bridge between Nim and Python. rnim is a bridge between R and Nim. nimjl is a bridge between Nim and Julia! Last but not least, genny generates a shared library and bindings for many languages such as Python, Node.js, C.
  • Genny – Generate Nim library bindings for many languages
    6 projects | news.ycombinator.com | 12 Sep 2021
    Now if only a full binding generator for C and C++ headers to Nim was done, the language would really be cooking!

    "What do you mean, Nim has two of these already?"

    Yeah, I know, and -- not to hurt anyone's feelings -- but: they kind of suck. And there's no way I see them able to be extended to do the job fully, based on the way they're currently built.

    Those are some bold claims to make!

    So before I get stoned to death (no offense to the authors, I am grateful that they exist and have used them both) let me attempt an explanation and back up these statements.

    ---

    To start off, the two tools available are "c2nim" and "nimterop". c2nim is a Nim official library, while nimterop is a community library.

      https://github.com/nim-lang/c2nim
  • ffipf - quickly jump to file in a project with a native module
    5 projects | /r/emacs | 10 Jan 2021
    Yes. Nim compiles to C and has a lot of features for interacting with C code. You can easily call C routines from Nim and Nim functions from C. There's a bit of a ceremony you need to go through, but most of it can be automated with c2nim tool: https://github.com/nim-lang/c2nim
  • C2nim: A tool to translate ANSI C code to Nim
    3 projects | news.ycombinator.com | 1 Jan 2021

tinycc

Posts with mentions or reviews of tinycc. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-04-03.
  • Autoconf makes me think we stopped evolving too soon
    8 projects | news.ycombinator.com | 3 Apr 2024
    A better solution is just to write a plain ass shell script that tests if various C snippets compile.

    https://github.com/oilshell/oil/blob/master/configure

    https://github.com/oilshell/oil/blob/master/build/detect-pwe...

    Not an unholy mix of m4, shell, and C, all in the same file.

    ---

    These are the same style as a the configure scripts that Fabrice Bellard wrote for tcc and QEMU.

    They are plain ass shell scripts, because he actually understands the code he writes.

    https://github.com/qemu/qemu/blob/master/configure

    https://github.com/TinyCC/tinycc/blob/mob/configure

    OCaml’s configure script is also “normal”.

    You don’t have to copy and paste thousands of lines of GNU stuff that you don’t understand.

    (copy of lobste.rs comment)

  • AST vs. Bytecode: Interpreters in the Age of Meta-Compilation [pdf]
    1 project | news.ycombinator.com | 15 Aug 2023
    I can highly recommend libtcc (https://github.com/TinyCC/tinycc.git) for this kind of thing. I recently ported the code developed in linux on an ARM chromebook to a generic windows box in 20 minutes.
  • Are there faster alternatives to GCC and Clang for C?
    2 projects | /r/Compilers | 5 Apr 2023
  • Offensive Nim
    8 projects | news.ycombinator.com | 1 Jan 2023
    I think it's a pretty nice prog.lang. You may be very happy. Though nothing is perfect, there is much to recommend it. By now I've written over 150 command-line tools with https://github.com/c-blake/cligen . A few are at https://github.com/c-blake/bu or https://github.com/c-blake/nio (screw 1970s COBOL-esque SQL) or in their own repos.

    If it helps, I like to use the "mob branch" [0] of TinyCC/tcc [1] for really fast builds in debugging mode, but this may only work if you toss `@if tcc: mm:markAndSweep @end` or similar in your nim.cfg. Then I have a little `@if r: ...` so I can say `nim c -d:r foo` for a release build with gcc/whatever.

    [0] https://repo.or.cz/w/tinycc.git

    [1] https://en.wikipedia.org/wiki/Tiny_C_Compiler

  • Bringing a dynamic environment to C: My linker project
    3 projects | news.ycombinator.com | 28 Oct 2022
    I have found the libtcc from https://github.com/TinyCC/tinycc to be absolutely fantastic. I'm using it to instantaneously compile the C output from my hobby language to create a repl. Once I had the compiler in good shape it allowed me to create a 100% compatible interpreter for (basically) free.

    The libtcc API is minimal. For my needs that has been 100% sufficient and a pleasure to work with.

  • tcc on RasPi, func pointers to standard functions are nil
    1 project | /r/C_Programming | 12 Feb 2022
    The latest version that people are working with can be found on the 'mob' branch at https://repo.or.cz/w/tinycc.git
  • Optimizing GoAWK with a bytecode compiler and virtual machine
    4 projects | news.ycombinator.com | 3 Feb 2022
    Instead of interpreters, if one has less of a "must be a full featured prog.lang" mentality and a fast compiler like Go or Nim [1] (or is willing to wait, for slow optimizing compiles to apply against big data sets) then an end-to-end simpler design for "one-liners" (or similarly simple programs) is the whole program generator. Maybe "big IFs", but also maybe not.

    To back up my simplicity claim, consider rp [2] -- like 60 non-comment/import/signature lines of code for the generator. Generated programs are even smaller. But, you can deploy gcc or clang or whatever against them and make fast libraries in the host language.

    Why, if you are willing to write those little generation command options in C99 then you can compile the harness with tcc [3] in about 1 millisecond which is faster than most interpreter start-up times - byte code or otherwise - and can link against gcc -O3 (or whatever) helper libraries.

    Anyway, I only write this because in my experience few people realize how much development cost they buy into when then insist on a full featured prog.lang, not to criticize Ben's work. You also make users need to learn quirks of that new language instead of the quirks of a "harness" which may be fewer.

    [1] https://forum.nim-lang.org/

    [2] https://github.com/c-blake/cligen/blob/master/examples/rp.ni...

    [3] https://repo.or.cz/w/tinycc.git

  • What's the best portfolio project that you have ever seen?
    1 project | /r/cscareerquestions | 14 Dec 2021
  • CHICKEN 5.3.0 has been released
    1 project | /r/scheme | 21 Nov 2021
    I think it is. At least there have been some recent activity in https://repo.or.cz/w/tinycc.git
  • Cwerg - an opinionated, light-weight compiler backend
    3 projects | /r/ProgrammingLanguages | 5 Jul 2021

What are some alternatives?

When comparing c2nim and tinycc you can also consider the following projects:

nimterop - Nimterop is a Nim package that aims to make C/C++ interop seamless

Cwerg - The best C-like language that can be implemented in 10kLOC.

futhark - Automatic wrapping of C headers in Nim

v - Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io

nimLUA - glue code generator to bind Nim and Lua together using Nim's powerful macro

pvsneslib - PVSnesLib : A small, open and free development kit for the Nintendo SNES

cinterop - A C/C++ interop library for the Nim programming language

genny - Generate a shared library and bindings for many languages.

cligen - Nim library to infer/generate command-line-interfaces / option / argument parsing; Docs at

nim-emacs-module

nimforum - Lightweight alternative to Discourse written in Nim