CS Software Engineering for Scientific Computing. Lecture 25:Mixed Language Programming.

Size: px
Start display at page:

Download "CS 294-73 Software Engineering for Scientific Computing. http://www.cs.berkeley.edu/~colella/cs294. Lecture 25:Mixed Language Programming."

Transcription

1 CS Software Engineering for Scientific Computing Lecture 25:Mixed Language Programming.

2 Different languages Technical, historical, cultural differences can result in people choosing to program codes you would like to use in different languages. Several options are available to you when you wish to invoke this code as Third Party Library - Re-implement the functions you want in your own language - While this sounds ridiculous, it is actually the dominant means of communicating algorithms to this day. - Translate the code using a tool - f2c is a classic in this category - creates code that lives in your repo. You branch from the reference implementation - Perform inter-language procedure calls, compilation and linking. - Implement a client-server or Service Oriented Architecture (SOA) design. 2"

3 Re-implement Cons Pros - You ll probably not have as much testing and robustness as the widely used package - You might get the routine wrong. - infeasible past a relatively simple level of complexity - You miss out on advances others make in the state-of-the-art. - If you are re-implementing something from a slower execution language (python, or Java) it will probably run faster. - Most tools are happiest when working with a single-language code environment - profilers, build systems, debuggers, revision control, documentation. - nothing special needed to call code written in your own language. Good practice - Keep an active regression test system that compares your implementation with the reference package - See if somebody else is already maintaining a mixed language binding for your language and join that team. Most of this applies to translation approaches 3"

4 Client-Server Models (or SOA) Problem: - Code written in language A - Code written in language B - One needs an operation to be performed be the other Solution: protocol written in language C! - example - HTTP HyperText Transfer Protocol - clients written in any language (browsers, crawlers, etc) - servers written in any language (apache, php, perl, C) While network-centric in practice it is not an essential element. - I can hook up programs with unix pipes and STDIN/STDOUT For long term viability and flexibility this is a good way to insulate your development - transfer all discussion of interoperability to just your own user community, as expressed in your transfer protocol. Communication protocols are much more forgiving than a language semantic but also a terror to debug. 4"

5 C++ calling C Despite the abbreviation, C++ is not C. The main difference is how symbols are named - symbol is the text string that is used to label a function name C compilers are all compatible in their convention for what symbols are named. - I can compile with different C compilers and usually successfully link them together into a common executable. C++ compiler have traditionally all had their own proprietary naming conventions. Easiest to show with an example 5"

6 f1.cpp vs f1.c void f1(int a_a, int a_b, int a_c)! {! int temp = a_a;! double b = a_b;! }! >g++ -c o f1.o f1.cpp! >gcc c o f1c.o f1.c! > nm f1.o ; nm f1c.o! 6"

7 Name Mangling s EH_frame1! T Z2f1iii! S Z2f1iii.eh! s EH_frame1! T _f1! S _f1.eh! Since C does not have overloading, or classes, symbol names do not require any form of mangling Mangling is the process of making up unique string names for member function and overloaded functions. You can look at various object files for classes and functions you have laying around. 7"

8 Linking So what are the consequences on linking your C++ program to C compiled code? #include "f1.h! int main()! {! }! f1(1,2,2);! return 0;! > g++ -c -o f1test.o f1test.cpp! > g++ f1test.o f1c.o! Undefined symbols for architecture x86_64:! "f1(int, int, int)", referenced from:! _main in f1test.o! 8"

9 nm f1test.cpp s EH_frame1! U Z2f1iii! U gxx_personality_v0! T _main! S _main.eh! The linker was looking for Z2f1iii! But f1c.o contains _f1 C++ and C name their functions differently We can tell C++ to instead look for the C named symbol 9"

