How are the programs in /bin directory compiled into a non-readable format?

Solution 1:

The commands/programs in /bin are not non-readable, but they are, as you say, compiled. This means that they were originally written in C (or some other programming language) and have been compiled to machine code (binary) so the processor can execute the code. To do the same, simply write the program you need in C and run the gcc command to produce an executable file.

To print any human readable text in a files use strings < /bin/file,

Solution 2:

Introduction

When a program is compiled from say C or C++ source code, a compiler such as gcc (see below) translates that code into the native binary language of the CPU, so that the program can be executed. Thus human readable material (source code) is turned into a non-human readable format (machine readable binary code).

Binaries and the Filesystem

If you enter echo $PATH, you will see a locations of all the executables on the system, both compiled binaries and scripts:

/home/mike/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

In the filesystem hierarchy key system tools such as cat and getty are present in /bin and /sbin respectively, and other tools such as dpkg and chroot are present in /usr/bin and /usr/sbin respectively. If you compile a program by downloading the source code, configuring the build, and the installing it, your program by default should go in /usr/local/bin and its other files in the /usr/local hierarchy.

Compilers

Probably one of the most well known tools used to compile binaries is gcc, which is known as the GNU Compiler Collection and earlier as the GNU C compiler; the version shipped with Ubuntu 12.04 is gcc 4.6.3. As it notes in the offical GNU manual,

GCC is an integrated distribution of compilers for several major programming 
languages. These languages currently include C, C++, Objective-C, Objective-C++, 
Java, Fortran, Ada, and Go.

Compiling a binary

The three commands ./configure, make and sudo make install (or sudo checkinstall) are often used together in order to compile a program.

Running ./configure, amongst other things, checks the version of gcc installed and prepares the build environment. The makefile is one of the most important things generated from running ./configure as it directs the build when make is run. The GNU make manual details the process in great depth. In sum, the rules in the makefile determine the main goal (to create an executable) so that the source code .c files will be made into compiled files (.o files) in order to generate the target executable file.

Resources

Two great resources are these Ubuntu compilation guides here and here, which contain some great advice and information for those new to compiling. Other resources such as the GNU gcc manual and the make manual I have mentioned already. For more information on C and creating a simple little C program, see chapter 22 of Rute and chapter 24 of the Linux Command Line.

Solution 3:

To compile Bash programs into binaries ( I'm assuming you're asking about Bash because your question is tagged bash) you should use the program Shc. You can download it from here. After you unpack the archive, compile and install shc with cd shc-3.8.9;make;sudo make install. Now, run shc -f filename, where filename is the path to the file you want to make into a non-readable code format. Shc will create two files: filename.x.c and filename.x. You can get rid of filename.x.c, filename is the non-readable file.