Why is it so difficult to copy source code that is not “open source”?

864 views

It’s been in my mind if we are using the software/program or even hardware of a tech company, we can play around, install-unsinstall and more. Then how is it so difficult for someone to “unhide” the source code that the device uses? Technically the code is in the device somewhere hidden in it, so it’s there, but still, it’s almost impossible to obtain the source code. How do they achieve this so no one copies their code?

In: 366

42 Answers

Anonymous 0 Comments

Source code is written by humans and is therefore human readable. Let me try to show you by example. You can write the following code in C++:

`// Your state sales tax`
`float SALES_TAX_PERCENT = 7.25;`
`// Calculate price with tax`
`double finalPriceWithTax(double price) {`
`return price * (SALES_TAX_PERCENT / 100);`
`}`

I am sure even somebody who doesn’t know how to program can understand it. After compiled, to a computer it becomes instructions and numbers. When you decompile it you will see this:

`L001:`
`.long 1088946176`
`L002(double):`
`push rbp`
`mov rbp, rsp`
`movsd QWORD PTR [rbp-8], xmm0`
`movss xmm0, DWORD PTR L001[rip]`
`movss xmm1, DWORD PTR .LC0[rip]`
`divss xmm0, xmm1`
`cvtss2sd xmm0, xmm0`
`mulsd xmm0, QWORD PTR [rbp-8]`
`movq rax, xmm0`
`movq xmm0, rax`
`pop rbp`
`ret`
`.LC0:`
`.long 1120403456`

Not so easy to understand now, is it? However, humans can still figure it out. Now imagine you intentionally add code which does nothing and start jumping back and forth. Computer can still handle that with easy, but for human to understand it it becomes very difficult. There are even more advanced ways of making your code even less human readable.

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