Overview. Rationale Division of labour between script and C++ Choice of language(s) Interfacing to C++ Performance, memory

Similar documents
Overview. Rationale Division of labour between script and C++ Choice of language(s) Interfacing to C++

What is a programming language?

Scripted Components: Problem. Scripted Components. Problems with Components. Single-Language Assumption. Dr. James A. Bednar

Scripted Components Dr. James A. Bednar

An Introduction to Tilde

Software Development. Integrated Software Environment

Design & Implementation Overview

Concepts of Programming Languages

Chapter 1 Preliminaries

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

Chapter 1. Preliminaries

Servlet Performance and Apache JServ

Chapter 1. Preliminaries

Principles of Programming Languages. Lecture Outline

Language Translation, History. CS152. Chris Pollett. Sep. 3, 2008.

Building a Multi-Language Interpreter Engine

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Programming Languages, Summary CSC419; Odelia Schwartz


Why are there so many programming languages?

Early computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed

CSE 333 Lecture 1 - Systems programming

Chapter 5. Names, Bindings, and Scopes

CMPSC 311- Introduction to Systems Programming Module: Systems Programming

CMPSC 311- Introduction to Systems Programming Module: Systems Programming

Principles of Computer Game Design and Implementation. Lecture 3

Topic 9: Type Checking

Topic 9: Type Checking

Compilers. Prerequisites

