c2nim
archive-program
c2nim | archive-program | |
---|---|---|
7 | 8 | |
489 | 2,998 | |
-0.2% | 0.0% | |
4.1 | 0.0 | |
6 months ago | about 2 months ago | |
Nim | ||
MIT License | - |
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
-
I learned 7 programming languages so you don't have to
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
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
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
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
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
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
archive-program
- Artic Code Vault
-
In practice, cool URLs can become inaccessible even if they don't change
If you ever end up in the distant future, go to Svalbard and look for the Arctic World Archive. They have microfilm copies of a huge amount of data. They have Wikipedia pages in microfilm format, so all you need is a magnifying glass to get started. You can then look for the Github Code Vault slides that explain how to restart technology from scratch and run the code in the git repository archives.
https://github.com/github/archive-program/blob/master/GUIDE....
https://github.com/github/archive-program/blob/master/TheTec...
https://arcticworldarchive.org/
-
Will historians thousands of years from now have a significantly harder time studying us because we no longer store any information on stone tablets? Like if the Sumerians stored the Epic of Gilgamesh on the latest SSD we would know a lot less.
According to Github:
-
Checked C
> But why not for instance use a build system in some "container"?
I am not sure how this helps.
> I think the project could "bother" contributors with something like that, couldn't it?
Which project?
> An embedded C developer I've talked with quite often on some other forum, who imho is quite competent, said that Coverity is a poor tool that generates way too much false negatives and overlooks at the same time glaring issues.
He likely violated a license agreement with Coverity, since no one is allowed to say anything comparing Coverity to anything else.
> Said that's mostly an issue with all OpenSource tools for static C analysis.
I have been filing bug reports.
> OTOH the commercial ones are very expensive usually, with a target market of critical things like aviation of safety systems in cars and military use, places where they spend billions on projects. Nothing there for the average company, and especially not for (frankly often underfunded) OpenSource projects.
So you understand my pain.
> CodeQL? It's mostly an semantic search and replace tool, as I know? Is it that helpful? (I had a look, but the projects I'm working on don't require it. One would just use the IDE. No need for super large-scale refactorings, across projects, in our case).
I have never heard about this function. It is a static analyzer whose checks are written in the CodeQL language. However, it is very immature. When github acquired it, they banished the less reliable checks to the extended-and-security suite, leaving it only with about ~50 checks for C/C++ code. Those catch very little, although in the rare instances that they do catch things, the catches are somewhat amazing. Unfortunately, at least one of those checks provides technically correct, yet difficult to understand, explanations of the problem, so most developers would dismiss its reports as false positives despite it being correct:
https://github.com/github/codeql/issues/11744
There are probably more issues like that, but I have yet to see and report them.
> SonarCloud, hmm… This one I've used (around web development though). But am not a fan of. It bundles other "scanner" tools, with varying quality and utility. At least what they had for the languages I've actively used it was mostly about "style issues". And when it showed real errors, the IDE would do the same… (The question then is how this could be committed in the first place. But OK, some people just don't care. For them you need additional checks like SonarCloud I guess.)
It is supposed to be able to integrate into github's code scanning feature, so any newly detected issues are reported in the PR that generated them. Anyway, it is something that I am considering. I wanted to use it much sooner, but it required authorization to make changes to github on my behalf, which made me cautious about the manner in which I try it. It is basically at the bottom of my todo list right now.
> Wouldn't it be easy to add at least this to the build by using some "build container"?
I do not understand your question. To use it, we need a few things:
1. To be able to show any newly introduced defect reports in the PR that generated them shortly after it was filed.
2. To be able to scan the kernel modules since right now, it cannot due to a bad interaction between the build system and how compiler interposition is done. As of a few days ago, I have a bunch of hacks locally that enable kernel module scans, but this needs more work.
> Well, that's why I think something equivalent to `-Wall -Werror` should be switched on before writing the first line of code, in any language.
OpenZFS has had that in place for more than a decade. I do not know precisely when it was first used (although I could look if anyone is particularly interested), but my guess is 2008 when ZFSOnLinux started. Perhaps it was done at Sun before then, but both events predate me. I became involved in 2012 and it is amazing to think that I am now considered one of the early OpenZFS contributors.
Interestingly, the earliest commits in the OpenZFS repository referencing static analysis are from 2009 (with the oldest commit being from 2008 when ZFSOnLinux started). Those commits are ports of changes from OpenSolaris based on defect reports made by Coverity. There would be no more commits mentioning static analysis until 2014 when I wrote patches fixing things reported by Clang's static analyzer. Coverity was (re)introduced in 2016.
As far as the current OpenZFS repository is concerned, knowledge of static analysis died with OpenSolaris and we lost an entire form of QA until we rediscovered it during attempts to improve QA years later.
> But I guess I will stay with engraving my data into solid rock. Proven for at least hundred thousand years.
That method is no longer reliable due to acid rain. You would need to bury it in a tomb to protect it from acid rain. That has the pesky problem of the pointers being lost over time.
> At least someone needs to preserve the cat pictures and meme of our current human era for the cockroach people of the distant future. I'm not sure they will have a compatible Linux kernel and compiler available to build the ZFS drivers, or even punch card readers…
Github's code vault found a solution for that:
https://github.com/github/archive-program/blob/master/GUIDE....
I vaguely recall another effort trying to include the needed hardware in time capsules, but I could be misremembering.
-
Maybe a Weird Request.
For long(er) therm you could check out the GitHub Arctic Code Vault.
- LTO Tape data storage for Linux nerds
- Artic Code Vault Guide
What are some alternatives?
nimterop - Nimterop is a Nim package that aims to make C/C++ interop seamless
ltfs - Reference implementation of the LTFS format Spec for stand alone tape drive
futhark - Automatic wrapping of C headers in Nim
noplate - generic data structures
nimLUA - glue code generator to bind Nim and Lua together using Nim's powerful macro
CodeHawk-C - CodeHawk C Analyzer: sound static analysis of memory safety (undefined behavior)
cinterop - A C/C++ interop library for the Nim programming language
ikos - Static analyzer for C/C++ based on the theory of Abstract Interpretation.
genny - Generate a shared library and bindings for many languages.
codeql - CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security
tinycc - Unofficial mirror of mob development branch
wuffs - Wrangling Untrusted File Formats Safely