14.07.2013 Views

Visual Programming: Cooking the Spaghetti - GOTO Conferences

Visual Programming: Cooking the Spaghetti - GOTO Conferences

Visual Programming: Cooking the Spaghetti - GOTO Conferences

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Visual</strong> <strong>Programming</strong>:<br />

<strong>Cooking</strong> <strong>the</strong> <strong>Spaghetti</strong><br />

<strong>GOTO</strong> Chicago '13<br />

Rick Lane<br />

rick.lane@tradingtechnologies.com<br />

@R1ck_L4n3 @trading_tech @<strong>GOTO</strong>Chgo


First things first<br />

● <strong>Visual</strong> <strong>Programming</strong> < Regular <strong>Programming</strong> (usually)<br />

● But, <strong>the</strong>re's a time and a place<br />

● How to make it work, when it makes sense to work


Who I am<br />

● Chief technology officer at Trading Technologies<br />

○ TT makes software for professional traders around<br />

<strong>the</strong> world<br />

● Background in wargaming: terrorist<br />

network modeling and analysis, agentbased<br />

modeling, etc.<br />

● Many similarities between <strong>the</strong>se<br />

industries: a knowledge gap between <strong>the</strong><br />

idea generators and <strong>the</strong> technologists


Who I am not<br />

Lakin, Fred, <strong>Visual</strong> Grammars for <strong>Visual</strong> Languages, Proceedings of <strong>the</strong> American Association for Artificial Intelligence,<br />

Seattle, Washington, July 1987.<br />

Keywords and Phrases: visual grammar notation, declarative programming, visual rules, formal visual languages, informal<br />

conversational graphics, visual lisp, visual emacs, vmacs, VPL-IV.C: Parsing, VPL-VI.A: Formal definition of VPLs, VPL-II.<br />

A.7: Logic languages<br />

Pandey, Rajeev and Margaret Burnett, Is It Easier to Write Matrix Manipulation Programs <strong>Visual</strong>ly or Textually? An<br />

Empirical Study, 1993 IEEE Symposium on <strong>Visual</strong> Languages, Bergen, Norway, August 24-27, 1993.<br />

Keywords and Phrases: Forms/3, VPL-II.A.4: Form-based and spreadsheet-based languages, VPL-VI.C.1: Cognitive and<br />

user-interface design issues<br />

Burnett, Margaret M. and Allen L. Ambler, Generalizing Event Detection and Response in <strong>Visual</strong> <strong>Programming</strong> Languages,<br />

1992 Proceedings of Advanced <strong>Visual</strong> Interfaces International Workshop, Rome, Italy, May 27-29, 1992.<br />

Keywords and Phrases: Forms/3, VPL-II.A.4: Form-based and spreadsheet-based languages, VPL-III.A: Abstraction, VPL-<br />

III.E: Event handling<br />

● I am not a visual programming academic<br />

● There is a sea of research on <strong>the</strong> various forms,<br />

families, perils and merits of visual programming<br />

○ You won’t find any of that here<br />

Meyer, Bernd, Beyond Icons: Towards New Metaphors for <strong>Visual</strong> Query Languages for Spatial Information Systems,<br />

Proceedings of <strong>the</strong> International Workshop on Interfaces to Database Systems, Glasgow, 113-135, July 1992. (published<br />

by Springer, London, 1993).<br />

Keywords and Phrases: VPL-II.A.7: Logic languages, VPL-II.B.1: Diagrammatic languages, VPL-V.B: Database languages<br />

Yang, S. and M. Burnett, From Concrete Forms to Generalized Abstractions through Perspective-Oriented Analysis of<br />

Logical Relationships, 1994 IEEE Symposium on <strong>Visual</strong> Languages, St. Louis, MO, 6-14, October 4-7, 1994.<br />

Keywords and Phrases: Forms/3, VPL-II.A.4: Form-based and spreadsheet-based languages<br />

Hays, Judith G. and Margaret M. Burnett, A Guided Tour of Forms/3, Oregon State University, Dept. of Computer Science,<br />

TR 95-60-6, June 1995.<br />

Keywords and Phrases: Forms/3, VPL-II.A.4: Form-based and spreadsheet-based languages<br />

Burnett, Margaret M. and Allen L. Ambler, A Declarative Approach to Event-Handling in <strong>Visual</strong> <strong>Programming</strong> Languages,<br />

1992 IEEE Workshop on <strong>Visual</strong> Languages, Seattle, WA, 34-40, Sept. 15-18, 1992.<br />

Keywords and Phrases: Forms/3, VPL-II.A.4: Form-based and spreadsheet-based languages, VPL-III.A: Abstraction, VPL-<br />

III.E: Event handling<br />

