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.81K 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

This is because HTML is a language that has been modified for decades to ensure safety. Its purpose is to provide formatting information to a browser, which renders the html into a visible design. Javascript is a full-on programming language that was introduced to browsers because it allows for things like posting requests and performing complicated functions. It is severely restricted in its capabilities to prevent malicious web pages from performing dangerous functions on a user’s computer.

Depending on the language a program was written in, it can be turned back into an exact (or close enough) copy of the original code. This is mostly possible with languages that use just-in-time compilers. The code presented to the executing-program is high-level enough that it can often be passed through the same program that generated it in reverse and yield results close to the source code.

At the end of the day, a computer only executes machine code, a binary expression of processor specific instructions. Programming languages may either turn a file into machine code to be executed, or translate a program in an intermediate language into machine code as it goes, basically interpreting a block of language, translating it into bytecode, and executing each step of the program.

In languages that are compiled in the traditional sense, it is often the complex nature of optimization functions that makes recomposing machine code into higher-level functions difficult or outright impossible. A binary can absolutely be turned back into something that resembles human-written code, but typically compilers do so much to make code run faster that the resulting machine code simply cannot be associated with a specific higher-level operation.

It is possible to read machine code directly (as bytecode or assembly), and unlike decompilation this code will always provide a true and exact representation of the operations happening in a program. Actually analyzing this code is difficult at first but gaining such a skill is incredibly valuable for malware analysts and software exploitation, among other things.

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