Cut. it s not just for Google. Eleanor McHugh.
|
|
- Brooke Dalton
- 6 years ago
- Views:
Transcription
1 Ro u gh Cut! Go it s not just for Google Eleanor McHugh
2 compiled
3 garbage collected
4 imperative
5 package main import fmt const HELLO string = hello var WORLD string = world func main() { fmt.println(hello, WORLD)
6 strongly typed
7 boolean, numeric, array value structure, interface reference pointer, slice, string, map, channel function function, method, closure
8 underlying type method set expressed type
9 underlying type method set expressed type embedded types
10 package Integer type Int int func (i *Int) Add(x int) { *i += Int(x)
11 type Buffer []Int func (b Buffer) Swap(i, j int) { b[i], b[j] = b[j], b[i] func (b Buffer) Clone() Buffer { s := make(buffer, len(b)) copy(s, b) return s func (b Buffer) Move(i, n int) { if n > len(b) - i { n = len(b) - i segment_to_move := b[:i].clone() copy(b, b[i:i + n]) copy(b[n:i + n], segment_to_move)
12 package main import fmt import "Integer" func main() { i := Integer.Buffer{0, 1, 2, 3, 4, 5 b := i.clone() b.swap(1, 2) b.move(3, 2) b[0].add(3) fmt.printf( b[0:2] = %v\n, b[0:2]) produces: b[0:2] = [6 4]
13 testable
14 func (b Buffer) Eq(o Buffer) (r bool) { if len(b) == len(o) { for i := len(b) - 1; i > 0; i-- { if b[i]!= o[i] { return r = true return
15 func TestSwap(t *testing.t) { i := Buffer{0, 1, 2, 3, 4, 5 b := i.clone() b.swap(1, 2) if!b[1:3].eq(buffer{2, 1) { t.fatalf("b = %v", b)
16 package Vector import. "Integer" type Vector struct { Buffer func (v *Vector) Clone() *Vector { return &Vector{v.Buffer.Clone() func (v *Vector) Slice(i, j int) Buffer { return v.buffer[i:j]
17 package Vector import "testing" func TestVectorSwap(t *testing.t) { i := Vector{Buffer{0, 1, 2, 3, 4, 5 v := i.clone() v.swap(1, 2) r := Vector{Buffer{0, 2, 1, 3, 4, 5 switch { case!v.eq(r.buffer): fallthrough case!v.buffer.eq(r.buffer): t.fatalf("b[0:5] = %v", v)
18 include $(GOROOT)/src/Make.inc TARG=integer GOFILES=\ integer.go\ vector.go include $(GOROOT)/src/Make.pkg
19 func BenchmarkVectorClone6(b *testing.b) { v := Vector{Buffer{0, 1, 2, 3, 4, 5 for i := 0; i < b.n; i++ { _ = v.clone() func BenchmarkVectorSwap(b *testing.b) { b.stoptimer() v := Vector{Buffer{0, 1, 2, 3, 4, 5 b.starttimer() for i := 0; i < b.n; i++ { v.swap(1, 2)
20 $ gotest -bench="benchmark" rm -f _test/scripts.a 6g -o _gotest_.6 integer.go vector.go nominal_typing_test.go embedded_typing_benchmark_test.go embedded_typing_test.go rm -f _test/scripts.a gopack grc _test/scripts.a _gotest_.6 PASS integer.benchmarkvectorswap ns/op integer.benchmarkvectorclone ns/op
21 dynamic
22 type Adder interface { Add(j int) Subtract(j int) Result() interface{ Reset()
23 type IAdder int func (i IAdder) Add(j int) { i[0] += i[j] func (i IAdder) Subtract(j int) { i[0] -= i[j] func (i IAdder) Result() interface{ { return i[0] func (i IAdder) Reset() { i[0] = *new(int)
24 type FAdder []float32 func (f FAdder) Add(j int) { f[0] += f[j] func (f FAdder) Subtract(j int) { f[0] -= f[j] func (f FAdder) Result() interface{ { return f[0]
25 func TestAdder(t *testing.t) { var a Adder a = IAdder{0, 1, 2 a.add(1) if i.result().(int)!= 1 { t.fatalf("iadder::add(1) %v!= %v", a.result(), 1) a.subtract(2) if a.result().(int)!= -1 { t.fatalf("iadder::subtract(2) %v!= %v", a.result()), -1 a = FAdder{0.0, 1.0, 2.0 a.add(1) if a.result().(float32)!= 1.0 { t.fatalf("fadder::add(1) %v!= %v", a.result(), 1.0)
26 reflected
27 package generalise import "reflect" func Allocate(i interface{, limit... int) (n interface{) { switch v := reflect.valueof(i); v.kind() { case reflect.slice: l := v.cap() if len(limit) > 0 { l = limit[0] n = reflect.makeslice(v.type(), l, l).interface() case reflect.map: return n = reflect.makemap(v.type()).interface()
28 package generalise import. "reflect" func Allocate(i interface{, limit... int) (n interface{) { switch v := ValueOf(i); v.kind() { case Slice: l := v.cap() if len(limit) > 0 { l = limit[0] n = MakeSlice(v.Type(), l, l).interface() case Map: return n = MakeMap(v.Type()).Interface()
29 func throwspanic(f func()) (b bool) { defer func() { if x := recover(); x!= nil { b = true () f() return
30 func TestAllocate(t *testing.t) { var s2 []int s1 := []int{0, 1, 2 m := map[int] int{1: 1, 2: 2, 3: 3 switch { case throwspanic(func() { s2 = Allocate(s1, 1).([]int) ): t.fatal("unable to allocate new slice") case len(s2)!= 1 cap(s2)!= 1: t.fatal("new slice should be %v not %v", make([]int, 0, 1), s2) case throwspanic(func() { Allocate(m) ): t.fatal("unable to allocate new map")
31 func Duplicate(i interface{) (clone interface{) { if clone = Allocate(i); clone!= nil { switch clone := ValueOf(clone); clone.kind() { case Slice: Copy(clone, ValueOf(i)) case Map: return m := ValueOf(i) for _, k := range m.keys() { clone.setmapindex(k, m.mapindex(k))
32 func TestDuplicateSlice(t *testing.t) { s1 := []int{0, 1, 2 var s2 []int if throwspanic(func() { s2 = Duplicate(s1).([]int) ) { t.fatalf("unable to duplicate slice %v\n", s1) switch { case len(s1)!= len(s2): fallthrough case cap(s1)!= cap(s2): fallthrough case s1[0]!= s2[0]: fallthrough case s1[1]!= s2[1]: fallthrough case s1[2]!= s2[2]: fallthrough t.fatalf("duplicating %v produced %v", s1, s2)
33 func TestDuplicateMap(t *testing.t) { m1 := map[int]int{1: 1, 2: 2, 3: 3 var m2 map[int]int if throwspanic(func() { m2 = Duplicate(m1).(map[int]int) ) { t.fatalf("unable to duplicate map %v\n", m1) switch { case len(m1)!= len(m2): fallthrough case m1[1]!= m2[1]: fallthrough case m1[2]!= m2[2]: fallthrough case m1[3]!= m2[3]: fallthrough t.fatalf("duplicating %v produced %v", m1, m2)
34 low-level
35 package raw import. "reflect" import "unsafe" var _BYTE_SLICE Type = Typeof([]byte(nil)) type MemoryBlock interface { ByteSlice() []byte func valueheader(v reflect.value) (Header *reflect.sliceheader) { if v.isvalid() { s := int(v.type().size()) header = &reflect.sliceheader{ v.unsafeaddr(), s, s return
36 func SliceHeader(i interface{) (Header *SliceHeader, Size, Align int) { switch value := Indirect(ValueOf(i)); value.kind() { case Slice: Header = (*SliceHeader)(unsafe.Pointer(value.UnsafeAddr())) t := value.type().elem() Size = int(t.size()) Align = t.align() case Interface: Header, Size, Align = SliceHeader(value.Elem()) return func Scale(oldHeader *SliceHeader, oldesize, newesize int) (h *SliceHeader) { if oldheader!= nil { s := float64(oldesize) / float64(newesize) h = &SliceHeader{ Data: oldheader.data h.len = int(float64(oldheader.len) * s) h.cap = int(float64(oldheader.cap) * s) return
37 func ByteSlice(i interface{) []byte { switch i := i.(type) { case []byte: return i case MemoryBlock: return i.byteslice() var header *SliceHeader switch v := ValueOf(i); value.kind() { case Interface, Ptr: header = valueheader(v.elem()) case Slice: h, s, _ := SliceHeader(i) header = Scale(h, s, 1) case String: s := v.get() h := *(*StringHeader)(unsafe.Pointer(&s)) header = &SliceHeader{ h.data, h.len, h.len default: header = valueheader(v) return unsafe.unreflect(_byte_slice, unsafe.pointer(header)).([]byte)
38 concurrent
39 package main import "fmt" func main() { var c chan int c = make(chan int) limit := 16 go func() { for i := limit; i > 0; i-- { fmt.print(<-c) () for i := limit; i > 0; i-- { select { case c <- 0: case c <- 1: produces:
40 func main() { var c chan int c = make(chan int, 16) go func() { for i := 16; i > 0; i-- { fmt.print(<-c) () go func() { select { case c <- 0: case c <- 1: () for { produces:
41 package generalise type SignalSource func(status chan bool) func Wait(s SignalSource) { done := make(chan bool) defer close(done) go s(done) <-done func WaitAll(count int, s SignalSource) { done := make(chan bool) defer close(done) go s(done) for i := 0; i < count; i++ { <- done
42 type Iteration func(k, x interface{) bool func (i Iteration) apply(k, v interface{, c chan bool) { go func() { c <-i(k, v) () func (f Iteration) Each(c interface{) { switch c := ValueOf(c); c.kind() { case Slice: WaitAll(c.Len(), SignalSource(func(done chan bool) { for i := 0; i < c.len(); i++ { f.apply(i, c.elem(i).interface(), done) )) case Map: WaitAll(c.Len(), SignalSource(func(done chan bool) { for _, k := range c.keys() { f.apply(k, c.elem(k).interface(), done) ))
43 type Results chan interface{ type Combination func(x, y interface{) interface{ func (f Combination) Reduce(c, s interface{) (r Results) { r = make(results) go func() { Iteration(func(k, x interface{) (ok bool) { s = f(s, x) return true ).Each(c) r <- s () return
44 type Transformation func(x interface{) interface{ func (t Transformation) Transform(x interface{) Value { return ValueOf(t(x)) func (t Transformation) Map(c interface{) (r interface{) { r = Allocate(c) if i := MapIterator(r); i!= nil { i.each(c) return
45 func MapIterator(c interface{) (i Iteration) { switch n := ValueOf(c); n.kind() { case Slice: i = Iteration(func(k, x interface{) bool { n.elem(k.(int)).setvalue(t.getvalue(x)) return true ) case Map: return i = Iteration(func(k, x interface{) bool { n.setmapindex(valueof(k), t.getvalue(x)) return true )
46 func main() { s := []int{0, 1, 2, 3, 4, 5 d := Transformation(func(x interface{) interface{ { return x.(int) * 2 ).Map(s) sum := Combination(func(x, y interface{) interface{ { return x.(int) + y.(int) ) fmt.printf("s = %v, sum = %v\n", s, (<- sum.reduce(s, 0)).(int)) fmt.printf("d = %v, sum = %v\n", d, (<- sum.reduce(d, 0)).(int)) produces: s = [ ], sum = 15 d = [ ], sum = 30
47 extensible
48 include $(GOROOT)/src/Make.inc TARG=sqlite3 CGOFILES=\ sqlite3.go\ database.go ifeq ($(GOOS),darwin) CGO_LDFLAGS=/usr/lib/libsqlite3.0.dylib else CGO_LDFLAGS=-lsqlite3 endif include $(GOROOT)/src/Make.pkg
49 package sqlite3 // #include <sqlite3.h> import "C" import "fmt" import "os" type Database struct { handle Filename Flags *C.sqlite3 string C.int func (db *Database) Error() os.error { return Errno(C.sqlite3_errcode(db.handle))
50 const( OK = Errno(iota) ERROR CANTOPEN = Errno(14) ) var errtext = map[errno]string { ERROR: "SQL error or missing database", CANTOPEN: "Unable to open the database file", type Errno int func (e Errno) String() (err string) { if err = errtext[e]; err == "" { err = fmt.sprintf("errno %v", int(e)) return
51 func (db *Database) Open(flags... int) (e os.error) { db.flags = 0 for _, v := range flags { db.flags = db.flags C.int(v) f := C.CString(db.Filename) if err := Errno(C.sqlite3_open_v2(f, &db.handle, db.flags, nil)); err!= OK { e = err else if db.handle == nil { e = CANTOPEN return func (db *Database) Close() { C.sqlite3_close(db.handle) db.handle = nil
52 func Open(filename string, flags... int) (db *Database, e os.error) { defer func() { if x := recover(); x!= nil { db.close() db = nil e = ERROR () db = &Database{ Filename: filename if len(flags) == 0 { e = db.open( C.SQLITE_OPEN_FULLMUTEX, C.SQLITE_OPEN_READWRITE, C.SQLITE_OPEN_CREATE ) else { e = db.open(flags...) return
53 fun!
54 finding out more twitter://#golightly wikipedia or google
Lecture 22 Go http://xkcd.com/979/ Go developed ~2007 at Google by Robert Griesemer, Rob Pike, Ken Thompson open sourced in 2009 compiled, statically typed very fast compilation C-like syntax garbage collection
More informationGo Cheat Sheet. Operators. Go in a Nutshell. Declarations. Basic Syntax. Hello World. Functions. Comparison. Arithmetic. Credits
Credits Go Cheat Sheet Most example code taken from A Tour of Go, which is an excellent introduction to Go. If you're new to Go, do that tour. Seriously. Original HTML Cheat Sheet by Ariel Mashraki (a8m):
More informationdeveloped ~2007 by Robert Griesemer, Rob Pike, Ken Thompson open source
Go developed ~2007 by Robert Griesemer, Rob Pike, Ken Thompson open source compiled, statically typed syntax looks sort of like C garbage collection built-in concurrency no classes or type inheritance
More informationGo Tutorial. To do. A brief, gentle intro to Go. Next Networking. q Today
Go Tutorial To do q Today A brief, gentle intro to Go q Next Networking About Go Developed by Google Webpage: https://golang.org/ Concurrency was a priority in the language design A bit of a mix between
More informationGo Forth and Code. Jonathan Gertig. CSC 415: Programing Languages. Dr. Lyle
J o n a t h a n G e r t i g P a g e 1 Go Forth and Code Jonathan Gertig CSC 415: Programing Languages Dr. Lyle 2013 J o n a t h a n G e r t i g P a g e 2 Go dogs Go or A Brief History of Go 6 years ago
More informationunderstanding
understanding nil @francesc thanks welcome every single one of you agenda what is nil? what is nil in Go? what does nil mean? is nil useful? nil? you misspelled null how I learn words how I learn words
More informationGO IDIOMATIC CONVENTIONS EXPLAINED IN COLOR
GO IDIOMATIC CONVENTIONS EXPLAINED IN COLOR REVISION 1 HAWTHORNE-PRESS.COM Go Idiomatic Conventions Explained in Color Published by Hawthorne-Press.com 916 Adele Street Houston, Texas 77009, USA 2013-2018
More informationGo for Java Developers
Go for Java Developers Stoyan Rachev May 26-27 16, Sofia 1 Agenda Introduction Variables and Control Flow Types and Data Structures Functions Methods and Interfaces Concurrency Conclusion 2 What is Go?
More informationThe Go Programming Language. Frank Roberts
The Go Programming Language Frank Roberts frank.roberts@uky.edu - C++ (1983), Java (1995), Python (1991): not modern - Java is 18 years old; how has computing changed in 10? - multi/many core - web programming
More informationGo Tutorial. Arjun Roy CSE 223B, Spring 2017
Go Tutorial Arjun Roy arroy@eng.ucsd.edu CSE 223B, Spring 2017 Administrative details TA Office Hours: EBU3B B250A, Tuesday 5-7PM TA Email: arroy@eng.ucsd.edu All labs due by 2359 PDT. Lab 1 due: 4/13/2017.
More informationLecture Overview Methods and Interfaces Methods review Interfaces Example: using the sort interface Anonymous fields in structs
1 Lecture Overview Methods and Interfaces Methods review Interfaces Example: using the sort interface Anonymous fields in structs Generic printing using the empty interface Maps Creating a map Accessing
More informationDistributed Systems. 02r. Go Programming. Paul Krzyzanowski. TA: Yuanzhen Gu. Rutgers University. Fall 2015
Distributed Systems 02r. Go Programming Paul Krzyzanowski TA: Yuanzhen Gu Rutgers University Fall 2015 September 15, 2015 CS 417 - Paul Krzyzanowski 1 Motivation In the current world, languages don't help
More informationIntroduzione a Go e RPC in Go
Università degli Studi di Roma Tor Vergata Dipartimento di Ingegneria Civile e Ingegneria Informatica Introduzione a Go e RPC in Go Corso di Sistemi Distribuiti e Cloud Computing A.A. 2017/18 Valeria Cardellini
More informationScientific GPU computing with Go A novel approach to highly reliable CUDA HPC 1 February 2014
Scientific GPU computing with Go A novel approach to highly reliable CUDA HPC 1 February 2014 Arne Vansteenkiste Ghent University Real-world example (micromagnetism) DyNaMat LAB @ UGent: Microscale Magnetic
More informationUsing DPDK with Go. Takanari Hayama Technology Consulting Company IGEL Co.,Ltd.
Using DPDK with Go Technology Consulting Company Research, Development & Global Standard Takanari Hayama taki@igel.co.jp Technology Consulting Company IGEL Co.,Ltd. 1 BACKGROUND 2017/9/26,27 DPDK Summit
More informationGO SHORT INTERVIEW QUESTIONS EXPLAINED IN COLOR
GO SHORT INTERVIEW QUESTIONS EXPLAINED IN COLOR REVISION 1 HAWTHORNE-PRESS.COM Go Short Interview Questions Explained in Color Published by Hawthorne-Press.com 916 Adele Street Houston, Texas 77009, USA
More informationLet s Go! Akim D le, Etienne Renault, Roland Levillain. June 8, TYLA Let s Go! June 8, / 58
Let s Go! Akim Demaille, Etienne Renault, Roland Levillain June 8, 2017 TYLA Let s Go! June 8, 2017 1 / 58 Table of contents 1 Overview 2 Language Syntax 3 Closure 4 Typed functional programming and Polymorphism
More informationSummary of Go Syntax /
Summary of Go Syntax 02-201 / 02-601 Can declare 1 or more variables in same var statement Variables Can optionally provide initial values for all the variables (if omitted, each variable defaults to the
More informationIssue with Implementing PrimeSieve() in Go
Slices 02-201 Issue with Implementing PrimeSieve() in Go func PrimeSieve(n int) [n+1]bool { var iscomposite [n+1]bool //ERROR! biggestprime := 2 for biggestprime < n for i:=2; i
More informationJython. An introduction by Thinh Le
Jython An introduction by Thinh Le precursor_python! Google App Engine! Dropbox! PyGTK (Gnome)! Vim (embedded)! BitTorrent/Morpheus! Civilization/Battlefield Jython! Interpretation of Python (1997)! Jim
More informationCOMP-520 GoLite Tutorial
COMP-520 GoLite Tutorial Alexander Krolik Sable Lab McGill University Winter 2019 Plan Target languages Language constructs, emphasis on special cases General execution semantics Declarations Types Statements
More informationGo Concurrent Programming. QCon2018 Beijing
Go Concurrent Programming chao.cai@mobvista.com QCon2018 Beijing Shared Memory Model Shared Memory Model class Worker implements Runnable{ private volatile boolean isrunning = false; @Override public void
More informationDon t let data Go astray
Don t let data Go astray A Context-Sensitive Taint Analysis for Concurrent Programs in Go Volker Stolz Bergen University College, Norway & University of Oslo, Norway 28 th Nordic Workshop on Programming
More informationGo in Action: Benchmarking
Go in Action: Benchmarking By William Kennedy with Brian Ketelsen and Erik St. Martin In this article, excerpted from the book Go in Action, we will look at a set of benchmark functions that reveal the
More informationGo Language September 2016
Go Language September 2016 Giacomo Tartari PhD student, University of Tromsø http://127.0.0.1:3999/golang2016.slide#34 1/53 Go http://127.0.0.1:3999/golang2016.slide#34 2/53 Why? Rob Pike's take (one of
More informationIntroduction to the Go Programming Language
Introduction to the Go Programming Language Basics, Concurrency and Useful Packages Fabian Wenzelmann April 6, 2017 F. Wenzelmann Introduction to Go April 6, 2017 1 / 114 Why Go? What is Go? Go is a programming
More informationgo get my/vulnerabilities Green threads are not eco friendly threads
go get my/vulnerabilities Green threads are not eco friendly threads 1 Who ( Web Mobile ) penetration tester Code reviewer Programmer Roberto Clapis @empijei 2 Go Google s language Born in 2007 (quite
More informationDon t Go Java! Edition 2019
Don t Go, Java! Don t Go Java! Don t Go Java! Edition 2019 Disclaimer Disclaimer I actually like Go! Guess The Movie Guess The Movie Guess The Movie Guess The Movie Who s That Dude? Chris Engelbert Senior
More informationPierce Ch. 3, 8, 11, 15. Type Systems
Pierce Ch. 3, 8, 11, 15 Type Systems Goals Define the simple language of expressions A small subset of Lisp, with minor modifications Define the type system of this language Mathematical definition using
More informationLecture 4: Golang Programming. Lecturer: Prof. Zichen Xu
Lecture 4: Golang Programming Lecturer: Prof. Zichen Xu Outline The history The reason The code Sophistication If more than one function is selected, any function template specializations in the set are
More informationCSci 4061 Introduction to Operating Systems. Input/Output: High-level
CSci 4061 Introduction to Operating Systems Input/Output: High-level I/O Topics First, cover high-level I/O Next, talk about low-level device I/O I/O not part of the C language! High-level I/O Hide device
More informationBasic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable
Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is
More informationWilliam Kennedy. Brian Ketelsen Erik St. Martin Steve Francia FOREWORD BY MANNING WITH
SAMPLE CHAPTER William Kennedy WITH FOREWORD BY Brian Ketelsen Erik St. Martin Steve Francia MANNING Go in Action by William Kennedy with Brian Ketelsen and Erik St. Martin Chapter 2 Copyright 2015 Manning
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationCSCI 171 Chapter Outlines
Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationAn application: foreign function bindings
1/ 19 An application: foreign function bindings C int puts ( const char *s); 2/ 19 C in two minutes object types numeric types int, char, float,... pointers int *, char *, int **,... structures and unions
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative
More informationGo Programming. Russ Cox and Rob Pike May 20, 2010
Go Programming Russ Cox and Rob Pike May 20, 2010 Live waving View live notes and ask questions about this session on Google Wave: http://bit.ly/go2010io 3 Go is different Go is more unusual than you might
More informationDAD Lab. 1 Introduc7on to C#
DAD 2017-18 Lab. 1 Introduc7on to C# Summary 1..NET Framework Architecture 2. C# Language Syntax C# vs. Java vs C++ 3. IDE: MS Visual Studio Tools Console and WinForm Applica7ons 1..NET Framework Introduc7on
More informationTranquility Publications. Web Edition MAC
Web Edition 2019 -MAC 2 Go Go language is a programming language initially developed at Google in the year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is a statically-typed language having
More informationIntroduction to C Language (M3-R )
Introduction to C Language (M3-R4-01-18) 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in OMR answer sheet supplied with the question paper, following
More informationRPC and Threads. Jinyang Li. These slides are based on lecture notes of 6.824
RPC and Threads Jinyang Li These slides are based on lecture notes of 6.824 Labs are based on Go language Why Golang? (as opposed to the popular alternacve: C++) good support for concurrency good support
More informationHomework 5: Spatial Games : Programming for Scientists Due: Thursday, March 3, 2016 at 11:59 PM
Homework 5: Spatial Games 02-201: Programming for Scientists Due: Thursday, March 3, 2016 at 11:59 PM 1. Reading Read Ch. 8 and Ch. 9 of An Introduction to Programming in Go (on pointers and structs).
More informationGo on NetBSD (and pkgsrc!) A modern systems programming language 23 March Benny Siegert Google Switzerland; The NetBSD Foundation
Go on NetBSD (and pkgsrc!) A modern systems programming language 23 March 2013 Benny Siegert Google Switzerland; The NetBSD Foundation Agenda What is Go? Building Go code with the gotool Running Go code
More informationPRINCIPLES OF OPERATING SYSTEMS
PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)
More informationExercise 6.2 A generic container class
Exercise 6.2 A generic container class The goal of this exercise is to write a class Array that mimics the behavior of a C++ array, but provides more intelligent memory management a) Start with the input
More information05-concurrency.txt Tue Sep 11 10:05: , Fall 2012, Class 05, Sept. 11, 2012 Randal E. Bryant
05-concurrency.txt Tue Sep 11 10:05:32 2012 1 15-440, Fall 2012, Class 05, Sept. 11, 2012 Randal E. Bryant All code available in: /afs/cs.cmu.edu/academic/class/15440-f12/code/class05 Managing Concurrency
More informationCS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find
CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS
More informationArrays and Strings
Arrays and Strings 02-201 Arrays Recall: Fibonacci() and Arrays 1 1 2 3 5 8 13 21 34 55 a Fibonacci(n) a ß array of length n a[1] ß 1 a[2] ß 1 for i ß 3 to n a[i] ß a[i-1] + a[i-2] return a Declaring Arrays
More informationpointers + memory double x; string a; int x; main overhead int y; main overhead
pointers + memory computer have memory to store data. every program gets a piece of it to use as we create and use more variables, more space is allocated to a program memory int x; double x; string a;
More informationC introduction: part 1
What is C? C is a compiled language that gives the programmer maximum control and efficiency 1. 1 https://computer.howstuffworks.com/c1.htm 2 / 26 3 / 26 Outline Basic file structure Main function Compilation
More informationValues (a.k.a. data) representation. Advanced Compiler Construction Michel Schinz
Values (a.k.a. data) representation Advanced Compiler Construction Michel Schinz 2016 03 10 The problem Values representation A compiler must have a way of representing the values of the source language
More informationValues (a.k.a. data) representation. The problem. Values representation. The problem. Advanced Compiler Construction Michel Schinz
Values (a.k.a. data) representation The problem Advanced Compiler Construction Michel Schinz 2016 03 10 1 2 Values representation The problem A compiler must have a way of representing the values of the
More informationCMSC 330: Organization of Programming Languages. OCaml Imperative Programming
CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory
More informationHomework 6: Spatial Games Due: 11:59pm on Friday, October 30
02-201 Homework 6: Spatial Games Due: 11:59pm on Friday, October 30 1. Set up The set up is the basically the same as for homework 4. 1. Create a directory called go someplace (different than where you
More informationCMSC 330: Organization of Programming Languages. Ownership, References, and Lifetimes in Rust
CMSC 330: Organization of Programming Languages Ownership, References, and Lifetimes in Rust CMSC330 Spring 2018 1 Memory: the Stack and the Heap The stack constant-time, automatic (de)allocation Data
More informationCMSC 330: Organization of Programming Languages. OCaml Imperative Programming
CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Fall 2017 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory All
More informationAll the operations used in the expression are over integers. a takes a pair as argument. (a pair is also a tuple, or more specifically, a 2-tuple)
Weekly exercises in INF3110 week 41 6-10.10.2008 Exercise 1 Exercise 6.1 in Mitchell's book a) fun a(x,y) = x+2*y; val a = fn : int * int -> int All the operations used in the expression are over integers.
More informationKurt Schmidt. October 30, 2018
to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed
More informationPointers, Dynamic Data, and Reference Types
Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple
More informationDRIVER AND LIBRARY FOR DB67 DSP BOARD DRIVER AND LIBRARY FOR DB67 DSP BOARD
DRIVER AND LIBRARY FOR DB67 DSP BOARD G.Petrosyan MVP, DESY (Hamburg, Germany), ErPhi (Erevan, Armenia) K. Rehlich DESY (Hamburg, Germany) P.Vetrov DESY (Hamburg, Germany), DRIVER The basic part of LLRF
More informationThe Awesomeness of Go. Igor Lankin DevFest Karlsruhe, Nov 2016
The Awesomeness of Go Igor Lankin DevFest Karlsruhe, Nov 2016 Igor Lankin Software Developer @ inovex C#, Java, Java Script, full-time GO (waipu.tv ) 2 What is Go? 3 An Awesome Programming Language 4 Imagine
More informationRheinisch-Westfälische Technische Hochschule Aachen. Lehrstuhl für Datenmanagement und -exploration Prof. Dr. T. Seidl. Proseminar.
Rheinisch-Westfälische Technische Hochschule Aachen Lehrstuhl für Datenmanagement und -exploration Prof. Dr. T. Seidl Proseminar Google Go illustrated on the basis of Fibonacci numbers Jan Pennekamp Mai
More informationMotivations History Principles Language Gommunity Success stories Conclusion. Let s Go! A brief introduction to Google s new language.
Let s Go! A brief introduction to Google s new language Aurélien Dumez Inria Bordeaux - Sud-Ouest aurelien.dumez@inria.fr Tuesday, October 2nd 2012 Content - 1/2 1 2 3 4 Characteristics SDK vs Examples
More informationFundamentals of Computer Security
Fundamentals of Computer Security Spring 2015 Radu Sion Software Errors Buffer Overflow TOCTTOU 2005-15 Portions copyright by Bogdan Carbunar and Wikipedia. Used with permission Why Security Vulnerabilities?
More informationIndex. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309
A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48
More informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More informationQuick Review of Object-Oriented Programming in Go
Quick Review of Object-Oriented Programming in Go 02-201 Structs: Grouping Variables as Objects type Rectangle struct { x1 float64 y1 float64 width float64 height float64 type Circle struct { x1 float64
More informationName MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
CMPSC11 Final (Study Guide) Fall 11 Prof Hartman Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) This is a collection of statements that performs
More informationCSci 4061 Introduction to Operating Systems. Programs in C/Unix
CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,
More informationNew Parallel Programming Languages for Optimization Research
New Parallel Programming Languages for Optimization Research John W. Chinneck, Stephane Ernst Systems and Computer Engineering Carleton University, Ottawa, Canada Motivation Challenges for optimization
More informationRecitation #11 Malloc Lab. November 7th, 2017
18-600 Recitation #11 Malloc Lab November 7th, 2017 1 2 Important Notes about Malloc Lab Malloc lab has been updated from previous years Supports a full 64 bit address space rather than 32 bit Encourages
More informationExercise Session 2 Systems Programming and Computer Architecture
Systems Group Department of Computer Science ETH Zürich Exercise Session 2 Systems Programming and Computer Architecture Herbstsemester 216 Agenda Linux vs. Windows Working with SVN Exercise 1: bitcount()
More informationGO - QUICK GUIDE GO - OVERVIEW
http://www.tutorialspoint.com/go/go_quick_guide.htm GO - QUICK GUIDE Copyright tutorialspoint.com GO - OVERVIEW Go is a general-purpose language designed with systems programming in mind.it was initially
More informationgrib_api.h File Reference
grib_api.h File Reference Copyright 2005-2013 ECMWF. More... Defines #define GRIB_API_VERSION (GRIB_API_MAJOR_VERSION*10000+G RIB_API_MINOR_VERSION*100+GRIB_API_REVISION_VERSI ON) #define GRIB_SECTION_PRODUCT
More informationAdvanced Systems Programming
Advanced Systems Programming Introduction to C++ Martin Küttler September 19, 2017 1 / 18 About this presentation This presentation is not about learning programming or every C++ feature. It is a short
More informationCSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community
CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine
More informationP.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above
P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above
More informationAdministrivia. Introduction to Computer Systems. Pointers, cont. Pointer example, again POINTERS. Project 2 posted, due October 6
CMSC 313 Introduction to Computer Systems Lecture 8 Pointers, cont. Alan Sussman als@cs.umd.edu Administrivia Project 2 posted, due October 6 public tests s posted Quiz on Wed. in discussion up to pointers
More informationMidterm CSE 131B Spring 2005
Signature Login Name _ Name Student ID Midterm CSE 131B Spring 2005 Page 1 Page 2 Page 3 Page 4 Page 5 (20 points) (18 points) (22 points) (20 points) (20 points) Subtotal Page 6 Extra Credit (100 points)
More informationLast Time: Objects and Abstraction. If it walks like a circle, swims like a circle, and quacks like a circle...!
Pointers 02-201 Last Time: Objects and Abstraction If it walks like a circle, swims like a circle, and quacks like a circle...! Bird s Eye View of Object-Oriented Programming http://null-byte.wonderhowto.com!
More informationAlgorithms & Data Structures
GATE- 2016-17 Postal Correspondence 1 Algorithms & Data Structures Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key
More informationIntroduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language
Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup starting in 1979 based on C Introduction to C++ also
More informationArrays (1A) Young Won Lim 12/4/17
Arrays (1A) Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version
More informationSymbolic Computation and Common Lisp
Symbolic Computation and Common Lisp Dr. Neil T. Dantam CSCI-56, Colorado School of Mines Fall 28 Dantam (Mines CSCI-56) Lisp Fall 28 / 92 Why? Symbolic Computing: Much of this course deals with processing
More informationGO MOCK TEST GO MOCK TEST I
http://www.tutorialspoint.com GO MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Go. You can download these sample mock tests at your local machine
More informationIn the CERTAINTY project, an application is defined as a network of independent processes with the following features:
C/C++ Coding Guide G. Giannopoulou, P. Huang, N. Stoimenov, L. Thiele April 15, 2014 This document describes how to program DOL-Critical applications using C/C++ as programming language. To be able to
More informationCompiler Construction
Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-16/cc/ Recap: Static Data Structures Outline of Lecture 18 Recap:
More informationTopic 6: A Quick Intro To C
Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions
More information1B1a Arrays. Arrays. Indexing. Naming arrays. Why? Using indexing. 1B1a Lecture Slides. Copyright 2003, Graham Roberts 1
Ba Arrays Arrays A normal variable holds value: An array variable holds a collection of values: 4 Naming arrays An array has a single name, so the elements are numbered or indexed. 0 3 4 5 Numbering starts
More informationIntroduction to C++ with content from
Introduction to C++ with content from www.cplusplus.com 2 Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup
More informationProgramming in C++: Assignment Week 2
Programming in C++: Assignment Week 2 Total Marks : 20 Each question carries one mark Right hand side of each question shows its Type (MCQ/MSQ) March 3, 2017 Question 1 Look at the code snippet below:
More informationREVIEW. The C++ Programming Language. CS 151 Review #2
REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,
More informationMemory Allocation. General Questions
General Questions 1 Memory Allocation 1. Which header file should be included to use functions like malloc() and calloc()? A. memory.h B. stdlib.h C. string.h D. dos.h 2. What function should be used to
More informationC BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.
C BOOTCAMP DAY 2 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Pointers 2 Pointers Pointers are an address in memory Includes variable addresses,
More informationFinding Bugs Using Xcode Runtime Tools
Session Developer Tools #WWDC17 Finding Bugs Using Xcode Runtime Tools 406 Kuba Mracek, Program Analysis Engineer Vedant Kumar, Compiler Engineer 2017 Apple Inc. All rights reserved. Redistribution or
More informationInput And Output of C++
Input And Output of C++ Input And Output of C++ Seperating Lines of Output New lines in output Recall: "\n" "newline" A second method: object endl Examples: cout
More informationCS 31: Intro to Systems Pointers and Memory. Martin Gagne Swarthmore College February 16, 2016
CS 31: Intro to Systems Pointers and Memory Martin Gagne Swarthmore College February 16, 2016 So we declared a pointer How do we make it point to something? 1. Assign it the address of an existing variable
More informationGO CONCURRENCY BASICS AND PATTERNS EXPLAINED IN COLOR
GO CONCURRENCY BASICS AND PATTERNS EXPLAINED IN COLOR REVISION 1 HAWTHORNE-PRESS.COM Go Concurrency Basics Explained In Color Published by Hawthorne-Press.com 916 Adele Street Houston, Texas 77009, USA
More information