Lakin, Fred, Computing with Text-Graphic Forms, Proceedings of <strong>the</strong> LISP Conference, Stanford University, August 1980.<br />

Keywords and Phrases: computing with text-graphic forms, visual pattern manipulation language, visual lisp, VPL-II.A.5:<br />

Functional languages, VPL-V.A: General-purpose languages, VPL-IV.D: Translators (interpreters and compilers)<br />

Cordy, James R. and T. C. Nicholas Graham, GVL: <strong>Visual</strong> Specification of Graphical Output, Journal of <strong>Visual</strong> Languages<br />

and Computing, 3, 1992.<br />

Keywords and Phrases: VPL-II.A.5: Functional languages, VPL-V.E: User-interface generation languages<br />

Graham, T. C. Nicholas and Tore Urnes, Relational Views as a Model for Automatic Distributed Implementation of Multi-<br />

User Applications, Proceedings of <strong>the</strong> Fourth Conference on Computer-Supported Cooperative Work, Toronto, October<br />

1992.<br />

Keywords and Phrases: VPL-II.A.5: Functional languages, VPL-V.E: User-interface generation languages<br />

Harvey, N. and J. Morris, NL: A General Purpose <strong>Visual</strong> Dataflow Language, Technical Report, University of Tasmania,<br />

October 1993.<br />

Keywords and Phrases: VPL-II.A.3: Data-flow languages, VPL-V.A: General-purpose languages<br />

Koelma, D., R. van Balen, and A. Smeulders, SCIL-VP: a multi-purpose visual programming environment, Proceedings of<br />

<strong>the</strong> 1992 ACM/SIGAPP Symposium on Applied Computing, 1188-1198, 1992.<br />

Keywords and Phrases: VPL-II.A.3: Data-flow languages, VPL-III.A.2: Procedural abstraction, VPL-VI.C.4: Scope<br />

M. Paltrinieri, A <strong>Visual</strong> Environment for Constraint <strong>Programming</strong> (Poster Paper), 11th IEEE International Symposium on<br />

<strong>Visual</strong> Languages, Darmstadt, Germany, September 5-9, 1995.<br />

Keywords and Phrases: VPL-II.A.2: Constraint-based languages<br />

Boursier, P. and M. Mainguenaud, Spatial Query Languages : Extended SQL vs. <strong>Visual</strong> Languages vs. Hypermaps, 5th<br />

International Symposium on Spatial Data Handling, Charleston, USA, August 3-7, 1992.<br />

Keywords and Phrases: VPL-II: Language Classifications<br />

Standing, C. and G. Roy, A Functional, <strong>Visual</strong> <strong>Programming</strong> Interface to Geographical Information Systems, Proceedings of<br />

OZCHI, Melbourne, Australia, 209-214, Nov. 28 - Dec. 1, 1994.<br />

Keywords and Phrases: VPL-II.A.5: Functional languages<br />

Schuerr, Andreas, Rapid <strong>Programming</strong> with Graph Rewrite Rules, USENIX Symposium Proc. on Very High Level<br />

Languages (VHLL), USENIX Association, 83-100, 1994.<br />

Keywords and Phrases: VPL-II.A.6: Imperative languages, VPL-II.A.8: Multi-paradigm languages, VPL-II.A.11: Rule-based<br />

languages, VPL-II.B.1: Diagrammatic languages<br />

Schuerr, Andreas, Introduction to PROGRES, an Attribute Graph Grammar Based Specification Language, Proc. WG'89<br />

Workshop on Graph<strong>the</strong>oretic Concepts in Computer Science, LNCS 411, (Nagl M., ed.), Springer Verlag, 151-165, 1989.<br />

Keywords and Phrases: VPL-II.A.6: Imperative languages, VPL-II.A.8: Multi-paradigm languages, VPL-II.A.11: Rule-based<br />

languages, VPL-II.B.1: Diagrammatic languages<br />

Glinert, Ephraim P. and Charles D. Norton, Novis: A <strong>Visual</strong> Laboratory for Exploring <strong>the</strong> Design of Processor Arrays,<br />

Journal of <strong>Visual</strong> Languages and Computing, Vol. 3, Number 2, 135-159, June 1992.<br />

Keywords and Phrases: Novis, VPL-II.A.1: Concurrent languages, VPL-II.B.2: Iconic languages, VPL-IV.A: Computational<br />

approaches, VPL-VI.C.6: <strong>Visual</strong> representation issues<br />

Burnett, Margaret M. and Allen L. Ambler, Interactive <strong>Visual</strong> Data Abstraction in a Declarative <strong>Visual</strong> <strong>Programming</strong><br />

Language, Journal of <strong>Visual</strong> Languages and Computing, 29-60, March 1994.<br />

