Extensibility in GNUstep & Étoilé

Similar documents
Traditional Smalltalk Playing Well With Others Performance Etoile. Pragmatic Smalltalk. David Chisnall. August 25, 2011

Outline Smalltalk Overview Pragmatic Smalltalk Closing. Pragmatic Smalltalk. David Chisnall. February 7,

Cocoa Programming. David Chisnall. March 18,

GNUstep: What is it? gnustep.org

Principles of Programming Languages. Objective-C. Joris Kluivers

Cocoa. Last Week... Music 3SI: Introduction to Audio/Multimedia App. Programming. Today... Why Cocoa? Wikipedia - Cocoa

Smalltalk in a C World

ios: Objective-C Primer

Java and C CSE 351 Spring

An Introduction to Object Orientation

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Using Scala for building DSL s

Types II. Hwansoo Han

Object Model. Object Oriented Programming Spring 2015

Data Abstraction. Hwansoo Han

What about Object-Oriented Languages?

Dynamic Dispatch and Duck Typing. L25: Modern Compiler Design

Week 7. Statically-typed OO languages: C++ Closer look at subtyping

Cog VM Evolution. Clément Béra. Thursday, August 25, 16

2. The object-oriented paradigm

CS193p Spring 2010 Thursday, April 29, 2010

About MSDOSX. Lecture 0

Organization of User Interface Software

Java and C I. CSE 351 Spring Instructor: Ruth Anderson

Concepts of Object-Oriented Programming. Richard Berger Johannes Kepler University Linz

Design Pattern and Software Architecture: IV. Design Pattern

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

Chapter 1 Getting Started

CS193E Lecture 17. Multiple Document Windows OpenGL & Cocoa

CPS 506 Comparative Programming Languages. Programming Language

Objective-C. Stanford CS193p Fall 2013

Object-Oriented Programming with Objective-C. Lecture 2

X Review. Mac OS X Roots: NeXT. BWS Available for virtually every OS

Object Model. Object Oriented Programming Winter

ITP 342 Mobile App Dev. Data Types

Objective-c Gnustep Base Programming Manual

Worksheet #4. Foundations of Programming Languages, WS 2014/15. December 4, 2014

NSObject. - (NSString *)description Provides us with a string description of the object

Announcements/Follow-ups

Sista: Improving Cog s JIT performance. Clément Béra

CS Programming In C

Skip the FFI! Embedding Clang for C Interoperability. Jordan Rose Compiler Engineer, Apple. John McCall Compiler Engineer, Apple

Announcements. My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM.

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?

Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns

JAVA An overview for C++ programmers

What are the characteristics of Object Oriented programming language?

Unboxing Sum Types. Johan Tibell - FP-Syd

Xcode Tricks. ios App Development Fall 2010 Lecture 13

Objective-C and COCOA Applications

Prototype Pattern Creational

Syllabus- Java + Android. Java Fundamentals

Xcode and Swift CS 4720 Mobile Application Development

Design Pattern- Creational pattern 2015

CS558 Programming Languages

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

OSGi on the Server. Martin Lippert (it-agile GmbH)

DESIGN PATTERN - INTERVIEW QUESTIONS

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Combined Object-Lambda Architectures

Subclasses, Superclasses, and Inheritance

Lecture 10: building large projects, beginning C++, C++ and structs

Chapter 2. Operating-System Structures

The Java Programming Language

GUI Implementation Support

Design Patterns in C++

Software Design COSC 4353/6353 D R. R A J S I N G H

Accelerating Ruby with LLVM

Software Tools. Scott Klemmer Autumn 2009

Programming Languages

I, J. Key-value observing (KVO), Label component, 32 text property, 39

Chapter 8 :: Composite Types

SDC Design patterns GoF

CS 376b Computer Vision

Introductory ios Development

CS260. UI Toolkits. Björn Hartmann University of California, Berkeley EECS, Computer Science Division Fall 2010

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Java and C. CSE 351 Autumn 2018

CSE 504: Compiler Design. Runtime Environments

The Java Language Implementation

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

This manual is for Libffi, a portable foreign-function interface library. Copyright c 2008, 2010, 2011 Red Hat, Inc. Permission is granted to copy,

Tcl/Tk lecture. What is the Wish Interpreter? CIS 410/510 User Interface Programming

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

LLVM for a Managed Language What we've learned

Java Internals. Frank Yellin Tim Lindholm JavaSoft

Jython. An introduction by Thinh Le

Francesco Nidito. Programmazione Avanzata AA 2007/08

Mobile Application Development

Compiler construction 2009

CS 371L - Mobile Computing (ios) Dr. William C. Bulko. CS 371L Mobile Computing (ios) Introduction

CSE Lecture 3: Objects 2 September Nate Nystrom University of Texas at Arlington

CSE 401/M501 Compilers

CS558 Programming Languages Winter 2013 Lecture 8

Objective-C Runtime. Cocoa s Jewel in the Crown. NSConference Nicolas

Intermediate Code, Object Representation, Type-Based Optimization

From C++ to Java. Duke CPS

What goes inside when you declare a variable?

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

Transcription:

Extensibility in GNUstep & Étoilé GNU Hackers 2011 http://www.gnustep.org http://www.etoileos.com

Objective-C & GNUstep

Objective-C Created by Brad Cox and Tom Love in 1986 to package C libraries in Smalltalk-like classes Comes with dynamic features such as message forwarding categories to extend existing classes resolve methods lazily etc.

Class Example @interface Person : NSObject - (void) sleep; @end @implementation - (void) sleep { NSLog(@ Zzzz! ); } @end

Category Example @interface Person (Talktative) - (NSString *) talk; @end @implementation Person (Talktative) - (NSString *) talk { return @ poumpoumpidoum ; } @end

