Programming

ruby-free-will

Programming can be an intimidating subject to newcomers. With all its various forms and features and classifications, it can deter people from tinkering, which I see as a high crime.

In this short primer I’ll explain all the various components so as to hopefully remove the mystique and make it approachable. The world needs more coders, and it can be a source of great enjoyment to become one.

To start off, let’s define programming.

That’s my definition. There are other more technical ones that don’t fit the purpose of this primer as well. The key point is creativity. You’re bending computers to your will.

In programming people refer informally to whether a given programming language is low level or high level. This basically deals with three things:

  1. How fast the language is when running on a computer

  2. How much code you must write to perform a given task

  3. How intuitive the language is to humans

These are inversely related.

So for a low level language you can consider low to be close to the computer, and high level to be close to the human. And when you write in a low level language you have to write lots of unintuitive code to do anything, but it runs faster. And when you write in a high level language you can write very little code, which is quite elegant, but that takes longer to run on a system.

So:

Low Level: Verbose, Unintuitive, Fast [assembler, c]High Level: Concise, Intuitive, Slow [ruby, python]

There are a few basic types of programming language:

  1. Compiled

  2. Interpreted

  3. Modern (hybrid)

[ NOTE: Modern isn’t formal; it’s my name for it. Another good name might be ‘hybrid’. ]

  • Compiled languages go from the source code to an executable, and that executable can only run on a certain type of CPU. Executables tuned for a particular CPU tend to be very fast, and are generally created using a low level language. The downside is that you can only run the executables on certain computers (based on which CPU it has).

  • Interpreted languages don’t have an executable step—they just run from the source code and are interpreted (translated) by the installation/environment into machine code. Interpreted code generally runs much slower and is created using high level languages. The upside of interpreted languages is that you can run the programs anywhere the environment is installed.

  • Modern (hybrid) languages have elements of both, and are designed for enterprises. They are both compiled and interpreted, and get many benefits from both, e.g., platform independence and speed.

Object Orientation is a way of building computer programs so that they are both intuitive to humans and functional for computers.

Objects have both attributes and methods. Attributes are basically characteristics, or data, about the object. And methods are operations or actions that can be performed on the object from other places in the program.

When you build a program using Object Orientation you basically build a collection of objects that interact with each other in various ways.

Principles

There are a few core tenets of OO worth mentioning.

  • Encapsulation is basically access control between the data within an object and the entities that call the object. It’s done by hiding accessors and mutators. Accessors ask objects about themselves, and mutators are public methods that modify the state of an object.

  • Abstraction is a method of controlling complexity by presenting a model, view, and controller that others can use to interact with the object.

  • Inheritance is the concept that when you make something from something else, you get the attributes for that thing. So if you have an object called mammal, with two eyes and live birth for example, then if you make a dog that inherits from mammal, then the dog would start with two eyes and live birth as well.

  • Polymorphism means having multiple methods with the same name but different functionality. Overriding polymorphism happens at runtime, and overloading polymorphism happens at compile time.

Here are some of the most important programming languages.

Unsupervised Learning — Security, Tech, and AI in 10 minutes…

Get a weekly breakdown of what's happening in security and tech—and why it matters.

  • c: Includes c++ for these purposes. This is pretty much the king of all programming languages given its role in creating Windows, Linux, etc. Learn it if you want to know the roots of computing, how to do things more manually than with modern languages, or to just be well-rounded.

  • Java: Highly enterprise focused. Very much like c++. Learn it if you want to do enterprise development in a Java shop, or if you want to be well-rounded.

  • JavaScript: Also c++ based. Started as the scripting engine for browsers, but has now become something of a superstar itself. You should likely learn a decent amount of JavaScript because it’s basically everywhere.

  • Lisp: A high level language often used by AI types.

  • Scala: An object oriented script-like language that compiles into Java bytecode.

  • Ruby: An elegant high-level, interpreted, object-oriented language popular with people looking to quickly implement ideas. Also serves as the foundation of Ruby on Rails.

  • Python: An elegant high-level, interpreted, object-oriented language popular with people looking to quickly implement ideas.

  • Objective C: The language used for creating mobile applications for Apple’s iOS platform before they came out with Swift.

  • Swift: The language used for creating mobile applications for Apple’s iOS platform that replaces Objective C. Implements a number of features for making development easier and safer than Objective C.

  • Go/Golang: Statically typed and loosely based on C. Created at Google and now used on a number of Google production systems.

  • Fortran / Cobol: Attack yourself.

  • PHP: An object oriented language originally designed to run CGI scripts for web applications, which is now the centerpiece for a number of web frameworks. Known for being insecure, but this is largely due to the context in which it was implemented, i.e. by web programmers looking to get the most done in the shortest amount of time.

  • Lua: The preferred scripting language for games and a number of embedded systems. Known for being fast.

