what is the source code?

246 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 programming code as written in a (usually) higher level language that is easy to understand. Source code is then compiled into executable code that is distributed to users so they can install/run the program.

If you can read the source code, you know how a program actually works, not just what it does. There are trade secret and copyright implications for source code.

(There are plenty of exceptions to the above generalized statements.)

Anonymous 0 Comments

Source code is the actual language telling the computer “Do X when a button is pushed or a mouse is clicked” then it is compiled into machine language the computer can act upon. It isn’t always protected but should be for the programmer’s intellectual property.

Anonymous 0 Comments

From my understanding, source code is the thing behind a program that makes it do what the program does. If you have the program as “open source”, that means that everybody can see what makes it tick, and can attempt to hack, cheat, steal, or something like that. It also can make it safer, because more people can fix the security holes in the program. “Closed source” means that not many people know what makes the program the way it is, making it harder to hack theoretically. I think it is part of the production version, it’s the backbone of the program which you build other features off of that. Hope that helped!

Anonymous 0 Comments

It’s basically the recipe and ingredients for the program. A compiler and a linker “bakes” the source code into a program that can be distributed.

If you have the source code itself, you can read it to find weak spots, or make changes and sell it.

Anonymous 0 Comments

Source code is the readable version of everything the program can do, when you open a program you prefer to see just the UI and click buttons instead of being able to stop at each line in a code and see more details about what is happening (As you can when you have source code and a debugger). Some programs can be reverse engineered and get the source code that way, although this is time consuming and involves a lot of expertise.

The reason it is kept secret is because of various reasons, these could be:
It contains the methods to keep sensitive data secure, such as passwords or encrypted personal information.
It makes you money, an antivirus company would go broke if anyone could remove the part of their software that locks it after a free trial.
Its not secret, its just not public, a lot of times something is not relevant enough to be put out there, there are markets so small there only 1 or 2 clients, these programs are usually just built by a single developer who never releases them.

TL:DR

Source code is the logic of a program, telling it what to do for everything a user may ever try to do (Or maybe not everything, thats what bugs are).
Its secret cause you make money off of selling the code instead of giving it away for free or it presents a security risk for private information such as texts & passwords

Anonymous 0 Comments

EDIT: fixed a duplicate paragraph.

First I’ll explain what a program is.

A program is just a set of instructions in a specific format a computer can read telling it what to do. Sometimes a program or set of programs are used to run other programs (as in the case of an operating system).

A program is basically transformed source code. The transformation process (compilation) may take the source code, combine it with the product of other source code transformations and turn it into (but not always) a machine readable binary set of of instructions targeted to run on a particular CPU and operating system combination.

Because CPUs and computer configurations may differ some clever programmers developed programs (specifically called run-times) which let other developers write code that is compiled at the last possible moment (when the execution context is definitely known ie. what kind of CPU and operating system combination is present). This Just in Time compilation allows the run-time to target efficient machine-readable code that’s specific to the instruction set on the CPU.

Some languages (the syntax convention used in the source code) have programs which are distributed in source code format. Examples of this are Javascript, HTML (well HTML is technically not a language but rather a specification) and something called Python are examples of languages whose programs are distributed in source code format. Python may be compiled at the last moment (but that is more like caching the machine readable instructions).

You asked about secrecy.

There are several ways the the secrecy of a program might be protected. Applications distributed in compiled form are kind of difficult but not impossible to reverse engineer back into their source code form, and languages such as JavaScript may be obfuscated into something a human would find very hard to read but again not impossible as could ostensibly write a program to make an obfuscated program more readable. In fact some languages or rather run-times have a feature which allows the compiled code to be reflected or interrogated at run-time as an enabler of a feature you might want (such as a late-binding plugin). On the other hand it would be impossible to reverse engineer a remote application exposed through an API such as over a computer network since such programs are black-boxes only exposing touch points ie their binaries sit on some far away machine and you use a protocol that accepts just the data needed to run the computation you want – there is nothing for you to decompile even if you wanted to.

Some languages like Typescript may be transpiled (kind of like recompiled) down to JavaScript so that when run in a browser execution context the browser might understand it since browsers are not able to run Typescript natively.

There are also visual languages such as Squeak which take take visual building blocks as the source code of its programs. You can be assured that somewhere this visual program is transpiled into something some run-time somewhere will understand.

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.

Anonymous 0 Comments

Source code is a set of instructions telling your computer how to do something. Imagine it as a recipe telling you how to bake a cake.

Now your computer doesn’t understand English, so we need to turn the recipe into machine code which your computer understands. The resulting machine code is produced using a fairly complex set of rules and it’s not easily reversible. You can’t easily get the English version of the recipe from the machine code version.

