semver-trick
metalang99
semver-trick | metalang99 | |
---|---|---|
15 | 42 | |
414 | 770 | |
- | - | |
2.8 | 3.7 | |
25 days ago | 30 days ago | |
Rust | C | |
Apache License 2.0 | 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.
semver-trick
-
Making Rust supply chain attacks harder with Cackle
Let's say crate B depends on crate A with a pinned dependency, and uses one of its types in a public interface.
Crate C depends on them both. It now can't bring in updates to A until B does, and when B updates that's a breaking change, so it better bump its major version.
Take a look at this teick, for example, for foundational crates updating their major version: https://github.com/dtolnay/semver-trick
Now imagine that being an issue every single patxh update.
-
The module system is too confusing
Rust modules require a tiny bit more definition up-front, but they neatly decouple the module hierarchy from file layout so you can reorganize code however you like in future, and they support very fine grained control of privacy (such as being able to say pub(super) and pub(crate)). In extreme cases, you can even re-export symbols from one module in another without it counting as a breaking change, so you have even more options for evolving your project without breaking existing consumers. Look at the the semver trick as an example of how powerful this can be and how much freedom it gives library implementors. (And even if you're only a library consumer, wouldn't you rather be consuming libraries by implementors that had more freedom and power?)
-
My first year with Rust: The good, the bad, the ugly
A library author concerned about this can use the semver trick. TL;DR: if your current version is 0.42, you can do a 1.0 release, then do a 0.43 release that depends upon your 1.0 release and re-exports all the symbols.
-
Does Rust have any design mistakes?
I mean for all the parts of the standard library that do not change, one could presumably use the semver-trick.
-
Rust is hard, or: The misery of mainstream programming
The semver trick can help with libraries at least when they go to unify the ecosystem. Release new versions that replicate previous APIs in a compatible way while moving to the standard library implementation.
-
Roadmap
Because you still run into the problem that's been seen when various important crates upgraded and either didn't use the semver trick or had downstream crates specifying Cargo.toml version requirements too narrowly for it to be effective.
- The Rust SemVer Trick (2019)
-
This Year in Embedded Rust: 2021 edition
It's called the "semver-trick" [1].
[1]: https://github.com/dtolnay/semver-trick
- The Semver Trick
-
The chip shortage keeps getting worse. Why can't we just make more?
The JVM is 114MiB on my machine. A near-minimal ggez program in debug mode is about 100MiB,¹ and ggez is small for a Rust application library. When you start getting into the 300s of dependencies (i.e. every time I've ever got beyond a trivial desktop application), you're lucky if your release build is less than 100MiB.
Sure, I could probably halve that by forking every dependency so they aren't duplicating versions, but that's a lot of work. (It's a shame Rust doesn't let you do conditional compilation based on dependency versions, or this would be a lot easier. As it is, we have to resort to the Semver trick: https://github.com/dtolnay/semver-trick/ — not that many people do that, so it's functionally useless.)
¹: I can get it down to around 8MiB with release mode, lto etc., but that significantly increases the build time and only about halves the weight of the intermediate build files.
metalang99
-
How to convert an enum to string in C++
There are also other approaches. Macro variants making use of `__VA_ARGS__` would be probably the best trade-off. If you want a slightly more ergonomic syntax, something like Metalang99 [1] will help (and the author even wrote a post about this exact subject [2]). Codegen is another option which may work better than other options depending on the situation and exact implementation strategy. And there is always the Reflection TS [3], which may or may not be incorporated to C++26...
[1] https://github.com/Hirrolot/metalang99
[2] https://hirrolot.github.io/posts/pretty-printable-enumeratio...
[3] https://en.cppreference.com/w/cpp/experimental/reflect
-
Few lesser known tricks, quirks and features of C
I went down the rabbit hole with C99 metaprogramming after reading through the list. For reference: https://metalang99.readthedocs.io/en/latest/, https://github.com/Hirrolot/metalang99
-
Boost:Unordered_flat_map
Honestly I have to disagree. There is nothing particularly special about what Super Template Tetris(STT) is doing.
At its core, template metaprogramming is just functional programming at compile time. STT is just a template and a runtime function which do the following:
1, take an input via compile time flag (the `-D DIRECTION`)
2. take a type input from an included header file containing the current state (`#include "current_game.h"`)
3. via functional programming, compute the results of a single step of the game.
4. specialise a single function using the results of step 3. this function prints the computed result to the screen and the computed game state to a file (`./current_game.h`).
5. gcc/clang exits. compilation is complete.
6. call the compiled binary.
7. the binary runs the specialised function and prints the outputs.
Sure it's fucky and you shouldn't do that in production but what sane individual is writing a piece of code that at runtime (after compiling) seeks out one of its own source files and modifies that file?
To prevent this from being possible you'd have to remove runtime file IO from the language. The other potential solutions wouldn't work:
1. Remove templates entirely: Still would be possible using https://github.com/Hirrolot/metalang99 which solely uses the preprocessor. Given that the pre-processor is literally just term substitution(a glorified copy/paste engine), if you removed that as well, you'd have to accept no form of metaprogramming at all.
2. Remove the ability to #include other files: Could still be done by doing everything inline. `#include` is just copy-paste anyways so it's more an abstraction than anything else to the compiler and preprocessor, it's basically the same as if all the code was pasted into the same file.
That leaves you with removing file IO. Without IO a programming language is basically useless, particularly as a systems programming language.
- What does the ??!??! operator do in C?
- Metalang99: Full-blown preprocessor metaprogramming for C/C++
-
Learning HTML was too hard so I made a compiler instead
P.S. I wrote Metalang99 BTW.
-
How did you choose the name for your programming language?
Metalang99, a metalanguage for C99. Simple :)
-
Rust is hard, or: The misery of mainstream programming
Just wait until you see some other things by the same author, like https://github.com/Hirrolot/metalang99
-
Conditional preprocessor macro, anyone?
I did get a few great responses there as well, though. One was a link to this impressive piece of work: https://github.com/Hirrolot/metalang99/blob/master/examples/lambda_calculus.c
-
What are the minimal changes required to turn C into a functional programming language?
Some preprocessor nonsense: https://github.com/Hirrolot/metalang99/blob/master/examples/lambda_calculus.c
What are some alternatives?
lang-team - Home of the Rust lang team
Windows11DragAndDropToTaskbarFix - "Windows 11 Drag & Drop to the Taskbar (Fix)" fixes the missing "Drag & Drop to the Taskbar" support in Windows 11. It works with the new Windows 11 taskbar and does not require nasty changes like UndockingDisabled or restoration of the classic taskbar.
cargo-llvm-lines - Count lines of LLVM IR per generic function
monkeytype - The most customizable typing website with a minimalistic design and a ton of features. Test yourself in various modes, track your progress and improve your speed.
rust-base64 - base64, in rust
map-macro - A recursive C preprocessor macro which performs an operation on each element of a list
Thruster - A fast, middleware based, web framework written in Rust
porth
rust-quiz - Medium to hard Rust questions with explanations
libexpat - :herb: Fast streaming XML parser written in C99 with >90% test coverage; moved from SourceForge to GitHub
serde - Serialization framework for Rust
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee - eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee