June 05, 2019

Python vs Forth


The main difference between Forth and Python is located on the number of preinstalled libraries. The surprising fact is, that Python is at first time a beginner friendly language and at the same time, the amount of predefined library is gigantic. Which means, that the newbie has to memorize a large corpus of Python modules. According to https://docs.python.org/3/library/
“Python’s standard library is very extensive, offering a wide range of facilities as indicated by the long table of contents listed below. “
And the self-description is right. Even the Python standard library provides a huge number of built-in functions. Additionally all the external python modules have to be added. In contrast, Forth doesn't provide anything. That means, the Forth 2012 standard provides a limited wordset and addtionally library are simply not there. This is the main reason, why Forth is perceived as a newbie unfriendly language. The question is not if a tab-based Python syntax or a stackbased Forth syntax is the better approach, the more important question is if the programmer needs a large library or not.
Let us take a look into the Python standard library. On the first look, it is very equal to the Standard-C library. The difference is, that the Python library has a larger volume. The huge amount of predefined statement is the main reason, why the example Python programs at rosettacode are very compact. Most impressive demonstration how powerful Python is, are starting with an import statement and then a library function is executed which is already there. An example is given in the subsection about the gzip function https://docs.python.org/3/library/gzip.html The user needs only 3 lines of code to open a compressed file. He is not programming the routine itself, but he utilize the predefined functions. The same is true for HTML related task. Python comes with a large amount of library functions which are created for parsing HTML data. That means, the user is not forced to program anything, but he imports a library and python will do the task.
This kind of behavior is not located in the Python language itself. It has to do with the library which is hidden in the Python environment. The amount of predefined library function is larger and they are well documented. This makes Python a powerhouse for newbie programmers. The surprising fact is, that the amount of vocabulary is large. We can only speculate if 100k or 500k different functions are available already. For each purpose, Python knows a dedicated word. This makes the programming easier.

No comments:

Post a Comment