Now, in the production environment, you will always have a copy of the machine code or binary version of the program. If you had a copy of the source code you could create new versions of the machine code, which companies don’t really want you to do because they want to sell you new products. There is a movement called “open source” which advocates for giving you the source code as well, but most software isn’t released under an open source license.

Anonymous 0 Comments

Think of the source code as the set of instructions that make anything on the internet what it is.

Everything is software.

The browser you’re using to access Reddit is a software. Reddit itself is a software. Windows is a software. Google is a software. Your Android/Apple OS is a software.

Software is written in what is known as a programming language. Think of it as a set of rules that tell what is to be done.

There are various programming languages – while they all achieve the same end target – the way they’re written is different. Their commands and terminology are different.

So like English or Spanish or German, you can be fluent in one or in several. And build using them.

Overtime, you can work with many different people and increase the complexity of your instructions (your code).

To illustrate by example, you’re tasked with carving the words “Explain Like I am Five” on a tree.

You begin your instructions in English, by providing very basic instructions. Step 1, move to the area where the tree is located. Step 2, open all the carving tools and lay them out, so they can be fetched easily when you begin work. Step 3, clean the area where the actual carving is to be made.

Now, a friend who speaks Spanish joins you. You ask him to work in parallel with you. He begins by creating a stencil – he gives these instructions in Spanish.

You both then begin working together, while you’re giving instructions to carve the word “Explain” – he’s working on the number “5”.

::

1AA – Gradually, you have more people joining in. Some other English Speaking friends, some more Spanish-speaking friends. Some who specialize in carving corners. Others who excel in actual design. Then there’s some who can provide an immaculate polishing job.

You all work together to finish this carving. And at the end of it, you have a fantastic end product that you’re all really proud of.

2AA – You’re still making changes to this product. Maybe in the future you will add an LED inside one of the letters. Maybe some glow-in-the-dark edges. Maybe you’ll build a small base mount for these letters to stay on.

3AA – While doing this, one of you discovers a unique method to smoothen the edges. You guys decide to call it “SmooooothAF”

4AA – Now other carvers in the area can look at this carving and can recreate it on their own with their own instructions. But they will never be able to replicate it 1 by 1, unless they have the explicit “instructions” you and your colleagues used to design this amazing carving job. And they sure as hell won’t be able to use your SmooooothAF technology.

However, if they do have those instructions. They can essentially copy it. Exactly.

These instructions are your source code. The basis of your software product.

If I had Facebook’s source code, I could essentially replicate Facebook with all the bells and whistles and technology.

::

For clarity

1AA – In the above case “English” and “Spanish” become your technology “stack”. Similarly, in a real-world example – a stack would be a set of programming languages used by a company.

Additionally, more people joining means the “creation of a team”. A software product has a large number of people working in conjunction to finish a particular section of a complex job.

2AA – Making changes = “Software Updates”. Planning changes = “Upgrade Pipeline”

3AA – SmooooothAF = Proprietary Technology. A piece of technology unique to one software. So for example, the way Reddit shows the top posts on the home is a form of proprietary technology. It’s not merely listing the latest posts, nor the most upvoted posts. It’s using a system to push a particular post there. If I were to recreate Reddit today using just what I can see with my own code, I’d have a real difficulty trying to reverse engineer the way Reddit does that.

4AA – This is why the “source code” or the original set of instructions is kept secure and confidential. It is years of hard work by many excellent programmers and essentially equal to the product and company itself.

::

Now that you’ve understood “source code” – you should try and understand “Open Source” as well.

Open source happens when a programmer or a company, releases the source code of their software under a license that allows you to see it, modify it and use it.

It can help reduce development costs, allows for transparency, is more often than not extremely reliable and allows for a lot of collaboration.

A good example is a [Chromium Web browser](https://en.wikipedia.org/wiki/Chromium_(web_browser)). It is completely open source. It is developed and maintained by Google. But is completely Open Source.

You must have heard of Google Chrome. Google Chrome is built majorly on Chromium with a lot of other proprietary features added in. Google Chrome is not open source.

There are several browsers on the Internet that work on “Chromium” as a base. Such as Microsoft Edge, Brave, Opera etc. These are all again closed source.

Hope I could help.

Anonymous 0 Comments

I know I’m late to the party and nobody will probably read this but…

A computer is a machine that does exactly what it is told to do. Exactly as it is told to do it. The only problem is, we don’t speak it’s language. At least not fluently or efficiently enough to give it the high end instructions we need to produce cutting edge software. Computers talk in 0’s and 1’s. We don’t.

So, we got a translator (source code) the can take our human languages and convert it into computer language and vice-versa.

Source code is the translator that allows us to speak to computers must faster and more efficiently.

Unfortunately, the translator is not perfect and can sometimes lead to mistranslations which is where computer bugs come from but that’s for a different eli5.