gboncoffee.dev.br

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit bf07aed5326e16e4d3f76d09ad1e8e1e5bfe6e16
parent 7ef2e35f05e027e76f3a1d254e29303266787d9b
Author: Gabriel G. de Brito <gabrielgbrito@icloud.com>
Date:   Sun, 20 Oct 2024 22:30:47 -0300

Added notes on C++

Diffstat:
Acontent/posts/notes-on-cpp.md | 28++++++++++++++++++++++++++++
Mpublic/categories/index.xml | 10++++++++++
Mpublic/index.xml | 10++++++++++
Mpublic/literature/index.xml | 10++++++++++
Mpublic/posts/index.html | 13+++++++++++++
Mpublic/posts/index.xml | 10++++++++++
Apublic/posts/notes-on-cpp/index.html | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpublic/sitemap.xml | 3+++
Mpublic/tags/index.xml | 10++++++++++
9 files changed, 187 insertions(+), 0 deletions(-)

diff --git a/content/posts/notes-on-cpp.md b/content/posts/notes-on-cpp.md @@ -0,0 +1,28 @@ ++++ +title = 'Notes on C++' +date = 2024-10-20T21:50:44-03:00 +draft = false ++++ + +This is a list of stuff to remember when programming in this hell of a language +called C++. I hate every single second of my life when I'm programming with it. +Unfortunatelly, I'm forced to some times. + +By the way, this is mostly about C++98, except when noticed. The sanest version. +Yes. Even the sanest version. + +I'll update this rather frequently. + +- Never, ever copy a `std::vector`. They create a new instance of the underlying + memory every time you copy them. Always keep only a single instance and pass + pointers to it. Yes, this means you have to dynamically allocate them when + they're shared with lower stack frames. +- Always reserve space in `std::vector`. Never, ever create one without + reserving sane space first. They usually grow in dumb always, for example + starting at 0 capacity and growing by 50% at each increment, when the sane way + would be starting at about 8 and grow by doubling. +- Never use `std::endl`. They force a flush onto the underlying stream. A + newline will flush a life-buffered output stream anyways, and you definitely + don't want to force flush a file output. +- Avoid `static` duration objects as their initialization and termination + processes happens at a not well-defined time. diff --git a/public/categories/index.xml b/public/categories/index.xml @@ -24,6 +24,16 @@ <item> + <title>Notes on C&#43;&#43;</title> + <link>http://gboncoffee.dev.br/posts/notes-on-cpp/</link> + <pubDate>Sun, 20 Oct 2024 21:50:44 -0300</pubDate> + + <guid>http://gboncoffee.dev.br/posts/notes-on-cpp/</guid> + <description><!-- raw HTML omitted --> +</description> + </item> + + <item> <title>Soneto Sobre Sonetos</title> <link>http://gboncoffee.dev.br/literature/soneto-sobre-sonetos/</link> <pubDate>Thu, 17 Oct 2024 00:52:25 -0300</pubDate> diff --git a/public/index.xml b/public/index.xml @@ -26,6 +26,16 @@ <item> + <title>Notes on C&#43;&#43;</title> + <link>http://gboncoffee.dev.br/posts/notes-on-cpp/</link> + <pubDate>Sun, 20 Oct 2024 21:50:44 -0300</pubDate> + + <guid>http://gboncoffee.dev.br/posts/notes-on-cpp/</guid> + <description><!-- raw HTML omitted --> +</description> + </item> + + <item> <title>Soneto Sobre Sonetos</title> <link>http://gboncoffee.dev.br/literature/soneto-sobre-sonetos/</link> <pubDate>Thu, 17 Oct 2024 00:52:25 -0300</pubDate> diff --git a/public/literature/index.xml b/public/literature/index.xml @@ -26,6 +26,16 @@ <item> + <title>Notes on C&#43;&#43;</title> + <link>http://gboncoffee.dev.br/posts/notes-on-cpp/</link> + <pubDate>Sun, 20 Oct 2024 21:50:44 -0300</pubDate> + + <guid>http://gboncoffee.dev.br/posts/notes-on-cpp/</guid> + <description><!-- raw HTML omitted --> +</description> + </item> + + <item> <title>Soneto Sobre Sonetos</title> <link>http://gboncoffee.dev.br/literature/soneto-sobre-sonetos/</link> <pubDate>Thu, 17 Oct 2024 00:52:25 -0300</pubDate> diff --git a/public/posts/index.html b/public/posts/index.html @@ -52,6 +52,19 @@ <h1 class="page-title">My articles, blogposts, etc... everything that&#39;s not in literature/</h1> <article class="blog-post-summary"> + <h3 class="blog-post-title"><a href="http://gboncoffee.dev.br/posts/notes-on-cpp/">Notes on C&#43;&#43;</a></h3> + + <p class="blog-post-info">Posted: <time>2024-10-20</time> + + + +</p> + <p><p>This is a list of stuff to remember when programming in this hell of a language +called C++. I hate every single second of my life when I&rsquo;m programming with it. +Unfortunatelly, I&rsquo;m forced to some times.</p><span> <a href="http://gboncoffee.dev.br/posts/notes-on-cpp/">Read more...</a></span> + </p> +</article> +<article class="blog-post-summary"> <h3 class="blog-post-title"><a href="http://gboncoffee.dev.br/posts/i-would-love-to-fall-in-love-with-haskell-but/">I Would Love to Fall in Love With Haskell BUT</a></h3> <p class="blog-post-info">Posted: <time>2024-09-28</time> diff --git a/public/posts/index.xml b/public/posts/index.xml @@ -26,6 +26,16 @@ <item> + <title>Notes on C&#43;&#43;</title> + <link>http://gboncoffee.dev.br/posts/notes-on-cpp/</link> + <pubDate>Sun, 20 Oct 2024 21:50:44 -0300</pubDate> + + <guid>http://gboncoffee.dev.br/posts/notes-on-cpp/</guid> + <description><!-- raw HTML omitted --> +</description> + </item> + + <item> <title>Soneto Sobre Sonetos</title> <link>http://gboncoffee.dev.br/literature/soneto-sobre-sonetos/</link> <pubDate>Thu, 17 Oct 2024 00:52:25 -0300</pubDate> diff --git a/public/posts/notes-on-cpp/index.html b/public/posts/notes-on-cpp/index.html @@ -0,0 +1,93 @@ +<!DOCTYPE html> +<html> +<head> + <title>Gabriel G. de Brito - Notes on C&#43;&#43; </title> + <link rel="stylesheet" type="text/css" href="/css/fonts.css"> + <link rel="stylesheet" type="text/css" href="/css/fontawesome.css"> + + + <link rel="stylesheet" type="text/css" href="/css/styles.min.d1b3428734153d8c3b5e2f3598da20a6372f630ae87c763594b98c554c580343.css"> + + + <link rel="icon" href="/profile.png"> + + <meta charset="UTF-8"> + <meta name="author" content="Gabriel G. de Brito"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + </head> +<body> +<header class="page-header"> + <div class="myname"> + <h2><a href="http://gboncoffee.dev.br/">Gabriel G. de Brito</a></h2> + </div> + <nav> + <ul class="navbar"> + <li class=""> + <a href="/"> + <span>Me</span> + </a> + </li> + <li class=""> + <a href="/projects/"> + <span>Projects</span> + </a> + </li> + <li class=""> + <a href="/posts/"> + <span>Posts</span> + </a> + </li> + <li class=""> + <a href="/literature/"> + <span>Literature</span> + </a> + </li> + </ul> + </nav> +</header> +<div id="content"> + <main> + <article> + + <h1 class="page-title blog">Notes on C&#43;&#43;</h1> + + <p class="blog-post-info">Posted: <time>2024-10-20</time> + + + +</p> + + <div class="blog-post-content"> + <p>This is a list of stuff to remember when programming in this hell of a language +called C++. I hate every single second of my life when I&rsquo;m programming with it. +Unfortunatelly, I&rsquo;m forced to some times.</p> +<p>By the way, this is mostly about C++98, except when noticed. The sanest version. +Yes. Even the sanest version.</p> +<p>I&rsquo;ll update this rather frequently.</p> +<ul> +<li>Never, ever copy a <code>std::vector</code>. They create a new instance of the underlying +memory every time you copy them. Always keep only a single instance and pass +pointers to it. Yes, this means you have to dynamically allocate them when +they&rsquo;re shared with lower stack frames.</li> +<li>Always reserve space in <code>std::vector</code>. Never, ever create one without +reserving sane space first. They usually grow in dumb always, for example +starting at 0 capacity and growing by 50% at each increment, when the sane way +would be starting at about 8 and grow by doubling.</li> +<li>Never use <code>std::endl</code>. They force a flush onto the underlying stream. A +newline will flush a life-buffered output stream anyways, and you definitely +don&rsquo;t want to force flush a file output.</li> +<li>Avoid <code>static</code> duration objects as their initialization and termination +processes happens at a not well-defined time.</li> +</ul> + + </div> + + + </article> + </main> + + </div><footer> + <span>© Gabriel G. de Brito (CC-BY-NC)</span> +</footer> +</body> +</html> diff --git a/public/sitemap.xml b/public/sitemap.xml @@ -2,6 +2,9 @@ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <url> + <loc>http://gboncoffee.dev.br/posts/notes-on-cpp/</loc> + <lastmod>2024-10-20T21:50:44-03:00</lastmod> + </url><url> <loc>http://gboncoffee.dev.br/literature/soneto-sobre-sonetos/</loc> <lastmod>2024-10-17T00:52:25-03:00</lastmod> </url><url> diff --git a/public/tags/index.xml b/public/tags/index.xml @@ -24,6 +24,16 @@ <item> + <title>Notes on C&#43;&#43;</title> + <link>http://gboncoffee.dev.br/posts/notes-on-cpp/</link> + <pubDate>Sun, 20 Oct 2024 21:50:44 -0300</pubDate> + + <guid>http://gboncoffee.dev.br/posts/notes-on-cpp/</guid> + <description><!-- raw HTML omitted --> +</description> + </item> + + <item> <title>Soneto Sobre Sonetos</title> <link>http://gboncoffee.dev.br/literature/soneto-sobre-sonetos/</link> <pubDate>Thu, 17 Oct 2024 00:52:25 -0300</pubDate>