supersoup:

This is going to be a different sort of Friday Facts. I suppose most of the ones I’m chiefly responsible for tend to be but here’s a warning anyway.

Programming, coding, software development – all words used to describe the same thing: writing human-readable words that are turned into the magical ones and zeros a computer can understand. Perhaps you’re curious how the programs and apps in your life work exactly. Or perhaps you’re considering taking up programming for yourself but feel like it’s all a bit overwhelming. This post will be aimed at both of those crowds with an introductory overview to code and what’s really going on behind the scenes. And rest assured – programming can be a hobby just as easily as it can be a career. It’s an incredibly interesting field, to say the least. Hopefully, regardless of your level of engagement, you’ll find something in here that catches your imagination as programming has mine.

Ready? Take a deep breath, then dive in with me!

Computers only know and understand binary: ones and zeros. Humans can have a hard time thinking like that, especially making sprawling and complex pieces of software with it. So we invented “programming languages” that allow us to write code in a more comfortable way – while another computer program called a compiler turns it all back into something your computer’s processor can understand.

The language chiefly responsible for NewCity, C/C++, is one such programming language. It’s generally referred to as C++, but to be precise, C contains the bulk of the language while C++ is a subset that adds a framework for something called “object-oriented programming” which we won’t dig into here.

Programming languages are a combination of syntax and semantics. Those are fancy words used to say that a programming language is a bundle of rules you must follow for proper use, and then of course the specifics about using those rules in a way that’s logically sound. While math can be important to programming, and the mental muscles behind the logic and structure of math certainly are, it isn’t strictly required in order for someone to be able to write a program.

The core syntax of any programming language defines keywords and rules for how to structure your program in a way that makes sense for the compiler. In C/C++, that means keywords like:

  • int: An integer, or whole number.
  • char: A character, generally a letter, but can also be a byte (8 bits) of data.
  • string: A bundle of characters, usually a word or a sentence. Can contain whitespace (empty characters).
  • void: Nothing! Generally used for functions which don’t return any value once they’re done.

In C/C++, a curly brace ({) opens a block of code, and another (}) closes it. Curly braces must be matched!

The programmer organizes their code into declarations (e.g. int myNumber = 0), and functions, which are declared in a similar manner. For a functional example, and one of the most famous, consider the block of code below:

#include iostream (should be enclosed, but Markdown just wasn’t having it)

int main() {

std::string hello = “Hello world!”;
std::cout « hello « std::endl;
return 0;
}

In this snippet, you see an example of “including” a library (iostream), or a bundle of code that’s already been written to handle some otherwise difficult task. You also see a function definition, main() returning an integer, with a single line of code that uses the Standard library output object (std::cout) to print a string to the console, also called the command line. In this case, it outputs the string variable hello – which we initialized (set to a value of) “Hello world!” – followed by an invisible character (std::endl) that moves the cursor to the next line. The return 0 line is necessary, as the function must return an integer. Then we close it up with a curly brace and off we go to the compiler!

This is just the tip of the iceberg, but hopefully it has piqued your interest. Google is your friend here – there are few questions you can ask which have not already been asked and answered in blogs, Stack Overflow posts, and other resources across the web. Programming is a powerful, exciting, and fun tool that I think is well worth anyone’s time to dig into. There’s lots you can learn all on your own with a little motivation, and it’s not as hard as it seems. Trust me!

If you liked this overview, please do let me know. If this receives a positive response, there may be more such posts in the future.

Happy programming!


At Lone Pine Games we are always looking for feedback to improve our game! The best way to provide it is through the NewCity Discord.

We are thankful to have such a lively and dedicated group of Mayors participating in discussions regarding new features, city planning strategy, development news, and just about anything else.

If you want to play the game and haven’t got it yet, head over to our Steam page. We’re also on Reddit and Twitter.

Steam Reviews are always appreciated as well!