SlideShare a Scribd company logo
A VISUAL INTERACTIVE PROGRAMMING ENVIRONMENT FOR PYTHON http://sites.google.com/site/larchenv G. FRENCH J. R. KENNAWAY A. M. DAY PYCON IRELAND 2011 The Larch Environment Image by alcomm, flickr.com
Motivation
We look at three problems
Textual output in a Python console can be difficult to understand(DEMO)
Source code in a text editor is not interactive enoughConsoles are only good for a few lines at a time
Textual source code can be difficult to understand and comprehend(think the vertices of a polygon in code form)
What is‘The Larch Environment’?
A visual interactive programming environment
The goal is:To make programming more visual
How do we do that? Visual object presentation Programming environment Visual console Worksheets Visual programming via embedded objects
Visual object presentation
“ Pictures are pretty”DEMOVisual console
What design pattern do we commonly use for developing GUI apps?
Model View Controller MVC Architecture
MVC requires:Model class, View class, Controller class
Our approach:Type coercionType coercion: coerce an object to another type.
Type coercion used throughout Python
Examples:repr(), str()__index__()etc
Its simple
The Larch Environment:Use type coercion for visual presentation
Coerce objects to something visual(a  Pres )
HOWTO:The simplified version
Define the following method:def __ present __(self, fragment, inherited_state)
For Java objects:Implement  Presentable  interface
Presentations constructed using a  combinatorial API
Label( ‘Hello’ ) Hello Button.buttonWithLabel( ‘Button’ ) Button a = Label( ‘A’ ) b = Label( ‘B’ ) c = Label( ‘C’ ) d = Label( ‘D’ ) Row( [ a, b, c, d ] ) ABCD Column( [ a, b, c, d ] ) A B C D
Presentation combinators:Many moreFlow layouts, mathematical fractions, superscriptRich text, other utilitiesWrite your own by combining existing ones!P.S. Appearance controlled with style sheets
“ Type coercion is easy”DEMO:__present__()
Can also handle objects in the Java or Python standard libraries
Create an ‘object presenter’.Register it for the relevant class.When asked to present an instance of the class, Larch finds the appropriate presenter and uses it.(no monkeypatching required)
Thats how the images were shown;they are java.awt.BufferedImage objects
Perspectives
Different perspectives present an object in different ways
Like different views in MVC
The one I have talked about ( __present__ ,  Presentable , etc) is the ‘Default perspective’
There are other perspectives
E.g. The inspector perspectives
“ Visual Introspection”DEMO: INSPECTOR PERSPECTIVE
Programming Environment-Visual console
You’ve seen most of it
So lets look at some of the more ‘esoteric’ features
Model dragging
Everything in Larch is an object being presented (via type coercion)
The home pageProjectsThe console itself!
What if we want to manipulate an object that we can see?
CTRL+ALT +drag it!
“ I see something: how does it work?”DEMO: inspect a project
An interesting side fact!
Our source code editor does not edit text
Its a structured editorCode is represented as an abstract syntax tree (AST)
A perspective is used to present is as something that looks and behaves (mostly) like text
It means our code is in tree form
We can write our own refactorings!
“ Change your code fast!”DEMO:Refactoring
Programming Environment-Worksheets
Interactive consoles are great.Caveat: gets difficult when working with more than a few lines of code at a timeE.g. Whole modules
For complete programs we turn to a text editorWe lose the interactivity 
What if we could blend the two?(and add rich text to boot)
“ Python modules. With pictures.”DEMO: WORKSHEET(with cellular automata)
Worksheets are active documents
Act as modulesCan import code from other worksheets within the project
You can divide your module code into a number of blocks
Each block can show a result – a step along the path of a computation
To refresh results: hit F5
Rapid Edit-Run-Debug cycle:Alter code F5 Repeat
“ Code faster!”DEMO: Edit-Run-Debug cycle(cellular automata)
Visual Programming
Quite a rich history in the research community
Circuit diagrams (LabView), data-flow diagrams, draggable tiles (Scratch, Squeak tile view), etc
Nice for small simple programs
Large programs look like rat’s nestsNot practical 
Text remains the dominant medium for source code
Diagrams are still appropriate in certain circumstances
Lets use diagrams (or visual layout) where we need them!
“ Play God.”DEMO: OrrerySub-demos:Table editorsEmbedded table
“ Drawings. Inside code.”DEMO: Polygon
Embedded objects can use a protocol to customise their behaviour
__py_eval__ Act like an expression - return the result of  evaluating __py_evalmodel__ Act like an expression - return an AST __py_exec__ Act like a statement – called at runtime __py_execmodel__ Act like a statement – return an AST
AST GenerationWhat does this sound like?
AST Generation~=Visual LISP macros 
Crosses compile-time / run-time barrier
Compile-time (edit-time) objects available at run time
Run-time objects / values can modify or be modified by compile-time objects
“ LISPy Smalltalky goodness”DEMO: LZW compressor
Literate programming style extensions
Literate programmingRefresher
Invented by Knuthcirca 1984
Basic idea
Present programs as documents suitable for reading by people
Break a program into sections, in the same way you do for a book
Each section consists of a natural language description, and the code that implements it
Present sections in the order of ‘human logic’*, not the order of the compiler * Wikipedia article on Literate Programming
Use the ‘weave’ tool to generate the human readable document, typeset with LATEX
Use the ‘tangle’ tool to generate compile code for compiler
Use the ‘tangle’ tool to generate compile code for compiler
Our approach
Use embedded objects to represent sections(Python expressions and suites)
Allow them to be references/used in multiple placed throughout the document
“ Interactive pretty docuemnts”DEMO: Literate extensions
Conclusions
Visual object presentation by type-coercion
Encourages a functional approach to UI composition Handling state changes:Re-create, DON’T MUTATE
Visual representation of values is a BIG  EPIC  WINEven if you use only visual cues (e.g. borders around text)
Worksheets are active documents. They also expand on the rapid edit-run cycle of the console
Allow for rapid development of visual interactive applications
Visual programming by embedded objects
Visual programming where you need it
Allows you to  visually  extend the syntax of the language
No need to alter the compiler – its just embedded object references
References to objects you implement yourself
Embedded object referencesCan cross compile-time / run-time barrier
LISPy / Smalltalky stuffIN PYTHON
PROJECT STATUS
Research Prototype(not ready for real use )
TODOs:DocumentationBug fixesToo much more........
Related Work
MathematicaMathematica CDFIntentional Software Domain WorkbenchJetbrains Meta Programming System
Acknowledgements
Dr. Richard Kennaway Prof. Andy Day University of East Anglia, Norwich, UK Academic supervisory team
Developing The Larch would have been very difficult without Jython The Jython team
IF TIME ALLOWS:DEMO: KD-Tree
IF TIME ALLOWS:DEMO: SIMPLE COMPILER
G. FRENCH J. R. KENNAWAY M. DAY http://sites.google.com/site/larchenv THANK YOU! Image by alcomm, flickr.com