Keywords and Phrases: Forms/3, VPL-II.A.4: Form-based and spreadsheet-based languages, VPL-III.A.1: Data<br />

abstraction, VPL-III.E: Event handling<br />

Schuerr, Andreas, A. Zuendorf, Nondeterministic Control Structures for Graph Rewriting Systems, Proc. WG'91 Workshop<br />

in Graph-<strong>the</strong>oretic Concepts in Computer Science, LNCS 570, Springer Verlag, 48-62, 1991. also: Technical Report AIB<br />

91-17, RWTH Aachen, Germany, 1991.<br />

Keywords and Phrases: VPL-II.A.6: Imperative languages, VPL-II.A.8: Multi-paradigm languages, VPL-II.A.11: Rule-based<br />

languages, VPL-II.B.1: Diagrammatic languages<br />

Schuerr, Andreas, PROGRES: A VHL-Language Based on Graph Grammars, Proc. 4th Int. Workshop on Graph-Grammars<br />

and Their Application to Computer Science, LNCS 532, Springer Verlag, 641-659, 1991. also: Technical Report AIB 90-16,<br />

RWTH Aachen, Germany, 1990.<br />

Keywords and Phrases: VPL-II.A.6: Imperative languages, VPL-II.A.8: Multi-paradigm languages, VPL-II.A.11: Rule-based<br />

languages, VPL-II.B.1: Diagrammatic languages<br />

Norton, Charles D. and Ephraim P. Glinert, A <strong>Visual</strong> Environment for Designing and Simulating Execution of Processor<br />

Arrays, 1990 IEEE Workshop on <strong>Visual</strong> Languages, Skokie, Illinois, 227-232, October 1990.<br />

Keywords and Phrases: Novis, VPL-II.A.1: Concurrent languages, VPL-II.B.2: Iconic languages, VPL-IV.A: Computational<br />

approaches, VPL-VI.C.6: <strong>Visual</strong> representation issues<br />

Carlson, Paul and Margaret Burnett, Integrating Algorithm Animation into a Declarative <strong>Visual</strong> <strong>Programming</strong> Language<br />

(poster paper), 1995 IEEE Symposium on <strong>Visual</strong> Languages, Darmstadt, Germany, September 1995.<br />

Keywords and Phrases: Forms/3, VPL-II.A.4: Form-based and spreadsheet-based languages<br />

Ambler, Allen L. and Margaret M. Burnett, <strong>Visual</strong> Languages and <strong>the</strong> Conflict Between Single Assignment and Iteration,<br />

1989 IEEE Workshop on <strong>Visual</strong> Languages, Rome, Italy, 138-143, Oct. 1989.<br />

Keywords and Phrases: Forms/2, VPL-II.A.4: Form-based and spreadsheet-based languages, VPL-III.B: Control flow<br />

Ambler, Allen L. and Margaret M. Burnett, <strong>Visual</strong> Forms of Iteration that Preserve Single Assignment, Journal of <strong>Visual</strong><br />

Languages and Computing, 1(2), Academic Press, June 1990.<br />

Keywords and Phrases: Forms/2, VPL-II.A.4: Form-based and spreadsheet-based languages, VPL-III.B: Control flow


Low-latency trading & VPL<br />

Communication Barriers<br />

Safety


Why I decided to build a VPL<br />

● I didn't! - I stumbled upon it<br />

● I was still learning <strong>the</strong> business<br />

● I had insanely aggressive deadlines (see: minutes)<br />

for writing and deploying production code<br />

It was built out of necessity


I got tired of <strong>the</strong>se guys yelling at me


Modules made my life easier<br />

Syn<strong>the</strong>tic<br />

Stop<br />

int qty = currOrderQty - _officialQty;<br />

if (qty > 0)<br />

