teleren/devto huggingface dataset:
Book Review: The Rust programming language
Tags: bookreview, rust, systemsprogramming
Published: 2020-09-20 11:46:41

---
title: Book Review: The Rust programming language
published: true
date: 2020-09-20 00:00:00 UTC
tags: BookReview,Rust,SystemsProgramming
canonical_url: https://hceris.com/book-review-the-rust-programming-language/
---

[![The Rust programming language](https://hceris.com/static/7f931d84318ba16de8617590fbf563e5/a5608/cover.jpg "The Rust programming language")](/static/7f931d84318ba16de8617590fbf563e5/a5608/cover.jpg)

_Rust_ is not a new language by any means, but it’s getting plenty of [attention](https://www.thoughtworks.com/de/radar/languages-and-frameworks/rust) [lately](https://thenewstack.io/microsoft-rust-is-the-industrys-best-chance-at-safe-systems-programming/). As you might’ve heard, it’s a relatively low-level systems programming language. Similar to [golang](https://golang.org/) in a sense, with a completely different approach to memory management.

Apart from the classical use cases, I really like using _Rust_ to make fast, super-portable CLI tools that are easy to package in a container. A compiled binary is a lot easier to handle than something like a _Python_-based tool with a ton of dependencies.

For a systems programming language, _Rust_ is surprisingly rich in features. Pattern matching, `Option`, and `Result` types, who knew? This power comes at the cost of complexity. _Rust_ is definitely **not** a simple language, which is why this book clocks at 500 pages. The borrow checker is very different from anything you’ve seen before, and you’ll have to re-read that chapter over and over until you start making sense of the concept. Lifetimes are pretty tricky as well. By the time things like multi-threading came around, I was pretty overwhelmed.

Luckily, this book is an excellent reference to navigate all these ideas. And it covers the ecosystem as well, which is a nice plus. You’ll learn about [cargo](https://crates.io/), its build system, and package manager. Testing makes an appearance, which is great news for all the TDD lovers.

All in all, if you want to get started understanding _Rust_, this book is an excellent starting point. It won’t be the last one you read if you’re going to get a deeper understanding of the whole thing.

## Verdict

This is a comprehensive book, not only introducing the language but the ecosystem as well. The only thing I missed was going a bit more into the community’s best practices and established conventions. Although to be fair, it’s already a pretty long book as it’s. It gets ⭐⭐⭐⭐ stars from me.
Getting started with React Native (Windows)
Published: 2020-09-19 23:49:07

This week I started working on my first React Native project, and I found the set up to be very simple. Here's how I got my project set up on Windows. 

**Node JS**

First you need to have node installed in order to run npm commands. that you'll need to download your environment files. It needs to be the LTS version and higher than 12. You can download this at the Node website. 

https://nodejs.org/en/download/

**Expo**

After getting Node installed you'll need to run an npm command to download the Expo dependency. You can do this by running 

```npm install -g expo-cli```

This will install the Expo dependency globally allowing you to now run expo commands in your terminal.

**Create a new project**

After downloading expo you should be able to run this command to create a new expo project

```expo init ProjectName```

After running this command, there is a potential error you could get which says that expo isn't recognized as an environment variable. 

To fix this you have to set your path system variables and add this route `%USERPROFILE%\AppData\Roaming\npm`.

This tutorial has instructions on how to do that [here](https://www.java.com/en/download/help/path.xml) for different windows versions.

**Running your project**

When you run `npm start` you should get something like this in your terminal. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/af9ie1un4raqm6ql63l0.PNG)

You can now access the developer tools page which allows you to run react native through a number of different mediums. Here are the options they give you.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lcud3kxcin7260fwkuxs.PNG)

If you want to test your code through the client, just select the client option and you should get a pop up browser.

If you want to test your code you'll need to download the Expo app on your Android or iOS device, and use your camera to scan the QR code provided on the bottom right. You can switch the type of connection, and for my own case, the only one that worked for me was tunnel. After scanning the code your phone should give you a push notification to open your project in the Expo app.

Welcome to React Native!
sobre mim.
Tags: beginners, studies
Published: 2020-09-19 22:32:03

Meu nome é Patrick, tenho 18 anos, ainda curso o terceiro ano do ensino médio.
 Comecei a me interessar por programação há pouco tempo, por influência do meu tio que já atua na área há muito tempo.
  Tenho feito um curso de python e um bootcamp online na IGTI. Esse blog é para compartilhar meus estudos e desenvolvimento com vocês.
The Pomodoro Technique - Why, What, How - Productivity, Worksheet, Timer, Music
Tags: productivity, timemanagement
Published: 2020-09-19 21:42:50

Are You a Procrastinator? IS time is your enemy? Do you always get short of time? Do you race against time to meet deadlines? The Pomodoro Technique to transform your lives.

- You know you are wasting time, and feel disappointed, because you have lost your day by scrolling social media feeds, emails, YouTube.
- You have no idea where the time has gone and you have nothing to showcase your work.
- You are a procrastinator.
- You did a lot of work and felt accomplished but you didn't complete exactly what is required from that day.
- You are working but not able to give 100%.

To solve the problems mentioned above, The Pomodoro technique was born and used by **Successful People** like Steven Sande, Natalie Sisson, Hayden Miyamoto, Tim Ferriss and many more.

Firstly, Find and list down tasks to be done. The following steps given below.

- Choose a task from the list.
- Focus for the next 25 mins. Work closely with little or zero distractions and no pause. Pomodoro teaches to manage distractions. List down if any distractions identified in this step.
- Take a 5 min break. Once 25 minutes ended, relax, clear your mind and come back after 5 mins.

- To continue reading, head over to [Box Piper](https://www.boxpiper.com/posts/the-pomodoro-technique-why-what-how-productivity-worksheet/) source.

To read more such interesting topics, follow and read <a href="https://boxpiper.com/">BoxPiper blog</a>.

Support my work and [buy me a Coffee](https://ko-fi.com/E1E72C2MM). It'll mean the world to me. 😇

<a href="https://ko-fi.com/E1E72C2MM"><img src="https://cdn.ko-fi.com/cdn/kofi1.png?v=2"/></a>
How do you prefer to learn? Videos, Books, both?
Tags: career, discuss, productivity
Published: 2020-09-19 21:19:02

Imagine there is a framework/language you want to learn and you have heard about a good book that explains very well the concepts/details. Also, there is a good YouTube/Udemy course that your colleges have recommended and you can take it in a couple of hours. Which is your first choice?
 
I believe everyone learns in different ways. I consider myself as a hands-on leaner, I prefer watching videos than reading a book because quite often go straight to the point and you can follow easily.

However, through the years, I have found out that (in my opinion) YouTube videos is a good start, because nowadays everybody can upload a video about programming concepts or frameworks. Also, I have noticed bad coding practices or design patterns on videos that I wouldn't definitely do in my projects, maybe it's because they want to teach an specific concept and forget about best practices or write clean code. I think this is harmful for new programmers.

On the other hand, books are to formal; Preface, Introduction, concept definitions and so on. However books explain with details about concepts and techniques, you can have a big picture about what you are learning and frequently they follow good programming practices, because they are written by professionals (PhDs, professors, researchers, experienced programmers).

So, my opinion is that YouTube videos is a good start, you can learn while doing and even ask if you got questions, but you shouldn't consider this as a *I'm done*, you know only the basics about something. If you really want to learn in depth about something I'd recommend reading a book, there are a lot great books about everything.

What do you think about this? What about Hackathons? College? In person courses? Let's talk about in the comments.
Why do some popular websites have cryptic page sources
Tags: css, webdev, html, discuss
Published: 2020-09-19 20:10:59

I recently decided to inspect the page sources of some popular sites to check out the CSS used on the avatars. I noticed two things in particular:
* The class names used are just cryptic. They just have random letters e.g. `s-v7te9w`.
* They use so many divs and other tags to achieve a desired effect (like avatars).

In contrast, Dev.to does not have cryptic class names (e.g `crayons-avatar__image`), and also does not use many tags to achieve its own avatar(for instance) styling.

These are my questions:
* Why are the class names so cryptic? Is it because of a framework? Are they dynamically generated?
* Why are there so many divs(and other tags) just to do one task? Aren't they unnecessary?

Thanks a lot 😁
Day 6 - Animating a Splash Page: Wine App Part III
Tags: codenewbie
Published: 2020-09-19 19:56:27

Today I made a quick animated splash page for the wine application I am slowly building. You can see the progress of the bigger application in the [repo](https://github.com/josno/youwillbewine).

![screenshot](https://media.giphy.com/media/zMH4lHOj15ClrWIW1L/giphy.gif)

## What I Learned

Timing is everything!

## How This Will Help Me

The idea of this application is to continue building on my frontend skills. I already knew the interaction and timing between elements is important. However from my experience as a person who goes on the internet, less animation is better. After some reading, I quickly got curious about how interactive (UI) animations are different from splash animations encompassing aspects of interaction design. I want to dig further into it and found the [Interactive Design Foundation](https://www.interaction-design.org
) and have decided to start one of their free courses.

Onto the next challenge
DNS
Tags: feynman, webdev, dns
Published: 2020-09-19 19:45:51

# DNS

DNS stands for "Domain Name System". It's the phonebook for the internet.

Imagine you want to call your friend. If you memorized their phone number, you can dial it to reach them.

![](https://dev-to-uploads.s3.amazonaws.com/i/jm7hkf1wfn1yn94dozcx.png)

But if you have a lot of friends, it can be difficult to memorize everyone's phone number.

![](https://dev-to-uploads.s3.amazonaws.com/i/hit7cvrt1fcld1ncpnv9.png)

A phonebook lets you get the phone number for your friend; all you need to know is their name. Memorizing a name is a lot easier than memorizing a phone number.

DNS is similar. You want to visit a website served by a server. If you memorized the server's IP address, you can reach them directly.

![](https://dev-to-uploads.s3.amazonaws.com/i/8q51s0jrffw4kr1meomw.png)

> Try this out yourself.
> Mac users can run `nslookup www.google.com`. You should get an IP address in your result. Copy and paste that IP address into your browser. That should bring you to `www.google.com`.
> ![](https://dev-to-uploads.s3.amazonaws.com/i/7qj2q6c651q3r6uhmgqe.png)

DNS lets you get the IP address for the server; all you need to know is their domain name.

When you enter a domain name into your browser, it looks up the IP address.

First, it checks if it already knows it. Someone else might have looked up the address before.

![](https://dev-to-uploads.s3.amazonaws.com/i/3q6wcb2zcjs8qbgk6197.png)

Then, your browser makes requests to DNS name servers. Name servers store DNS records for a domain. They receive queries for names, and return IP addresses.

![](https://dev-to-uploads.s3.amazonaws.com/i/h8xvx2riebzv2rmjpq4b.png)

Name servers are organized into a domain hierarchy. Each domain has its own name server.

![](https://dev-to-uploads.s3.amazonaws.com/i/qbbtbekyll264cxwzlpv.png)

For example, let's imagine you're visiting `www.wikipedia.org`. We ask the `root` name server. This is the top of the hierarchy and knows about all domains.

The `root` name server might not have the DNS record for `www.wikipedia.org`, but redirects you to the `.org` name server. We ask the `.org` name server. It might have the DNS record for it, or it might direct you to another name server that has it. Eventually, you'll get back the IP address for `www.wikipedia.org`.

![](https://dev-to-uploads.s3.amazonaws.com/i/bvdodhwmpxsj6khlyzhw.png)

There are name servers all around the world. If you were in Japan, you could get a different IP address for `www.google.com` than someone in San Francisco. This allows you to access servers that are physically closer to you, so you can have a faster experience.
Crypto Prices in Discord - Bot
Tags: tutorial, javascript, discord, bot
Published: 2020-09-19 19:44:35

# Crypto Prices in Discord - Bot
Sorry for the long delay, but this is the second and last part of my series of bringing cryptocurrency prices into Discord. This tutorial will use a Discord bot.

## Setting up
To create our bot template, we are going to use a cool project called [create-discord-bot](https://github.com/peterthehan/create-discord-bot).

Run `npx peterthehan/create-discord-bot` in the bash if you are on a Unix based system and in the Git bash if you are on Windows. Fill out the questions that it prompts you and you have a Discord bot ready to be used.

We will also be using the CoinGecko API to get prices for cryptocurrency, so run `npm install --save coingecko-api`.

## How the current bot works
Our bot currently runs on a widget based framework. Any folder located under the folder `widgets` is considered a widget and every widget must contain a folder `handlers` with `.js` files with names of `discord.js` events. There is one widget `command` which comes with it, and has it's own system of commands. You can insert any command into it's `commands` folder and use a `CommandBuilder` class to create commands.

## Programming the bot
First, you should run `npm run dev` to start `nodemon` so you don't need to keep on restarting the bot.

Create a new file in the `command/commands` folder called `coinPrice.js`. Put this inside of it:
```javascript
const CommandBuilder = require("../classes/CommandBuilder");

const CoinGecko = require("coingecko-api");

const CoinGeckoClient = new CoinGecko();

module.exports = new CommandBuilder()
  .setName("coinprice")
  .setAliases(["coin", "price"])
  .setOwnersOnly(false)
  .setGuildOnly(false)
  .setRequireArgs(true)
  .setDeletable(false)
  .setCooldown(10)
  .setDisabled(false)
  // eslint-disable-next-line
  .setExecute(async (message, user, args) => {
    let data = await CoinGeckoClient.simple.price({
      ids: [args[0]],
      vs_currencies: [args[1]],
    });
    await message.channel.send(
      `${args[2] || 1} ${args[0]} -> ${
        data.data[args[0]][args[1]] * (args[2] || 1)
      } ${args[1]}`
    );
  });

```
This basically allows you to run the command `coin` with this format: `.coin <coinToCheck> <currencyToCompareAgainst> [optionalAmountForCoinToCheck]`

## Finishing Thoughts
Try adding more commands such as comparison of margin and other things you could do.

**WARNING** The [create-discord-bot project](https://github.com/peterthehan/create-discord-bot) is currently going through some major changes migrating the codebase to Typescript in a way that you still won't have to change your project. You may still need to change your project for that though.

[Source code on Github](https://github.com/shadowtime2000/cryptobot)
How to add auto-reload to your Node JS app?
Tags: node, javascript
Published: 2020-09-19 19:29:12

This is one of the first things I searched for, when I started learning Node JS with Express, since it was becoming too hard of a job to keep stopping and re-running the server, again and again. This is why, I use an npm package called [**nodemon**](https://www.npmjs.com/package/nodemon)

## Setting up a node server
I hope you have NodeJS installed in your machine.
- Let's setup the directory
```sh
mkdir nodemon_tutorial && cd nodemon_tutorial
```

```sh
npm init -y
```
>This would create a package.json
- Now, let's install express to start a server
```sh
npm install express
```

- Now, let's create a file named index.js
```sh
touch index.js
```

- Open the folder in your favourite Code Editor. I use VS Code, so I will run:
```sh
code .
```

- Now inside index.js add the following
```js
const express = require('express');
const app = express();
const port = process.env.PORT || 3000

app.get('/', (req, res) => {
   res.send("Hello World!");
})

app.listen(port, () => {
   console.log(`App is running at port: ${port}`);
})
```
### Explanation of code
- *Line 1:* In line 1, we are just importing the express package for running the server
- *Line 2:* We are making an app, by instantiating the express module
- *Line 3:* We are creating a variable for the port. It will search for an environment variable with name `PORT`. If it does not find any, by default, it assigns it to `3000`.
- *Line 5-7:* Here, we are just creating a route. So, if a person, sends a `get` request to `/`, then he will get `Hello World` as response
- *Line 9-11:* We are just making the app run and listen on port variable
Now, you could run this app, by simply saying
```sh
node index.js
```

This will give the output
```sh
App is running at port: 3000
```
- Now just go to your browser and type: `localhost:3000/`

## Disadvantage of this
- Now go to index.js and change `"Hello World!"` to `"Hello, this is my first nodemon app!"`
- Now, even if you go to the browser and refresh, it will remain the same

## Settings up nodemon to run the server
- To install **nodemon** run:
```sh
npm install nodemon --save-dev
```
- We are adding `--save-dev` because we want this only in development and not while publishing it.

- Now, go to `package.json` file and remove the following line:

```js
"test": "echo \"Error: no test specified\" && exit 1"
```
**And add the following line**

```js
"start":"nodemon index.js"
```

- So, what we are doing is that we are making nodemon run the server instead of node.
- Now, terminate the server which was running and run:
```sh
npm start
```

- Now, go to localhost:3000
- Try changing the response while getting / in the index.js and after you save it, the browser should auto-reload to show you the new response
JIT vs AOT in layman's terms
Tags: webdev, angular, typescript, javascript
Published: 2020-09-19 19:29:00

I am more Java guy and quite new to web development. I had to go through a bundle of articles to understand what's JIT & AOT mean for web development. Without using fiery Jargons, I will share my understanding in more layman's terms.

Before comparing JIT & AOT compilers, lets start with basics of what it takes to bring up a webpage in browsers.

###**Javascript Engine**
Every browser has a embedded JavaScript engine. This engine reads (“parses”) the javascript, converts (“compiles”) the script to the machine language.And then the machine code runs, pretty fast.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kzv1mqafgqliuzoh32g3.png)

####*so what???*
From this we can infer that if the input **Javascript source code is efficient**, the interpretation/compilation will have less task and webpage shows up faster!!. I am going to compare JIT & AOT compilers based on this factor. I will be using Angular  framework and this can be inferred for other JS frameworks as well.

Angular offers two ways to compile your application:

Just-in-Time (JIT), which compiles your app in the browser at runtime. This was the default until Angular 8.
Ahead-of-Time (AOT), which compiles your app and libraries at build time. This is the default since Angular 9.

###**JIT (Just In Time) Compiler**
Here is what happens before the JS code is renderred  to browser.
1. Develop Angular app using Typescript+HTML+CSS
2. Execute **ng build**. 
This will compile Typescript to Javascript bundles (inline.bundle.js, vendor.bundle.js, main.bundle.js, polyfills.bundle.js, scripts.build.js) and places them in Dist folder, which is to be deployed later.

The **vendor.bundle.js** will be **HUGE** in size. This file contains any libraries imported into your app (app.module), including the Angular libraries.

So the Angular build has angular libraries(compiler) which are needed to compile Angular in browser at runtime. 

Since the rendered Javascript source code is less efficient, this adds an overhead to browser JS engine causing delay in spinning up webpage.

###**AOT(Ahead Of Time) Compiler**
Here the step 1 remains same.
At Step 2 , execute **ng build --prod**
This will generate same set of JS bundles, but the size of vendor.bundle.js reduces significantly. 

AoT runs the compile step during the build process instead of inside the browser, so when you build your project for production, the compiler (angular) disappear completely from the output.

The build will have efficient javascript source code, which doesn't require Angular libraries for further compilation. Hence the interpretation/compilation in browser will have less task and webpage shows up faster!!.
Blog Posting Platform
Tags: writing, discuss
Published: 2020-09-19 19:24:43

I was debating between two platforms that essentially do the same thing which is take Markdown -> shiny.

## Docusaurus

The first one I've used heavily for documentation purposes but rarely for blogging. It's a project from facebook called [Docusaurus](https://v2.docusaurus.io/) (Linking their beta version because its just so much prettier ).

I feel like it's more geared at writing docs than blogging, but here's the pluses.  

- Write once in MD and get pretty output.
- Easy to deploy to github.io and other hosting sites.
- I supports jsx so you can embed quasi html code inside your markdown.  
- Since it's a react app you utilize react component to enhance your blog.

Downsides:
  - Although it has advanced features like jsx and react components, the source .md will not really look right on github for example.  You'll need to generate it to see the whole picture. (Though it's the price you pay for it)
  - I can't seem to manage to every spell docusaurus correctly no matter how many times I type it out. :\ personal issue.

## Hugo

I haven't explored this fully but it's a markdown generator written in Go (big win for me).  It's super fast though I doubt I'll need to worry about compiling 20,000 md files anytime soon. 

There are also interesting tooling like [Hugo Academic](https://github.com/wowchemy/wowchemy-hugo-modules) which provides an easy way of creating content.  (Then again, VSCode works just as well for starting out )

It also seems to have a much wider array of themes to choose from, though most of them are giving me issues, likely a noob problem.



Any thoughts on these two or any other ones you'd like to toss in the mix?

Honestly the main goal is to write in .md push to some 'origin' self hosted version and able to also publish to say dev.to, medium, and other fun platforms i post on.