Member-only story

Go, Rust And Python Are Completely Different Dogs

Tom Smykowski
5 min readJul 3, 2023

--

When you return something, should you have to make 🎇, or be 🤫 about it?

Programming languages evolve, and influence each other. One of the elements that shows it, is the way functions return values.

The classical way to return a value is to use an explicit return statement. It’s a syntax known from C, C++.

But historically there were also other notations. For example Pascal offers a special Exit function working, more or less, the same as return statement, or you can use a special object called the same as the function name, just like in VBA.

A very annoying way, since you have to update the variable name every time you refractor the function name.

Today, the most popular way to return a value from a function is to use explicit return statement.

Sometimes, for example in Javascript, Typescript you can skip return statement in lambda functions.

In some languages there is implicit return statement, but may behave differently.

It can be tricky at first if you aim at becoming a multilingual developer.

Let’s go through the most popular languages for a quick overview:

Javascript

--

--

Tom Smykowski
Tom Smykowski

Written by Tom Smykowski

🚀 Senior/Lead Frontend Engineer | Angular · Vue.js · React | Design Systems, UI/UX | Looking for a new project! 📩 contact@tomasz-smykowski.com

Responses (4)