Click here to Skip to main content
15,886,362 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Why am I having such a hard time learning Rust? Pin
Joss45111-Jul-22 5:10
Joss45111-Jul-22 5:10 
GeneralRe: Why am I having such a hard time learning Rust? Pin
dwight1000011-Jul-22 5:19
dwight1000011-Jul-22 5:19 
GeneralRe: Why am I having such a hard time learning Rust? Pin
Dweeberly11-Jul-22 5:55
Dweeberly11-Jul-22 5:55 
GeneralRe: Why am I having such a hard time learning Rust? Pin
honey the codewitch11-Jul-22 6:54
mvahoney the codewitch11-Jul-22 6:54 
GeneralRe: Why am I having such a hard time learning Rust? Pin
Bertrand Mouton11-Jul-22 11:17
Bertrand Mouton11-Jul-22 11:17 
GeneralRe: Why am I having such a hard time learning Rust? Pin
Stuart Dootson12-Jul-22 3:00
professionalStuart Dootson12-Jul-22 3:00 
GeneralRe: Why am I having such a hard time learning Rust? Pin
honey the codewitch12-Jul-22 3:46
mvahoney the codewitch12-Jul-22 3:46 
GeneralRe: Why am I having such a hard time learning Rust? Pin
Stuart Dootson12-Jul-22 4:06
professionalStuart Dootson12-Jul-22 4:06 
It has functional aspects, but it's still very much an imperative language. The way that it melds being an expression language with being an imperative one is that the semicolon separates and sequences expressions, much like the comma does in C.

What can make it useful, though, is cases like those Rust making bindings immutable by default. For example, in C++, I might write
C++
int x;
switch(some_value) {
   case 0: 
      x = 15;
      break;
   case 2: 
      x = 29;
      break;
   default:
      x = some_function(some_value);
      break;
}

I need to declare the variable separately from its initialisation, and then rely on it being mutable to do the initialisation (although I could do it all in one with an immediately invoked lambda expression...).

In Rust, this becomes:
Rust
let x =
   match some_value {
      0 => 15,
      2 => 29,
      v => some_function(v), // Match any other integer value and bind v to it
   };

Rust requires all bindings to be initialised, so for complex cases, getting a value out of something like a match can be very useful.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

JokeRe: Why am I having such a hard time learning Rust? Pin
Chad3F13-Jul-22 15:47
Chad3F13-Jul-22 15:47 
GeneralCCC OTD Pin
Pete O'Hanlon7-Jul-22 21:41
mvePete O'Hanlon7-Jul-22 21:41 
GeneralRe: CCC OTD Pin
pkfox7-Jul-22 22:57
professionalpkfox7-Jul-22 22:57 
GeneralRe: CCC OTD Pin
Pete O'Hanlon7-Jul-22 22:59
mvePete O'Hanlon7-Jul-22 22:59 
GeneralRe: CCC OTD Pin
pkfox7-Jul-22 23:09
professionalpkfox7-Jul-22 23:09 
GeneralRe: CCC OTD - We have a winner Pin
Pete O'Hanlon8-Jul-22 0:32
mvePete O'Hanlon8-Jul-22 0:32 
GeneralRe: CCC OTD - We have a winner Pin
englebart8-Jul-22 2:53
professionalenglebart8-Jul-22 2:53 
GeneralRe: CCC OTD - We have a winner Pin
jmaida8-Jul-22 9:42
jmaida8-Jul-22 9:42 
GeneralRe: CCC OTD - We have a winner Pin
FreedMalloc8-Jul-22 11:51
FreedMalloc8-Jul-22 11:51 
GeneralRe: CCC OTD - We have a winner Pin
englebart9-Jul-22 15:46
professionalenglebart9-Jul-22 15:46 
GeneralSound of the Week Pin
Sander Rossel7-Jul-22 20:48
professionalSander Rossel7-Jul-22 20:48 
GeneralRe: Sound of the Week Pin
musefan7-Jul-22 22:48
musefan7-Jul-22 22:48 
GeneralRe: Sound of the Week Pin
Sander Rossel9-Jul-22 0:05
professionalSander Rossel9-Jul-22 0:05 
GeneralRe: Sound of the Week Pin
yacCarsten7-Jul-22 23:34
yacCarsten7-Jul-22 23:34 
GeneralRe: Sound of the Week Pin
Sander Rossel8-Jul-22 2:04
professionalSander Rossel8-Jul-22 2:04 
GeneralRe: Sound of the Week Pin
David O'Neil8-Jul-22 5:29
professionalDavid O'Neil8-Jul-22 5:29 
GeneralRe: Sound of the Week Pin
Sander Rossel9-Jul-22 0:13
professionalSander Rossel9-Jul-22 0:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.