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 · 93 words · Me

Unsafe Strings

What does the below C++ program do? #include <iostream> #include <string> void someFunction(const std::string& name) { const_cast<std::string&>(name) = "test"; } int main() { const std::string name = "immutable"; std::cout << "before someFunction name = '" << name << "'" << std::endl; someFunction(name); std::cout << "after someFunction name = '" << name << "'" << std::endl; return 0; } name is declared in main as a const variable. We pass name as a constant reference to someFunction assuming it cannot be mutated. But in someFunction we can cast to a mutable reference and write to it. ...

April 6, 2025 · 1 min · 136 words · Me