dotGo 2016 - Dave Cheney - Do not fear first class functions
Video Statistics and Information
Channel: dotconferences
Views: 24,476
Rating: 4.9357944 out of 5
Keywords:
Id: 5buaPyJ0XeQ
Channel Id: undefined
Length: 18min 54sec (1134 seconds)
Published: Fri Oct 28 2016
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
The first part scared me a little, but his calculator example was great and actually really applied to what I'm working on at the moment in go (an NES emulator). I was trying different ways to do like function tables and look ups in an attempted to try and avoid giant changing if or case functions. Thanks for sharing and of course thanks to Dave!
if functions were first class values, how do I serialize them, send them over network, deserialize and call them?
yes, i want to send iterators over wire, distribute, continue.
Not sure why a dislike of first class functions translated to fearing them.
I certainly understand what he's advocating here but aiming for expressive over simplicity of readability at the expense of a few case clauses feels contrived. I didn't find any of the examples using this approach more readable than their more imperative counterparts.
Looks like the visitor pattern.
Although I enjoyed this presentation a lot, I felt a little off by the way Dave sneaked in the usage of his
errors
package at 16:36. Nothing wrong with advertising your own work but when you are trying to explain such a concept, it's not so helpful to sneak in an external package that could be doing god knows what. Obviously it does not affect the main point but it did make me scratch my head.P.S. I mean no disrespect by this. I deeply appreciate all the work Dave has done for the Go community.
I am wondering why the PrivateMsg example at 16:45 isn't a data race. It looks like the function requests a copy of net.Conn, which it gets. Then it sends data to the net.Conn copy, but this is done off the loops goroutine. Reading the documentation of net.TCPConn, I cannot find information regarding if Write is thread-safe, so I assume it is not. I understand a copy of net.Conn is used, but this must have some form of connection with the original net.Conn, else Writes to it won't end up at the correct network. Can anyone explain?
Seeing as nobody is going to make a comment, I'll go first. I still fear first class functions.
I did come up with something similar in my chat:
https://github.com/elcct/taillachat/blob/master/chat/map.go