Hide AppDelegate.scpt source code for macOS application - Xcode
When you save the AppleScript file you have the option of checking "Run Only" - in that case the script is compiled into a new form that can be run exactly as the original script, but it is not meant for further editing/development. 

It doesn't mean that the run-only file is complete protected or non-readable, but parts of your code, comments, etc. are not included or not easily readable.

If you want to do more you'll need a code obfuscator if you still want to use AppleScript - however I'm not sure if one exists on the market, or you need to develop your own.

Regarding the second part of your question - most programmers do not use AppleScript. For other languages such as Objective-C, C, C++, etc. the problem is not the same as their programs are ordinarily compiled before they can run, and in the process of compilation they are translated into a non-human readable form.

Some implementations of languages do not exhibit this behaviour - for example ordinary PHP scripts are interpreted or compiled at run-time. For PHP, Javascript, etc. you can buy obfuscators that helps "masking" or "hiding" the original source code while allowing the program to run.