Squirrel Programming Language By Nandini Bhatta CS537 Summer 2008.

Slides:



Advertisements
Similar presentations
Semantic Analysis Chapter 6. Two Flavors  Static (done during compile time) –C –Ada  Dynamic (done during run time) –LISP –Smalltalk  Optimization.
Advertisements

Introduction to Java Objects CSIS 3701: Advanced Object Oriented Programming.
Written by: Dr. JJ Shepherd
Introduction to the C# Programming Language for the VB Programmer.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Rossella Lau Lecture 8, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 8: Polymorphism & C++ pointer  Inheritance.
Java Syntax Primitive data types Operators Control statements.
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Pointers and Arrays C and Data Structures Baojian Hua
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Java CourseWinter 2009/10. Introduction Object oriented, imperative programming language. Developed: Inspired by C++ programming language.
Arrays, Conditionals & Loops in Java. Arrays in Java Arrays in Java, are a way to store collections of items into a single unit. The array has some number.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Programming Languages and Paradigms Object-Oriented Programming.
Java and C++, The Difference An introduction Unit - 00.
Imperative Programming
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Adapted from Prof. Necula UCB CS 1641 Overview of COOL ICOM 4029 Lecture 2 ICOM 4029 Fall 2008.
OOP with PHP Roman Bednarik
Introduction to Java University of Sunderland CSE301 Harry R. Erwin, PhD.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
An Introduction to Python Blake Brogdon. What is Python?  Python is an interpreted, interactive, object-oriented programming language. (from python.org)
CS212: Object Oriented Analysis and Design Lecture 7: Arrays, Pointers and Dynamic Memory Allocation.
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
Introduction to Java COM379 (Part-Time) University of Sunderland Harry R Erwin, PhD.
Java Programming Java Basics. Data Types Java has two main categories of data types: –Primitive data types Built in data types Many very similar to C++
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
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.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Java – An Object Oriented Language CS 307 Lecture Notes Lecture Weeks 5-6 Khalid Siddiqui.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Object Oriented Programming Lecture 2: BallWorld.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Modern Programming Tools And Techniques-I
Ruby: An Introduction Created by Yukihiro Matsumoto in 1993 (named after his birthstone) Pure OO language (even the number 1 is an instance of a class)
Andy Wang Object Oriented Programming in C++ COP 3330
Java Programming Language
An overview of Java, Data types and variables
PHP.
CS5220 Advanced Topics in Web Programming JavaScript Basics
University of Kurdistan
What is Lua? Brandon Burgess Csc 415.
Assessment – Java Basics: Part 1
Course Overview PART I: overview material PART II: inside a compiler
ICOM 4029 Fall 2003 Lecture 2 (Adapted from Prof. Necula UCB CS 164)
String Class.
Presentation transcript:

Squirrel Programming Language By Nandini Bhatta CS537 Summer 2008

Contents Introduction Features Development State Keywords & Operators Data types Functions, Class & Class instance Variables Local & Global variables…. Squirrel statements Function declaration Class declaration Array Constructor Groovy Vs Squirrel Syntax Comparision Examples Work in progress References

Introduction Started in the year 2003 High level OO programming language Light weight programming language featuring higher- order functions, classes/inheritance Powerful scripting tool that fits in the size, memory bandwidth Real-time requirements of applications like games It has a C-like syntax

Features Open Source Inheritance Exception Handling Polymorphism Compiles on both 32-bit & 64-bit architectures Tail Recursion Dymanic Typing Automatic memory management

Development State Two versions : 1.01 & The current stable release is It can be Compiled and run on Windows and Linux Squirrel is known to run also on MacOS X, GameCube, PSP and XBOX

Keywords & Operators Similar to keywords & operators in Java Keyword examples : case, catch, class, constructor, parent, yield, while, return, resume, null default, delegate, delete, else, enum, switch, true, false, throw, try…. Operators examples : !,!=, ||, ==, &&, >, + +,/, /=, *, *=, %, %=, ++, --, <-, =, &, ^………

Data types Squirrel is a dynamically typed language so variables have no types They refer to a value that does not have a type Squirrel basic types include integer, float, string, null, table, array, function, generator, class, instance, Boolean

Functions, Class & Class instance Functions similar to those in C language Classes created through class expression or class statement. Class members are inherited from another class object at creation time. After creation, members can be added until an instance of the class is created.

Variables Two types of variables in squirrel : local and global variables. Global variables stored in tables and hence referred to as table slots

Local & Global variables…. Squirrel first checks if an identifier is local variable (function arguments) If not it checks if it is a member of the environment object (this) For example : function testy(arg) { local a=10; print(a); return arg; } will access to local variable 'a' and prints 10. function testy(arg) { local a=10; return arg+foo; } In this case ’foo’ is treated as ‘this.foo’

Global variables Global variables are stored in root table Environment object is the root table To explicitly access global table from another scope, the slot name must be pre fixed with ‘::’

Example: Accessing global variable To access global variable ‘foo’ function testy(arg) { local a=10; return arg +::foo; }

Squirrel statements Squirrel program is a simple sequence of statements Squirrel statements are similar to C statements such as assignment, function calls, program flow control structures etc. Statements can be separated with new lines or using ‘;’ stats := stat [';'|'\n'] stats

Function declaration Syntax: funcname := id [ '::' id] stat:= 'function' id [ '::' id]+ '(' args ')'[ ':' '(' args ')'] stat Example: T <- { } function T::ciao(a,b,c) { return a+b-c; }

Class declaration To create a new class : Syntax: memberdecl : = id '=' exp [ ';'] | '[ ' exp ']' '=' exp [ ';'] | functionstat | 'constructor' stat:= 'class' derefexp ['extends' derefexp] '{' [memberdecl] '}‘

contd… Example : class Foo { //constructor constructor(a) { testy = ["stuff",1,2,3]; } //member function function PrintTesty() { foreach(i,val in testy) { ::print("idx = "+i+" = "+val+" \n"); } //property testy = null; }

Array Constructor Syntax: exp := ‘[’ [explist] ‘]’ Example: a <- [ ] //creates an empty array Arrays can be initialized with values during the construction Example: a <- [1,"string!",[ ],{ }] //creates an array with 4 elements

Groovy Vs Squirrel Both are object oriented and dynamic languages. Both can be used as a Scripting Language for the Java Platform. Groovy syntax is similar to Java where as Squirrel syntax is similar to C.

Syntax Comparision The following presents a side-by-side comparison of Groovy with Squirrel: Example 1: Print Statement: Groovy: println "hello world" Squirrel: Local a= “hello world”; Print (a) ;

Example 2 Groovy: def x = x.each{println it} Squirrel: local a=0; do { print(a+"\n"); a+=1; } while(a>10

Example 3 Groovy: if (a>b) { assert c == a-b println c } else { assert c == b-a println c } Squirrel: if(a>b) { c= a-b; print (c); } else { c=b-a; Print (c); }

Inheritance Example class Foo { function DoSomething() { ::print("I'm the base"); } }; class SuperFoo extends Foo { //overridden method function DoSomething() { //calls the base method ::Foo.DoSomething(); ::print("I'm doing something"); }

Work in progress Comparision with Groovy and Java Exploring Squirrel with game programming Exploring Squirrel SQL database

References anguage_-_syntax anguage_-_syntax