Skip to content
DevMeme
3523 of 7590
Languages Post #3859 · source on Telegram

Fifteen-layer pointer pyramid: how Java devs imagine every C/C++ session

Description

Large black text on white reads "What Java devs think C/C++ devs do". Below, a dark-theme editor tab titled "vim" shows C++ code forming a ridiculous star pyramid: #include <iostream>, int main(){, int p0 = 45;, int * p1 = &p0;, int ** p2 = &p1;, int *** p3 = &p2;, int **** p4 = &p3;, int ***** p5 = &p4;, int ****** p6 = &p5;, int ******* p7 = &p6;, int ******** p8 = &p7;, int ********* p9 = &p8;, int ********** pa = &p9;, int *********** pb = &pa;, int ************ pc = &pb;, int ************* pd = &pc;, int ************** pe = &pd;, int *************** pf = &pe;, std::cout << ***************pf << std::endl;, return 0;, }. Each successive declaration adds another asterisk, culminating in a 15-level pointer that is finally dereferenced for output. The meme satirises the perception that C/C++ developers constantly wrestle with extreme pointer indirection while Java developers enjoy garbage-collected safety

Comments

17
Anonymous ★ Top Pick Fifteen levels of * is scary until you remember your Spring front-end → API gateway → service mesh → twelve microservices → Hibernate → DB call chain has more indirection than that
  1. Anonymous ★ Top Pick

    Fifteen levels of * is scary until you remember your Spring front-end → API gateway → service mesh → twelve microservices → Hibernate → DB call chain has more indirection than that

  2. Anonymous

    This is what happens when you tell a Java developer that C++ doesn't have garbage collection - they assume we're manually tracking 19 levels of indirection for every integer, probably while debugging with gdb and crying into our undefined behavior documentation

  3. Anonymous

    This perfectly captures the Java developer's nightmare vision of C++ - a Kafkaesque descent through fifteen levels of pointer indirection, as if we're manually implementing garbage collection one asterisk at a time. In reality, seasoned C++ engineers know that anything beyond a triple pointer usually means you've either discovered a novel data structure or should seriously reconsider your life choices. Meanwhile, Java devs are blissfully unaware that their JVM is doing pointer arithmetic behind the scenes anyway - they've just outsourced the segfaults to Oracle

  4. Anonymous

    Fewer derefs than our Kubernetes YAML indentation, but twice the crash potential

  5. Anonymous

    Fifteen layers of indirection: the C++ answer to “add another abstraction layer” - cout eventually finds 45; your pager finds you when a single & goes missing

  6. Anonymous

    Java devs think C++ is “count the asterisks until it prints”; veterans know the real work is deleting indirection so the cache stays warm, ownership is RAII-clear, and UB doesn’t wake you at 2 a.m

  7. @Tomato_Bomb_Tom 4y

    What C++ actually do: std::unique_ptr<int> p0 = new int(45);

    1. Deleted Account 4y

      Why would you use new operator with smart pointers?

    2. Deleted Account 4y

      And for this meme it's more like: std::shared_ptr<int> ptr = std::make_shared<int>(45); And sharing it with other shared pointers.

    3. @cringy_frog 4y

      auto p0 = std::make_unique<int>(45);

  8. @glcky 4y

    but they do

  9. @mpolovnev 4y

    I've told my child that if he behaves badly, a c++ developer will reinterpret_cast him!

  10. @azizhakberdiev 4y

    Multi-dimensional arrays are shit

    1. @RiedleroD 4y

      they can be useful

  11. Deleted Account 4y

    It's true tho

  12. @LeaveMyYard 4y

    int p0 = 42; int * p1 = &p0; @@@ std::unique_pointer<int> p0 = new int(42); @@@ std::shared_pointer<int> p0 = make_shared<int>(42); @@@ auto p0 = std::make_unique<int>(42); @@@ C++ in a nutshell

    1. @CcxCZ 4y

      https://bartoszmilewski.com/2013/09/19/edward-chands/

Use J and K for navigation