10 extern C extern "C" {! #include "f1.h! }! int main()! {! f1(1,2,2);! return 0;! }! We can tell the C++ compiler to NOT mangle a function name, but just use the default C naming conventions. Also, I should mention this is called conditional compilation s EH_frame1! U gxx_personality_v0! U _f1! T _main! S _main.eh! 10"

11 Writing a portable C header: f1.h #ifdef cplusplus! extern "C" {! #endif! A macro that is defined by all C++ compilers void f1(int a_a, int a_b, int a_c);! #ifdef cplusplus! }! #endif! 11"

12 Fortran 2003 C Interoperability More cumbersome than you would imagine subroutine f1(a, b, c) BIND(C)! USE ISO_C_BINDING! integer (C_INT) a, b, c;! return! end! Like with the C++ compiler, I can now tell the Fortran compiler to create a symbol with a C naming convention. To call this function from C++ I would need a declaration extern "C" {! }! void f1(int* a, int* b, int* c);! 12"

13 C as the typical default LCD Most languages will provide a means to make their functionality accessible to a C interface. In general, this creates the two step process as shown for Fortran 2003 and C++ 1. library code is instructed to create a C named symbol 2. calling code is instructed to look for a C named symbol - Then the linker can find everything and hook it all up Some languages, like C++, embed their strong typing in their naming convention. Others, like C and F77, do not catch the error of calling a function with the wrong number or type of arguments. We ll stop here with compiled languages. The approach for the rest is the same, but you will rarely encounter the other compiled languages. 13"

14 Interpreted languages Interpreted languages (Java, Python, MATLAB, etc.) These are not linkable (no.o objects) The procedure is quite different depending on which direction you want to go. Interpreted language are executing inside a virtual machine. - It is like an abstraction of a computer, but is in reality just another executing process Python calling C++: Extending Recall, most languages provide a mechanism to create a C binding for their functions. - Write wrapper code that includes Python.H - This includes parsing your string inputs - compile to a C binding - link into a shared library - load shared library into the python interpreter with the import function 14"

15 Simple wrapped function #include Python.h! static PyObject * toy_system(pyobject *self, PyObject *args)! {! }! const char *command; int sts;! if (!PyArg_ParseTuple(args, "s", &command))! return NULL;! sts = system(command);! return Py_BuildValue("i", sts);! 15"

16 Not done yet. Also need a vtable static PyMethodDef ToyMethods[] =! { {"system", toy_system, METH_VARARGS, "Execute a shell command."},! {NULL, NULL, 0, NULL} /* Sentinel */ }; //and still not done yet static struct PyModuleDef toymodule = {! PyModuleDef_HEAD_INIT,! "toy", /* name of module */! NULL, /* module documentation, may be NULL */! -1, /* size of per-interpreter state of the module,! variables. */! ToyMethods! };! or -1 if the module keeps state in global 16"

17 and still not done yet: Init function PyObject* PyInit_toy(void)! {! PyObject* res = PyModule_Create(&toymodule);! if (!res) return NULL;! return res;! }! So, what do you do with this toy.cpp file?! 17"

18 Compiling and linking a python module > g++ -c -fpic -I/Library/Frameworks/ Python.framework/Versions/3.2/include/python3.2m/ -o toy.o toy.cpp! - -fpic creates Position Independent Code. It means that all the pointer offsets in the function are relative to the stack frame, not the function address. This makes is relocatable. > g++ -shared -L/Library/Frameworks/ Python.framework/Versions/Current/lib -lpython3.2 -o toy.so toy.o! - -shared means we are building a dynamic or shared library 18"

19 Using a Python Module > python! Python (v3.2.2:137e45f15c0b, Sep , 17:28:59)! [GCC (Apple Inc. build 5666) (dot 3)] on darwin! Type "help", "copyright", "credits" or "license" for more information.! >>> import toy! >>> toy.system("ls -la");! total 40! drwxr-xr-x 5 bvs bvs 170 Nov 21 17:15.! drwxr-xr-x 102 bvs bvs 3468 Nov 21 16:39..! -rw-r--r-- 1 bvs bvs 831 Nov 21 17:03 toy.cpp! -rw-r--r-- -rwxr-xr-x 0! >>>! 1 bvs bvs 1872 Nov 21 17:03 toy.o! 1 bvs bvs 8748 Nov 21 17:06 toy.so! 19"

20 Why would we do this? Python is nice and fun to use. Good for rapidly prototyping new ideas. The interpreter can make you code quite slow. You can link in optimized and compiled code for the performance critical operations in your program. 20"

21 Why would we not do this? Good bye debugging Good bye profiling To get those things back you end up re-implementing your code base in the compiled language It is not hopeless to debug python modules 21"

22 Debugging Python Modules >gdb python! (gdb) run! >>> import toy! Reading symbols for shared libraries. done! >>>! Program received signal SIGINT, Interrupt.! 0x00007fff8a3ad932 in select$darwin_extsn ()! (gdb) break toy_system! Breakpoint 1 at 0x100669e66! (gdb) cont! Continuing.! toy.system("ls -la");! Breakpoint 1, 0x e66 in toy_system ()! (gdb) where! #0 0x e66 in toy_system ()! #1 0x b31f4 in PyEval_EvalFrameEx ()! #2 0x b41ba in PyEval_EvalCodeEx ()! #3 0x b44cf in PyEval_EvalCode ()! #4 0x db16e in PyRun_InteractiveOneFlags ()! #5 0x db43e in PyRun_InteractiveLoopFlags ()! #6 0x dbc71 in PyRun_AnyFileExFlags ()! #7 0x f0982 in Py_Main ()! #8 0x e5f in dyld_stub_strlen ()! #9 0x d04 in?? ()! 22"

23 C++ calling Python: Embedding #include <Python.h>! int main(int argc, char *argv[])! {! }! Py_Initialize();! PyRun_SimpleString("from time import ctime\n! Py_Finalize();! return 0;! print(ctime())\n");! >g++ -I/Library/Frameworks/Python.framework/Versions/ 3.2/include/python3.2m/ -L/Library/Frameworks/ Python.framework/Versions/3.2/lib -lpython3.2 simple.cpp! >./a.out! Mon Nov 21 21:45: ! 23"

24 To get fancier, you need to use Py interface Catching the return types from functions - PyObject dynamic casting return types to their derived types Turning your arguments into strings that get handed through the python parser. This gets ugly very quickly - It also changes syntax as you move through minor Python version numbers (?!?!) yes, that is a bad thing You end up parsing a lot of PyList objects in the raw interface. 24"

25 Tools SIP and SWIG - Automate much of the mechanical part of generating wrapper code given existing C or C++ code. Just have to follow certain coding conventions - Still not really automatic - Not all language semantics have an analogue between the languages. Boost.python - A set of C++ classes and templates that make 25"

26 Boost.python #include <boost/python.hpp>! char const* greet()! { return "hello, world"; }! BOOST_PYTHON_MODULE(hello_ext)! { using namespace boost::python;! def("greet", greet);! }! I ll skip the complicated compilation.! >>> import hello_ext! >>> print hello_ext.greet()! hello, world! 26"

27 Java works in a similar way The two languages are contemporaries really Java has been a bit schizophrenic about it s C interface. - Native C interfaces make it very hard to make your program certifiably secure. - Native C code makes your Java code non-portable, non- webbish Still, you have to either provide *everything* in your language, or provide an interface to C. - Not too many device drivers get written in Java. (Java s support for Real Time execution is still pretty new and brittle). The Java Native Interface is specified in <jni.h> First, we look at extending 27"

28 HelloWorld.h #include <jni.h>! #ifndef _Included_HelloWorld! #define _Included_HelloWorld! extern "C" {! JNIEXPORT void JNICALL Java_HelloWorld_print (JNIEnv *, jobject);! }! #endif! 28"

29 HelloWorld.cpp #include <jni.h>! #include <stdio.h>! #include "HelloWorld.h! JNIEXPORT void JNICALL Java_HelloWorld_print(JNIEnv *env, jobject obj)! {! }! printf("hello World!\n");! return;! 29"

30 HelloWorld.java class HelloWorld! {! private native void print();! public static void main(string[] args)! {! new HelloWorld().print();! }! static! { System.loadLibrary("HelloWorld"); }! }! 30"

31 Building it all and running >javac HelloWorld.java! >g++ -shared HelloWorld.cpp -o libhelloworld.so! >java HelloWorld! Hello World!! Now, there are also tools to help you get further along - javah - SWIG - reads a java class file and generates a header file stub for you - can parse your C/C++ code and generate shadow classes and wrappers to help you with JNI as well. Microsoft thinks they know better, or they just want Java to fail. MS tools to link with Java are notoriously buggy 31"

32 Java Embedding #include <jni.h>! JNIEnv* create_vm(javavm ** jvm)! { JNIEnv *env; JavaVMInitArgs vm_args;! JavaVMOption options;! options.optionstring = "-Djava.class.path=D:\ \Java Src\\TestStruct";! vm_args.version = JNI_VERSION_1_6;! vm_args.noptions = 1;! vm_args.options = &options;! vm_args.ignoreunrecognized = 0;! int ret = JNI_CreateJavaVM(jvm, (void**)&env, &vm_args);! if(ret < 0) printf("\nunable to Launch JVM\n");! return env;! }! 32"

33 What do you do with a JavaVM? Much the same as you would do with a Python VM Build up strings to pass to Java functions Handle Java Objects as return types. Most useful if you have a large Java written GUI already set up and working, but want to call it from your code. - This doesn t come up very often Mostly just wanted to show that interpreted languages have two kinds of interoperability, and there is a virtual machine. 33"

Numerical Algorithms Group

Numerical Algorithms Group Title: Summary: Calling C Library Routines from Java Using the Java Native Interface This paper presents a technique for calling C library routines directly from Java, saving you the trouble of rewriting

More information

The C Programming Language course syllabus associate level

The C Programming Language course syllabus associate level TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

More information

CSC230 Getting Starting in C. Tyler Bletsch

CSC230 Getting Starting in C. Tyler Bletsch CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly

More information

Programming CAN-based Fieldbus Systems using Java

Programming CAN-based Fieldbus Systems using Java Title Programming CAN-based Fieldbus Systems using Java Manuel Joaquim Pereira dos Santos, Ricardo José Caetano Loureiro Universidade de Aveiro, Aveiro, Portugal, Helmut Dispert Department of Computer

More information

An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer. University of Wyoming MA 5310 An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

More information

Using EDA Databases: Milkyway & OpenAccess

Using EDA Databases: Milkyway & OpenAccess Using EDA Databases: Milkyway & OpenAccess Enabling and Using Scripting Languages with Milkyway and OpenAccess Don Amundson Khosro Khakzadi 2006 LSI Logic Corporation 1 Outline History Choice Of Scripting

More information

Introduction to Native Android Development with NDK

Introduction to Native Android Development with NDK Introduction to Native Android Development with NDK Outline Motivation: case study of a real project Android Architecture Simplified Tool chain Diagram Adding 3 rd party modules Adding pdf and encrypted

More information

Extending your Qt Android application using JNI

Extending your Qt Android application using JNI Extending your Qt Android alication using JNI Dev Days, 2014 Presented by BogDan Vatra Material based on Qt 5.3, created on November 13, 2014 Extending your alication using JNI Extending your alication

More information

Crash Course in Java

Crash Course in Java Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

More information

CSC 551: Web Programming. Spring 2004

CSC 551: Web Programming. Spring 2004 CSC 551: Web Programming Spring 2004 Java Overview Design goals & features platform independence, portable, secure, simple, object-oriented, Programming models applications vs. applets vs. servlets intro

More information

Getting Started with the Internet Communications Engine

Getting Started with the Internet Communications Engine Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2

More information

Java Crash Course Part I

Java Crash Course Part I Java Crash Course Part I School of Business and Economics Institute of Information Systems HU-Berlin WS 2005 Sebastian Kolbe skolbe@wiwi.hu-berlin.de Overview (Short) introduction to the environment Linux

More information

A Native Client for the Hadoop Distributed Filesystem by Colin P. McCabe

A Native Client for the Hadoop Distributed Filesystem by Colin P. McCabe A Native Client for the Hadoop Distributed Filesystem by Colin P. McCabe About Me I work on HDFS and related storage technologies at Cloudera. Committer on the HDFS and Hadoop projects. Previously worked

More information

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint) TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions

