Programming Languages war Golang vs Rust
Tags: go, rust, beginners
Published: 2021-11-20 02:21:29

## Install new fighters

I'm back, first if anyone miss my post I offer my apologizes, but I was without inspiration, but I'm here again with new fighters.


![wwe-the-miz.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918199365/zT0yzqZ02.gif)

Ladies and gentlemen, in this corner first appeared in 2009 with memory safety, garbage collection, structural typing and is loved according to Stack Overflow 2021 by 62.74% Goooooolang

Now the next fighter had the first appeared in 2010 with memory safety without garbage collection, reference counting is optional and is loved according to Stack Overflow 2021 by 86.98% Ruuuuuuuust.

Note: Please read that like WWE or Boxing presentations.

Now we're going with the tech stuff, but remember, I don't know which is better, but I'll try to figure it out. I hope y'all enjoy this series. Obviously We have to start the installation and amazing "Hello, World!". The whole series I'm going to use SO Ubuntu, then if you need support for other SO I'm going to be here to help you.

Pre requirements

  Install curl
  ``` apt install curl ```

![Screenshot_20211113_191136.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918238470/ZGDqJF4t_.png)

## Golang/Go

This is our recipe to install Golang/Go

- Step 1:

  Download golang from the website https://golang.org/doc/install#download I recommend to use curl to download the file
  ```
curl https://dl.google.com/go/go1.17.3.linux-amd64.tar.gz --output go1.17.3.linux-amd64.tar.gz 
```

![Screenshot_20211113_194718.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918278230/FRTl9Ymuh.png)

- Step 2

  Now you have to decompress the file in folder /usr/local
  ``` rm -rf /usr/local/go && tar -C /usr/local -xzf go1.17.3.linux-amd64.tar.gz ```

- Step 3

  Add to the file .bashrc the next line
  ``` export PATH=$PATH:/usr/local/go/bin ```

![Screenshot_20211113_195304.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918319793/dVUuvYZsG.png)

  After that, close the shell or run
  ``` . .bashrc ```

![Screenshot_20211113_195413.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918338070/DAQj-y88b.png)

  If you run that and has an output, all was good
  ``` go version ```

![Screenshot_20211113_195451.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918348180/Joip8mvi1.png)

- Step 4

  Create a folder and join in it
  ```
mkdir hello
cd hello/
```

- Step 5

  You have to enable dependency tracking for your code
  ``` go mod init example/hello ```

![Screenshot_20211113_195840.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918387345/Xw07k3uPd.png)

- Step 6

  You have to create a file, can you guess the name?
  Image tic tac

  hello.go

  ```
  package main

  import "fmt"

  func main() {
      fmt.Println("Hello, World!")
  }
  ```

- Step 7

  It's time to run our program
  ``` go run . ```

![Screenshot_20211113_200155.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918490532/shkmLdU-7.png)

## Rust

This is our recipe to install Rust

Pre requirements
  Install build-essential
  ``` apt install build-essential ```

![Screenshot_20211113_192506.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918544963/gXt47uXSp8.png)

- Step 1

  Download the tools that you need to run the rust language from the website https://www.rust-lang.org/tools/install
  ``` curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ```

![Screenshot_20211113_191305.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918584064/1D5Nmk3Fp.png)

![Screenshot_20211113_191803.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918608149/ScSPj4Xmm.png)

  You only require to choose the first option

  And run that
  ``` source $HOME/.cargo/env ```

![Screenshot_20211113_191847.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918619033/iEADMtQYY.png)

- Step 2

  This tool is called "cargo", this tool creates all structure for you and do other things, but this time only you create the structure
  ``` cargo new hello_world ```

![Screenshot_20211113_191944.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918635297/WwRutkD5k.png)

  By default, "cargo" creates this structure with the file to make our "Hello world!"


![Screenshot_20211113_192115.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918665275/GF5x4GEhk.png)

  ```
  fn main() {
      println!("Hello, world!");
  }
  ```

- Step 3

  It's time to run our program, you can guess how to?
  ``` cargo run ```


![Screenshot_20211113_210545.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918686627/vPSfe6wYb.png)

Resume

Entertainment fight, Golang starts with its better punch, show a simple structure, but Rust responds with fewer steps to run, Golang requires import the package "fmt" to print with "Println" something and Rust needs to use the macro Println, by the way both have the same method ending with "ln" you know why? To add a break line. 

![icegif-607.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1636918799429/Tel-fU5B6.gif)

This is our first view about two amazing languages, how you could see we can use any language in so many environments for the same things, but which is better, today we can see a few conclusions:

- Golang/Go requires more step to run.
- Golang requires import packages to print, and Rust uses macros to the same.
- Rust in addition to the language, install the tool "cargo" can run and create the structure base to Rust.

I hope you enjoy my post and remember that I am just a Dev like you!