> nft_ptr has negligible performance overhead compared to std::unique_ptr, as shown by this benchmark on our example program:
std::unique_ptr 0.005 seconds
nft_ptr 3 minutes
That said, I don't really think 3 minutes is that terrible for what it's doing. But man the phrasing there tickled me.
Printing on green paper did not make it white.
Ah.
> written in rust for the hipster cred.
I'm probably a founding member of the Rust Evangelism Strike Force but stuff like this seems ... way overboard. Almost like a Poe's Law demonstration - it's hard to determine whether it's satire or not.
Of course it's written in Rust.
The paranoid part of me worries this will be used for real in the future.
The thing with building abstractions is, once you cover enough pieces to make a complete abstraction, people might run away with it and build castles on top, completely ignoring that the abstraction is implemented in terms of a joke. And once enough software is built on it, it'll be easier to start optimizing the joke to work faster than to get rid of it...
(Also, I don't see any mention what happens to the NFT when the nft_ptr goes out of scope.)
I’m just looking for a “sanity check” example, but I only have a vague notion of pointer being a reference to a spot in memory, as well as knowing that doing transactions on the ETH network incurs fees.
Are there any “power user” examples? Like, how much would it cost to run `ls` on a folder of 200 files, or encoding a video with `ffmpeg` (or insert proper example here since I don’t know where `unique_ptr` is used lol)
This is a very clever joke, so let me dissect it:
The "carcinization" is a callout to, I presume, xkcd 2314 ( https://xkcd.com/2314/ ), about how crustaceans tend to repeatedly evolve into crabs, and xkcd 2418 ( https://xkcd.com/2418/ ), which makes the claim that any conversation with Randall evolves towards the topic of carcinization.
A cutesy nickname for Rust fans is "Rustaceans". (Rust-aceans, like crustaceans.) With some creativity, we may then see the process of becoming an experienced Rust user as another instance of carcinization, especially given the similarity between xkcd's "metacarcinization" and the way that rustaceans, as fans are wont to do, tend to find a way to make the conversation about Rust.
That’s not an xkcd joke though, it’s an actual observation of evolutionary biology, first published in 1916.
> nft_ptr instances are themselves ERC-20 tokens with 0 supply, for forward compatibility with our next library, nft_shared_ptr.
> nft_shared_ptr will implement reference counting with security by selling shares to the owned object until the SEC complains.
The whole repo is a goldmine but this really had me in stitches.
Made my day.
how C++ smart pointers are implemented
how to implement a Non-Fungible Token
how the Ethereum ecosystem has evolved since I wrote my last smart contract in 2017
how to integrate my previous Solidity, Truffle, and Ganache workflow with new tools such as OpenZeppelin and hosted wallets
how to write a (trivial) program in Rust without fighting the borrow checker once
how to use rust-web3, serde_json, and the openssl crates
how to call Rust from C
I often struggle with deciding what to build as a practice project when I want to learn a new skill, and this is a good reminder that “humor” is an acceptable answer. Using a satirical project to learn how smart pointers are implemented is genius.>> What are the gas prices like for copying a pointer?
> Copying an nft_ptr is illegal. Moving an nft_ptr takes 87,169 gas: https://goerli.etherscan.io/tx/0xcbe06fdd54bd9d221993c875022... at mainnet gas prices of ~100 Gwei, equal to 0.0087169 ETH, or $18.69 USD. (This was intentionally written to waste resources for no benefit, just like cryptocurrencies themselves)
> The C++ "as-if" rule means the compiler is allowed to optimize away the move, but it still needs to charge the $18.
This made me chuckle.
From the readme:
> others may view the NFT/use the object, but only the owner can transfer/destroy the NFT/object. > absolutely no protection against just pirating the image represented by the NFT/copying the pointer out of the unique_ptr
I would open an issue to support RFC 8959 and refuse to mint NFTs with secret-token URIs, but I think instead I will learn how to mint an NFT of RFC 8959.
> [...] absolutely no protection against just pirating the image represented by the NFT/copying the pointer out of the unique_ptr
Perfect!
Don't know why but the deadpan humor here really reminds me of reading Bill Bryson.
curiously apt, yet true...