Don t Go Java! Edition 2019

Similar documents
Motivations History Principles Language Gommunity Success stories Conclusion. Let s Go! A brief introduction to Google s new language.

Go Tutorial. Arjun Roy CSE 223B, Spring 2017

developed ~2007 by Robert Griesemer, Rob Pike, Ken Thompson open source

Remote Procedure Call

William Kennedy. Brian Ketelsen Erik St. Martin Steve Francia FOREWORD BY MANNING WITH

The Go Programming Language. Frank Roberts

Operating Systems. 18. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Spring /20/ Paul Krzyzanowski

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

Chapter 1 Getting Started

Oral Question Bank for CL-3 Assignment

Recap: Functions as first-class values

understanding


Distributed Systems 8. Remote Procedure Calls

Go Tutorial. To do. A brief, gentle intro to Go. Next Networking. q Today

Pierce Ch. 3, 8, 11, 15. Type Systems

CS558 Programming Languages

CSC209 Review. Yeah! We made it!

Variables and Bindings

Swift. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

Functions & Variables !

416 Distributed Systems. RPC Day 2 Jan 12, 2018

Introduction to C: Pointers

COMP-520 GoLite Tutorial

Go Cheat Sheet. Operators. Go in a Nutshell. Declarations. Basic Syntax. Hello World. Functions. Comparison. Arithmetic. Credits

Distributed Systems. How do regular procedure calls work in programming languages? Problems with sockets RPC. Regular procedure calls

Lecture Overview Methods and Interfaces Methods review Interfaces Example: using the sort interface Anonymous fields in structs

Instantiation of Template class

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Go for Java Developers

Introduction to Programming Using Java (98-388)

CS 222: Arrays, Strings, Structs

SWIFT! init(title: String) { self.title = title } // required initializer w/ named parameter

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).

Object Oriented Programming in C#

The Awesomeness of Go. Igor Lankin DevFest Karlsruhe, Nov 2016

Remote Invocation. To do. Request-reply, RPC, RMI. q Today q. q Next time: Indirect communication

the gamedesigninitiative at cornell university Lecture 7 C++ Overview

Course May 18, Advanced Computational Physics. Course Hartmut Ruhl, LMU, Munich. People involved. SP in Python: 3 basic points

Scala : an LLVM-targeted Scala compiler

Introduction and Overview Socket Programming Lower-level stuff Higher-level interfaces Security. Network Programming. Samuli Sorvakko/Nixu Oy

Python Training. Complete Practical & Real-time Trainings. A Unit of SequelGate Innovative Technologies Pvt. Ltd.

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

2D Game design Intro to Html 5

6. Pointers, Structs, and Arrays. 1. Juli 2011

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

Go Forth and Code. Jonathan Gertig. CSC 415: Programing Languages. Dr. Lyle

Java Basics. Object Orientated Programming in Java. Benjamin Kenwright