More information

C Programming Review & Productivity Tools

C Programming Review & Productivity Tools Review & Productivity Tools Giovanni Agosta Piattaforme Software per la Rete Modulo 2 Outline Preliminaries 1 Preliminaries 2 Function Pointers Variadic Functions 3 Build Automation Code Versioning 4 Preliminaries

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Wrapper Generator using Java Native Interface

Wrapper Generator using Java Native Interface Wrapper Generator using Java Native Interface Abstract V.S.Vairale 1 and K.N.Honwadkar 2 1 Department of Computer Engineering, AISSMS College of Engineering, Pune University, Pune, India vaishali.vairale@gmail.com

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

GDB Tutorial. A Walkthrough with Examples. CMSC 212 - Spring 2009. Last modified March 22, 2009. GDB Tutorial

GDB Tutorial. A Walkthrough with Examples. CMSC 212 - Spring 2009. Last modified March 22, 2009. GDB Tutorial A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program

More information

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,

More information

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution CSE 452: Programming Languages Java and its Evolution Acknowledgements Rajkumar Buyya 2 Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java

More information

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 1 Goals of the Lecture Present an introduction to Objective-C 2.0 Coverage of the language will be INCOMPLETE

More information

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

Development_Setting. Step I: Create an Android Project

Development_Setting. Step I: Create an Android Project A step-by-step guide to setup developing and debugging environment in Eclipse for a Native Android Application. By Yu Lu (Referenced from two guides by MartinH) Jan, 2012 Development_Setting Step I: Create

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Java applets. SwIG Jing He

