Why we can see the source code for an HTML page but not for a program, unless the programmer (or the owner) shares it?

1.80K views

Why we can see the source code for an HTML page but not for a program, unless the programmer (or the owner) shares it?

In: Technology

9 Answers

Anonymous 0 Comments

So the other answers aren’t wrong, but I feel they leave a bit out.

In computing, there are a few different ways to program. These are typically referred to as being low-level (closer to the native 1’s and 0’s that computers understand) and high-level (closer to a human-readable language)

At the lowest level we have assembly. This is some of the most bare-bones code, where instructions are written out line by line for what each part of the computer does at each step of the code; what values in memory get moved into what part of the processor and what operation is done and where the output goes, *really* low-level stuff.

A level above that and we have the *compiled languages*; these are languages like the C/C++/C# family, along with a few others that are largely lost to time. When you code in C or C++, you get some advantages like being able to automate a lot of the things you would have to do manually in Assembly, like cleaning up memory after you were done using it, and the code, while it still isn’t any natural language, is more understandable to the average person; it’s kind of like if you are fluent in Spanish and you try to read Portugese: some words are different and you might not understand some context in some places, but you can discern the general gist if you understand some basic concepts.

These are called compiled languages because the text file that is your source code has to be run through a program called a compiler, which uses a set of rules to convert that code you wrote into raw machine code, and packages it so it can be run as a .exe

Then a level up, we have interpreted languages – these are languages like Python and Ruby, and they do for C/C++/C# what those languages did for Assembly: make it easier to read and write more complex programs in less human hours.

These are run through a program called an interpreter, and unlike with a compiler, the interpreter has to be called each time the program file is run. So unlike in C variants, where the compiler spits out a .exe, a python file requires being sent into a python interpreter to give any outputs (at least generally; there are ways to get a .exe out of it, but it generally takes longer to do, as fundamentally the programs end up being bigger).

Finally you have scripting languages; these are sometimes considered not “real” languages, but the idea is that you have a program (like a web browser) that looks at code fed to it and then follows it like a script using its interface. These tend to be more specialized than any other type of programs, and it’s used as a way to share content without allowing random untrusted code to run directly with your user permissions (not that that always works, but…) – so for instance a web browser’s scripting languages (html, javascript, css, etc;) lets you call predetermined elements from top to bottom of a page which the web browser then displays as best as it can, calling the images and whatnot to use during runtime.

Because scripting languages and interpreted languages are taking the source code and reading it during the runtime of the program, as opposed to putting out an independent program to be run on its own, it needs to be able to “see” that code, and if you have access to the program that means you can access it.

Compared to compiled programs which aren’t easy to reverse from bytes to readable C (things like variable names get erased during reverse-engineering and makes it hard to track what the program is doing, as the computer discards that during compiling; it’s there for human readability).

Because interpreted languages and scripting languages fundamentally

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