Computer Components. Software{ User Programs. Operating System. Hardware

Chapter 1. Preview. Reason for Studying OPL. Language Evaluation Criteria. Programming Domains

CS Exam #1-100 points Spring 2011

CSE 333 Lecture 1 - Systems programming

Chapter Twelve. Systems Design and Development

IMGD 4000 Technical Game Development II Scripting

Compilation I. Hwansoo Han

Technical Game Development II IMGD 4000 (D 11) 1. having agents follow pre-set actions rather than choosing them dynamically

CS 360 Programming Languages Interpreters

Dynamic Languages Toolkit. Presented by Andrey Tarantsov

Why study Programming Language Concepts? Chapter One. Language Evaluation Criteria. Programming Domains. Readability Writability Reliability Cost

Seminar report Java Submitted in partial fulfillment of the requirement for the award of degree Of CSE

(p t y) lt d. 1995/04149/07. Course List 2018

CMPSC 311- Introduction to Systems Programming Module: Systems Programming

Summary: Issues / Open Questions:

Outline. S: past, present and future Some thoughts. The 80s. Interfaces - 60s & 70s. Duncan Temple Lang Department of Statistics UC Davis

Welcome to Python! If you re the type of person who wants to know

Advance Mobile& Web Application development using Angular and Native Script

Simplicity and minimalism in software development

JAVA An overview for C++ programmers

LabWare 7. Why LabWare 7?

Lecture content. Course goals. Course Introduction. TDDA69 Data and Program Structure Introduction

BCS THE CHARTERED INSTITUTE FOR IT. BCS Higher Education Qualifications BCS Level 6 Professional Graduate Diploma in IT EXAMINERS' REPORT

Python. Jae-Gil Lee Based on the slides by K. Naik, M. Raju, and S. Bhatkar. December 28, Outline

! Broaden your language horizons. ! Study how languages are implemented. ! Study how languages are described / specified

Chapter 2 First Java Programs

Using Java for Scientific Computing. Mark Bul EPCC, University of Edinburgh

Fiji VM Safety Critical Java

Computer Components. Software{ User Programs. Operating System. Hardware

PyROOT: Seamless Melting of C++ and Python. Pere MATO, Danilo PIPARO on behalf of the ROOT Team

Chapter 3.3 Programming Fundamentals. Languages Paradigms Basic Data Types Data Structures OO in Game Design Component Systems Design Patterns

D Programming Language

Tutorial 1 Answers. Question 1

Design of Generic Web Based Automation Framework for Network Testing

CIS 194: Homework 3. Due Wednesday, February 11, Interpreters. Meet SImPL

COP 3402 Systems Software. Lecture 4: Compilers. Interpreters

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Design for Testability of Web Applications Manager s Perspective

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Visual Basic Primer A. A. Cousins

Assigns a number to 110,000 letters/glyphs U+0041 is an A U+0062 is an a. U+00A9 is a copyright symbol U+0F03 is an

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

IA010: Principles of Programming Languages

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Dynamic Languages Strike Back. Steve Yegge Stanford EE Dept Computer Systems Colloquium May 7, 2008

CSE373: Data Structure & Algorithms Lecture 23: Programming Languages. Aaron Bauer Winter 2014

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Using the Computer Programming Environment

CCReflect has a few interesting features that are quite desirable for DigiPen game projects:

Objective: To learn meaning and concepts of programming. Outcome: By the end of this students should be able to describe the meaning of programming

COSC Software Engineering. Lecture 23: Multilingual and Component Programming

Notes to Instructors Concerning the BLITZ Projects

Deviations are things that modify a thread s normal flow of control. Unix has long had signals, and these must be dealt with in multithreaded

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

A NET Refresher

Programming Languages

Simply-Typed Lambda Calculus

Graphics Performance Benchmarking Framework ATI. Presented to: Jerry Howard. By: Drew Roberts, Nicholas Tower, Jason Underhill

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Active Server Pages Architecture

Computer Science Seminar. Whats the next big thing? Ruby? Python? Neither?

Programming. Dr Ben Dudson University of York

Programming Paradigms

Book keeping. Will post HW5 tonight. OK to work in pairs. Midterm review next Wednesday

PyPy - How to not write Virtual Machines for Dynamic Languages

Skill Area 336 Explain Essential Programming Concept. Programming Language 2 (PL2)

Why Hash? Glen Becker, USAA

Chapter 3:: Names, Scopes, and Bindings (cont.)

Transcription:

SCRIPTING

Overview Rationale Division of labour between script and C++ Choice of language(s) Interfacing to C++ Reflection Bindings Serialization Performance, memory

Rationale C++ isn't the best choice for all problems Complicated feature set, syntax Low-level, dangerous Lengthy shutdown/compile/link/rerun development process Many game projects use scripting to address some of these problems

Advantages of Scripting Expressiveness Expressiveness Scripting languages employ higher level constructs than C++ Reduced iteration time Interpreted, or byte-code compiled on-the-fly Useful features Automatic resource management (garbage collection) No pointers Safe data structures Dynamic typing Accessibility Accessibility Easier for casual programmers to grok than C++ Customizable Write your own language, or change an existing one to suit your needs

Problems Additional work to bind the chosen language to C++ These bindings are often non-trivial Standard C++ tools are not script aware Debugger, compiler, profiler Script is a black hole to C++ Multi-language debugging is harder Script code runs slower Harder to keep memory usage in check Having non-programmers write code can be a disaster

Division of Labour Script can can be employed with varying levels of commitment Loading only, scripts just wire up C++ at load time Script high level game flow, only one script running Event responders, game updates from C++, but scripts are called in response to exceptional events Entity behaviour scripted. Each entity is running a little script (usually a state machine of some sort). Write the whole game in the script language Not really scripting any more then, is it? Where a team stands on this depends on the type of game they are writing, the programming ability of the scripters, and how much performance they are willing to trade for the benefits of scripting

Concurrency It is often convenient to model an entities behaviour/brain/state machine as an independent thread of execution Scripts provide a convenient mechanism to support this Often built in language support (e.g. Lua co-routines, UnrealScript latent functions ) Script threads are co-operatively scheduled, so there are fewer issues compared to pre-emptive OS-level threads No locking primitives, race conditions, etc. Better performance Cheap context switch

Choice of Languages Lua Lua Widely used in the game industry Designed for embedding Byte-code interpreted Dynamically typed Very flexible tables (associative arrays) as the fundamental data structure Simple, clean syntax Garbage collection Not natively object-oriented, but can fake it effectively Good performance (for a scripting language)

Choice of Languages Java / C# Basically, C++ with pointers removed, garbage collection added Statically typed Very rich standard libraries Object oriented Object reflection, serialization Properties (C#) Good performance Some safety benefit over C++, but not much gain in expressiveness Generally these languages are too close to C++ to offer huge benefits as a scripting language A decent choice as an alternative to C++

Choice of Languages Perl / Python / Ruby All have been used in games at one time or another Very different syntax, but similar feature sets Rich standard libraries Dynamically typed Byte-code interpreted Object oriented to one degree or another Garbage collection Generally pretty slow Large memory footprint All have ambitions to be full-blown application languages Fairly hostile to embedding in C++ Optimised for text processing, which isn't a big concern for games

Choice of Languages Lisp, Scheme, etc. Very expressive syntax Not terribly readable, though Dynamically typed Compiled, or interpreted Easy to write an interpreter for Garbage collection Decent performance (if you have a good implementation) Doesn't play well with C++ Hard for people trained in imperative programming styles to learn Full-blown Lisp works better as an application language No support on consoles though Lots of implementations out there

Choice of Languages PHP, JavaScript, Small, Squirrel, Io, interpreted C (LCC), Tcl, etc. There are a lot of choices out there Roll your own? Not for this project, but... Get exactly the mix of features you want Seamless C++ bindings, state-machines, concurrency, event handling, resource management Write your own native-code compiler! UnrealScript: Java with game-oriented features GOAL: Great until your Lisp guy retires... Writing a language is not a task to take lightly Be careful, or you will end up with Perl, but not as useful

Binding to C++ Simple attribute binding C-function binding Object reflection

How to Bind By hand No Macros Macros Clunky, but proven Templates Templates boost::python Hard to write, convenient to use IDL Complex, but language independent IDL Code parsers SWIG Complex, but convenient Symbol file parsers

Summary It's worth using multi-language development to gain some productivity back that C++ takes away Scripting in a game can take on many forms and this influences language selection Lua seems to be the most popular choice currently Custom languages are still popular, however