{<br />

OrderProfileBase orderProfile = null;<br />

AutospreaderSyn<strong>the</strong>ticOrderProfile aop = null;<br />

if (currInstrument.IsASEInstrument)<br />

{<br />

//aop = new AutospreaderSyn<strong>the</strong>ticOrderProfile(currInstrument.OrderFeed,<br />

aop = TopMostAlgorithm.CreateAutospreaderOrderProfile(currInstrument, r<br />

orderProfile = aop;<br />

}<br />

else<br />

{<br />

orderProfile = TopMostAlgorithm.CreateAlgoExchangeChildOrderProfile(cur<br />

}<br />

Order<br />

Quoter<br />

Timed<br />

Hedge<br />

2-Legged<br />

Spread<br />

//orderProfile = new AlgoExchangeChildOrderProfile(currInstrument.Order<br />

AlgoExchangeChildOrderProfile algoExchangeChildOrderProfile = (AlgoExch<br />

algoExchangeChildOrderProfile.LeaveWhenPaused = leaveOnPause;<br />

algoExchangeChildOrderProfile.LeaveWhenCanceled = leaveOnCancel;<br />

if (IsFlagColorSet)<br />

algoExchangeChildOrderProfile.Color = flagColor;<br />

Market<br />

Maker<br />

Arb<br />

Routine<br />

orderProfile.Action = OrderAction.Add;<br />

orderProfile.QuantityToWork = Quantity.FromInt(m_CurrInstrument.Instrument,<br />

orderProfile.BuySell = m_Buy ? BuySell.Buy : BuySell.Sell;<br />

orderProfile.OrderTag = m_Flag;<br />

orderProfile.OrderType = m_OrderType;


But modules weren't enough<br />

● Bugs could still spell disaster<br />

● I wanted <strong>the</strong> traders to be in control<br />

○ Just piecing <strong>the</strong>m toge<strong>the</strong>r took work and<br />

programming know-how<br />

○ This "work" wasn't going to add any business<br />

value


The VPL was born<br />

● I built a GUI that let <strong>the</strong>m visually link <strong>the</strong>se modules<br />

toge<strong>the</strong>r<br />

● I didn't know I was building a VPL<br />

● Algo Design Lab (ADL)


The "Deutsch Limit"<br />

“The problem with visual programming languages is<br />

that you can't have more than 50 visual primitives on<br />

<strong>the</strong> screen at <strong>the</strong> same time.”<br />

-Peter Deutsch


The "Deutsch Limit"<br />

● The limit of 50 primitives is arbitrary<br />

● We rely on our IDE to help us solve this problem<br />

○ "Find References/Usages"<br />

○ "Go to Definition/Declaration"<br />

○ "Find in Files"<br />

○ Refactoring<br />

● Mental Map


The solution is threefold<br />

1. Domain specificity<br />

2. Hiding <strong>the</strong> "dirty stuff"<br />

3. Mitigating <strong>the</strong> "Deutsch Limit"


1. Domain specificity<br />

"The ability for <strong>the</strong> general public to understand a VPL is<br />

inversely proportional to <strong>the</strong> likelihood that it will actually<br />

do something useful."<br />

-me<br />

● This is really no different from a well-made API<br />

○ Abstracts away unnecessary granularity<br />

● Unspecific: Scratch, AppInventor, etc.<br />

● Specific: Lego Mindstorms


2. Hiding <strong>the</strong> "dirty stuff"<br />

● All VPLs hide some of <strong>the</strong> generic dirty stuff<br />

● Goes hand-in-hand with domain specificity<br />

○ If not domain-specific, it's hard to identify <strong>the</strong><br />

dirty stuff<br />

● Examples of dirty stuff in automated trading<br />

○ In-flight Orders<br />

○ Fairness<br />

○ "It just works"


3. Mitigating <strong>the</strong> "Deutsch Limit"<br />

● Browser-based navigation<br />

● Show Up/Downstream Blocks<br />

● Block searching<br />

● Componentization<br />

● Breakpoints<br />

● "Jump Blocks"


We want our users to eat fruit<br />

Kathy Sierra - http://goo.gl/hKd95<br />

● Cake vs. Fruit<br />

● We want <strong>the</strong>m to focus on idea generation, not<br />

implementation<br />

● It's also about safety


Let's do an experiment<br />

● Build a simple trading strategy:<br />

○ Place an order to buy 100 shares of stock (e.g.<br />

GOOG) at <strong>the</strong> last-traded-price (LTP)<br />

○ Whenever <strong>the</strong> LTP of GOOG changes, we should<br />

change our order's price to match<br />

○ If <strong>the</strong> LTP of GOOG *ever* falls below $770, we<br />

should cancel our order<br />

● Scratch-->Domain Specific Language-->ADL


stock=GOOG;volume=5433728;LTP=782.03;


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Domain Specific


Algo Design Lab (ADL)<br />

(that's it.)


Domain Specific


Domain Specific


Wrap-up*<br />

● VPLs can work for a very narrow set of<br />

industries and applications<br />

● Domain specificity<br />

● Hiding <strong>the</strong> dirty stuff<br />

● Mitigating <strong>the</strong> "Deutsch Limit"<br />

● Are our users fruit or cake eaters?<br />

* Please exit through <strong>the</strong> back for processing


Questions?


Appendix


Flowcharts are evil<br />

“The flowchart is a very poor abstraction of software<br />

structure.”<br />

-Fred Brooks


Flowcharts are evil<br />

● Poor representation of <strong>the</strong> actual effort needed to<br />

realize <strong>the</strong> intended goal<br />

● Flowcharts tend to be written after you write code,<br />

not before<br />

● Too many assumptions; too abstract

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

Saved successfully!

Ooh no, something went wrong!