Start Programming Now

No CS degree needed

Alexander Tamoykin

Contents

- Preface

- Chapter 1 Introduction

- 1.1 What it is

- 1.2 Who is it for

- 1.3 Results

- 1.4 I’m down. What’s the plan?

- 1.5 Expectations

- Chapter 2 Setup

- 2.1 Using Mac OS X?

- 2.1.1 OS X command line tools

- 2.1.2 Package Manager

- 2.1.3 Install rbenv

- 2.1.4 Install Ruby

- 2.1.5 Install Gems

- 2.1.6 Git

- 2.1.7 Database

- 2.1.8 Rails

- 2.1.9 IDE (Integrated Development Environment)

- 2.2 What we just covered

- Chapter 3 Programming Basics

- 3.1 How Programming Works

- 3.2 Variables

- 3.2.1 Try it out!

- 3.3 Data Types

- 3.4 Control Structures

- 3.4.1 Conditionals

- 3.4.2 Loops

- 3.5 Arrays and Hashes

- 3.5.1 Arrays

- 3.5.2 Hashes

- 3.6 Classes

- 3.7 Methods aka Functions

- 3.8 Objects

- 3.9 Iterators

- 3.10 Inheritance

- 3.11 What we just covered

- Chapter 4 Coding

- 4.1 Simple todo application

- 4.1.1 rails new

- 4.1.2 Create, Edit, Delete tasks

- 4.2 Complete a task

- 4.3 How Rails works

- 4.4 Database migration

- 4.5 Task model

- 4.6 TasksController

- 4.7 Routing

- 4.8 Task Views

- 4.8.1 Adding ability to complete a task

- 4.8.2 Showing a completed task

- 4.8.3 Adding a status to task listing

- 4.9 What we just covered

- Chapter 5 Deployment

- 5.1 Setting up Heroku

- 5.1.1 Sign up for Heroku account

- 5.1.2 Install heroku-toolbelt

- 5.1.3 Authenticate with heroku

- 5.1.4 Install heroku-push plugin

- 5.2 Pushing to Heroku

- 5.2.1 Create a Heroku app

- 5.2.2 Add a database

- 5.2.3 Push

- 5.2.4 Migrate

- 5.3 What we just covered

- Chapter 6 What to do next

- Chapter 7 Thank you

Preface

This book[1] helps you to start programming from scratch. No Computer Science degree needed. It’s practical and simple. It helps you to get the ball rolling.

1. Photo by eguidry ↑

Chapter 1 Introduction

1.1 What it is

This book is the bare minimum guide helping you to start programming from scratch. In almost anything, the hardest part is to get the ball rolling. After reading this book you will be comfortable with programming. Further learning will require less effort since the ball is already rolling.

1.2 Who is it for

- You don’t have a Computer Science degree ?

- You would love to create software but don’t know where to start ?

- Want to put your software skills into real practice ?

If the answer to any of these question is yes, then this book is for you. I’ve been there. I don’t have a Computer Science degree. My degree is in Telecommunication Engineering and not in Software Engineering. Software was always what I wanted to do. Therefore I decided to learn it myself. I read many different books and practiced a lot. Most of books are so in depth. There was nothing that explains the most important basics of different aspects of programming. This is what this book is about. It helps you to connect the dots and start programming something useful.

1.3 Results

After reading this book you will be able to do 3 things:

1. Create a basic web application and put it on the Internet.

2. Write code yourself.

3. Understand and modify existing code.

1.4 I’m down. What’s the plan?

We’re going to build a web application using the framework called Ruby on Rails. Why web app? Because everything is on the Internet these days. Have you heard of Twitter, YellowPages, Groupon and many more? They are all doing business on the Internet using Ruby on Rails. Why Ruby on Rails ? Because it’s really easy to start. It’s really powerful and it’s hot on the job market.

I’ll show you how to set up your computer for software development. We’ll cover the basics of Ruby programming language. Next, we’ll get to hands on coding. This is where we create our first web application. We’ll put it on the Internet. Lastly, I’ll tell you what to do next and how to improve your skills going forward.

1.5 Expectations

This book touches on basics. It’s enough to get your hands on the keyboard and Start Programming Now. However, we don’t dive deep into every aspect of programming. Basic stuff is just the tip of the iceberg. It’s enough to get you started. From here, only sky is the limit.

Chapter 2 Setup

We need tools in order to program. This is where programming starts. Unfortunately, for many people this is where it also ends. I’ve seen people fighting with incompatible versions or programs and giving up. But don’t worry, I went through this process myself. I tried every piece of software and I can tell you that it works for sure. Follow the instructions and you’ll be fine. Ready, get set, go!

Nowadays it’s possible to get Ruby on Rails setup on all major platforms. I recommend using Mac OS X or any flavor of Linux. If you’re using windows, you’ll be fine too.

2.1 Using Mac OS X?

2.1.1 OS X command line tools

Go to Apple Developer Site. Register or sign in if you have an account already. Search for “Command Line Tools”. Choose the one for you version of OS X (Mountain Lion, Mavericks, etc), download it and install it.

2.1.2 Package Manager

Package manager is a program that installs and manages different packages. Ubuntu already has a built in package manager called apt-get. On Mac OS X you’ll need to download Homebrew. Open up the program named Terminal and execute this script to install it:

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

2.1.3 Install rbenv

$ brew update
$ brew install rbenv ruby-build
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile

2.1.4 Install Ruby

$ rbenv install 2.1.0
$ rbenv global 2.1.0 # set ruby 2.1.0 as a default

2.1.5 Install Gems

$ gem install rbenv-rehash bundler

2.1.6 Git

$ brew install git

2.1.7 Database

We’re going to use the database called PostgreSQL aka Postgres. It’s simple to install and use. It’s supported by many platforms. Let’s install it using Homebrew. We’ll also configure Postgres to run locally.

$ brew install postgresql
$ echo "export PGHOST=localhost" >> ~/.bash_profile
$ echo "export PGDATA=/usr/local/var/postgres" >> ~/.bash_profile
$ source ~/.bash_profile

Following commands make it so Postgres starts up on boot. It’s convenient. You won’t need to start it manually every time you reboot.

$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Now it’s time to create a database user for our application.

$ createuser todo -s

2.1.8 Rails

Now is time to install Rails framework. Rails is distributed as a ruby gem. RubyGems is a packaging system that comes with ruby installation. We’ll need to use gem command to install it

$ gem install rails --version 4.0.2

2.1.9 IDE (Integrated Development Environment)

I recommend to start with RubyMine. I used it myself to start with. It does a lot of stuff for you automatically so you can focus on learning how to program instead of configuring your development environment. Download and install the 30 days trial from JetBrains Downloads

2.2 What we just covered

Congratulations! Now you have all necessary software to start programming. Can’t wait to write a first line of code ? Let’s learn how to do it.