-
Intro to C++ - Types
Friday, March 13, 2020
We’ll be investigating the primitive types C++ has to offer in this post and reference types in the following post. Integers The Integer type store whole numbers and come in four sizes: short int, int, long int, long long int. In addition, each type can be signed (negative whole numbers permitted) or unsigned (only positive numbers). A short is typically 2 bytes in size and an int is 4 bytes. A long is 4 bytes on everything except on 64-bit Linxu/macOS where it is 8 bytes.…more
-
Intro to C++ - Getting Started
Tuesday, March 10, 2020
To begin, we write human-redable C++ code in a source file which is then compiled to produce machine code that our computers can run. Here’s an example of a minimal source file: // main.cpp #include <cstdio> int main() { printf("Hello, World!"); return 0; } The above declares a function called main which serves as an entry point to our program, after all, the program has to stat somewhere. Within our main function we call another function printf which prints the text to the terminal.…more
-
Intro to Rust - Collections
Friday, March 6, 2020
Collections are data structures that contain multiple values. However, unlike arrays and tuples that are stored on the stack, these types are stored on the heap. Vectors Vectors are similar to arrays except they can grow dynamically. Like an array, it can only store a single data type. To a create a new vector, we write: let a: Vec<u32> = Vec::new(); The type annotation above is necessary as we’ve created an empty vector so Rust has nothing to infer from.…more
-
Intro to Machine Learning
Thursday, March 5, 2020
Machine learning is the field of study that gives a computer the ability to learn without being explicitly programmed. As an example, the spam filter from your email provider can learn and analyze what emails are being reported as spam and then apply that filter before the email even reaches you. If we were to program this manually, we might use regular expressions to search for certain keywords we provide in the email and feed each email that comes in through that algorithm.…more
-
Intro to Rust - Structs
Tuesday, March 3, 2020
A struct is a data type that allows you to group multiple related values under a single type. To define a struct in Rust, we use the struct keyword: struct Point { x: i32, y: i32, } And we create an instance of the struct like so: let p = Point{ x: 3, y: 4 }; And to access a field on the struct we use dot notation: println!("x: {}, y: {}", p.…more
-
Intro to Rust - Ownership
Monday, March 2, 2020
Every programming language has to have some way to manage the memory it consumes while the program is running. In higher level languages like JavaScript this is managed with a garbage collector or with lower level languages like C, the memory is allocated and freed manually. Rust uses a different approach with a concept known as ownership. Stack and Heap The stack and heap are parts of memory that your program can utilize at runtime.…more
-
Intro to Rust - Variables
Wednesday, February 26, 2020
Variables are conceptually labeled boxes that we can store values. The box is the address in memory where the value is stored and the label is just a human readable alias for that address. All variable declarations in Rust start with the let keyword followed by the name we assign to variable. Here we are declaring a variable called z and assigning the value 12 to it: let z = 12; By default, all variables in Rust are immutable meaning you cannot re-assign a value to them.…more
-
Intro to Rust - Hello World
Tuesday, February 25, 2020
Installing and configuring Rust is a breeze with rustup which is an installer for Rust. You can download it by visiting: https://rustup.rs/ And following the onscreen instructions. You can confirm that the installation has worked by running: rustc --version The rustup installation also comes with another command line tool called cargo which is the Rust packager manager – akin to npm for Node. Rust packages are called crates and there is an online repository of crates visible here:…more
-
Intro to Typescript - Getting Started
Monday, February 24, 2020
What is TypeScript? TypeScript is a transpile-to-JavaScript language meaning that a program written in Typescript must first be translated (transpiled) to JavaScript before it can be run in the browser. Although compiling typically has a different meaning, the TypeScript community refers to this process as compilation. Why would anyone want to go through this process though? Because TypeScript comes with a host of features on top of those already available in JavaScript, all aimed at making writing JavaScript code more robust.…more
-
Intro to Object Oriented Programming
Friday, February 21, 2020
Introduction What exactly is an object? An object is defined by two components: properties and behaviors. A car has properties like its color, the year it was made, if it’s 4WD or not, etc. It also has behaviors such as starting, driving and so on. Having both of these components is key because if you just have behaviors then you’re simply dealing with functions that transform their inputs and return the output.…more