1.08k likes | 1.21k Vues
The Larch Environment is a visual interactive programming environment designed to make programming more accessible and intuitive, especially within Python. By employing type coercion and visual object presentation, it transforms traditional text-based coding into a more dynamic and interactive experience. The environment features a visual console, worksheets, and a combinatorial API for creating rich presentations of data. Unique perspectives allow for visual introspection and manipulation of objects, enhancing understanding and engagement with code. Ideal for developers looking to enhance their visual coding experience.
E N D
The Larch Environment A visual interactive programming environment http://sites.google.com/site/larchenv G. French J. R. Kennaway A. M. Day Europython 2011 Image by alcomm, flickr.com
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)
How do we do that? • Visual object presentation • Programming environment • Visual console • Worksheets • Visual programming via embedded objects
What design pattern do we commonly use for developing GUI apps?
MVC Architecture Model View Controller
Our approach:Type coercionType coercion: coerce an object to another type.
The Larch Environment:Use type coercion for visual presentation
Define the following method:def __present__(self, fragment, inherited_state)
Label( ‘Hello’ ) Hello Button Button.buttonWithLabel( ‘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
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
The one I have talked about (__present__, Presentable, etc) is the ‘Default perspective’
Everything in Larch is an object being presented (via type coercion)
Its a structured editorCode is represented as an abstract syntax tree (AST)