Java applets. SwIG Jing He Java applets SwIG Jing He Outline What is Java? Java Applications Java Applets Java Applets Securities Summary What is Java? Java was conceived by James Gosling at Sun Microsystems Inc. in 1991 Java is

More information

SQLITE C/C++ TUTORIAL

SQLITE C/C++ TUTORIAL http://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm SQLITE C/C++ TUTORIAL Copyright tutorialspoint.com Installation Before we start using SQLite in our C/C++ programs, we need to make sure that we have

More information

C# and Other Languages

C# and Other Languages C# and Other Languages Rob Miles Department of Computer Science Why do we have lots of Programming Languages? Different developer audiences Different application areas/target platforms Graphics, AI, List

More information

Channel Access Client Programming. Andrew Johnson Computer Scientist, AES-SSG

Channel Access Client Programming. Andrew Johnson Computer Scientist, AES-SSG Channel Access Client Programming Andrew Johnson Computer Scientist, AES-SSG Channel Access The main programming interface for writing Channel Access clients is the library that comes with EPICS base Written

More information

Programmierpraktikum

Programmierpraktikum Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 21 10/16/2012 09:29 AM Java - A First Glance 2 of 21 10/16/2012 09:29 AM programming languages

More information

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

More information

What Perl Programmers Should Know About Java

