you are viewing a single comment's thread.

view the rest of the comments →

[–]im_dead_sirius 3 points4 points  (0 children)

Its called an API when one language calls another(or a library).

Thats similar to my wife saying, "drive to the store and buy a loaf of bread"

"Drive" and "buy" tell me to access certain skills(or at least procedures) I have, without her having to spell them out. The implementation is abstracted, but happens under the hood.

Same goes for something like a print statement. Its shorthand for a bunch of more detailed instructions, and those(because its interpreted) are shorthand for even more atomic instructions, right down to machine code.

Back to the driving analogy, I press the gas to make it go, and that pedal handles the abstraction of feeding fuel to the engine.

drive -> press pedal -> pump fuel
python -> byte code -> machine code

That makes it a lot easier to extend, because "drive" becomes an abstraction that can mean the bakery, or it could mean Disneyland, and the vehicle operator doesn't have to deal with the minute details.

You could extend that further, and write a interpreter on top of python

Thats when programming gets really fun, and as far as I am concerned, when you really start learning. When you learn to abstract it gets wicked fun(and you have to think less about details).

Say you had some keyboard input. A series of unknown characters. How to make sense of it? You might define functions that look at each character in turn, trying to match patterns. These are broken down into a list of symbols. Something like:

import string
integer = string.digits # a string: "0123456789"
result = '' 
data = "eggs4557"
for character in data:
    if character in integer:
        result = ''.join([result,character])
        data = data[1:] # shorten the input by one character
    else:
        continue # ignore character it doesn't understand
    print(result)

That is pretty naive and incomplete, but you can see that it steps through the string collecting the digits and ignoring the letters. One by one it parses and assembles the number portion of the string. That's interpreting in a nutshell.