A Q&A ON THE ABCs OF PROGRAMMING

Before we can do anything, we’ve got to cover the basics. Here’s what you have to know before you can get started.

WHEN WE SAY «PROGRAMMING,» WHAT DOES THAT REALLY MEAN?

For this article, we’re going to use a fairly narrow definition of pro­gramming, and say that what we’re talking about is the process of creating software on a computer. That process involves writing out a series of commands for the computer to execute, which will create our desired behavior. We write those commands using a program­ming language.

WHAT’S A PROGRAMMING LANGUAGE?

There’s an incredible variety of programming languages available for use, but the vast majority of commercial and personal software is written in one of a core group of languages including C/C++, Java, C#, Python, and a few others. Modern programming languages share a lot of the same basic concepts and some syntax, so learning your second, third, or fourth programming language is much easier than learning your first.

what makes one programming language different from another?

C and C++ are low-level languages, meaning that code written in C is closer to the machine code that your CPU understands (see side­bar below). Low-level languages can produce faster, more efficient software, so they’re used where performance is at a premium—for programming an operating system or a 3D gaming engine, for in­stance. High-level languages, like Java and Python, have the advan­tage of being much easier to program in, and the same program can generally be written with fewer lines of code in a high-level language.

But which one’s the best?

There’s no one best language — it really depends on what kind of programming you want to do. If you want to program native Windows applications, you’ll use C#; if you want to program sophisticated web applications, Ruby would be a good choice; if you want to be the next John Carmack, you should probably start with C.

No, for real, which language should I START WITH?

The secret is to not stress too much about whichever particu­lar language you start with. The important things you will be learning are all basic concepts that work pretty much the same in every programming language. You’ll learn how to use data structures and conditionals and loops to manage how your code flows. You’ll learn to structure your program in a way that’s readable and organized. Once you’ve done all that, learning a bit of syntax to pick up a new language won’t seem like much work at all.

But, if you really want a suggestion, start with JavaScript. It’s an easy language to learn, it’s got some practical applica­tions, and its syntax is similar enough to some more-powerful languages like C# and Java that making the transition later on won’t be too hard.

Is HTML a programming language?

Not quite! HTML is a markup language, used to define the contents of a webpage. Although HTML has a specific syntax (a set of rules defining how you have to write things), it doesn’t have semantics, or meaning. An HTML document is rendered, rather than executed. That said, if you have written an HTML document, you at least have experience writing a formalized computer language, which may make the jump to program­ming easier.

WHAT’S AN IDE?

An IDE (short for integrated development environment] is the software suite programmers use to actually write programs. They generally include a specialized text editor for writing the source code, as well as the ability to test and debug your program. Two of the most popular IDEs are Eclipse (open source, free, and avail­able at www.eclipse.org) and Microsoft Visual Studio (proprietary and expensive, but with a free “Express» version that’s limited to and excels at programming in C, C#, and BASIC].

How can I start writing a program, like, right now?

Unfortunately, it can be a bit of a hassle to get started coding in most programming languages. You generally have to install and configure an SDK (software developer kit], and sometimes an IDE as well, in order to be able to write and compile code in a new language. It’s rarely super hard, but be prepared to spend 15-30 minutes Googling, reading a guide for your chosen language, and setting things up.

Fortunately, JavaScript is much easier to get started with. In fact, you can start writing code right this second, using an in-browser coding environment like JSFiddle.net. An in-browser IDE isn’t a good solution for serious programming projects, but it’s a great way to get started as a beginner. To start writing JavaScript in an interactive environment with structured lessons, you can visit www.codeacademy.com (but more on that later).

How Does It Actually Work?

When you write a program in a high-level language like Java­Script, the document you create isn’t something that your com­puter’s low-level hardware can understand. The CPU has only a limited number of instructions it can perform, such as addition, subtraction, and moving num­bers into and out of memory. These instructions are actually physically implemented in the CPU using transistors organized into logic gates. Though mod­ern instruction sets, such as the X86-64 set implemented in any consumer 64-bit CPU, are actu­ally very large and sophisticated, programming for the CPU direct­ly (using a super-low-level lan­guage called assembly language) is an arduous, slow process.

High-level languages allow you forgo a lot of the techni­cal grunt work. For instance, in a high-level language, you can simply declare and use variables as you please, without ever wor­rying about what exactly is going on in your system’s memory. In assembly language, you have to manually assign data to loca­tions in memory as you use it, and clear up the memory when you’re done.

In order to get your high-level program to run on the CPU, you need a compiler—a piece of soft­ware that optimizes your code and converts it into a machine- readable executable file. Some languages, such as Java, are not compiled, but rather inter­preted, which means that the source code itself is distributed, and then compiled on the end user’s machine. The upside of an interpreted language is that you can distribute a single file that can be run on Windows, OSX, or Linux. The downside is that who­ever runs the file has to have a copy of the interpreter on their machine—an annoyance that anyone who’s tried to run a Java­Script applet on a new computer will be familiar with.

SQL - 12 | 0,508 сек. | 7.86 МБ