What Perl Programmers Should Know About Java Beth Linker, blinker@panix.com Abstract The Java platform is by no means a replacement for Perl, but it can be a useful complement. Even if you do not need to or want to use Java, you should know a bit

More information

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY COURSE MODULE (C, C++, DS) KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

More information

Contents. Java - An Introduction. Java Milestones. Java and its Evolution

Contents. Java - An Introduction. Java Milestones. Java and its Evolution Contents Java and its Evolution Rajkumar Buyya Grid Computing and Distributed Systems Lab Dept. of Computer Science and Software Engineering The University of Melbourne http:// www.buyya.com Java Introduction

More information

Chapter 12 Programming Concepts and Languages

Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages Paradigm Publishing, Inc. 12-1 Presentation Overview Programming Concepts Problem-Solving Techniques The Evolution

More information

Jonathan Worthington Scarborough Linux User Group

Jonathan Worthington Scarborough Linux User Group Jonathan Worthington Scarborough Linux User Group Introduction What does a Virtual Machine do? Hides away the details of the hardware platform and operating system. Defines a common set of instructions.

More information

Chapter 1 Java Program Design and Development

Chapter 1 Java Program Design and Development presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented

More information

1001ICT Introduction To Programming Lecture Notes

1001ICT Introduction To Programming Lecture Notes 1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 3 A First MaSH Program In this section we will describe a very

More information

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Programs and Methods Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Programs and Methods 1 / 8 The Anatomy of a Java Program It is customary

More information

Multithreading and Java Native Interface (JNI)!

Multithreading and Java Native Interface (JNI)! SERE 2013 Secure Android Programming: Best Practices for Data Safety & Reliability Multithreading and Java Native Interface (JNI) Rahul Murmuria, Prof. Angelos Stavrou rmurmuri@gmu.edu, astavrou@gmu.edu

More information

Programming in Python. Basic information. Teaching. Administration Organisation Contents of the Course. Jarkko Toivonen. Overview of Python