More Related Content

PPTX
Algorithm and Programming
PDF
Xtend - better java with -less- noise
PDF
Code Generation idioms with Xtend
PPTX
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
PPT
Smoothing Your Java with DSLs
PDF
Functional programming with Xtend
PDF
Ateji PX for Java
PDF
Introduction of c# day3
Algorithm and Programming
Xtend - better java with -less- noise
Code Generation idioms with Xtend
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Smoothing Your Java with DSLs
Functional programming with Xtend
Ateji PX for Java
Introduction of c# day3

What's hot (20)

PDF
Metaprogramming JavaScript
PDF
Swift Programming Language
PPTX
02 java programming basic
PDF
OO Design and Design Patterns in C++
PDF
Batch Scripting with Drupal (Featuring the EntityFieldQuery API)
PDF
Metaprogramming with javascript
PPT
Core java slides
PDF
Windows Phone and Open Source 1
PPT
00 intro to java
PDF
Swift Tutorial Part 2. The complete guide for Swift programming language
PPT
Introduction to java
PDF
Extending JS WU2016 Toronto
PDF
Extending js codemotion warsaw 2016
PPTX
Go f designpatterns 130116024923-phpapp02
PDF
The Synergy of Drupal Hooks/APIs (Custom Module Development with ChartJS)
PPTX
Android with kotlin course
PDF
Bootstrapping iPhone Development
PPTX
Dart presentation
Metaprogramming JavaScript
Swift Programming Language
02 java programming basic
OO Design and Design Patterns in C++
Batch Scripting with Drupal (Featuring the EntityFieldQuery API)
Metaprogramming with javascript
Core java slides
Windows Phone and Open Source 1
00 intro to java
Swift Tutorial Part 2. The complete guide for Swift programming language
Introduction to java
Extending JS WU2016 Toronto
Extending js codemotion warsaw 2016
Go f designpatterns 130116024923-phpapp02
The Synergy of Drupal Hooks/APIs (Custom Module Development with ChartJS)
Android with kotlin course
Bootstrapping iPhone Development
Dart presentation
Ad

