r/ProgrammerHumor • • 2d ago

Meme howProgrammingHasChanged

Post image
571 Upvotes

102 comments sorted by

View all comments

8

u/Depnids 1d ago

I don't know much about rust, but I am just curious why the last line doesn't have a "return" keyword? Does it just assume the last line is the value to return? Could you include the "return" keyword if you wanted?

3

u/No-Consequence-1863 1d ago

If there is no `;` then the last statement is considered the return value. You can include the return if you want but then you also need the `;` at the end.

2

u/Stunning_Ride_220 1d ago

Darnnnn....'intuitive'

1

u/-Ambriae- 12h ago

It is intuitive, once you realise all statements you can write in functions are expressions, even if they evaluate to the unit type

2

u/Stunning_Ride_220 11h ago

"It is intuitive, once you realise"

That made my day, thank you

1

u/-Ambriae- 9h ago

I don't get your comment

that's how intuition works?

1

u/luziferius1337 8h ago

"intuitive" is often meant to be "you know how it works just by looking at it briefly"

1

u/Stunning_Ride_220 3h ago

Intuition is by definition immediate without reasoning, so no, what you wrote is not how intuition works.

https://en.wikipedia.org/wiki/Intuition (or any english dictionary site)

1

u/-Ambriae- 2h ago

… which it is, if you know ahead of time how the language is structured.

If you mean ‘not intuitive for someone who never wrote a single line of rust before’ then fine. So is literally any programming language concept. FP is not intuitive for someone who only ever done OOP/procedural programming, and vice versa. Rust is structured differently from most other languages, therefore intuition doesn’t necessarily transfer over. Let’s not be pedantic.

But if you coded in rust for more than 10 minutes you’ll realise everything is an expression, which then makes aspects of the language, such as implicit return types, intuitive.

1

u/Stunning_Ride_220 1h ago

Mate, I do not care enough about any language I use (and about various claims about intuitiveness).

I just found the statement per-se quite a bit amusing, so it made my day.