Programming in Python. Basic information. Teaching. Administration Organisation Contents of the Course. Jarkko Toivonen. Overview of Python Programming in Python Jarkko Toivonen Department of Computer Science University of Helsinki September 18, 2009 Administration Organisation Contents of the Course Overview of Python Jarkko Toivonen (CS

More information

Tutorial: Getting Started

Tutorial: Getting Started 9 Tutorial: Getting Started INFRASTRUCTURE A MAKEFILE PLAIN HELLO WORLD APERIODIC HELLO WORLD PERIODIC HELLO WORLD WATCH THOSE REAL-TIME PRIORITIES THEY ARE SERIOUS SUMMARY Getting started with a new platform

More information

Programming Languages CIS 443

Programming Languages CIS 443 Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception

More information

Java Programming. Binnur Kurt binnur.kurt@ieee.org. Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Java Programming. Binnur Kurt binnur.kurt@ieee.org. Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0. Java Programming Binnur Kurt binnur.kurt@ieee.org Istanbul Technical University Computer Engineering Department Java Programming 1 Version 0.0.4 About the Lecturer BSc İTÜ, Computer Engineering Department,

More information

Chapter 1. Dr. Chris Irwin Davis Email: cid021000@utdallas.edu Phone: (972) 883-3574 Office: ECSS 4.705. CS-4337 Organization of Programming Languages

Chapter 1. Dr. Chris Irwin Davis Email: cid021000@utdallas.edu Phone: (972) 883-3574 Office: ECSS 4.705. CS-4337 Organization of Programming Languages Chapter 1 CS-4337 Organization of Programming Languages Dr. Chris Irwin Davis Email: cid021000@utdallas.edu Phone: (972) 883-3574 Office: ECSS 4.705 Chapter 1 Topics Reasons for Studying Concepts of Programming

More information

VOC Documentation. Release 0.1. Russell Keith-Magee

VOC Documentation. Release 0.1. Russell Keith-Magee VOC Documentation Release 0.1 Russell Keith-Magee February 07, 2016 Contents 1 About VOC 3 1.1 The VOC Developer and User community................................ 3 1.2 Frequently Asked Questions.......................................

More information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

How To Use The C Preprocessor

How To Use The C Preprocessor Environnements et Outils de Développement Cours 3 The C build process Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire PPS, Université Paris Diderot - Paris 7 URL http://upsilon.cc/~zack/teaching/1112/ed6/

More information

Semantic Analysis: Types and Type Checking

Semantic Analysis: Types and Type Checking Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors

More information

CTutor. Tiago Aguiar tiago.afonso.aguiar@ist.utl.pt. Instituto Superior Técnico, Lisboa, Portugal November 2014

CTutor. Tiago Aguiar tiago.afonso.aguiar@ist.utl.pt. Instituto Superior Técnico, Lisboa, Portugal November 2014 CTutor Tiago Aguiar tiago.afonso.aguiar@ist.utl.pt Instituto Superior Técnico, Lisboa, Portugal November 2014 Abstract CTutor is a program visualization tool for the programming language, C. As the name

More information

1/20/2016 INTRODUCTION

1/20/2016 INTRODUCTION INTRODUCTION 1 Programming languages have common concepts that are seen in all languages This course will discuss and illustrate these common concepts: Syntax Names Types Semantics Memory Management We

More information

Libmonitor: A Tool for First-Party Monitoring

Libmonitor: A Tool for First-Party Monitoring Libmonitor: A Tool for First-Party Monitoring Mark W. Krentel Dept. of Computer Science Rice University 6100 Main St., Houston, TX 77005 krentel@rice.edu ABSTRACT Libmonitor is a library that provides

More information

6.s096. Introduction to C and C++

6.s096. Introduction to C and C++ 6.s096 Introduction to C and C++ 1 Why? 2 1 You seek performance 3 1 You seek performance zero-overhead principle 4 2 You seek to interface directly with hardware 5 3 That s kinda it 6 C a nice way to

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper

More information

Lesson 06: Basics of Software Development (W02D2

Lesson 06: Basics of Software Development (W02D2 Lesson 06: Basics of Software Development (W02D2) Balboa High School Michael Ferraro Lesson 06: Basics of Software Development (W02D2 Do Now 1. What is the main reason why flash

More information

ECS 165B: Database System Implementa6on Lecture 2

ECS 165B: Database System Implementa6on Lecture 2 ECS 165B: Database System Implementa6on Lecture 2 UC Davis, Spring 2011 Por6ons of slides based on earlier ones by Raghu Ramakrishnan, Johannes Gehrke, Jennifer Widom, Bertram Ludaescher, and Michael Gertz.

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

sys socketcall: Network systems calls on Linux

sys socketcall: Network systems calls on Linux sys socketcall: Network systems calls on Linux Daniel Noé April 9, 2008 The method used by Linux for system calls is explored in detail in Understanding the Linux Kernel. However, the book does not adequately

More information

Motorola 8- and 16-bit Embedded Application Binary Interface (M8/16EABI)

Motorola 8- and 16-bit Embedded Application Binary Interface (M8/16EABI) Motorola 8- and 16-bit Embedded Application Binary Interface (M8/16EABI) SYSTEM V APPLICATION BINARY INTERFACE Motorola M68HC05, M68HC08, M68HC11, M68HC12, and M68HC16 Processors Supplement Version 2.0

More information

Comp151. Definitions & Declarations

Comp151. Definitions & Declarations Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const

More information

Keil C51 Cross Compiler

Keil C51 Cross Compiler Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation

More information

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014 CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages Nicki Dell Spring 2014 What is a Programming Language? A set of symbols and associated tools that translate (if necessary) collections

More information

Application Note C++ Debugging

Application Note C++ Debugging Application Note C++ Debugging TRACE32 Online Help TRACE32 Directory TRACE32 Index TRACE32 Documents... High-Level Language Debugging... Application Note C++ Debugging... 1 Sample Code used by This Application

More information

Parallelization: Binary Tree Traversal

Parallelization: Binary Tree Traversal By Aaron Weeden and Patrick Royal Shodor Education Foundation, Inc. August 2012 Introduction: According to Moore s law, the number of transistors on a computer chip doubles roughly every two years. First

More information

The programming language C. sws1 1

The programming language C. sws1 1 The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

Mixing Python and Java How Python and Java can communicate and work together

Mixing Python and Java How Python and Java can communicate and work together Mixing Python and Java How Python and Java can communicate and work together EuroPython 2009 (June 30th 2009, Birmingham) Andreas Schreiber German Aerospace Center (DLR), Cologne,

More information

C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

Python, C++ and SWIG

Python, C++ and SWIG Robin Dunn Software Craftsman O Reilly Open Source Convention July 21 25, 2008 Slides available at http://wxpython.org/oscon2008/ Python & C++ Comparisons Each is a general purpose programming language,

More information

CS 253: Intro to Systems Programming

CS 253: Intro to Systems Programming CS 253: Intro to Systems Programming Spring 2014 Amit Jain, Shane Panter, Marissa Schmidt Department of Computer Science College of Engineering Boise State University Logistics Instructor: Amit Jain http://cs.boisestate.edu/~amit

More information

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1 The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose

More information

Introduction to Scientific Computing Part II: C and C++ C. David Sherrill School of Chemistry and Biochemistry Georgia Institute of Technology

Introduction to Scientific Computing Part II: C and C++ C. David Sherrill School of Chemistry and Biochemistry Georgia Institute of Technology Introduction to Scientific Computing Part II: C and C++ C. David Sherrill School of Chemistry and Biochemistry Georgia Institute of Technology The C Programming Language: Low-level operators Created by

More information

Class 16: Function Parameters and Polymorphism

Class 16: Function Parameters and Polymorphism Class 16: Function Parameters and Polymorphism SI 413 - Programming Languages and Implementation Dr. Daniel S. Roche United States Naval Academy Fall 2011 Roche (USNA) SI413 - Class 16 Fall 2011 1 / 15

More information

Introduction. Why (GIS) Programming? Streamline routine/repetitive procedures Implement new algorithms Customize user applications

Introduction. Why (GIS) Programming? Streamline routine/repetitive procedures Implement new algorithms Customize user applications Introduction Why (GIS) Programming? Streamline routine/repetitive procedures Implement new algorithms Customize user applications 1 Computer Software Architecture Application macros and scripting - AML,

More information

Chapter 13 - The Preprocessor

Chapter 13 - The Preprocessor Chapter 13 - The Preprocessor Outline 13.1 Introduction 13.2 The#include Preprocessor Directive 13.3 The#define Preprocessor Directive: Symbolic Constants 13.4 The#define Preprocessor Directive: Macros

More information

Compiler I: Syntax Analysis Human Thought

Compiler I: Syntax Analysis Human Thought Course map Compiler I: Syntax Analysis Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy Translator Chapters 7-8 Assembly

More information

6.170 Tutorial 3 - Ruby Basics

6.170 Tutorial 3 - Ruby Basics 6.170 Tutorial 3 - Ruby Basics Prerequisites 1. Have Ruby installed on your computer a. If you use Mac/Linux, Ruby should already be preinstalled on your machine. b. If you have a Windows Machine, you

More information

1 Abstract Data Types Information Hiding

1 Abstract Data Types Information Hiding 1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content

More information

9/11/15. What is Programming? CSCI 209: Software Development. Discussion: What Is Good Software? Characteristics of Good Software?

9/11/15. What is Programming? CSCI 209: Software Development. Discussion: What Is Good Software? Characteristics of Good Software? What is Programming? CSCI 209: Software Development Sara Sprenkle sprenkles@wlu.edu "If you don't think carefully, you might think that programming is just typing statements in a programming language."

More information

Glossary of Object Oriented Terms

Glossary of Object Oriented Terms Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

More information

How To Write Portable Programs In C

How To Write Portable Programs In C Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important

More information

Evolution of the Major Programming Languages

Evolution of the Major Programming Languages 142 Evolution of the Major Programming Languages Object Oriented Programming: Smalltalk Object-Oriented: It s fundamental characteristics are: Data abstraction, Inheritance and Dynamic Binding. The essence

More information

CORBA Programming with TAOX11. The C++11 CORBA Implementation

CORBA Programming with TAOX11. The C++11 CORBA Implementation CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy

More information

Format string exploitation on windows Using Immunity Debugger / Python. By Abysssec Inc WwW.Abysssec.Com

Format string exploitation on windows Using Immunity Debugger / Python. By Abysssec Inc WwW.Abysssec.Com Format string exploitation on windows Using Immunity Debugger / Python By Abysssec Inc WwW.Abysssec.Com For real beneficiary this post you should have few assembly knowledge and you should know about classic

More information

Testing for Security

Testing for Security Testing for Security Kenneth Ingham September 29, 2009 1 Course overview The threat that security breaches present to your products and ultimately your customer base can be significant. This course is

More information

Programming Languages

Programming Languages Programming Languages Qing Yi Course web site: www.cs.utsa.edu/~qingyi/cs3723 cs3723 1 A little about myself Qing Yi Ph.D. Rice University, USA. Assistant Professor, Department of Computer Science Office:

More information

Parameter Passing. Standard mechanisms. Call by value-result Call by name, result

Parameter Passing. Standard mechanisms. Call by value-result Call by name, result Parameter Passing Standard mechanisms Call by value Call by reference Other methods Call by value-result Call by name, result Terms Function definition where the details of the function are presented (type,

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II C++ intro Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 26, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February 26,

More information

Instructor: Betty O Neil

Instructor: Betty O Neil Introduction to Web Application Development, for CS437/637 Instructor: Betty O Neil 1 Introduction: Internet vs. World Wide Web Internet is an interconnected network of thousands of networks and millions

More information

PetaLinux SDK User Guide. Application Development Guide

PetaLinux SDK User Guide. Application Development Guide PetaLinux SDK User Guide Application Development Guide Notice of Disclaimer The information disclosed to you hereunder (the "Materials") is provided solely for the selection and use of Xilinx products.

More information

LINKED DATA STRUCTURES

LINKED DATA STRUCTURES LINKED DATA STRUCTURES 1 Linked Lists A linked list is a structure in which objects refer to the same kind of object, and where: the objects, called nodes, are linked in a linear sequence. we keep a reference

More information

Java Programming Fundamentals

Java Programming Fundamentals Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few

More information

02 B The Java Virtual Machine

02 B The Java Virtual Machine 02 B The Java Virtual Machine CS1102S: Data Structures and Algorithms Martin Henz January 22, 2010 Generated on Friday 22 nd January, 2010, 09:46 CS1102S: Data Structures and Algorithms 02 B The Java Virtual

More information

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

An Introduction to Assembly Programming with the ARM 32-bit Processor Family An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2

More information

Tail call elimination. Michel Schinz

Tail call elimination. Michel Schinz Tail call elimination Michel Schinz Tail calls and their elimination Loops in functional languages Several functional programming languages do not have an explicit looping statement. Instead, programmers

More information

www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk

www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling

More information

Advantages of PML as an iseries Web Development Language

Advantages of PML as an iseries Web Development Language Advantages of PML as an iseries Web Development Language What is PML PML is a highly productive language created specifically to help iseries RPG programmers make the transition to web programming and

More information

Example of Standard API

Example of Standard API 16 Example of Standard API System Call Implementation Typically, a number associated with each system call System call interface maintains a table indexed according to these numbers The system call interface

More information