Header-Image_2083x875-9

Should You Only Learn Memory-Safe Languages Now?

03/01/2024
4 minutes

The White House is urging programmers to move away from older programming languages like C and C++ in favor of “memory-safe” languages like Rust. There’s evidence that building software with memory-safe languages can significantly reduce vulnerabilities and prevent cyberattacks, according to a report issued Monday.  

As aspiring programmers and code enthusiasts, you’re probably wondering what this federal guidance means for you. Are memory-safe languages our only option for building software and apps? Is it time to stop learning C and C++ and pivot to something else?

When you’re choosing a programming language to learn or use, you have to consider what you want to create and how easy the language is to understand. Other factors, like the frameworks used in a project or the legacy codebase, also matter. Although security and safety may not be your first concern, it’s crucial, as highlighted in the White House report.

Ahead, we’ll break down the news, explain the difference between memory-safe languages and unsafe ones, and share free courses you can take to start learning memory-safe languages today.

Learn something new for free

What does “memory safe” mean?

Memory safety is a feature found in certain programming languages that prevents programmers from introducing a type of bug that messes with how computer memory is accessed and stored.

Nobody likes bugs, but memory-safety bugs are a big problem in computing because they affect how computer memory is written, allocated, or deallocated. This can lead to crashes and open the door to cyber-attacks. Studies from Microsoft and Google shows that up to 70% of security vulnerabilities are caused by memory safety issues.

Memory safety errors can cause vulnerabilities. Two common types are: “out of bounds read,” which happens when a program attempts to access or modify data outside of its allocated memory; and a “use after free” bug, which occurs when a program tries to access a memory location that’s already been freed.

Which programming languages are considered memory safe?

Memory-safe languages are designed to automatically catch this type of error at compile time. Here are some examples of memory-safe programming languages — with links to courses if you want to start learning them today:

Each of these languages approach memory safety through different features. As for languages that are memory unsafe, the White House report calls out C and C++ as languages that lack built-in memory safe assurances. If you’re curious how you can manage memory allocation manually with these languages, check out our in-depth tutorial.  

What are memory-safe languages used for?

Memory-safe languages can be used to create all sorts of apps. If you know Swift, for example, you can develop software for Apple devices that run iOS and macOS. C# is a popular language developed by Microsoft that you can use to build web apps and games. Python is a fan favorite because it’s versatile and can be used for data analytics, machine learning, web development, and more. Rust was named the top desired programming language in the Stack Overflow 2023 Developer Survey and is beloved in blockchain, VR, and game development.  

“If I was starting a project from scratch and it didn’t have major interdependencies on other frameworks or libraries, I would have a hard time finding a reason of going out of the Rust-Go-Python spectrum,” explains Judah Anthony, Senior Director of Software Engineering at Codecademy. “If I found myself reaching for C/C++ and/or Assembly, I probably have a very specific reason why.”

Should I still learn C and C++?

This directive isn’t necessarily a reason to give up on learning C and C++. There are specific times and places when you might want to use these languages. You might work in an industry where all the legacy code is written in these languages. For example, C++ is used heavily in gaming, because it can optimize resources to accommodate graphics and multiple players.

Not to mention, there are plenty of reasons to learn programming languages beyond just being able to use them in production. Learning how each language frames a problem can help you understand programming concepts better.

TL;DR

Every programming language has strengths and weaknesses: “What you should learn needs to be connected to when you should learn it,” Judah says. The right choice for you completely depends on what it is you’d like to do and where you are in your coding journey. As new research and technology emerge, the methods and languages we use to code will keep evolving — this is just the latest development to consider.

Learn memory-safe languages for free

Take the first step towards safer coding practices by mastering memory-safe languages. If you’re familiar with programming basics in other languages, we recommend starting with the free course Rust for Programmers. Or if you’re starting from zero, we have beginner friendly free courses Learn Swift, Learn Kotlin, Learn Java, and Learn Go. With our interactive lessons, you’ll dive into practical projects, gain hands-on experience, and build a solid foundation in memory-safe programming that’ll empower you to develop robust and secure software applications.

Related courses

8 courses

Related articles

7 articles
Header-Image_2083x875-14.png?w=1024

What Is Splunk? 

03/04/2024
5 minutes
By Codecademy Team

Learn how Splunk makes big data analytics easier by helping organizations monitor their data and derive insights through machine learning.

Featured-Thumbnails_1200x558-1-1.png?w=1024

Should I Learn Swift?

09/28/2021
By Adam Carpenter

Discover the benefits of learning Swift and the kinds of applications it’s used for. Codecademy’s courses can prepare you for a career in Swift development.