what is the source code?

665 views

What is the source code for a program? And why is it kept under secret, is it always part of the production version?

In: 2

10 Answers

Anonymous 0 Comments

Source code is the code that humans actually write when they write software. It’s designed to be easy to understand and work with. There are many different programming languages that all look very different, but an example of source code for a simple program that just shows the text “Hello World!” might look something like this:

print(“Hello World!”)

Computer processors generally don’t understand source code natively (there are a few exceptions, but I’ll ignore them because they’re rare). In order for a computer to run the program, it must first be *compiled* into machine code. (There’s also a second way to run source code called “interpreting”, but interpreting requires the source code on the machine running it, so programs that are supposed to be kept secret don’t use it.) This compiled code is what is installed onto your computer, which is why you generally can’t see the source code for the programs you have installed.

Machine code is a simple code that’s designed to be understood by the computer processor. Rather than text, the “instructions” as they’re called are all just numbers. Each number corresponds to a specific task the computer knows how to do, such as “add two numbers”, “load a number from a file”, and so on. When you compile a program, a second program called the *compiler* looks over the source code and turns it into machine code using a number of different rules (These can be very complex rules, depending on the programming language). The end result might look something like this:

0x02 0x48 0x00001201
0x02 0x65 0x00001202
0x02 0x6C 0x00001203
0x02 0x6C 0x00001204
0x02 0x6F 0x00001205
0x02 0x20 0x00001206
0x02 0x57 0x00001207
0x02 0x6F 0x00001208
0x02 0x72 0x00001209
0x02 0x6C 0x0000120A
0x02 0x64 0x0000120B
0x02 0x21 0x0000120C
0x02 0x00 0x0000120D
0x34 0x9B 0x00001201

As you can see, source code is *much* easier to read than machine code. It is possible to painstakingly analyze machine code to determine what it is doing, but the process is difficult and extremely time-consuming, especially for large programs.

In general, source code that is kept secret is secret because the company that makes it doesn’t want people to learn how the software works. There are several reasons for this, including:

– A specific algorithm in the software may be a trade secret (such as Google’s search engine recommendation algorithm). Someone with the source code would be able to replicate it.
– Hackers can look through the source code to find security holes. It’s much easier to find a hole by searching through the source code compared to just randomly trying things to see if they work.
– Software pirates with the source code could create a modified DRM-free version.
– Someone with the source code can create a version of the software with all the “premium” features permanently turned on, denying the company the revenue from selling those features.

Source code does not have to be kept secret, however, and there is a large Open Source movement that is dedicated to creating software where the source code is freely available to anyone who wants it.

You are viewing 1 out of 10 answers, click here to view all answers.