Unsafe Strings

What does the below C++ program do? #include <iostream> #include <memory> #include <string> void someFunction( const std::string& name ) { static const std::string* pCachedName = nullptr; if (pCachedName == nullptr) { pCachedName = &name; std::cout << "in someFunction set pCachedName to value: " << *pCachedName << std::endl; } else { std::cout << "in someFunction pCachedName has value: " << *pCachedName << std::endl; } } int main() { std::shared_ptr<std::string> name; name.reset(new std::string("alice")); std::cout << "before someFunction name = '" << *name << "'" << std::endl; someFunction(*name); name.reset(new std::string("bob")); someFunction(*name); std::cout << "after someFunction name = '" << *name << "'" << std::endl; return 0; } name is declared in main as a std::shared_ptr to a string. We pass name as a constant reference to someFunction assuming we do not need to worry about it being mutated or stored. ...

May 16, 2025 · 2 min · Aaron Riekenberg

I Like Go

I like Go. It is definitely not perfect but there is much to like. Let me count some things I like: Simplicity and Correctness Go values simplicity and correctness, both for the language itself and its tooling. Unlike many other languages where choices of build tools, networking, threading models, memory management, and event loops are up to the user, Go takes the opposite route. Go has one simple, high-quality way to do things. ...

May 4, 2025 · 5 min · Aaron Riekenberg

Programming Languages

A well-known quote from Bjarne Stroustrup the creator of C++: There are only two kinds of languages: the ones people complain about and the ones nobody uses. I can definitely understand the sentiment of this having experience with a number of popular and not-so-popular languages in my career from C and C++ to Python, Java, Kotlin, Go, Rust, and even Ada. To try something positive I am going to write about some points I like from my favorite languages, why I like them, and why I might choose to use one over another.

April 10, 2025 · 1 min · Aaron Riekenberg