Showing posts with label Rafe Habedank. Show all posts
Showing posts with label Rafe Habedank. Show all posts

Sunday, January 29, 2017

Computer Science: Programming languages

-Programming Languages: How humans interact with computers


Python

Java













Fortran
C












    Computers at their most basic level are machines that take an input and give an output accordingly. What happens in between the intake of information and the output of a result is where I like to call where the "humanity" resides in a computer. In the form of programs we can bring computers to life to preform tasks limited only by our ability to command them. It truly is an art form.

    Programs at their most basic level are sets of instructions that can be understood by a computers hardware to make it preform a task. That's where a kink comes in. Computers cannot understand human languages so to speak. Their processing structure only allows them to work with command values that direct finite operations to data. An example of this would be to add a value to another value in memory or to move a piece of data to a new memory location. These control values take the form of binary numbers of a specific length that are run about a billion per second through the computers CPU. In other words, its impossible to directly put a language like English into a computers processing unit.

   But don't despair! There is a solution. Programming languages that make our lives many times easier. These Languages are not directly person speak per-to-say but they are definitely not 8 bit command codes. They are in a place in between that composes of special jargon and syntax that is later translated into information that computers can understand. Some are more "low level" languages that allow you more direct control of the computers direct hardware. Example of lower level languages would be C and its variants. "High level" languages are closer to human languages and logic. This allows for greater focus on the big picture when programing while sacrificing some control and potential performance improvements. Some examples of Higher level languages would be Python and Java.   

     Programing languages come in many flavors for different purposes. It is impossible to create a one size fit all programing language without creating a bloated mess. David Evans explains this quite nicely in his "Introduction to Computing":


"Programming languages come in many flavors. It is difficult to simultaneously


satisfy all desired properties since simplicity is often at odds with economy. Every

feature that is added to a language to increase its expressiveness incurs a cost

in reducing simplicity and regularity."
   


    Its many times more effective to create programing languages to fit more niche purposes. I would never even dream of using C++ to script web applications. Creating a console application to do my math homework is a much better fit due to its lower level nature. If you want to create web pages HTML, CSS, and JavaScript will serve you well. If want a general purpose language for doing a multitude of useful things, Python and Java are good fits for the bill. If you want bleeding knife edge performance and don't mind losing most of your sanity C, C#, and C++ exist for things like scripting video games and other things that need to go as fast as possible.  If you have a interest for computers in the 1980's BASIC is nice to know.


   One main thing that separates programing languages is how they are read by the computer. They are either compiled or they are interpreted. A compiled language is put into a compiler which reads the program line by line and converts it into information that the computers CPU can run. C, C++, and Java are examples of this. Actually, to be technical Java compiles to run on the JVM(Java Virtual Machine) which is a program that communicates with the CPU. Java is like this so you compile it once and it will run on any JVM whether it is on a PC or a cell phone. Interpreted languages read short portions of the code you write and compile them real time. This allows you to inspect your code as you run it, but it also slows it down. It also requires a compiler to be on the machine you plan to run you code on. An example of an interpreted language would be Python.


    In this blog post you learned what a programing language is, what it does, why they exist, and some real life examples of what some could be used for. If you have any desire to learn a programming language I implore you to go out and seek out the knowledge you desire. There are many fantastic books on how to program in different languages. Some are even free online.
But know when you run into a problem or something you cannot seem to figure out, know that programming requires you to think a little differently. And know that it a good thing.


#import<iostream>


using namespace std;


int main
{


     cout << "This is Rafe Habedank signing out!" << endl;


     cout <<"Also, if you have any questions leave a comment below!" << endl;
     return 0;
}


Citations:
Evans, David. Introduction to Computing: Explorations in Language, Logic, and Machines. N.p.:   n.p., 2011.




























Computer science: Mathimatics and Logic





-How computers use Logic: A mathematical approach-

    For a computer to preform meaningful work it has to use some sort of structured way of preforming logic. All things that can preform logic do this. 
Everything from a $3 calculator to the human mind has a methodology of manipulating the information given to it.

    When building a computer that preforms logic based on mathematical calculations the logic behind those calculations are ideally based on math, like how a humans logic of what action to take is based upon the prominence of previous memory's relating to that action.

    Modern computing devices are based upon a few simple mathematically based logical operations that are combined to preform more complex tasks. we call this logic Boolean logic after it's creator in 1854, George Boole. The logic is not directly tied to a medium of computation, only to the methodology. Anything from electricity, to bottles of wine and buckets can use Boolean logic if structured properly.

    In the following examples taken from the book: Introduction to computing by: David Evans, wine is used as an example medium to demonstrate a simpler abstraction of the logic.


"To implement logic using a machine, we need physical ways of representing the



two possible values [true and false]. We use a full bottle of wine to represent true and an empty
bottle of wine to represent false. If the value of an input is true, we pour a bottle
of wine in the input nozzle; for false inputs we do nothing. Similarly, electronic
computers typically use presence of voltage to represent true, and absence of
voltage to represent false.


And. A logical and function takes two inputs and produces one output. The
output is true if both of the inputs are true; otherwise the output is false.



One way to do this is shown in Figure 6.1. Both inputs pour into


a basin. The output nozzle is placed at a height corresponding to one bottle of
wine in the collection basin, so the output bottle will fill (representing true), only

if both inputs are true."(Evans 109)





Figure 6.1: Computing AND with wine





Truth Table for AND:

   A   |   B   | (and A B)
-------------------------
false |false | false
true  |false | false
false |true  | false
true  |true  | false





    The machine above would likely not operate perfectly, some of the wine would likely spill causing the output to not be completely full. To solve this problem we use Digital Abstraction to define the bottle. We could say if the bottle is more than half full it counts as a full bottle. This removes the possibility of infinite possible outputs of a system based in an imperfect reality. An example of Digital Abstraction in modern computers would be the abstraction of if there is electricity present in a part of a circuit, the circuit is representing True.


    Digital Abstraction provides a link between the physical world and the world of discrete values that exists with mathematical logic. It is much simpler to work with these discrete values than with infinite variable ones when mathematical logic is used.


OR: returns true if one of the input values is true.


NOT: The output of not is the opposite of its input value.



Computing NOT with wine



Computing OR with wine






 













    The best part of the 3 basic logical operations is their ability to be combined to preform more complex tasks like addition, subtraction, multiplication, and division of many true or false input values. These structures can then be assembled into an  Arithmetic logic Unit that is the heart of a computers CPU that enables it to manipulate data. If I were to get into exactly how one could design and combine these structures this blog post would be many pages long.




   In this blog post you have learned the basics of how computations are based on mathematically defined logic that uses Digital Abstraction of real world values to return a result. The structures that preform this mathematical logic can be combined to form more complex structures that can preform more complex tasks using true or false input data.


   Knowing how the things around me functioned at the most basic level has always fascinated me since i was a young child. There is always a new level of understanding that can be attained about anything in life. I implore you to go out and ask yourself, what can a learn from this?





Source:
Evans, David. Introduction to Computing: Explorations in Language, Logic, and Machines. N.p.:   n.p., 2011.
page(s): 108-116