Żywe języki programowaniaLiving it up with a Live Programming Language
Sean McDirmid Ecole Polytechnique Fédérale de Lausanne (EPFL) sean.mcdirmid@epfl.ch 5/24/2010 Marcin Hagmajer 1
A dynamic language improves programmer productivity through flexible typing, a focus on high-level programming, and by streamlining the edit-compile-debug cycle. Live languages go beyond dynamic languages with more programmer-centric features. A live language supports live programming that provides programmers with responsive and continuous feedback about how their edits affect program execution. A live language is also based on declarative programming constructs such as rules or data-flow connections so that programmers can write less code. A live language should also provide programmers with responsive semantic feedback to enable time-saving services such as code completion. This paper describes the design a textual live language known as SuperGlue. SuperGlue is based on reactive values known as signals that are supported with declarative data-flow connections and dynamic inheritance. Through signals and dynamic inheritance, SuperGlue supports live programming, declarative programming, and responsive semantic feedback. We demonstrate live programming in SuperGlue with a working prototype. ‹#›
Tekstowy, żywy język programowania 5/24/2010 Marcin Hagmajer 6
SuperGlue
5/24/2010 Marcin Hagmajer 7 Dane zmienne w czasie Sygnały dynamicznie dziedziczą po klasach
Przykład początkowy
5/24/2010 Marcin Hagmajer 8
As an opening example, consider the following SuperGlue code that defines the Ghost class, three ghost signals, and connects the fill color of all ghost signals. The first line of this code defines a Ghost class with a member fill signal that extends the Color class. The second line defines three signals, blinky, clyde, and bashful, which extend the Ghost class. The third line is a rule that connects the fill signal of all ghosts, including blinky, clyde, and bashful, to the color blue. When used in expressions, class identifiers are variable that quantify over all signals that extend the identified class. Unlike imperative assignments, connection rules have declarative meaning that is unrelated to statement execution order; e.g., on line three, blue is continuously connected to rather than discretely assigned to the ghost’s fill color. ‹#›
Sygnały
Wartości w grafie przepływu danych, które ułatwiają komunikację pomiędzy komponentami. Są to obiekty dziedziczące po klasach, połączone z innymi sygnałami i zawierające sygnały zdefiniowane w ich nadrzędnych klasach. Definiuje się je jako elementy klasy używając słowa kluczowego port 5/24/2010 Marcin Hagmajer 9
Klasy
Definiują zachowanie Nie są wartościami i mogą być rozszerzone jedynie przez sygnały Definiowane w najwyższej warstwie programu lub jako elementy inncyh klasy z wykorzystaniem słowa kluczowego class 5/24/2010 Marcin Hagmajer 10
Połączenia
Definiują zależność pomiędzy sygnałami, dzięki czemu ich wartość jest jednakowa Są regułami podobnymi do prostych, jednokierunkowych ograniczeń. Określany przy użyciu operatora = 5/24/2010 Marcin Hagmajer 11
Rozszerzenia (extensions)
Sprawiają, że sygnały rozszerzają klasy Reguły wycelowane w sygnały poza ich definicją Definiowane z wykorzystaniem operatora / „:” 5/24/2010 Marcin Hagmajer 12
Warunki (conditions)
Określają kiedy reguły połączeń i rozszerzeń mogą być zastosowane. Odpytują istniejące połączenia i rozszerzenia za pomocą tych samych operatorów (= i ), których używa się do ich stworzenia Tworzeone przez konstrukcje if otaczające reguły połączeń i rozszerzeń 5/24/2010 Marcin Hagmajer 13
Cel: uproszczony PacMan
5/24/2010 Marcin Hagmajer 14
Rysunek (1/4)
5/24/2010 Marcin Hagmajer 15
The programmer types “port pacMan . Figure” to define a pacMan signal that extends the game’s Figure class so pacMan is drawn on the game’s canvas. Because a shape for pacMan has not been specified, it is drawn by default as a rectangle. ‹#›
Rysunek (2/4)
5/24/2010 Marcin Hagmajer 16
The programmer types the extension “pacMan . Pie,” which causes pacMan to extend the Pie class and be drawn as a circle. The shape of pacMan is updated on screen as soon as the programmer types the “e” in Pie. ‹#›
Rysunek (3/4)
5/24/2010 Marcin Hagmajer 17
The programmer types the connection “pacMan.fill = yellow,” causing this circle to be immediately colored yellow. Through type inference, code completion can complete typing for .fill in pacMan. ‹#›
Rysunek (4/4)
5/24/2010 Marcin Hagmajer 18
The programmer types “pacMan.extent = 330.” As the programmer types each character in “330,” pacMan’s appears respectively as a 357, 327, and finally a 30 degree slice. The programmer than finishes this line with “+ (time % 30),” which causes pacMan’s mouth to close continuously in a 30 degree motion. ‹#›
Comments