1 / 108

The Larch Environment

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. Motivation. We look at three problems.

lazar
Download Presentation

The Larch Environment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. Motivation

  3. We look at three problems

  4. Textual output in a Python console can be difficult to understand(DEMO)

  5. Source code in a text editor is not interactive enoughConsoles are only good for a few lines at a time

  6. Textual source code can be difficult to understand and comprehend(think the vertices of a polygon in code form)

  7. What is‘The Larch Environment’?

  8. A visual interactive programming environment

  9. The goal is:To make programming more visual

  10. How do we do that? • Visual object presentation • Programming environment • Visual console • Worksheets • Visual programming via embedded objects

  11. Visual object presentation

  12. “Pictures are pretty”DEMOVisual console

  13. What design pattern do we commonly use for developing GUI apps?

  14. MVC Architecture Model View Controller

  15. MVC requires:Model class, View class, Controller class

  16. Our approach:Type coercionType coercion: coerce an object to another type.

  17. Type coercion used throughout Python

  18. Examples:repr(), str()__index__()etc

  19. Its simple

  20. The Larch Environment:Use type coercion for visual presentation

  21. Coerce objects to something visual(a Pres)

  22. HOWTO:The simplified version

  23. Define the following method:def __present__(self, fragment, inherited_state)

  24. For Java objects:Implement Presentable interface

  25. Presentations constructed using a combinatorial API

  26. 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

  27. Presentation combinators:Many moreFlow layouts, mathematical fractions, superscriptRich text, other utilitiesWrite your own by combining existing ones!P.S. Appearance controlled with style sheets

  28. “Type coercion is easy”DEMO:__present__()

  29. Can also handle objects in the Java or Python standard libraries

  30. 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)

  31. Thats how the images were shown;they are java.awt.BufferedImage objects

  32. Perspectives

  33. Different perspectives present an object in different ways

  34. Like different views in MVC

  35. The one I have talked about (__present__, Presentable, etc) is the ‘Default perspective’

  36. There are other perspectives

  37. E.g. The inspector perspectives

  38. “Visual Introspection”DEMO: INSPECTOR PERSPECTIVE

  39. Programming Environment-Visual console

  40. You’ve seen most of it

  41. So lets look at some of the more ‘esoteric’ features

  42. Model dragging

  43. Everything in Larch is an object being presented (via type coercion)

  44. The home pageProjectsThe console itself!

  45. What if we want to manipulate an object that we can see?

  46. CTRL+ALT +drag it!

  47. “I see something: how does it work?”DEMO: inspect a project

  48. An interesting side fact!

  49. Our source code editor does not edit text

  50. Its a structured editorCode is represented as an abstract syntax tree (AST)

More Related