Typing has to do with assigning a type to the variables, expressions, functions, or modules that can exist within a program. Types include integers, strings, arrays, etc.

So Typing basically locks down each part of your program into one of these for the purpose of reducing bugs. If you don’t do this you’ll have people trying to multiply “dogs” the integer with “dogs” the string, which causes all sorts of drama—especially in large applications.

Static typing takes place at compile time, meaning that when you run the app it’s already locked in. Dynamic typing takes place at runtime.

There are a number of ways to build software at scale. Here are few of the main ones—each having its own set of advantages and disadvantages.

The main types are: sequential (do one, don’t go back), incremental (a series of mini-waterfalls), iterative (work on small pieces to find problems), and rapid (create prototypes quickly).

Here are some of the main named approaches:

  • Waterfall: A sequential approach where the development is seen to flow downwards through several phases, such as requirements, design, development, testing, integration, deployment, and maintenance. A key concept in Waterfall is not revisiting a phase once you leave it. This is an older model that was supplanted by Agile in many enterprises in the 2010’s, but Waterfall is making a strong comeback.

  • Agile: An iterative approach where the requirements and solutions evolve via collaboration between cross-functional teams. The central concept is lighter structure and more focus on human feedback.

  • Spiral: A hybrid approach that combines waterfall and rapid prototyping approaches.

  • REPL stands for Read Evaluate Print Loop, and is the simple interactive computing environment that allows you to test your code in a given language. IRB is an example of a REPL (for Ruby).

  • Just in Time Compilation (also known as dynamic translation) improves the runtime performance of programs based on using byte code, or virtual machine code. Byte code is interpreted, so it’s slower that compiled code, but faster than traditional languages. .NET and Java are JIT languages. They bytecode is kept in memory and segments are compiled as they are needed. This also allows security checks to be applied as code is run. Caching is also used during translation to get near compilation speeds.

  • Dynamic Compilation is used by languages like Java to improve performance as an applicaiton runs. Code is optimized as it is run, and thus after this happens on a large system for a few minutes the system gets faster. Many apps can’t wait for the initial slowdown and use another approach.

  • A Data Strcuture is a way of storing and organizing information in a cojputer so it can be used efficiently, e.g.: array, record, hash, union, set, object

  • Arity is how many parameters something takes. So, an arity of 0, 1, or n.

  1. A Programmer is someone who can solve problems by by manipulating computer code. They can have a wide range of skill levels—from just being “ok” with basic scripting to being an absolute sorcerer with any language.

  2. A Hacker is someone who makes things. In this context, it’s someone who makes things by programming computers. This is the original, and purest definition of the term, i.e., that you have an idea and you “hack” something together to make it work. It also applies to people who modify things to significantly change their functionality, but less so.

  3. A Developer is a formally trained programmer. They don’t just solve problems or create things, but do so in accordance with a set of design and implementation principles. These include things like performance, maintainability, scale, robustness, and (ideally) security.

Basically, all three solve problems using code. Programmer is the umbrella term which means problem solver, a Hacker is the creator/tinkerer, and a Developer is a formally trained programmer who doesn’t just solve problems but does so in a structured and disciplined way likely learned a part of a formal education.

Programming is about shaping the world through a tangible implementation of your ideas. These can be artistic or creative ideas, or ways to find answers to questions by leveraging technology.

Either way, programming is quickly becoming a mandatory skill rather than an extracurricular one. Embrace it.

Notes

  1. This is a mid-level primer, not an absolute baseline. Notice that I’m not talking about what variables are, etc.

Related posts: