0:00:04.524,0:00:06.694 good evening again this is the first time 0:00:06.699,0:00:10.699 I'm seeing this okay I'm holding it up 0:00:10.699,0:00:14.699 this is a gopher Singapore edition so 0:00:14.699,0:00:21.915 gopher Merlion and the title of my talk 0:00:21.957,0:00:24.518 if I speak it quickly 0:00:24.524,0:00:28.524 oops stay 0:00:28.741,0:00:31.821 nvm it doesn't want to 0:00:31.821,0:00:33.072 title of my talk if you speak it quickly 0:00:33.132,0:00:37.674 is Go for you? That's a pun there. 0:00:44.310,0:00:47.250 All of us have limited mental capacity 9:59:59.000,9:59:59.000 limited mind budget 0:00:48.380,0:00:52.380 budget some of us can keep more things 9:59:59.000,9:59:59.000 in our mind some of us can keep less 9:59:59.000,9:59:59.000 things in our mind but you know in all 9:59:59.000,9:59:59.000 cases it's limited so what do you mean 9:59:59.000,9:59:59.000 by mine budget if you know how to drive 9:59:59.000,9:59:59.000 a car it's instinctive 9:59:59.000,9:59:59.000 you still know you still need to know 9:59:59.000,9:59:59.000 where you're going so that consumes 9:59:59.000,9:59:59.000 energy and mine budget so the point I'm 9:59:59.000,9:59:59.000 trying to ask is what are your current 9:59:59.000,9:59:59.000 skills what you currently do today and 9:59:59.000,9:59:59.000 what you want to do tomorrow so for 9:59:59.000,9:59:59.000 example if I currently write stuff for 9:59:59.000,9:59:59.000 the web 9:59:59.000,9:59:59.000 typically web front-ends I know 9:59:59.000,9:59:59.000 JavaScript quite well by definition but 9:59:59.000,9:59:59.000 I want to write back-end stuff around 9:59:59.000,9:59:59.000 the right back-end servers I want to 9:59:59.000,9:59:59.000 write API service your look you know 9:59:59.000,9:59:59.000 because you can write back-end stuff in 9:59:59.000,9:59:59.000 JavaScript it's called no GS you still 9:59:59.000,9:59:59.000 need to know about the rules of writing 9:59:59.000,9:59:59.000 API servers you still need to learn 9:59:59.000,9:59:59.000 about that domain but you don't have to 9:59:59.000,9:59:59.000 learn a new language because learning 9:59:59.000,9:59:59.000 new stuff consumes mine budget and it's 9:59:59.000,9:59:59.000 difficult 9:59:59.000,9:59:59.000 before coming to go I used to write in 9:59:59.000,9:59:59.000 Java so I know Java quite well and I 9:59:59.000,9:59:59.000 want to write web front-ends well you 9:59:59.000,9:59:59.000 can write web front-ends in Java it's 9:59:59.000,9:59:59.000 not impossible but it's like using that 9:59:59.000,9:59:59.000 to pull out nails so the point I'm 9:59:59.000,9:59:59.000 trying to say 9:59:59.000,9:59:59.000 the final point I'm trying to make is 9:59:59.000,9:59:59.000 you need to have the right tools so what 9:59:59.000,9:59:59.000 is goal good for so hammer is good for 9:59:59.000,9:59:59.000 hammering in stuff that cow hammer is 9:59:59.000,9:59:59.000 not good for pulling out nails go is 9:59:59.000,9:59:59.000 good for writing cloud services back-end 9:59:59.000,9:59:59.000 service it's good for being well this is 9:59:59.000,9:59:59.000 debatable but those people who have 9:59:59.000,9:59:59.000 written in go think it's actually quite 9:59:59.000,9:59:59.000 simple to read and understand it's good 9:59:59.000,9:59:59.000 for having this thing funny thing called 9:59:59.000,9:59:59.000 implicit interface satisfaction which 9:59:59.000,9:59:59.000 I'll talk about in a while it's got 9:59:59.000,9:59:59.000 fantastic concurrency and my favorite 9:59:59.000,9:59:59.000 feature its Java done right it's 9:59:59.000,9:59:59.000 cross-platform 9:59:59.000,9:59:59.000 Sogo is somewhat familiar that's the 9:59:59.000,9:59:59.000 first line hello will in go if you 9:59:59.000,9:59:59.000 ignore the funny fmt in the capital case 9:59:59.000,9:59:59.000 it's not a class print line it just goes 9:59:59.000,9:59:59.000 way of denoting a public variable you 9:59:59.000,9:59:59.000 see it's pretty much the same across 9:59:59.000,9:59:59.000 many many different languages so goal is 9:59:59.000,9:59:59.000 somewhat familiar and therefore somewhat 9:59:59.000,9:59:59.000 easy to learn in fact go about design to 9:59:59.000,9:59:59.000 be easy to learn anybody who comes from 9:59:59.000,9:59:59.000 a Java environment or c-lite language 9:59:59.000,9:59:59.000 will find go somewhat familiar go is 9:59:59.000,9:59:59.000 definitely type safe I like to I like to 9:59:59.000,9:59:59.000 put up this example do you think this 9:59:59.000,9:59:59.000 come this program will run do you think 9:59:59.000,9:59:59.000 this program will compile really compile 9:59:59.000,9:59:59.000 it won't even compile let's try how many 9:59:59.000,9:59:59.000 of you have run your presentations 9:59:59.000,9:59:59.000 before I'm going to run the presentation 9:59:59.000,9:59:59.000 and let's read their messages go error 9:59:59.000,9:59:59.000 messages are not too bad actually 9:59:59.000,9:59:59.000 so what it's done is taken this HTML fed 9:59:59.000,9:59:59.000 it into a temporary file called compiled 9:59:59.000,9:59:59.000 0 dot go and the compiler complained 9:59:59.000,9:59:59.000 cannot use B type string in an integer 9:59:59.000,9:59:59.000 for assignment can you do in JavaScript 9:59:59.000,9:59:59.000 yes or no yes let's prove it and you put 9:59:59.000,9:59:59.000 down a microphone 9:59:59.000,9:59:59.000 so I is definitely okay thank you my 9:59:59.000,9:59:59.000 anything so I is definitely an integer 9:59:59.000,9:59:59.000 now I is a string 9:59:59.000,9:59:59.000 javascript is bad truffles I'm starting 9:59:59.000,9:59:59.000 a flame war here actually not true 9:59:59.000,9:59:59.000 javascript is a pretty good language now 9:59:59.000,9:59:59.000 in a godo so let's talk about go alright 9:59:59.000,9:59:59.000 this one is not so obvious how strongly 9:59:59.000,9:59:59.000 typesafe is go 9:59:59.000,9:59:59.000 why type safety at all but let's let's 9:59:59.000,9:59:59.000 look at this code and let's see whether 9:59:59.000,9:59:59.000 it will compile at all 9:59:59.000,9:59:59.000 I declare a type called mynum as an 9:59:59.000,9:59:59.000 integer and over here I declare a 9:59:59.000,9:59:59.000 variable I it's of type my num and I 9:59:59.000,9:59:59.000 assign it the value two over here I 9:59:59.000,9:59:59.000 assign a variable J of type int integer 9:59:59.000,9:59:59.000 of value three can I assign I and J in 9:59:59.000,9:59:59.000 Java cannot can in ogs definitely can 9:59:59.000,9:59:59.000 bingo 9:59:59.000,9:59:59.000 No let's see the error message some of 9:59:59.000,9:59:59.000 you already guessed answer's no let's 9:59:59.000,9:59:59.000 look at error message 9:59:59.000,9:59:59.000 cannot use type J cannot use J type 9:59:59.000,9:59:59.000 integer as type mine um so my num 9:59:59.000,9:59:59.000 even though was derived from an integer 9:59:59.000,9:59:59.000 is a separate typing goal so it is very 9:59:59.000,9:59:59.000 very very strongly typed and this is 9:59:59.000,9:59:59.000 very useful if you write big code if you 9:59:59.000,9:59:59.000 write code that is shared with loads of 9:59:59.000,9:59:59.000 programmers it's also very useful for 9:59:59.000,9:59:59.000 code you have written years ago this is 9:59:59.000,9:59:59.000 the equivalent of keeping everything in 9:59:59.000,9:59:59.000 its right place and the right place for 9:59:59.000,9:59:59.000 everything but there's always two sides 9:59:59.000,9:59:59.000 to a coin keeping everything in the 9:59:59.000,9:59:59.000 right place takes a lot of time a lot of 9:59:59.000,9:59:59.000 bookkeeping nodejs 9:59:59.000,9:59:59.000 allows you to throw things all the place 9:59:59.000,9:59:59.000 a teenager's bedroom nodejs is like a 9:59:59.000,9:59:59.000 teenager's bedroom go is like a 9:59:59.000,9:59:59.000 well-kept well-groomed house so strong 9:59:59.000,9:59:59.000 static typing allows you to catch most 9:59:59.000,9:59:59.000 errors at compile time and the runtime 9:59:59.000,9:59:59.000 is quite predictable in other words 9:59:59.000,9:59:59.000 after compiling and you deploy 9:59:59.000,9:59:59.000 production you can expect predictable 9:59:59.000,9:59:59.000 performance but the flip side of it is 9:59:59.000,9:59:59.000 if you are trying to throw a no-show to 9:59:59.000,9:59:59.000 get a short script a language like 9:59:59.000,9:59:59.000 nodejs Python or Ruby is much more 9:59:59.000,9:59:59.000 appropriate so guess the message is what 9:59:59.000,9:59:59.000 do you want to do what you already know 9:59:59.000,9:59:59.000 and what you want to do in the future so 9:59:59.000,9:59:59.000 decide whether you want to learn go let 9:59:59.000,9:59:59.000 me try to convince you that go is worth 9:59:59.000,9:59:59.000 learning so go has implicitly satisfied 9:59:59.000,9:59:59.000 interfaces those come in from Java know 9:59:59.000,9:59:59.000 about Java interfaces go tries to keep 9:59:59.000,9:59:59.000 keeping a house in order 9:59:59.000,9:59:59.000 static typing strong static typing more 9:59:59.000,9:59:59.000 pleasant so over here I declare an 9:59:59.000,9:59:59.000 interface type it's called one D fire 9:59:59.000,9:59:59.000 and it's got one 9:59:59.000,9:59:59.000 that in it called quantify and quantify 9:59:59.000,9:59:59.000 it takes nothing and returns an integer 9:59:59.000,9:59:59.000 so over here I declare another type my 9:59:59.000,9:59:59.000 SDR or my string it's derived from type 9:59:59.000,9:59:59.000 string and it also has a quantify method 9:59:59.000,9:59:59.000 now how do I know there is a method this 9:59:59.000,9:59:59.000 funny syntax which go created the way 9:59:59.000,9:59:59.000 you read this line means quantify is a 9:59:59.000,9:59:59.000 method of s of type my string which 9:59:59.000,9:59:59.000 returns an integer that's how you read 9:59:59.000,9:59:59.000 it so basically it's a matter of my 9:59:59.000,9:59:59.000 string it says print that means printer 9:59:59.000,9:59:59.000 screen quantifying s and was s its 9:59:59.000,9:59:59.000 length of s it returns the length of s 9:59:59.000,9:59:59.000 as the funny has a final value this is 9:59:59.000,9:59:59.000 just a side effect you just print out 9:59:59.000,9:59:59.000 the string now I declare another type 9:59:59.000,9:59:59.000 called 9:59:59.000,9:59:59.000 my int and it's derived from integer and 9:59:59.000,9:59:59.000 to quantify this integer I did tell me 9:59:59.000,9:59:59.000 whether it's positive negative or zero 9:59:59.000,9:59:59.000 that simple code for that so let's cut 9:59:59.000,9:59:59.000 to the chase 9:59:59.000,9:59:59.000 well this code were let's go to line by 9:59:59.000,9:59:59.000 line 9:59:59.000,9:59:59.000 that's just a print statement this line 9:59:59.000,9:59:59.000 is interesting 9:59:59.000,9:59:59.000 oh by the way go has this funny reversed 9:59:59.000,9:59:59.000 declaration syntax so a variable Q is of 9:59:59.000,9:59:59.000 type quantifier that's why it means it 9:59:59.000,9:59:59.000 is not quantifier is of type 2 it's the 9:59:59.000,9:59:59.000 other way around so variable Q is of 9:59:59.000,9:59:59.000 type quantifier so the quantifier has a 9:59:59.000,9:59:59.000 quantified method Q equals my int 3 now 9:59:59.000,9:59:59.000 that's another funny go Lang go language 9:59:59.000,9:59:59.000 syntax all he's saying is victory and 9:59:59.000,9:59:59.000 make it my it so I'm casting 3 to my end 9:59:59.000,9:59:59.000 think of it like a constructor in Java 9:59:59.000,9:59:59.000 so that's a constructor kind of thing 9:59:59.000,9:59:59.000 print queue 25 so 3 is a numeric it's 9:59:59.000,9:59:59.000 positive so should be 1 I guess so 9:59:59.000,9:59:59.000 Q equals my string ABC and the length of 9:59:59.000,9:59:59.000 ABC is 3 so we run this program the 9:59:59.000,9:59:59.000 first one should be 1 the second one 9:59:59.000,9:59:59.000 should be 3 let's check it out and sure 9:59:59.000,9:59:59.000 enough it is 1 in 3 now 9:59:59.000,9:59:59.000 let me edit my presentation and rerun it 9:59:59.000,9:59:59.000 anybody learn how to edit your 9:59:59.000,9:59:59.000 presentation and rerun it let's change 9:59:59.000,9:59:59.000 this to a minus four let's editing my 9:59:59.000,9:59:59.000 presentation this is written in go by 9:59:59.000,9:59:59.000 the week 9:59:59.000,9:59:59.000 real cool stuff and let's run it again 9:59:59.000,9:59:59.000 so now it shows up as minus one can 9:59:59.000,9:59:59.000 everybody at a backseater bottom rows 9:59:59.000,9:59:59.000 good now no surprise if I change it to 9:59:59.000,9:59:59.000 zero it should be zero let's run it and 9:59:59.000,9:59:59.000 it shows up as zero if I change this to 9:59:59.000,9:59:59.000 a four letter word maybe a five letter 9:59:59.000,9:59:59.000 word it just returns the length of the 9:59:59.000,9:59:59.000 string now I'm going to show you goes 9:59:59.000,9:59:59.000 see you routes anybody know see here 9:59:59.000,9:59:59.000 good what do you think will happen here 9:59:59.000,9:59:59.000 0x20 a see that's a hexadecimal number 9:59:59.000,9:59:59.000 what do you think what happened you 9:59:59.000,9:59:59.000 volunteers shout out your answer really 9:59:59.000,9:59:59.000 will one character well let's try it on 9:59:59.000,9:59:59.000 quantifying euro 0x20 AC is the Unicode 9:59:59.000,9:59:59.000 for Euro the Euro symbol and the Euro 9:59:59.000,9:59:59.000 symbol is a single character string and 9:59:59.000,9:59:59.000 it says 3 because the signal character 9:59:59.000,9:59:59.000 string is actually an integer and it's 9:59:59.000,9:59:59.000 of length 3 really confusing stuff but 9:59:59.000,9:59:59.000 here are the things they will trip you 9:59:59.000,9:59:59.000 up it's sea routes 9:59:59.000,9:59:59.000 alright why is this useful why are these 9:59:59.000,9:59:59.000 car interfaces useful now let's say I 9:59:59.000,9:59:59.000 have another type call exam paper and 9:59:59.000,9:59:59.000 exam paper you submitted it as Syrian 9:59:59.000,9:59:59.000 Dom I shouldn't use Microsoft should use 9:59:59.000,9:59:59.000 Google stuff anyway that's the URL for 9:59:59.000,9:59:59.000 my exam paper submission and let's say 9:59:59.000,9:59:59.000 exam paper is to create me quantify how 9:59:59.000,9:59:59.000 do you test this car stuff it's 9:59:59.000,9:59:59.000 difficult right it's gonna make a 9:59:59.000,9:59:59.000 service call go out to the Internet 9:59:59.000,9:59:59.000 grab the real exam paper and try to test 9:59:59.000,9:59:59.000 it and that's not very predictable the 9:59:59.000,9:59:59.000 internet connection may be down I may 9:59:59.000,9:59:59.000 have changed my exam my exam submission 9:59:59.000,9:59:59.000 but I can have fake exam paper to HTTP 9:59:59.000,9:59:59.000 does not matter dot see you in the doc 9:59:59.000,9:59:59.000 it never makes the internet call but 9:59:59.000,9:59:59.000 fake exam paper because it 9:59:59.000,9:59:59.000 satisfies quantify it works and it's 9:59:59.000,9:59:59.000 great for testing so this is how I use 9:59:59.000,9:59:59.000 interfaces all the time but this way of 9:59:59.000,9:59:59.000 defining interfaces is very very useful 9:59:59.000,9:59:59.000 because in Java or similar languages you 9:59:59.000,9:59:59.000 must say this class implements this and 9:59:59.000,9:59:59.000 you may find that the implements may be 9:59:59.000,9:59:59.000 implements ABCD efg until Zach a very 9:59:59.000,9:59:59.000 very long string of implements in go 9:59:59.000,9:59:59.000 there is no implements cuit it's 9:59:59.000,9:59:59.000 implicit implementation so long as it's 9:59:59.000,9:59:59.000 got a quantifier method it works the 9:59:59.000,9:59:59.000 most fantastic example of this is IO 9:59:59.000,9:59:59.000 reader and IO writer you can print line 9:59:59.000,9:59:59.000 to a database because it I all right I 9:59:59.000,9:59:59.000 will read ok so that is the second 9:59:59.000,9:59:59.000 reason why go is such a good language if 9:59:59.000,9:59:59.000 I'm losing any of you if you want us any 9:59:59.000,9:59:59.000 questions just shout out interrupt me 9:59:59.000,9:59:59.000 yes 9:59:59.000,9:59:59.000 so Java has if you have a functional 9:59:59.000,9:59:59.000 interface yeah Java it onwards has 9:59:59.000,9:59:59.000 function interfaces and the question is 9:59:59.000,9:59:59.000 if you use the functional interface of 9:59:59.000,9:59:59.000 Java you have this kind of capability 9:59:59.000,9:59:59.000 sort of right and how is it different 9:59:59.000,9:59:59.000 from the Java interface well I like to 9:59:59.000,9:59:59.000 think go start the refers Java copied it 9:59:59.000,9:59:59.000 but here that's actually a very good 9:59:59.000,9:59:59.000 question 9:59:59.000,9:59:59.000 go JavaScript and I'm sorry 9:59:59.000,9:59:59.000 leave go office JavaScript nodejs Java 9:59:59.000,9:59:59.000 Kotlin all the new modern languages if 9:59:59.000,9:59:59.000 you hear one of the authors of go speak 9:59:59.000,9:59:59.000 his name is Robert by interesting 9:59:59.000,9:59:59.000 speaker he says all these languages are 9:59:59.000,9:59:59.000 becoming more and more alike they're 9:59:59.000,9:59:59.000 getting more and more features Java is 9:59:59.000,9:59:59.000 getting functional features node.js is 9:59:59.000,9:59:59.000 trying to get classes so all these 9:59:59.000,9:59:59.000 languages are converging more or less 9:59:59.000,9:59:59.000 the same language perhaps it differs 9:59:59.000,9:59:59.000 slightly different syntax who is 9:59:59.000,9:59:59.000 different go is very very limited I'd 9:59:59.000,9:59:59.000 want to use this word but it is quite 9:59:59.000,9:59:59.000 relevant limited stupid basic language 9:59:59.000,9:59:59.000 it is designed so that anybody coming 9:59:59.000,9:59:59.000 from a C language can look at it and 9:59:59.000,9:59:59.000 solve kind of understand it it's 9:59:59.000,9:59:59.000 designed so that you can write code that 9:59:59.000,9:59:59.000 is efficient that compiles quickly and 9:59:59.000,9:59:59.000 when you look at here five years later 9:59:59.000,9:59:59.000 you can still understand it so goal is 9:59:59.000,9:59:59.000 designed somewhat like Python what 9:59:59.000,9:59:59.000 design Python was designed to be clear 9:59:59.000,9:59:59.000 and easily readable so many people have 9:59:59.000,9:59:59.000 actually come from Python to go 9:59:59.000,9:59:59.000 why because Python is really slow global 9:59:59.000,9:59:59.000 interpreter lock 9:59:59.000,9:59:59.000 I came to go not from Python but from 9:59:59.000,9:59:59.000 Ruby the rubies are fantastic language 9:59:59.000,9:59:59.000 it makes developers like me who write in 9:59:59.000,9:59:59.000 Ruby very happy it's a very very fun 9:59:59.000,9:59:59.000 language but but but yes group global 9:59:59.000,9:59:59.000 interpreter lock it's really slow but 9:59:59.000,9:59:59.000 that wasn't my issue it was fast enough 9:59:59.000,9:59:59.000 Ruby was fast enough for me but Ruby 9:59:59.000,9:59:59.000 code because it was so fun to write when 9:59:59.000,9:59:59.000 you look at it five years later what am 9:59:59.000,9:59:59.000 I trying to write here go tries to 9:59:59.000,9:59:59.000 circumvent that problem by anyway let's 9:59:59.000,9:59:59.000 go to goes the feature which I want to 9:59:59.000,9:59:59.000 talk about which is concurrency which is 9:59:59.000,9:59:59.000 something which for a person new to 9:59:59.000,9:59:59.000 programming finds it really hard and for 9:59:59.000,9:59:59.000 person who does JavaScript finds it 9:59:59.000,9:59:59.000 quite hard as well so over here I 9:59:59.000,9:59:59.000 declare a function let's call plus and 9:59:59.000,9:59:59.000 all it does for event however prints 9:59:59.000,9:59:59.000 the plus sign that's all it does after 9:59:59.000,9:59:59.000 one second it Blin prints another plus 9:59:59.000,9:59:59.000 forever and ever 9:59:59.000,9:59:59.000 here we have basically the same routine 9:59:59.000,9:59:59.000 but it brings out a period brings out a 9:59:59.000,9:59:59.000 dot okay 9:59:59.000,9:59:59.000 most of us when we start out writing 9:59:59.000,9:59:59.000 code we write code like this this this 9:59:59.000,9:59:59.000 one compiled so 9:59:59.000,9:59:59.000 let's run it like this this one compiled 9:59:59.000,9:59:59.000 it all it's got some real error message 9:59:59.000,9:59:59.000 about to execute select so I'm about to 9:59:59.000,9:59:59.000 execute select fatal all goroutines are 9:59:59.000,9:59:59.000 sleep deadlock which means there is 9:59:59.000,9:59:59.000 something in NGO called a goroutine and 9:59:59.000,9:59:59.000 his detected deadlock and its crash the 9:59:59.000,9:59:59.000 program and it's exited so okay let's 9:59:59.000,9:59:59.000 make the program work 9:59:59.000,9:59:59.000 let's fix me ok let's run + let's run 9:59:59.000,9:59:59.000 this program ok pluses are running but 9:59:59.000,9:59:59.000 my aim is to run + and go at the same 9:59:59.000,9:59:59.000 time concurrently so as a beginner 9:59:59.000,9:59:59.000 programmer I would do that of course 9:59:59.000,9:59:59.000 do you think that will never work 9:59:59.000,9:59:59.000 no why 9:59:59.000,9:59:59.000 a sequential execution plus is holding 9:59:59.000,9:59:59.000 on to the CPU I just want to let go 9:59:59.000,9:59:59.000 let's prove it yes plus is hogging the 9:59:59.000,9:59:59.000 CPU doesn't want to let go it doesn't 9:59:59.000,9:59:59.000 let go any time to run it all okay I am 9:59:59.000,9:59:59.000 the creator I'm the right of this 9:59:59.000,9:59:59.000 program now dot can run correct yeah 9:59:59.000,9:59:59.000 don't runs by one go and plus and dot to 9:59:59.000,9:59:59.000 run at the same time how do I do that 9:59:59.000,9:59:59.000 anybody we got go experts here come on 9:59:59.000,9:59:59.000 ah yes the goalkeeper do ah start a go 9:59:59.000,9:59:59.000 routine let's do that 9:59:59.000,9:59:59.000 I added three characters g/o and a space 9:59:59.000,9:59:59.000 and I've turned a regular routine into a 9:59:59.000,9:59:59.000 go routine in the routine that doesn't 9:59:59.000,9:59:59.000 block let's prove it hey it doesn't 9:59:59.000,9:59:59.000 block it works but hold on this part the 9:59:59.000,9:59:59.000 code is not executing this particle 9:59:59.000,9:59:59.000 which says about to execute select is 9:59:59.000,9:59:59.000 not executing how do I get that to 9:59:59.000,9:59:59.000 execute as well 9:59:59.000,9:59:59.000 oh you guys are learning fast 9:59:59.000,9:59:59.000 put another make dot a go routine so 9:59:59.000,9:59:59.000 let's do that 9:59:59.000,9:59:59.000 bang now there's something interesting 9:59:59.000,9:59:59.000 here this comes from printing lying go 9:59:59.000,9:59:59.000 concurrency this comes from about to 9:59:59.000,9:59:59.000 execute select and then the pluses and 9:59:59.000,9:59:59.000 dots what is actually happened here is 9:59:59.000,9:59:59.000 the program ran put that into the 9:59:59.000,9:59:59.000 background it's running independently in 9:59:59.000,9:59:59.000 the background put that in a background 9:59:59.000,9:59:59.000 that took a few hundred microseconds 9:59:59.000,9:59:59.000 fraction of a millisecond so in a 9:59:59.000,9:59:59.000 fraction of a millisecond or maybe a 9:59:59.000,9:59:59.000 millisecond later the print line 9:59:59.000,9:59:59.000 executed and I needed to put this select 9:59:59.000,9:59:59.000 here select here select is a statement 9:59:59.000,9:59:59.000 which actually tries to determine which 9:59:59.000,9:59:59.000 grow routine is ready to run but if I 9:59:59.000,9:59:59.000 remove that select if I remove the wait 9:59:59.000,9:59:59.000 forever what do you think will happen 9:59:59.000,9:59:59.000 the program would actually the program 9:59:59.000,9:59:59.000 would terminate 9:59:59.000,9:59:59.000 what happened to my goal routines if 9:59:59.000,9:59:59.000 main terminates the core routines 9:59:59.000,9:59:59.000 dominate let's prove that 9:59:59.000,9:59:59.000 so no more select it's commented out and 9:59:59.000,9:59:59.000 by the way the double slash if you've 9:59:59.000,9:59:59.000 not figured it out its comment 9:59:59.000,9:59:59.000 program exited no dots no plus so that's 9:59:59.000,9:59:59.000 another feature of go 9:59:59.000,9:59:59.000 it has garbage collected the goal 9:59:59.000,9:59:59.000 routines goal is a garbage collector 9:59:59.000,9:59:59.000 language with a very very very 9:59:59.000,9:59:59.000 performant garbage collector those 9:59:59.000,9:59:59.000 people coming from Java every now and 9:59:59.000,9:59:59.000 then when the garbage collector collects 9:59:59.000,9:59:59.000 garbage it stops the world the whole 9:59:59.000,9:59:59.000 system stops go garbage collector used 9:59:59.000,9:59:59.000 to be like that as well stop the world 9:59:59.000,9:59:59.000 for a few hundred milliseconds the 9:59:59.000,9:59:59.000 latest version or go stops the world for 9:59:59.000,9:59:59.000 a few hundred microseconds so it doesn't 9:59:59.000,9:59:59.000 really stop the world alright 9:59:59.000,9:59:59.000 those people who know JavaScript will 9:59:59.000,9:59:59.000 know no js' that's nothing new 9:59:59.000,9:59:59.000 no Jas has concurrency as well so let's 9:59:59.000,9:59:59.000 prove it I'll put it here 9:59:59.000,9:59:59.000 f12 to get console 9:59:59.000,9:59:59.000 so over here I've defined two JavaScript 9:59:59.000,9:59:59.000 functions function plus and function dot 9:59:59.000,9:59:59.000 and this is very JavaScript every 1000 9:59:59.000,9:59:59.000 milliseconds lakh to the console a plus 9:59:59.000,9:59:59.000 every 1000 milliseconds log to the 9:59:59.000,9:59:59.000 console a - no - a dot so when I run 9:59:59.000,9:59:59.000 that well pluses go on to pluses four 9:59:59.000,9:59:59.000 pluses five pluses go on and on 9:59:59.000,9:59:59.000 if I run dot if I can type 9:59:59.000,9:59:59.000 now you got plus and dot's so javascript 9:59:59.000,9:59:59.000 can do what go to us mind budget if you 9:59:59.000,9:59:59.000 know JavaScript do you want to learn go 9:59:59.000,9:59:59.000 okay was it the same sort of sort of the 9:59:59.000,9:59:59.000 same what I just did in my in my web 9:59:59.000,9:59:59.000 browser was I made use of a web worker 9:59:59.000,9:59:59.000 which will consume this is roughly 9:59:59.000,9:59:59.000 equivalent to one java thread which is 9:59:59.000,9:59:59.000 roughly equivalent to one operating 9:59:59.000,9:59:59.000 system-level thread so if my computer 9:59:59.000,9:59:59.000 has four cores it can run four threats 9:59:59.000,9:59:59.000 at the same time at the same time you 9:59:59.000,9:59:59.000 can have many many threads like an when 9:59:59.000,9:59:59.000 you run for them at the same time a go 9:59:59.000,9:59:59.000 routine is not blind the JavaScript web 9:59:59.000,9:59:59.000 worker know a goroutine well a million 9:59:59.000,9:59:59.000 go routines can share one thread 9:59:59.000,9:59:59.000 somebody actually did a demo a million 9:59:59.000,9:59:59.000 go routine share one thread so it's a 9:59:59.000,9:59:59.000 very simple very lightweight go routine 9:59:59.000,9:59:59.000 almost does nothing but still a million 9:59:59.000,9:59:59.000 go routines can say one thread and on a 9:59:59.000,9:59:59.000 fork or machine you get four million go 9:59:59.000,9:59:59.000 routines so the next point I'll make is 9:59:59.000,9:59:59.000 ah after Java II guess guess who the 9:59:59.000,9:59:59.000 coffee 9:59:59.000,9:59:59.000 guess who do you copy the coffee go the 9:59:59.000,9:59:59.000 ideas are very old the ideas are very 9:59:59.000,9:59:59.000 very old right goroutine is actually not 9:59:59.000,9:59:59.000 the correct word to use it's correct in 9:59:59.000,9:59:59.000 go by it came from paper called 9:59:59.000,9:59:59.000 concurrently concurrent sequential 9:59:59.000,9:59:59.000 processes it's called co-routines 9:59:59.000,9:59:59.000 spelled with a c' nobody paid attention 9:59:59.000,9:59:59.000 to co-routines except for the line for a 9:59:59.000,9:59:59.000 long long time 9:59:59.000,9:59:59.000 right then goal came out and say 9:59:59.000,9:59:59.000 co-routines are cool and I'm gonna brand 9:59:59.000,9:59:59.000 them goroutines and then everybody 9:59:59.000,9:59:59.000 started saying hmm Cortland once it as 9:59:59.000,9:59:59.000 well 9:59:59.000,9:59:59.000 Java wants it as well so all these 9:59:59.000,9:59:59.000 languages are becoming known as the same 9:59:59.000,9:59:59.000 language with different syntax they're 9:59:59.000,9:59:59.000 getting features before coming to go yes 9:59:59.000,9:59:59.000 Rudy as a Jordi no I programmed in Java 9:59:59.000,9:59:59.000 and I was looking for better Java so I 9:59:59.000,9:59:59.000 thought Scala is good 9:59:59.000,9:59:59.000 Scala is an extremely powerful language 9:59:59.000,9:59:59.000 don't get me wrong it can do everything 9:59:59.000,9:59:59.000 you can write dsls domain-specific 9:59:59.000,9:59:59.000 languages in Java it is so big that I 9:59:59.000,9:59:59.000 can't read my code after one week I can 9:59:59.000,9:59:59.000 be so undisciplined there I cannot read 9:59:59.000,9:59:59.000 my own code after one week that is color 9:59:59.000,9:59:59.000 anyway 9:59:59.000,9:59:59.000 how good is gos concurrency that's 9:59:59.000,9:59:59.000 that's another thing I want to highlight 9:59:59.000,9:59:59.000 about goal is course concurrency good go 9:59:59.000,9:59:59.000 is design the birthplace of goal was 9:59:59.000,9:59:59.000 actually Google we are at its birthplace 9:59:59.000,9:59:59.000 the organization not here but 9:59:59.000,9:59:59.000 organization and goal was invented the 9:59:59.000,9:59:59.000 story goes when you're trying to compile 9:59:59.000,9:59:59.000 a big C++ program that big C++ program 9:59:59.000,9:59:59.000 took about 40 minutes to compile they 9:59:59.000,9:59:59.000 compile the equivalent program in go and 9:59:59.000,9:59:59.000 it took less than a minute few seconds 9:59:59.000,9:59:59.000 but compiled time is one thing how 9:59:59.000,9:59:59.000 performin is it this is a whole web 9:59:59.000,9:59:59.000 browser in go now those people working 9:59:59.000,9:59:59.000 in no job no GSA say I can have Express 9:59:59.000,9:59:59.000 and I can write a similarly short web 9:59:59.000,9:59:59.000 browser in three lines or four lines or 9:59:59.000,9:59:59.000 two lines 9:59:59.000,9:59:59.000 let's besides the point the point is can 9:59:59.000,9:59:59.000 no GS perform on my really crappy laptop 9:59:59.000,9:59:59.000 11,000 requests per second with almost 9:59:59.000,9:59:59.000 no optimization well go optimization 9:59:59.000,9:59:59.000 compared with nginx same laptop running 9:59:59.000,9:59:59.000 a static website all it does is serve 9:59:59.000,9:59:59.000 hello well it came out with about the 9:59:59.000,9:59:59.000 same 10,000 requests per second 11,000 9:59:59.000,9:59:59.000 requests the second it's within the 9:59:59.000,9:59:59.000 arrow pens right what I'm trying to say 9:59:59.000,9:59:59.000 here is for beginner who knows nothing 9:59:59.000,9:59:59.000 about OS tuning who knows nothing about 9:59:59.000,9:59:59.000 concurrency you can write code that's 9:59:59.000,9:59:59.000 production-ready 9:59:59.000,9:59:59.000 as good as engineer 9:59:59.000,9:59:59.000 so goal is designed for heavy-duty 9:59:59.000,9:59:59.000 back-end service production-ready 9:59:59.000,9:59:59.000 back-end service a really good really 9:59:59.000,9:59:59.000 performant easy to read easy to extend 9:59:59.000,9:59:59.000 back-end service and my favorite feature 9:59:59.000,9:59:59.000 of all Java done right if you use pure 9:59:59.000,9:59:59.000 go in other words you don't link against 9:59:59.000,9:59:59.000 the C library you can link go against a 9:59:59.000,9:59:59.000 CLI breathe that's called C go if we 9:59:59.000,9:59:59.000 don't use Seco or use Windows specific 9:59:59.000,9:59:59.000 dll's or Mac specific libraries you can 9:59:59.000,9:59:59.000 all you need to do to cross compile the 9:59:59.000,9:59:59.000 Gnostic oh you go enable equals zero 9:59:59.000,9:59:59.000 turn off Seco specify an operating 9:59:59.000,9:59:59.000 system windows I've got clients that 9:59:59.000,9:59:59.000 insist on using Windows what they do no 9:59:59.000,9:59:59.000 near windows old windows 386 windows now 9:59:59.000,9:59:59.000 x64 go Buell hello well it generates an 9:59:59.000,9:59:59.000 exe file a windows 386 exe file let's 9:59:59.000,9:59:59.000 look at the complete list 9:59:59.000,9:59:59.000 Hayek's 9:59:59.000,9:59:59.000 Wow Android Darwyn what's dragonfly 9:59:59.000,9:59:59.000 don't know what dragonfly is FreeBSD 9:59:59.000,9:59:59.000 some funny always called illumos I don't 9:59:59.000,9:59:59.000 know about it 9:59:59.000,9:59:59.000 ah this is really really really 9:59:59.000,9:59:59.000 interesting javascript was a web 9:59:59.000,9:59:59.000 assembly yes cool can compile to the 9:59:59.000,9:59:59.000 JavaScript web assembly binaries and 9:59:59.000,9:59:59.000 these people are using it because they 9:59:59.000,9:59:59.000 want to play games on the web browser 9:59:59.000,9:59:59.000 and go a so performin they put a whole 9:59:59.000,9:59:59.000 game engine in the web assembly with 9:59:59.000,9:59:59.000 with physics and everything in there 9:59:59.000,9:59:59.000 nice target before go is just another 9:59:59.000,9:59:59.000 target it targets all these platforms my 9:59:59.000,9:59:59.000 platform happens be Linux AMD 64 so 9:59:59.000,9:59:59.000 let's go back another presentation 9:59:59.000,9:59:59.000 if you won a coat download the whole 9:59:59.000,9:59:59.000 presentation download its there soohyun 9:59:59.000,9:59:59.000 github lots of other presentations there 9:59:59.000,9:59:59.000 as well but this one is there and you 9:59:59.000,9:59:59.000 can run your presentation like I ran my 9:59:59.000,9:59:59.000 presentation thanks for listening thank 9:59:59.000,9:59:59.000 you questions comments flamewars yes 9:59:59.000,9:59:59.000 okay the question was usually 9:59:59.000,9:59:59.000 machine-learning folks used something 9:59:59.000,9:59:59.000 like Python and Python is a fantastic 9:59:59.000,9:59:59.000 language for machine learning because 9:59:59.000,9:59:59.000 Python was written by dude over in 9:59:59.000,9:59:59.000 Russell my pronouncing that name all 9:59:59.000,9:59:59.000 wrong 9:59:59.000,9:59:59.000 he's a mathematics professor so before 9:59:59.000,9:59:59.000 tensorflow came out you had numpy and 9:59:59.000,9:59:59.000 Python was an absolutely great language 9:59:59.000,9:59:59.000 in that area go is not it's not a 9:59:59.000,9:59:59.000 machine language optimized language is 9:59:59.000,9:59:59.000 the wrong tool to use go for machine 9:59:59.000,9:59:59.000 language but go is very very good for 9:59:59.000,9:59:59.000 data engineering before you can do 9:59:59.000,9:59:59.000 machine learning you need to get your 9:59:59.000,9:59:59.000 data in shape you need to clean your 9:59:59.000,9:59:59.000 data so go has data flow libraries which 9:59:59.000,9:59:59.000 can clean up massive amounts of data 9:59:59.000,9:59:59.000 really quickly but not the actual 9:59:59.000,9:59:59.000 machine learning itself any other 9:59:59.000,9:59:59.000 questions comments reactions you like go 9:59:59.000,9:59:59.000 is it worth learning yes okay my friend 9:59:59.000,9:59:59.000 here has a difficult question for me he 9:59:59.000,9:59:59.000 promised me a difficult question doesn't 9:59:59.000,9:59:59.000 matter repeat your question yes 9:59:59.000,9:59:59.000 [Music] 9:59:59.000,9:59:59.000 okay okay I guess I guess you can 9:59:59.000,9:59:59.000 summarize the question is summarized the 9:59:59.000,9:59:59.000 question is can you share pine can you 9:59:59.000,9:59:59.000 share memory effectively if you got 9:59:59.000,9:59:59.000 sixty instances of the same thing can 9:59:59.000,9:59:59.000 you share memory sort of kind of it will 9:59:59.000,9:59:59.000 eat up it will be 60 times the memory 9:59:59.000,9:59:59.000 okay 9:59:59.000,9:59:59.000 so let's answer actually is a very very 9:59:59.000,9:59:59.000 good question 9:59:59.000,9:59:59.000 let me attack let me attack the first 9:59:59.000,9:59:59.000 question first let me address the first 9:59:59.000,9:59:59.000 question first go binaries can get 9:59:59.000,9:59:59.000 pretty big pretty fast that hello world 9:59:59.000,9:59:59.000 was about one to two megabytes why is it 9:59:59.000,9:59:59.000 so big why is a hello world almost two 9:59:59.000,9:59:59.000 megabytes 9:59:59.000,9:59:59.000 yes when you write a Java class 9:59:59.000,9:59:59.000 HelloWorld in Java class and the class 9:59:59.000,9:59:59.000 file is a few hundred bytes a go 9:59:59.000,9:59:59.000 executable is a few megabytes almost two 9:59:59.000,9:59:59.000 megabytes but the Java file can run on 9:59:59.000,9:59:59.000 its own you need the JVM which is 50 9:59:59.000,9:59:59.000 megabytes or more the last time I 9:59:59.000,9:59:59.000 checked the entire JVM for go the entire 9:59:59.000,9:59:59.000 go runtime is embedded in the binary the 9:59:59.000,9:59:59.000 entire go runtime the handles go 9:59:59.000,9:59:59.000 routines the entire go runtime that does 9:59:59.000,9:59:59.000 all this smart implicit interfaces 9:59:59.000,9:59:59.000 entire go runtime that does strong 9:59:59.000,9:59:59.000 static types is embedded in that one or 9:59:59.000,9:59:59.000 two megabytes in the hello world so most 9:59:59.000,9:59:59.000 go binaries are self-contained most HTTP 9:59:59.000,9:59:59.000 is not self-contained but you can make 9:59:59.000,9:59:59.000 it self-contained and can make a pure 9:59:59.000,9:59:59.000 coding net HTTP or the net library 9:59:59.000,9:59:59.000 actually makes use of the operating 9:59:59.000,9:59:59.000 systems resolver library which means 9:59:59.000,9:59:59.000 it's a time I'm a clear link library and 9:59:59.000,9:59:59.000 many pure go operas don't like it so 9:59:59.000,9:59:59.000 they turn off see go and you can produce 9:59:59.000,9:59:59.000 a pure goal binary and that consumes 9:59:59.000,9:59:59.000 maybe about five megabytes to eight 9:59:59.000,9:59:59.000 megabytes the entire web browser 9:59:59.000,9:59:59.000 resolver stack so that's why gold 9:59:59.000,9:59:59.000 binaries can get big quite fast the 9:59:59.000,9:59:59.000 entire docker binary was written in go 9:59:59.000,9:59:59.000 and it's about fifty megabytes I think 9:59:59.000,9:59:59.000 right so really really huge projects 9:59:59.000,9:59:59.000 like docker kubernetes cube control cube 9:59:59.000,9:59:59.000 CTL they win roughly tens of megabytes 9:59:59.000,9:59:59.000 when you deploy a goal binary in a 9:59:59.000,9:59:59.000 docker container I don't use Alpine 9:59:59.000,9:59:59.000 because I guess I just used from scratch 9:59:59.000,9:59:59.000 in docker terms from scratch means start 9:59:59.000,9:59:59.000 with an empty container empty docker 9:59:59.000,9:59:59.000 container and in my go binary is five 9:59:59.000,9:59:59.000 megabytes my docker containers five 9:59:59.000,9:59:59.000 megabytes really tiny docker containers 9:59:59.000,9:59:59.000 so the mantra for goal is don't 9:59:59.000,9:59:59.000 communicate by sharing memory right 9:59:59.000,9:59:59.000 don't communicate by sharing memory 9:59:59.000,9:59:59.000 share memory by communicating so 9:59:59.000,9:59:59.000 everything in goal is independent and 9:59:59.000,9:59:59.000 unshared non share you communicate 9:59:59.000,9:59:59.000 across different processes using 9:59:59.000,9:59:59.000 channels any other comments questions 9:59:59.000,9:59:59.000 reactions if not I think Xiao Zhang yes 9:59:59.000,9:59:59.000 yes I've used a patch a benchmark to 9:59:59.000,9:59:59.000 test the let me repeat the question for 9:59:59.000,9:59:59.000 the audience the question was is go now 9:59:59.000,9:59:59.000 because that hello world was static 9:59:59.000,9:59:59.000 content static web browsers everybody 9:59:59.000,9:59:59.000 knows it's blazingly fast right any any 9:59:59.000,9:59:59.000 person can write a fast static web 9:59:59.000,9:59:59.000 browser the question was is go the right 9:59:59.000,9:59:59.000 tool for IO intensive dynamic content 9:59:59.000,9:59:59.000 and absolutely that's the purpose of 9:59:59.000,9:59:59.000 goal it's designed to have very very 9:59:59.000,9:59:59.000 fast io intensive stuff if if everything 9:59:59.000,9:59:59.000 is compute intensive like video encoding 9:59:59.000,9:59:59.000 go will not be very effective because 9:59:59.000,9:59:59.000 the compute or CPU resource hungry 9:59:59.000,9:59:59.000 process will grab the CPU but if it is 9:59:59.000,9:59:59.000 IO intensive go is the perfect fit much 9:59:59.000,9:59:59.000 much much better than no GS know GS 9:59:59.000,9:59:59.000 rocked the world because it multiplexed 9:59:59.000,9:59:59.000 a lot of i/o intensive process 9:59:59.000,9:59:59.000 on two one thread go multiplex the same 9:59:59.000,9:59:59.000 thing actually cause some copy no GS in 9:59:59.000,9:59:59.000 their sense but knock not one trip on 9:59:59.000,9:59:59.000 all available threads if you have a 64 9:59:59.000,9:59:59.000 core CPU 64 processes can be called the 9:59:59.000,9:59:59.000 task versus one process in no js' and 9:59:59.000,9:59:59.000 yet that yes ok take two days 9:59:59.000,9:59:59.000 I'll just because need ok 9:59:59.000,9:59:59.000 go good for writing back in service 9:59:59.000,9:59:59.000 . go is fantastic for writing back-end 9:59:59.000,9:59:59.000 service second question is cool 9:59:59.000,9:59:59.000 resource-hungry does go require a lot of 9:59:59.000,9:59:59.000 resources like Java for example in the 9:59:59.000,9:59:59.000 answer is no go is very very efficient 9:59:59.000,9:59:59.000 next to see in terms of efficiency if C 9:59:59.000,9:59:59.000 was the ghost and there is one it uses 9:59:59.000,9:59:59.000 100% go would use maybe of 110% maybe 9:59:59.000,9:59:59.000 hundred five percent so it is very very 9:59:59.000,9:59:59.000 resource efficient thank you 9:59:59.000,9:59:59.000 [Applause]