09.07.2015 Views

Prograph: A Visual Programming Language

Prograph: A Visual Programming Language

Prograph: A Visual Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Prograph</strong>: A <strong>Visual</strong> <strong>Programming</strong> <strong>Language</strong>David Heise & Tomas Joynerdheise@cs.byu.edutomasjoyner@yahoo.comEECS 330: Introduction to <strong>Programming</strong> <strong>Language</strong>sFall 2004


<strong>Visual</strong> <strong>Programming</strong> <strong>Language</strong>s:For years, programmers have interacted with their computers via a command prompt.Programs were run, and windows were opened, one line at a time. Then came the revolution.When a GUI was applied to an operating system, things began to change. The visualrepresentation of file structures became more relevant. Navigating the system and its commandsbecame trivial. People who ten years before would not even approach the seemingly magicalbox were now classified as “users”. As a direct result of the GUI upgrade, the computer hasbecome a staple in every home.There is a similar tremor in the waters of the programming world. Often, when handed aproblem, a programmer first determines a sort of flow chart for the program's functionality. Theprogrammer must then translate the visual concept into textual code. This mapping typicallyproves difficult due to “the use of a one-dimensional textual formalism to represent a multidimensionalprocess” [1] . The solution in the works is <strong>Visual</strong> <strong>Programming</strong> <strong>Language</strong>s. LikeWindows to DOS, so is <strong>Visual</strong> <strong>Programming</strong> to traditional text-based languages.There has been theoretical work on <strong>Visual</strong> <strong>Programming</strong> since the late 60's. Some of thethinking of yesteryear has come to fruition in the form of GPL, LabVIEW, APPWare, and<strong>Prograph</strong>, among others.A Brief History:As with the creation of most <strong>Visual</strong> <strong>Programming</strong> <strong>Language</strong>s, <strong>Prograph</strong> was formed withthe intent of making programming easier for the programmer. <strong>Prograph</strong> graphically shows datamovement. In this respect it differs from languages such as C and Java, whose focus is on controlpassing – that is, stepping through a series of commands.


<strong>Prograph</strong> was conceived in 1983 as the brainchild of Tomasz Pietrzykowski and Philip T.Cox. While Pietrzykowski soon moved on to other projects, Cox stayed with the languageadding improvements over the years. In '85 <strong>Prograph</strong> was distributed with the additional featureof a compiler. When Object-Oriented <strong>Programming</strong> became the big buzz, Cox announced theadvantages of <strong>Prograph</strong>'s modularity and Object abilities.<strong>Prograph</strong> hit the markets and was used for various applications, though primarily distributedon the Macintosh. Games, HTML editors, and spreadsheets have all claimed primary usage ofthe graphical language. Businesses also turned to <strong>Prograph</strong> for some in-house applications.Today <strong>Prograph</strong> is dead. <strong>Programming</strong> software for <strong>Prograph</strong> is still existent, and sold, butthe language has grown stagnant. Pictorius, the primary distributor of <strong>Prograph</strong> (with Cox at thehead), went under in 1996.The <strong>Prograph</strong> <strong>Language</strong>:<strong>Prograph</strong> is a functional language. It's data flow can becompared to Scheme's (or any other functional language) withthe primary difference that the programmer does not have tokeep track of parenthesis. <strong>Prograph</strong> use is simple: data isrepresented with lines and methods are various boxes. Each boxFigure 1 – A Simple “HelloWorld” Program in <strong>Prograph</strong>contains nodes for inputs (terminals) and outputs (roots). <strong>Prograph</strong> methods have more than justvariable arity; they also have output arity. The methods have an I->O mapping from one or moreinputs (I) to one or more outputs (O).The data in <strong>Prograph</strong> is passed by value. This enables several methods the use of a singleoutput from another method. These receiving methods can then be run in parallel without one