Objective-C Runtime No virtual machine, but a small runtime library class_getsuperclass() class_setsuperclass() class_replacemethod() method_getargumenttype() etc. Provides type infos for C types such as structs, unions, pointer etc.

Class Transform Dynamic implicit subclass creation Many Use cases Persistency (Fast Portable Orthogonally Persistent Java) Change Notifications (Key Value Observing) Prototypes (Google V8, libobjc2) Faulting, State Machine, AOP etc.

Composition of Class Transforms Multiple transforms create several implicit subclasses Methods can be overriden several times Composition order matters How to be sure the resulting behavior is correct? No well-known model to support composition

Safe Composition of Class Transforms V8, libobjc2 and Foundation approach restricts the supported transforms to the core language or library level hides the implicit subclass id obj = [A new] objc_setassociatedreference(obj, key, value, retainpolicy) [[obj class] isequal: object_getclass(obj)] // A in both cases

Class Cluster Variation on the Abstract class idea A single public Class Multiples concrete implementation classes The public class initializer and copy methods choose the class of the returned object For example NSSet, NSArray, NSNumber, NSString etc.

NSString Class Cluster GSPlaceholderString GSString GSCString GSCBufferString GSCInlineString GSCSubString GSUnicodeString (same subclasses than GSCString)

Class Cluster In theory very nice :-) In practice Poorly documented API contracts by Apple No way to register new implementations and control how the concrete classes are choosen

Class Registration Extra classes loaded on-demand to provide new abilities e.g. reading/writing new document format Registration API involves method such as +registerclass: +unregisterclass: +registeredclasses

NSImage Example [NSImageRep registerimagerepclass: [MySVGImageRep class]]; NSImage *img = [[NSImage alloc] initwithcontentsoffile: @ ~/tiger.svg ]; // [img representations] contains a MySVGImageRep instance

Drawing Backend Example GNUstep imaging is based on the DisplayPostScript model NSGraphicsContext is the public API and an abstract class Concrete subclasses adapts the DPS model to various drawing libs e.g. Cairo, Xlib, GDI CairoContext, XGContext, WIN32Context

Drawing Backend Example NSGraphicsContext is part of the AppKit framework While each concrete subclass is located in a bundle that is choosen at launch time System/Library/Bundles can contain libgnustepxlib.bundle or libgnustep-cairo.bundle defaults write MyApp GSBackend libgnustep-cairo

Étoilé

Étoilé A desktop environment built around Pervasive Data Sharing & Versioning Composite Document Collaboration Light & Focused Applications (1000 loc max per app)

Étoilé Today Well, presently more or less a development platform centered around LanguageKit CoreObject EtoileUI

Small in the long run An entire desktop environment in 150 000 loc atop GNUstep and some other dependencies such as LLVM, FFmpeg, TagLib etc. Most frameworks are between 2 000 and 6 000 loc Only two frameworks are above 10 000 loc LanguageKit EtoileUI

LanguageKit

LanguageKit A framework to build dynamic languages based on the ObjC object model Small and modular ~ 15 000 loc Fast

Already Fast LLVM built-in passes Small objects hidden in pointers (e.g. efficient integer computation) The new GNUstep runtime comes with various extra passes type feedback to generate profiling infos related to call sites

ObjC Runtime Passes Cached lookup fragile instance variable and class access classes messages messages in a loop Method inlining class methods speculative

Benchmarks Almost the same speed as C integer arithmetic e.g. Fibonacci benchmark ran the same speed as GCC 4.2.1 With all optimizations, can be faster than C in some micro-benchmarks Probably 5 to 10 times the speed than an open source Smalltalk such as Squeak Floating point still slow but will become fast soon :-)

Primitive Support Automatically box and unbox primitive types such as int, float etc. Integer operations/methods as C functions, compiled to bitcode and inlined by LLVM 4 + 4 in Smalltalk is as fast as C As a bonus, C direct library access without FFI, just do C sqrt: 42 for sqrt(42)

Modular Composed of several components in separate libraries An AST geared towards dynamic languages bundled with an AST interpreter A code generator-based on LLVM (JIT or static compilation) Two language front-ends (Smalltalk, EScript currently)

Mixing Languages Methods written in EScript, Smalltalk and ObjC can belong to the same object can call each other You can clone an object in EScript then pass it around to some Smalltalk or ObjC code ObjC and Smalltalk blocks are interchangeable

EtoileUI

Bird View EtoileUI CoreObject EtoileUI EtoileFoundation GNUstep Drawing Support Widget Backend

Surprisingly Small Found on Digg (in 2007) Konqueror itself is really a surprisingly small app: approx 40k lines of code. Not tiny, by any stretch of the imagination, but way, way smaller than people seem to think it is. 40x what is allowed in Étoilé :-/ From: http://digg.com/linux_unix/nautilus_vs_dolphin_vs_konqueror

Code Compression Étoilé Generic Object Manager 700 loc Étoilé Model Builder 1 000 loc

Model Builder Editing a package & browsing a repository

Post-WIMP? From the whole screen to a single row in a list view It s just an uniform tree structure No special window, list or row node

Why? An existing application should be easy to retarget personal computer mobile phone tablet web

Why a new UI toolkit? Everything can be changed at runtime Simple, compact and highly polymorphic API Write less code and develop faster Feeling of manipulating real objects

What does it solve? Generic protocol for Structured Document Building blocks for Graphics Editor Custom widget development As little code as possible Plasticity

Separation of Concerns No monolithic view/wigdet, but rather UI aspects Styles, Decorators, Layouts Tools, Action Handlers Widgets Model Objects, Controllers

Turtles all the way down Many things are just layout items selection rectangle handles shapes windows layers

gnustep.org etoileos.com