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

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

An Introduction to Tilde

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

Software Development. Integrated Software Environment

Concepts of Programming Languages

Building a Multi-Language Interpreter Engine

Principles of Programming Languages. Lecture Outline

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

Design & Implementation Overview

Chapter 1. Preliminaries

Chapter 1 Preliminaries

Principles of Computer Game Design and Implementation. Lecture 3

Chapter 1. Preliminaries

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

Chapter 5. Names, Bindings, and Scopes

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

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

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

Programming Languages, Summary CSC419; Odelia Schwartz

CSE 333 Lecture 1 - Systems programming

IMGD 4000 Technical Game Development II Scripting

Servlet Performance and Apache JServ

CMPSC 311- Introduction to Systems Programming Module: Systems Programming

Fiji VM Safety Critical Java

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

Lecture 1 Introduction to Android. App Development for Mobile Devices. App Development for Mobile Devices. Announcement.

Qt + Maemo development


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

Why are there so many programming languages?

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

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

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

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

D Programming Language

CSE 333 Lecture 1 - Systems programming

Programming Paradigms

Compilation I. Hwansoo Han

CMPSC 311- Introduction to Systems Programming Module: Systems Programming

CS 360 Programming Languages Interpreters

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

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

Programming. Dr Ben Dudson University of York

LabWare 7. Why LabWare 7?

Compilers. Prerequisites

Summary: Issues / Open Questions:

Lecture 16. Introduction to Game Development IAP 2007 MIT

Principles of Computer Game Design and Implementation. Lecture 23

CMPSC 311- Introduction to Systems Programming Module: Systems Programming

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

CS Exam #1-100 points Spring 2011

Scripting with Luerl

Chapter Twelve. Systems Design and Development

Using the Computer Programming Environment

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

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

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

A NET Refresher

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

JAVA An overview for C++ programmers

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

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

Visual Basic Primer A. A. Cousins

Vortex OpenSplice. Python DDS Binding

CPSC 3740 Programming Languages University of Lethbridge. Data Types

the gamedesigninitiative at cornell university Lecture 9 Memory Management

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

First Programming Language in CS Education The Arguments for Scala

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

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

Lecture 1: Overview of Java

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

Create-A-Page Design Documentation

LECTURE 3 ADMINISTRATION SECTION -A

Topic 9: Type Checking

Topic 9: Type Checking

Java FX 2.0. Dr. Stefan Schneider Oracle Deutschland Walldorf-Baden

Chapter 21a Other Library Issues

News in RSA-RTE 10.2 updated for sprint Mattias Mohlin, May 2018

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

Martin Kruliš, v

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

Windows 8. Rainer Stropek. System Architecture. System Architecture re of Windows Store Apps. Saves the day. software architects gmbh

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

Our topic. Concurrency Support. Why is this a problem? Why threads? Classic solution? Resulting architecture. Ken Birman

Tutorial 1 Answers. Question 1

Why Hash? Glen Becker, USAA

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

Creating User-Friendly Exploits

Administrivia. Minute Essay From 4/11

Creating Enterprise and WorkGroup Applications with 4D ODBC

Advance Mobile& Web Application development using Angular and Native Script

Is Functional Programming (FP) for me? ACCU Conference 2008 Hubert Matthews

JavaScript Context. INFO/CSE 100, Spring 2005 Fluency in Information Technology.

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

CONTROLLER API EXPLAINED

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

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

Transcription:

Scripting 1

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

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 Scripting languages employ higher level constructs than C++ Reduced iteration time Interpreted, or byte-code compiled on-the-fly Live reload Useful features Automatic resource management (garbage collection) No pointers, safer data structures Dynamic typing 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 Not always significant. 90/10 rule 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++ components at load time Small number of high level scripts running 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? Use C/C++ only to accelerate the performance-critical stuff

Common uses of scripting Mission scripting Track high level goals for player (location to go to) Position mission specific items / entities AI entity behaviours Find nearest entity of another type Issue a pathfind Controlling cut scenes Position entities and cameras, trigger animation and dialog tracks Animation trees / blending If this button gets pressed in this frame range of an animation play this animation

Scripting Philosophy 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 Remember the 90/10 rule

Concurrency It is often convenient to model an entity s 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 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 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# Statically typed Very rich standard libraries Object oriented Object reflection, serialization Properties (C#) Good performance Significant 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 Very different syntax, but similar feature sets Rich standard libraries Dynamically typed Garbage collection Generally pretty slow Large memory footprint All are intended to be much more self contained 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, GC d, interpreted or compiled 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 JavaScript Lots of advantages due to ubiquity in web programming Easy to find/train developers Very fast and embeddable implementations out there

Choice of Languages PHP, Small, Squirrel, Io, interpreted C (LCC), Tcl, etc. There are a lot of choices out there Roll your own? Get exactly the mix of features you want Seamless C++ bindings, state-machines, concurrency, event handling, resource management Less common even at AAA level now UnrealScript: Java with game-oriented features, deprecated GOAL: Naughty Dog s lisp variant, ditched when their Lisp guy retired

Visual scripting languages Get away from text oriented programming environment Popularized by Kismet in UE3 and now Blueprint in UE4 Even more accessible to non-developers

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

How to Bind Macros Clunky, but proven Templates boost::python Hard to write, convenient to use IDL Complex, but language independent 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 Lots of other options though