method altering the data in another. This feature will find its usefulness if ever the von Neumannmodel for parallel processing is upgraded to its more visionary counterparts.Heretofore, method inputs and outputs have been referred to as data as opposed tovariables. Strictly speaking, <strong>Prograph</strong> does not have variables. Inputs and outputs are namedonly as a convenience to the programmer. A consequences of this is lower overhead for amethod's environment (if there are no variables, there is no need for an environment). Scoping,in this context, becomes irrelevant.Object-Oriented <strong>Programming</strong> comes naturallywith <strong>Prograph</strong>'s modularity.A class is defined just asreadily as a persistent, and is still visually expressive. Aclass contains methods and variables. In this case,variables are simply persistents with another name.Inheritance is easily shown via a line from the parentFigure 2 – Classes and Inheritance. Classes athrough e are depicted and inheritance isshown bottom to top (i.e. class e inheritsfrom class c which inherits from class a)class to the child class.Learning to use <strong>Prograph</strong> is time consuming. After getting acquainted with the graphicalnature of the language, the programmer must then prepare for the challenge associated withlearning the variety of constructs. On top of that, some universal constructs (such asconditionals) have their own <strong>Prograph</strong> version that requires attention. The conditional, forexample, has 16 different possible implementations.The greatest disadvantage of programming in <strong>Prograph</strong> is the challenge of all <strong>Visual</strong><strong>Programming</strong> <strong>Language</strong>s: spaghetti code. For a simple program with 15 methods, each withthree inputs and three outputs, the potential for readability loss is great. This difficulty isovercome with experience. In practice, <strong>Prograph</strong> is quite readable (perhaps “viewable” would be


more descriptive).Constructs and SyntaxIn <strong>Prograph</strong> there exits 9 basicconstructs, 6 external constructs, 4 mainconstructs, and 10 control constructs. Theseconstructs, in addition to the other symbolsand cases, provide the ability to program asin any other language. The four mainconstructs are named: section, universal,class, and persistent. These are the overallconstructs that allow for creation ofFigure 3 – Some <strong>Prograph</strong> Constructsprograms. Sections consist of universals,classes, and persistents. Universals aremethods (i.e. functions, procedures, subprograms). Classes, as in other languages, are datastructures that allow for the combining of data and the methods that operate on that data. Classesconsist of methods and fields. The class methods and fields are essentially the same as universalsand persistents respectively. Persistents are most similar to global variables in most otherlanguages; however their data persists from run-time to run-time such that the data retains itsvalue until changed or the entire process is destroyed.Methods (whether class methods or universals) consist of the remaining 15 constructs.The basic nine constructs are: simple, constant, match, persistent, instance, get, set, local, andevaluate. These constructs provide for the main program execution and are at the heart of


corner rectangle, is simply a call to another method. There are five additional graphicalannotations to a simple, not including control symbols, which reveal additional informationabout the method call. A bar under the method name indicates that the method call is to aprimitive. A bar over the method name indicates that it is to an external method call (i.e. from aDLL, or external program of some sort). A single slash before the method name indicates that themethod is a class method and <strong>Prograph</strong> will determine the proper method to call from theinstance that is required as the leftmost root. A double slash before the method name indicatesthat the method is context-determined thus, for instance, the method might be another methodwithin the same class. Also an up arrow next to the simple indicates that it is a call to a classmethod of its parent class (i.e. super).A Constant construct, denoted by the constant value with a bar and a root underneath,allow for constants as in other languages. A Constant value can be any valid value and will beautomatically typed.A Match construct, denoted by a terminal and bar over a constant value and nearlyalways with a control construct to the right, allow for if statements. A match will attempt to see ifthe data input is the same as the constant supplied. Depending on the control operation associatedwith the match, they may do as the control indicates (controls will be discussed in further detaillater in this discussion).Persistent constructs access the value of the persistent (i.e. global values). It has at mostone terminal and one root, to allow for both reading and writing to the persistent.Instance constructs create an instance of the class. It has one terminal and one root. If novalues flow into the terminal then the class is initialized with no parameters, however thepermission of the terminal indicates that class constructors can take inputs.


Get and Set constructs allow for reading and writing of class attributes. Both constructstake in an instance into its terminal, and an instance out of its root. The Get has an additional rootto provide for the data requested, and the Set has an additional terminal to provide for the storageof the requested data in the requested attribute.Local constructs allow for grouping of a section of code into a single graphical element.This provides for a better view of the program as Locals allow for better space management ofthe development environment, which is identical to the expensive silicon real estate in circuitdesign.The Evaluate construct provides mathematical expressions into the language. AnEvaluate has one root, and as many terminals as desired. The expression uses the alphabet (caseinsensitive ‘a’ to ‘z’ only) as designations for terminals within the expression. For example theexpression “a/b+c” would have three terminals, starting on the left with a, then b in the middle,and c on the right. The Evaluate will have as many terminals as letters used, however letters mustbe used in alphabetical order (i.e. using the letter x will automatically make 24 terminals to theEvaluate construct). The expression may contain the following mathematical operations: @(exponentiation), + (binary and unary addition), - (binary and unary subtraction), *(multiplication), / (floating point division), // (integer division), % (remainder from integerdivision), & (bitwise AND), | (bitwise OR), ^ (bitwise XOR), ~ (unary bitwise NOT), > (bit shift right).The External constructs simply allow the Simple, Constant, Match, Persistent, Get, andSet to reference external data stored in a DLL, etc. In addition to these there is also an ExternalAddress construct that takes an external structure as input and returns a pointer to that structure.The External Persistent is called External Global to point out the differences between a <strong>Prograph</strong>


