If you have no interest in Python yet, you don't actually need this chapter. Think of it as "extra credit,” but definitely don't worry if Python seems too complicated.
A few months of coding in any language should make learning Python easier, and there are better intros to the language than this one; this one is just made for people comfortable with fig.
If this chapter only started with what makes Python different than fig, you might think Python is either pure genius (it basically is) or that it makes things more difficult than necessary (it sometimes does.)
Python is a little closer to what you should expect from most languages than fig is. Fig was designed specifically to round off (some might even say cut) as many corners as possible. Today, most languages are case-sensitive, Python has to be indented just so, and while fig
has a "main variable” at the beginning of most lines, Python requires that you at least set every variable to something before you can reference it.
Fig COULD automatically return 0 for any variable referenced, even if not used already. Since most modern languages don't do this (and even have a good argument against it) Fig uses its main variable concept instead, which has the following features:
* It makes it obvious what variables are used in a
* It zeroes unused variables in a way that is less
work than Python, but relatively compatible with
most modern languages-- it is minimalist yet still
* It works like a "named pipe,” (a concept in Unix-
like operating systems) where a number of built-in
functions can reference and change the contents of
a stream of data implicitly:
- Code: Select all
x arropen "file.txt" | join x " " | ucase | print
works kind of like this command in GNU/Linux:
- Code: Select all
x=$(cat file.txt | sed 's/\n/\ /g' | tr a-z A-Z) ; echo $x
The pipes: | in fig don't change the way that fig works, they are simply a substitute command separator for Python's ";" or Basic's ":".
Fig is therefore also a simple (sort of) introduction to coding in Bash. Although it barely
is the case, the main variable functionality does transition a little to using pipes in Bash.