Dialects of ML. CMSC 330: Organization of Programming Languages. Dialects of ML (cont.) Features of ML. Functional Languages. Features of ML (cont.

1d: tests knowing about bitwise fields and union/struct differences.

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Overview. Exercise 0: Implementing a Client. Setup and Preparation

Begin at the beginning

Symbolic Computation and Common Lisp

Crash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++

Introduction and Overview Socket Programming Higher-level interfaces Final thoughts. Network Programming. Samuli Sorvakko/Nixu Oy

Programming Languages

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Future Web App Technologies

CS 32. Lecture 5: Templates

go-tutorial Documentation Release latest

Develop your Embedded Applications Faster: Comparing C and Golang. Marcin Pasinski Mender.io

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

Applications. Cloud. See voting example (DC Internet voting pilot) Select * from userinfo WHERE id = %%% (variable)

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

CS558 Programming Languages

Remote Procedure Calls (RPC)

Overview. Exercise 0: Implementing a Client. Setup and Preparation

CS 220: Introduction to Parallel Computing. Arrays. Lecture 4

News. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values

Short Notes of CS201

Starting to Program in C++ (Basics & I/O)

Python INTRODUCTION: Understanding the Open source Installation of python in Linux/windows. Understanding Interpreters * ipython.

the gamedesigninitiative at cornell university Lecture 6 C++: Basics

D Programming Language

CS201 - Introduction to Programming Glossary By

CPSC 213. Introduction to Computer Systems. Instance Variables and Dynamic Allocation. Unit 1c

CSE 341: Programming Languages

CSE 413 Spring Introduction to Ruby. Credit: Dan Grossman, CSE341

Rust intro. (for Java Developers) JFokus #jfokus 1. 1

CS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.

CS 2113 Software Engineering

CSci 4223 Lecture 12 March 4, 2013 Topics: Lexical scope, dynamic scope, closures

Exception Namespaces C Interoperability Templates. More C++ David Chisnall. March 17, 2011

Processes. Operating System Concepts 8 th Edition

Beyond Blocks: Python Session #1

CMSC 330: Organization of Programming Languages. OCaml Expressions and Functions

Distributed Systems. 03. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Fall 2017

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst

Summary of Go Syntax /

Perl 6 Hands-On Tutorial

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Introduction to RPC, Apache Thrift Workshop. Tomasz Powchowicz

CS 222: Pointers and Manual Memory Management

APIs and API Design with Python

User Scripting April 14, 2018

Lecture 15: Object-Oriented Programming

Back to OCaml. Summary of polymorphism. Example 1. Type inference. Example 2. Example 2. Subtype. Polymorphic types allow us to reuse code.

Transcription:

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 Developer Advocate @ Instana Java-Passionate (10+ years) Go (2 years) Performance Garbage Collection Benchmark Fairytales

Who s That Dude? @instanahq

Who s That Dude? Adores TypeScript Prefers Kotlin Codes Java @instanahq

Who s That Dude? Kinda likes Go Adores TypeScript Prefers Kotlin Codes Java @instanahq

Who s That Dude? Kinda likes Go Adores TypeScript Forced to use JS Prefers Kotlin Totally hates Python Codes Java @instanahq

Who s That Dude? Kinda likes Go Adores TypeScript Forced to use JS Prefers Kotlin Totally hates Python Codes Java LOVES BEER! (Dah, German) @instanahq

What is?

What Is Go? s t r a P d o o G e h T : Go d e t a nion i p o s t I. 1 https://www.pexels.com/photo/blank-paper-with-pen-and-coffee-cup-on-wood-table-6357/

What Is Go? General Purpose Language Inception: 2009 Version 1.0: 2012 Current Release: 1.12.1

What Is Go?

What Is Go? Type Inference package main func main() { value := "my string"

What Is Go? Type Inference Package Declaration package main func main() { value := "my string"

What Is Go? Type Inference Package Declaration package main Main (Entry) Function func main() { value := "my string"

What Is Go? Type Inference Package Declaration package main Main (Entry) Function Variable Declaration func main() { value := "my string"

What Is Go? Type Inference Package Declaration package main Main (Entry) Function Variable Declaration func main() { value := "my string" Variable

What Is Go? Type Inference Package Declaration package main Main (Entry) Function Variable Declaration func main() { value := "my string" Variable Create and Infer Type

What Is Go? Type Inference Package Declaration package main Main (Entry) Function Variable Declaration func main() { value := "my string" Variable Some String Create and Infer Type

What Is Go? Type Inference package main func main() { value := "my string"

What Is Go? Type Inference package main func main() { value := "my string" Compile Error

What Is Go? Type Inference package main func main() { value := "my string Compile Error

What Is Go? Extensive Stdlib package main import "io/ioutil" func main() {

What Is Go? Extensive Stdlib package main Import Declaration import "io/ioutil" func main() {

What Is Go? Extensive Stdlib Archive (tar, zip, ) Sorting Byte Manipulation Math HTML Templates (Buffered) IO Time Debugging Reflection OS (Exec, File, ) Database (SQL) Encoding (base64, hex, csv, json, xml, ) Compression (bzip2, flate, gzip, ) Crypto (aes, dsa, rsa, sha, tls, ) Logging Net (TCP, UDP, Unix Socket, )

What Is Go? Extensive Stdlib package main import "io/ioutil" func main() {

What Is Go? Extensive Stdlib package main import "io/ioutil" func main() { Compile Error

What Is Go? Extensive Stdlib package main import "io/ioutil" func main() { Compile Error

What Is Go? Multi-Value Return func main() { x, y := findcoordinates("conference") func findcoordinates(place string) (x, y int) { return 0, 0

What Is Go? Multi-Value Return func main() { x, y := findcoordinates("conference") func findcoordinates(place string) (x, y int) { return 0, 0 Defines Two Return Values (both type int)

What Is Go? Automatic Resource Management package main import "os" func main() { file, _ := os.open("/tmp/foo") defer file.close()

What Is Go? Automatic Resource Management package main import "os" func main() { ignore return value file, _ := os.open("/tmp/foo") defer file.close()

What Is Go? Automatic Resource Management package main import "os" func main() { ignore return value file, _ := os.open("/tmp/foo") defer file.close() file.close() should be called on Method return

What else is? Unfortunately!

What Is Go too? - Unfortunately Error Handling func main() { file, err := os.open("/tmp/foo") if err!= nil { log.fatal(err) defer file.close()

What Is Go too? - Unfortunately Error Handling func foo() error { file, err := os.open("/tmp/foo") if err!= nil { return err defer file.close() return nil

What Is Go too? - Unfortunately Public Vs. (Package) Private func Foo() { func foo() {

What Is Go too? - Unfortunately Public Vs. (Package) Private public func Foo() { func foo() { private

What Is Go too? - Unfortunately Public Vs. (Package) Private? func 日本語 () {

What Is Go too? - Unfortunately Public Vs. (Package) Private private func 日本語 () {

What Is Go too? - Unfortunately Syntax func (f *foo) method(p1 *string) (foo, error) { if p1 == nil { return "", errors.new("nil pointer") return "foo", nil

What Is Go too? - Unfortunately Syntax Bind Method to Type Pointer-To-Foo func (f *foo) method(p1 *string) (foo, error) { if p1 == nil { return "", errors.new("nil pointer") return "foo", nil

What Is Go too? - Unfortunately Syntax func (f *foo) method(p1 *string) (foo, error) { if p1 == nil { return "", errors.new("nil pointer") return "foo", nil

What Is Go too? - Unfortunately Syntax func (f *foo(*string)) method(p1 *string) (foo, error) { if p1 == nil { return "", errors.new("nil pointer") return "foo", nil

What Is Go too? - Unfortunately

5 Things You Can Hate About Go But You Don t Have To

You re Crazy, But Don t You Worry!

You re Crazy, But Don t You Worry! func foo(var1 string) { { var1 := "bar" fmt.println(var1) break func main() { foo("foo")

You re Crazy, But Don t You Worry! func foo(var1 string) { { fmt := "bar" fmt.println(var1) break func main() { foo("foo")

You re Crazy, But Don t You Worry! type task struct { func main() { task := &task{

You re Crazy, But Don t You Worry! type task struct { func main() { instantiation task := &task{

You re Crazy, But Don t You Worry! type task struct { func main() { task := &task{ task = &task{

Clone Or Not Clone, That Is The Question!

Clone Or Not Clone, That Is The Question! type handle int func types(val interface{) { switch v := val.(type) { case int: fmt.println(fmt.sprintf("i am an int: %d", v)) switch v := val.(type) { case handle: fmt.println(fmt.sprintf("i am an handle: %d", v))

Clone Or Not Clone, That Is The Question! type handle int func types(val interface{) { switch v := val.(type) { reflective type case int: fmt.println(fmt.sprintf("i am an int: %d", v)) switch v := val.(type) { case handle: fmt.println(fmt.sprintf("i am an handle: %d", v))

Clone Or Not Clone, That Is The Question! func main() { var var1 int = 1 var var2 handle = 2 type handle int types(var1) types(var2) func types(val interface{) { switch v := val.(type) { case int: fmt.println(fmt.sprintf("i am an int: %d", v)) switch v := val.(type) { case handle: fmt.println(fmt.sprintf("i am an handle: %d", v))

Clone Or Not Clone, That Is The Question! func main() { var var1 int = 1 var var2 handle = 2 type handle = int types(var1) types(var2) func types(val interface{) { switch v := val.(type) { case int: fmt.println(fmt.sprintf("i am an int: %d", v)) switch v := val.(type) { case handle: fmt.println(fmt.sprintf("i am an handle: %d", v))

Clone Or Not Clone, That Is The Question! func main() { var var1 int = 1 var var2 handle = 2 type handle int types(var1) types(var2) func types(val interface{) { switch v := val.(type) { case int: fmt.println(fmt.sprintf("i am an int: %d", v)) switch v := val.(type) { case handle: fmt.println(fmt.sprintf("i am an handle: %d", v))

Clone Or Not Clone, That Is The Question! func main() { var var1 int = 1 var var2 handle = 2 type handle = int types(var1) types(var2) func types(val interface{) { switch v := val.(type) { case int: fmt.println(fmt.sprintf("i am an int: %d", v)) switch v := val.(type) { case handle: fmt.println(fmt.sprintf("i am an handle: %d", v))

Clone Or Not Clone, That Is The Question! type Callable func() func test(callable Callable) { callable() func main() { mycallable := func() { fmt.println("callable") test(mycallable)

Clone Or Not Clone, That Is The Question! type Callable func() func main() { callable1 := func() { fmt.println("callable1") func test(val interface{) { switch v := val.(type) { case func(): var callable2 Callable callable2 = func() { fmt.println("callable2") v() default: fmt.println("wrong type") test(callable1) test(callable2)

He Looks Lazy, Isn t He?

He Looks Lazy, Isn t He? func main() { functions := make([]func(), 3) for i := 0; i < 3; i++ { functions[i] = func() { fmt.println(fmt.sprintf("iterator value: %d", i)) functions[0]() functions[1]() functions[2]()

He Looks Lazy, Isn t He? func main() { functions := make([]func(), 3) map instantiation for i := 0; i < 3; i++ { functions[i] = func() { fmt.println(fmt.sprintf("iterator value: %d", i)) functions[0]() functions[1]() functions[2]()

He Looks Lazy, Isn t He? func main() { functions := make([]func(), 3) for i := 0; i < 3; i++ { map instantiation loop functions[i] = func() { fmt.println(fmt.sprintf("iterator value: %d", i)) functions[0]() functions[1]() functions[2]()

He Looks Lazy, Isn t He? func main() { functions := make([]func(), 3) for i := 0; i < 3; i++ { functions[i] = func() { map instantiation loop closure fmt.println(fmt.sprintf("iterator value: %d", i)) functions[0]() functions[1]() functions[2]()

He Looks Lazy, Isn t He? func main() { functions := make([]func(), 3) for i := 0; i < 3; i++ { functions[i] = func() { fmt.println(fmt.sprintf("iterator value: %d", i)) functions[0]() functions[1]() functions[2]()

He Looks Lazy, Isn t He? func main() { functions := make([]func(), 3) for i := 0; i < 3; i++ { functions[i] = func(i int) func() { return func() { fmt.println(fmt.sprintf("iterator value: %d", i)) (i) functions[0]() functions[1]() functions[2]()

He Looks Lazy, Isn t He? func main() { functions := make([]func(), 3) for i := 0; i < 3; i++ { i := i functions[i] = func() { fmt.println(fmt.sprintf("iterator value: %d", i)) functions[0]() functions[1]() functions[2]()

Aren t We All A Little Bit Gopher?

Aren t We All A Little Bit Gopher? type Sortable interface { Sort(other Sortable)

Aren t We All A Little Bit Gopher? type Sortable interface { Sort(other Sortable) type MyStruct struct{ func (m MyStruct) Sort(other Sortable) {

Aren t We All A Little Bit Gopher? type Sortable interface { Sort(other Sortable) type MyStruct struct{ func (m MyStruct) Sort(other Sortable) { func main() { var foo Sortable = &MyStruct{ foo.sort(&mystruct{)

Aren t We All A Little Bit Gopher? type Sortable interface { Sort(other Sortable) type MyStruct struct{ func (m MyStruct) Sort(other Sortable) {

Aren t We All A Little Bit Gopher? type Sortable interface { Sort(other Sortable) type MyStruct struct{ func (m MyStruct) Sort(other Sortable) { var _ Sortable = MyStruct{ var _ Sortable = (*MyStruct)(nil)

It s Nil Or Nothing!

It s Nil Or Nothing! type MyError string func (m MyError) Error() string { return string(m)

It s Nil Or Nothing! type MyError string func (m MyError) Error() string { return string(m) type error interface { Error() string

It s Nil Or Nothing! type MyError string func (m MyError) Error() string { return string(m)

It s Nil Or Nothing! type MyError string func (m MyError) Error() string { return string(m) func test(v bool) error { var e *MyError = nil if v { return nil return e func main() { fmt.println(nil == test(true)) fmt.println(nil == test(false))

Seriously? I Don t Give A FAQ!

Seriously? I Don t Give A FAQ! https://golang.org/doc/faq

Remember Not Here To Scare You!

Remember Not Here To Scare You! But There Will Be Dragons

? Questions???

? Thank You??