Skip to content
DevMeme
2719 of 7590
Blockchain Post #3004 · source on Telegram

Solving C++ Memory Management with Blockchain-Powered Smart Pointers

Description

A screenshot of a tweet from user David Kanter (@TheKanter). The tweet satirically proposes a solution for C++'s complex memory management by integrating blockchain. The text reads: 'C++ memory management is difficult, opaque, and insecure. Adding blockchain to a problem makes it simple, transparent, and cryptographically secure. Thus, we extend std::unique_ptr, the popular C++ smart pointer used for memory management, with blockchain.' Below the text is a code snippet demonstrating the concept with 'auto ptr1 = make_nft<Cow>();' and 'nft_ptr<Animal> ptr2;', followed by 'ptr2 = std::move(ptr1);'. The image also shows a mock 'Trading History' of an NFT transfer and a GitHub link preview for a repository named 'zhuowei/nft_ptr', described as 'C++ `std::unique_ptr` that represents each object as an NFT on the Ethereum blockchain'. The humor stems from applying a slow, expensive, and distributed technology like blockchain to a problem that requires microsecond-level performance and is confined to a single process. It's a sharp critique of 'solutionism' and the tech industry's tendency to apply hyped technologies like blockchain to entirely inappropriate domains, a frustration well-understood by experienced engineers who value efficiency and practicality

Comments

13
Anonymous ★ Top Pick My new `nft_ptr` costs $60 in gas fees and takes 15 seconds to destruct, but at least my memory leaks are now permanently recorded on an immutable distributed ledger
  1. Anonymous ★ Top Pick

    My new `nft_ptr` costs $60 in gas fees and takes 15 seconds to destruct, but at least my memory leaks are now permanently recorded on an immutable distributed ledger

  2. Anonymous

    Great news: every std::move on our nft_ptr now settles on Ethereum - bad news: freeing 32 bytes costs 50 gwei, so the memory leaks are technically our most valuable assets

  3. Anonymous

    Finally, a solution where your memory leaks cost actual gas fees and your dangling pointers can be front-run by MEV bots - because nothing says 'production-ready' like waiting for blockchain consensus before your destructor runs

  4. Anonymous

    Finally, a solution to C++'s memory management woes: just pay gas fees every time you need to transfer ownership, wait for block confirmation before your destructor runs, and hope the network isn't congested when you need to deallocate. RAII? More like RAII-on-chain. At least when your program crashes, you'll have an immutable, cryptographically-signed record of exactly which memory leak caused it - permanently stored on Ethereum for only $47 per allocation

  5. Anonymous

    nft_ptr: the only smart pointer where std::move is an on-chain transfer, double-free is a 51% attack, and your destructor waits for block finality

  6. Anonymous

    nft_ptr proves that when unique_ptr already ensures single ownership, the only missing feature was paying unpredictable gas to call std::move during your on-call

  7. Anonymous

    Unique_ptrs were unique enough; now they're ERC-721 minted, ensuring no aliasing - unless you lose your private key

  8. @YaroST12 5y

    Am I having a stroke?

    1. Deleted Account 5y

      idk

  9. @nuntikov 5y

    This is a joke

  10. @caesar_84 5y

    Too difficult, request for an explanation team

  11. Deleted Account 5y

    c++ moment

  12. @f3rr0us 5y

    This may be a joke, but it exists and works. I regret to admit I tried it in Rust

Use J and K for navigation