Parrot in a nutshell1 Parrot in a Nutshell Dan Sugalski

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
OO in Parrot Dan Sugalski April 14, 2003.
Chapter 10- Instruction set architectures
Click to add text © IBM Corporation Optimization Issues in SSE/AVX-compatible functions on PowerPC Ian McIntosh November 5, 2014.
CSI 3125, Preliminaries, page 1 Programming languages and the process of programming –Programming means more than coding. –Why study programming languages?
Chapter 3.2 C++, Java, and Scripting Languages “The major programming languages used in game development.”
CS 300 – Lecture 23 Intro to Computer Architecture / Assembly Language Virtual Memory Pipelining.
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
Portability CPSC 315 – Programming Studio Spring 2008 Material from The Practice of Programming, by Pike and Kernighan.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
SM3121 Software Technology Mark Green School of Creative Media.
3-1 3 Compilers and interpreters  Compilers and other translators  Interpreters  Tombstone diagrams  Real vs virtual machines  Interpretive compilers.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Prince Sultan College For Woman
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
CS 355 – Programming Languages
Parrot in detail1 Parrot in Detail Dan Sugalski
Instruction Set Architecture
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
CS 102 Computers In Context (Multimedia)‏ 01 / 23 / 2009 Instructor: Michael Eckmann.
1 History of compiler development 1953 IBM develops the 701 EDPM (Electronic Data Processing Machine), the first general purpose computer, built as a “defense.
Ruby! Ronald L. Ramos. What is Ruby? Ruby is a scripting language designed by Yukihiro Matsumoto, also known as Matz. It runs on a variety of platforms,
CS 147 June 13, 2001 Levels of Programming Languages Svetlana Velyutina.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
IT253: Computer Organization
10/27: Lecture Topics Survey results Current Architectural Trends Operating Systems Intro –What is an OS? –Issues in operating systems.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
Processes Introduction to Operating Systems: Module 3.
Programming language. Definition Programming language is a formal language designed to communicate instructions to a computer. Programming languages can.
Perl 6 Internals Dan Sugalski TPC 5.0 “Here there be dragons”
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
Implementing an Interpreter Dan Sugalski
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
NETW3005 Memory Management. Reading For this lecture, you should have read Chapter 8 (Sections 1-6). NETW3005 (Operating Systems) Lecture 07 – Memory.
Parrot in a nutshell1 Parrot in a Nutshell Dan Sugalski
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Getting ready. Why C? Design Features – Efficiency (C programs tend to be compact and to run quickly.) – Portability (C programs written on one system.
1 Languages and Compilers (SProg og Oversættere) Bent Thomsen Department of Computer Science Aalborg University With acknowledgement to Norm Hutchinson.
Chapter 7 Continued Arrays & Strings. Arrays of Structures Arrays can contain structures as well as simple data types. Let’s look at an example of this,
Copyright © 2005 – Curt Hill MicroProgramming Programming at a different level.
Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Basic Concepts Microinstructions The control unit seems a reasonably simple device. Nevertheless, to implement a control unit as an interconnection of.
The heavyweight parts of lightweight languages LL1 Workshop November 17, 2001.
Efficient Software-Based Fault Isolation
Lecture 1b- Introduction
Component 1.6.
High or Low Level Programming Language? Justify your decision.
Chapter 14: System Protection
A Closer Look at Instruction Set Architectures
The heavyweight parts of lightweight languages
History of compiler development
Introduction to Computers
Chapter 2: Operating-System Structures
Compiler Construction
Central Processing Unit
Portability CPSC 315 – Programming Studio
Lesson Objectives Aims Key Words Compiler, interpreter, assembler
CMP 131 Introduction to Computer Programming
Outline Chapter 2 (cont) OS Design OS structure
Mastering Memory Modes
(Computer fundamental Lab)
Parrot in the Real World
System calls….. C-program->POSIX call
CSc 453 Interpreters & Interpretation
Design of the Parrot Virtual Machine The OO-ish bits
Presentation transcript:

Parrot in a nutshell1 Parrot in a Nutshell Dan Sugalski

Parrot in a nutshell2 What is Parrot The interpreter for perl 6 A multi-language virtual machine An April Fools joke gotten out of hand

Parrot in a nutshell3 The official point of Parrot Build something to support perl 6 Build a faster perl Build a cleaner perl

Parrot in a nutshell4 The Unofficial point of Parrot Generic fast interpreter engine Annoy the Mono folks Really annoy the python people Try and take over the world

Parrot in a nutshell5 Parrot’s guiding goals Speed Maintainability Longevity Extensibility Flexibility

Parrot in a nutshell6 Speed Faster is good A slow interpreter is of little use Things almost never get any faster Parrot sets the maximum speed

Parrot in a nutshell7 Maintainability Try and keep things black-box Try and enforce a coding standard Open Source projects have limited engineering resources Things rarely get more maintainable Maintenance always consumes the most resources for projects that actually finish

Parrot in a nutshell8 Longevity Software always lives on well past the point you think it should Designing for long-term expandability puts off the inevitable rewrites We’re going to be looking at this code for the better part of a decade, so we’d best make sure we want to look at it

Parrot in a nutshell9 Extensibility Everyone wants to add on with C Things are never quite fast enough There are lots of external libraries worth using A good extension mechanism is a great thing A bad one really hurts

Parrot in a nutshell10 Flexibility General solutions have more long-term potential than specific ones People always do things you don’t expect If you plan for it now, it doesn’t cost more later Even if it costs a little more now

Parrot in a nutshell11 Multi-language capabilities Support perl Support Dynamic Languages in general Nice target for language designers

Parrot in a nutshell12 Support perl Perl 6 was the reason this all started Perl has the most complex semantics of all the dynamic languages in common use Perl is a major pain to implement, as languages go

Parrot in a nutshell13 Support Dynamic Languages in general Includes Ruby and Python, for example Languages that have some compile- time uncertainty Actually trivial, just a matter of thinking about it

Parrot in a nutshell14 Nice Target If we express all the semantics, it makes it easier for language designers Many now target C, or GCC Impedance mismatch lower for many languages

Parrot in a nutshell15 Play Zork natively Yep, that’s right parrot -b:zmachine zork.dat Doing this right is harder than doing Java, Python, or.NET bytecode If we can do this, we can do anyone’s bytecode Plus it’s really cool

Parrot in a nutshell16 Interpreter basics Chunk of software that executes other software A CPU in software Generally flexible Generally slow Easy to write for Easy to write Portable

Parrot in a nutshell17 CPU in software It’s the “V” in VM The compiler writer can treat the interpreter as a form of CPU chip Allows much easier customization of ‘core’ behavior Sometimes software does become hardware But often it shouldn’t

Parrot in a nutshell18 Generally flexible Since the core functionality is in software, it’s changeable Software generally has fewer limits to it than hardware It’s easier to think about software than hardware, so more people can Incremental cost of changes much lower

Parrot in a nutshell19 Generally slow It’s a layer of indirection between the user’s program and the hardware that executes it It’s very easy to have impedance mismatch problems It’s also very easy to let speed dribble away

Parrot in a nutshell20 Easy to write for It’s easy to gloss over the tough parts The interpreter should express itself in ways that are easy to use You built it as the target, so if it isn’t, you’ve done something wrong

Parrot in a nutshell21 Easy to write Interpreters are pure semantics, and semantics aren’t that difficult to express Though defining the semantics can take much longer A simple interpreter can be put together in a week (Though parrot is far from simple) Just a SMOP, even for the fancy ones

Parrot in a nutshell22 Portable Generally the expressed semantics are mostly platform-neutral Means the platform-specific stuff can be isolated Platform specific but unimplemented things can be emulated Normally just a small cluster of really nasty code to deal with

Parrot in a nutshell23 Core Parrot Concepts Register based Language Neutral Very high level Introspective Mutable Threaded With continuations

Parrot in a nutshell24 Register Based 32 each Integer, String, Float, and PMC Registers are a kind of named temporary slot for the interpreter Modeled on hardware CPUs Generally more efficient than a pure stack-based model

Parrot in a nutshell25 Language Neutral In the human sense We don’t force ASCII, Unicode, Latin-1, or EBCDIC on the user The engine has facilities to deal with data regardless of its encoding Important when dealing with native- language text, which is most text

Parrot in a nutshell26 Very high level Threads, closures, continuations, aggregate operations, multimethod dispatch all core elements Don’t relegate the hard stuff to libraries Easier on compiler writers Bit more of a pain for the interpreter implementers

Parrot in a nutshell27 Introspective Code can inspect the current state of the interpreter Most, if not all, the core data structures are accessible Includes stack entries, symbol tables, lexical variables Also variable arenas, memory pools, and interpreter statistics

Parrot in a nutshell28 Mutable Code can be created on the fly Libraries can be dynamically loaded Opcodes can be redefined on the fly Base variable methods can be overridden at runtime

Parrot in a nutshell29 Threaded Threads are a core element of Parrot Threading interpreters is an interesting task For nasty values of “interesting” They must be designed in from the start

Parrot in a nutshell30 With Continuations Really odd Lisp thing Sort of like a closure for control flow For reference, exceptions are a simplified kind of continuation They will rot your brain If your brain’s already gone, though, they let you do some Terribly Clever Things

Parrot in a nutshell31 Quick benchmark numbers Simple MOPS benchmark Ruby 1.6.6:207 Sec Perl 5.6.0:165 Sec Python 2.2:136 Sec Parrot:18.75 Sec Parrot (faster):9 Sec Parrot (fastest):4.9 Sec

Parrot in a nutshell32 Fetching Parrot Anon CVS