fig educational programming language

Posts: 148
figosdev
Joined: 29 Jun 2017
#1
(featured in the first distrowatch weekly from this year.)

how to install:

mkdir fig29-31 ; cd fig29-31 ; wget
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://distro.ibiblio.org/refracta/files/extra_packages/fig29-31_1.0.deb"
linktext was:"http://distro.ibiblio.org/refracta/file ... 31_1.0.deb"
====================================
; sudo dpkg -i fig29-31_1.0.deb ; cd ..


how to examine:

mkdir fig29-31 ; cd fig29-31 ; wget
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://distro.ibiblio.org/refracta/files/extra_packages/fig29-31_1.0.deb"
linktext was:"http://distro.ibiblio.org/refracta/file ... 31_1.0.deb"
====================================
; dpkg-deb -x fig29-31_1.0.deb . ; find # will unpack all files, but wont install

(note the complete lack of package contents that conflict with anything; documentation and some python scripts.)


what it is:

fig is a language i developed after trying to teach basic (or python or bash) to people that werent very interested in coding. its a language for teaching people you would like to understand coding, but arent very committed to it-- absolute beginners with short attention spans.

(do i actually use fig for this? yes, most recently i helped someone who had never learned to code learn fig, he said it was"very accessible" despite his lack of experience. i also use fig to try to encourage people to learn to code, and even to design small programming languages.)

fig takes successes from making coding easier from the 1960s (basic) and the 21st century (python) and tries to make coding easier still-- without going all the way towards drag/drop block programming. fig is also a language for performing real computing tasks, not just animation or arbitrary lessons or fun silly nonsense; but it can be used for all of those. (for animation its pretty weak.
on a gnu/linux system fig has no requirements other than python 2. an experimental version exists for more recent versions of python. fig has an inline python feature; it is a translator implemented in python that outputs python scripts that are ready to run. obviously the inline python feature is specific to the major version of python it runs on.

beginner-unfriendly features that fig mitigates:

* large boilerplate for things like pygame, abstracted to simple pset/line commands. small boilerplate for simple things like stdout.write and math.cos abstracted to simple commands like prints and cos.

* fig is not case sensitive. case sensitivity throws off a lot of people. this is a beginner friendly language and some of those are case-sensitive, some are not

* fig does not care about indentation (except regarding inline python.) if youre a python fan, you probably love indentation; so do i. fig uses keywords to end blocks, like bash often does.

* fig requires far less punctuation/syntax (though it is optional) and parses left-to-right, making a programming language that is more like english in structure; it is not a"natural language paradigm" like applescript, but closer to basic or python in command structure.

* fig has < 100 commands. it does far, far more than most people learning python for the first time, and it does it in a way that is easier.

* fig comes with a full manual/tutorial that really needs to be rewritten to be more friendly or simple. its not terrible (except the introduction which can be skipped) but its"too complete." (really, it is.)

the package is larger than i thought because of a single large gif file that i wish wasnt included. that one unnecessary file brings the package closer to 1mb and fig 2.9 is < 60k in size. the pdf manual is only 164k.

since antix includes python, the only file actually needed is fig29.py, which translates source files to python.

* variables / arrays (a special version of fig with dictionaries added exists.)
* locate and term color commands implemented in ansi (works in os/x and gnu/linux and bsd; also windows if colorama library is installed OR ansi.sys is configured)
* pset/line commands use pygame if it is installed, otherwise emulates graphics using ansi and unicode 9608
* a separate/public domain circle routine exists (implemented in fig)
* built-in trig functions based on math.cos etc
* conditionals, for / forin / while loops, basic error trapping using try/except/resume
* user-defined functions
* string functions inspired by python, but uses left right mid commands instead of slices
* (slices available via inline python)
* only required syntax:"strings in quotes" # hashes for comments plus obviously float: 5.8

function funcname param1 param2 etc
# function has python scope
now = param2 ; print # semicolon is optional; so is equals
ifequal param1 param2
x"p1 and p2 are equal" print
fig
fig

p funcname 2"hello" 5.7 # call funcname as sub ; would change value of p if return command used

"but i like syntax"

ok, this works:

Code: Select all

# public domain
function funcname(param1, param2, etc):
    # function has python scope
    now=param2 ; print # semicolon is optional; so is equals
    ifequal(param1, param2):
        x ="p1 and p2 are equal" ; print
        fig
    fig

p=funcname(2 ,"hello", 5.7) # call funcname as sub
other advantages over python for"real work":

* less elaborate setup for calling shell commands:

p"nano figexample.fig ; leafpad figexample.fig" shell # run nano

filelist"find -type f 2> /dev/null" arrshell # put output of command into array"filelist"

arropen command:
p arropen"figexample.fig" # file is now in array

arrcurl:
p arrcurl"
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://antix.freeforu ms.org"
linktext was:"http://antix.freeforu ms.org"
====================================
" # html page is now in array



program that creates the sphere graphic:

Code: Select all

#### license: creative commons cc0 1.0 (public domain)
#### http://creativecommons.org/publicdomain/zero/1.0/
function rgbcolour r g b c
python
    figcgapal[c] = (r, g, b)
    fig
    fig
v 1
c 400
w 3.14159 divby 2
function radians a
    x a  times 3.141592653589793  divby 180  return x
    fig
for r  490 110 -.50    
    e w  minus 0.00413367105263  swap e w  # 3.14159 / 4 / (490 - 300)
    for p 1 360 .5
        e w  cos  times 380  divby 1  int
        rc r  divby 2  int
        rd 256  minus rc  rgbcolour rc 0 rc 11
        x p  radians x  times 2  cos  times e  plus c  int
        y p  radians y  times 2  sin  times e  plus r  minus 50  int
        m 6.28  plus 1.57  divby 108.503  divby 2
        now v   plus m     swap now v
        rc r    #divby 4   int  mod 2
        iftrue rc
            now v  times 2  int  mod 2  times 11  pset x y now
            y2 y   minus 1                        pset x y2 now
            fig
        next
    now display
    next
now display  lineinput