Persistent and the idea of Global variables in other languages.The Controls in <strong>Prograph</strong> allow for change of the control flow based on how constructsterminate. The most common use of controls is on a Match construct. The logic for the control isdenoted by a check or an x beside the construct. Also a control will dictate what course of actionshould be taken upon a successful check: Next Case, Terminate, Finish, Continue, and Fail. Thecheck indicates that it is true, while the x indicates it is not true. For example say we have aMatch named “STRING” with a check next to the name. If the input into the Match is also“STRING” then it would do the appropriate action dictated by the control (i.e. Fail, Continue,etc). The control action directs the program execution. The Next Case action will cause themethod to execute the next case with its current inputs and is depicted with a rounded boxaround the check or x. The Terminate action will cause the method to immediately end executionwith a successful result and is depicted with rounded box and a bar above the check or x. TheFinish action will cause the method to complete the current case then immediately end executionwith a successful result and is depicted with a rounded box and a bar below the check or x. TheFail action will halt the current method and send a fail signal to the calling method and isdepicted with a circle around the check or x. The Continue action will cause execution tocontinue in the current case and is depicted with a rounded box and a bar above and a bar belowthe check or x.In addition to the aforementioned constructs, individual constructs can be connected by aDatalink and/or a Syncro link. A Datalink connects a root and a terminal depicting flow ofinformation. It is this depiction and functionality that make <strong>Prograph</strong> a functional language. ASyncro link directionally connects two constructs guaranteeing that start node will execute beforethe end node. Since any construct could execute at any time (and is chosen randomly at design


time), the Syncro link provides a way to have the traditionalimperative execution to the degree chosen by the developer.Other constructs not explained here include (but are notlimited to): Repeat annotations (construct is repeated until a fail,Figure 5 – Syncro Links; awill run before both b andc; both b and c will runbefore d, but no guaranteeabout the order ofexecution for b and cterminate, or finish signal is sent), List annotation (construct willapply itself to every member of the list), Loop annotations(construct is repetitively called with the outputs sent as inputs tothe next iteration), Partition annotations (splitting a list based on Boolean criteria), and the Injectcontrol (allowing for the name of the operation to be supplied at run-time).T ypesIn <strong>Prograph</strong> there exist the following types: boolean, integer, list, none, null, point, real,rectangle, rgb, string, and undefined. Boolean values are denoted and displayed as TRUE orFALSE (case sensitive). Integers consist of traditional signed integers (2^32), a number of anybase (i.e. a binary number 2#10010101), and a 1, 2, or 4 byte ASCII character sequence. A list isidentical to a list in scheme or lisp with a limited number of elements (2^16 - 1 in the interpreter,and 2^32 -1 in the complier). The none type is used by <strong>Prograph</strong> to depict a type when a terminalis not connected to a datalink. The Null type indicates no value on a root or a class attribute. Thepoint type is two integers enclosed by curly brackets (“{}”) and separated by a space; itrepresents the coordinates for a two dimensional point in space. Reals are the same as traditionalreal numbers allowing for values from -1.1E+4932 to +1.1E+4932. A Rectangle type depicts thecoordinates for two points defining the upper left and lower right corners of a rectangle; this typeis like a point but with four values instead of two. The RBG type indicates a color denoted by the


ed blue and green values that compose it; this is similar to a point but with three values. A stringin <strong>Prograph</strong> consists of any sequence of typeable characters limited in length to the sameconstraints of the list type. Finally the undefined type is another internal type used by <strong>Prograph</strong>when an operation/construct is skipped during execution.Types may be specified on roots and terminals, but are not required. In addition to theaforementioned types, the specified type may also be: pointer, direct, a class name, a list oftypes, or “” (which indicates that the type must be of the same class the method is in). Formore exact specifics on type definitions see the BNF of the data types in the appendices.ConclusionLike all languages, <strong>Prograph</strong> has its positive and negative aspects. It provides an easyway to depict programs following a flow model, and the translation from flow chart to code isvery simple, as code is just as graphical as the flow chart. One of the biggest disadvantages of allvisual languages is the longer than normal learning curve that a programmer must go throughbefore becoming proficient in the language. Also to <strong>Prograph</strong> specifically, it is a dead languagein that it is not widely used and as a language is not being developed. However <strong>Prograph</strong>, withother visual languages, provide for a new dimension to traditional programming not foundelsewhere.


Appendix A: Type BNF ::= | ::= | | ::= any string which is not a ::= | | | | | | | | | ::= any other than FALSE, TRUE, NULL, UNDEFINED, orNONE ::= FALSE | TRUE ::= NULL ::= UNDEFINED ::= NONE ::= () ::= | |::= | | ::= { } ::= { } ::= { } ::= any nonempty string of characters whose ASCII values are lessthan or equal to that of blank ::= " | "" ::= any string of characters, except "::= | ::= | ::= any nonempty string of characters having ASCII valuesgreater than that of blank except those included in::= ::= | | ::= ::= | _ | ::= # ::= | | | ::= a | b | c | d | e | f | g | h | i | j | k | l |m | n |o | p | q | r | s | t | u | v | w | x | y | z | A | B |C | D | E | F | G | H | I | J | K | L | M | N | O | P |Q | R | S | T | U | V | W | X | Y | Z | _ ::= '' | '' |'' ::= any string of characters having ASCII values greater thanthat of blank, except ' | ' '::= ::= | . | . ::= | E | ::= - | - | ::= | ::= ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ::= the empty string


Appendix B: Primitives by CategoryBitbit-and bit-not bit-orbit-shift-l bit-shift-r bit-xortest-all? test-bit? test-one?Callbacksdispose-method-pointermake-method-pointerCOMCOM-create-object COM-dispose-objectDatacopy get-resource-info get-resource-listget-string-resource inst-to-list list-to-instshallow copyFileclose create deletefile-size get-file get-positionopen put-file readread-line rename resource-fileset-position write write-lineGraphicsfind-bounds ints-to-point ints-to-rectints-to-rgb point-to-ints points-to-rectrect-to-ints rect-to-points rgb-to-intsInput/Outputaccept answer answer-vask display print-textselect set-dialog-font showInterpreter controlabortabort-callbackcompiled?debugcallexecutefind-methodhaltlookup-external-constant open-info-windowopen-method-window switch-to-prographtraceyield-cpuLists(in) (join) (length)attach-l attach-r detach-ldetach-nth detach-r find-instancefind-sorted get-nth insert-nthmake-list pack reverseset-nth set-nth! sortsplit-nthunpack


calls-to-get calls-to-meth calls-to-setchildren class-com class-sectionclasses create-class create-methoddescendants editor-methods meth-commeth-com-g meth-com-s meth-io-commeth-io-com-g meth-io-com-s method-aritymethod-classes method-section methodspers-com persistent-section persistentssection-com section-contents sectionsset-attr-com set-class-com set-meth-comset-meth-com-g set-meth-com-s set-pers-comset-section-comTypeboolean? instance? integer?list? external-type number?real? string? typeWin32get-application-instances get-application-main-windowget-command-line MakeIntResourceset-application-window


Appendix C: Optimus PrimeAs part of this project we wrote code in <strong>Prograph</strong> to implement the Sieve of Eratosthenes.This took quite a bit of work as learning <strong>Prograph</strong> was not as easy as learning new syntax, but itwas an entirely different way of programming. The following image shows the entire program:This code will be made available along with the freeware Prolog Windows Interpreter on


our website at http://students.cs.byu.edu/~dheise/cs330. The code is run by executing the method“start_Loop”. This will prompt the user for a number and then, using the algorithm, compute allthe prime numbers smaller than the given number. One draw back of the freeware interpreter isthe limited number of ways to show information to the user. The show primitive has a limitednumber of lines available to the user and going beyond this limit is possible, but futile since theuser cannot see that information. Therefore, although the algorithm correctly computes theinformation, the user can only see a limited number of results using the show primitive.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!