Similar to The Larch - a visual interactive programming environment (20)

PPTX
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
PPTX
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
PPTX
Framework engineering JCO 2011
PPTX
.NET 4 Demystified - Sandeep Joshi
PDF
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
PDF
Ruby On Rails
PPT
Lunch and learn as3_frameworks
PDF
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
PDF
C# Summer course - Lecture 1
PDF
Design Patterns in Cocoa Touch
PDF
Fewd week4 slides
PPT
Eclipse 2011 Hot Topics
PPTX
CouchDB
PDF
Lezione 03 Introduzione a react
PPTX
Eclipse Overview
PDF
PJ_M01_C01_PPT_Introduction to Object Oriented Programming Using Java.pdf
PPT
Plug-in Architectures
PDF
Class 6: Introduction to web technology entrepreneurship
PPTX
C# Scripting with Microsoft's Project Roslyn
PPTX
mbeddr meets IncQuer - Combining the Best Features of Two Modeling Worlds
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
Framework engineering JCO 2011
.NET 4 Demystified - Sandeep Joshi
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Ruby On Rails
Lunch and learn as3_frameworks
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
C# Summer course - Lecture 1
Design Patterns in Cocoa Touch
Fewd week4 slides
Eclipse 2011 Hot Topics
CouchDB
Lezione 03 Introduzione a react
Eclipse Overview
PJ_M01_C01_PPT_Introduction to Object Oriented Programming Using Java.pdf
Plug-in Architectures
Class 6: Introduction to web technology entrepreneurship
C# Scripting with Microsoft's Project Roslyn
mbeddr meets IncQuer - Combining the Best Features of Two Modeling Worlds
Ad

More from Python Ireland (20)

PDF
Async I/O in Python
PDF
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
PDF
Python Ireland - Who, how, what
PPT
Object Orientation vs. Functional Programming in Python
PDF
What's the Scoop with Python 3?
PDF
Google App Engine in 40 minutes (the absolute essentials)
PDF
Introduction to Erlang for Python Programmers
PPT
Web-service based Mobile Geospatial Application Development using Python
PDF
Utopia Kingdoms scaling case. From 4 users to 50.000+
PDF
Python vs JLizard.... a python logging experience
PDF
Vim and Python
PDF
Python Ireland Nov 2009 Talk - Appengine
ODP
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
PDF
Python Ireland Nov 2010 Talk: Unit Testing
PDF
Python Ireland Nov 2010 - RESTing with Django
ODP
Python Ireland Feb '11 Talks: Introduction to Python
PPTX
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
PDF
KEY
Python for cloud computing
ODP
IPython: The awesome python shell
Async I/O in Python
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland - Who, how, what
Object Orientation vs. Functional Programming in Python
What's the Scoop with Python 3?
Google App Engine in 40 minutes (the absolute essentials)
Introduction to Erlang for Python Programmers
Web-service based Mobile Geospatial Application Development using Python
Utopia Kingdoms scaling case. From 4 users to 50.000+
Python vs JLizard.... a python logging experience
Vim and Python
Python Ireland Nov 2009 Talk - Appengine
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 - RESTing with Django
Python Ireland Feb '11 Talks: Introduction to Python
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
Python for cloud computing
IPython: The awesome python shell

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Modernizing your data center with Dell and AMD
PPTX
MYSQL Presentation for SQL database connectivity
PDF
cuic standard and advanced reporting.pdf
PDF
REPORT: Heating appliances market in Poland 2024
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Newfamily of error-correcting codes based on genetic algorithms
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Sensors and Actuators in IoT Systems using pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Modernizing your data center with Dell and AMD
MYSQL Presentation for SQL database connectivity
cuic standard and advanced reporting.pdf
REPORT: Heating appliances market in Poland 2024
Review of recent advances in non-invasive hemoglobin estimation
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
NewMind AI Weekly Chronicles - August'25 Week I
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
“AI and Expert System Decision Support & Business Intelligence Systems”
madgavkar20181017ppt McKinsey Presentation.pdf
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Newfamily of error-correcting codes based on genetic algorithms
Chapter 3 Spatial Domain Image Processing.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Advanced Soft Computing BINUS July 2025.pdf
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
20250228 LYD VKU AI Blended-Learning.pptx

The Larch - a visual interactive programming environment