The document discusses the Go programming language and how it differs from Ruby. It provides examples of Go code demonstrating type declarations, embedded types, exported variables and functions, and variable redeclaration. It also discusses some concepts in Go like interfaces, channels, and concurrency that are different from Ruby. The document suggests that Go teaches programmers awareness about variables, types, and errors that can improve Ruby code.
This session will uncover some useful, but not so well known VIM features as well as go over a number of VIM plugins that are essential for programmers.
This session will uncover some useful, but not so well known VIM features as well as go over a number of VIM plugins that are essential for programmers.
I heard from many sources that my productivity would increase if I used Vim as my text editor. I attempted to scale the steep learning cliff (not so much a curve...). One week I decided that I would learn by forcing myself to use vim all week. Since that week I've embraced my inner vim. In this talk I will go over the resources I used to learn vim and the basic cool operations that I love with vim. Topics will include basic text operations, vimrc, creating color schemes, and using vim plugins. If you ever wanted to give vim a shot but didn't know where to start, then you can start here.
These are the slides I was using when delivering a short talk in Vienna PHP. The talk took place in Vienna on September 22th. More information about the PHP course I deliver can be found at php.course.lifemichael.com
Desde que empecé con Linux hace años, la consola, los scripts y yo nos hemos ido conociendo poco a poco hasta que ha surgido una bonita amistad. Hoy, en cuanto me surge la oportunidad juego con ellos para automatizar casi cualquier cosa de mi sistema operativo.
En esta charla quiero enseñar a programar scripts de Bash desde cero e ir subiendo la complejidad para terminar con AWK.
Originalmente es un taller que presenté en el t3chfest y que tuvo muy buena acogida, y que para el CommitConf he reducido y reestructurado como charla para que los que vengáis aprendáis los conceptos básicos de Bash y de AWK.
Presentation given at the Glasgow Perl Mongers a while ago, about how I sped up part of my Multi User Dungeon written in Perl, and some lessons learnt from it
Highlights a bunch of different Python tricks and tips - from the stupid to the awesome (and a bit of both).
See how to register a 'str'.decode('hail_mary') codec, call_functions[1, 2, 3] instead of call_functions(1, 2, 3), creating a "Clojure-like" threading syntax by overloading the pipe operator, create useful equality mocks by overloading the equality operator, ditch JSON for pySON and put together a tiny lisp based on Norvig's awesome article.
You believe in the power of JavaScript modules, but you have an existing app, stack or platform infrastructure to keep running. Between maintenance and new features, where do you carve out time to switch over? After a brief overview of modules and why they're great, we'll dig into how to actually migrate a code base, from plotting your approach to implementation tips.
Video: http://youtu.be/FbdcdC8mqwE?t=50m51s (watch the entire video from the beginning for other great talks about shadow DOM and competing task runners)
Talk from February 19, 2014 NYCHTML5 Meetup: http://www.meetup.com/nychtml5/events/160684962/
I heard from many sources that my productivity would increase if I used Vim as my text editor. I attempted to scale the steep learning cliff (not so much a curve...). One week I decided that I would learn by forcing myself to use vim all week. Since that week I've embraced my inner vim. In this talk I will go over the resources I used to learn vim and the basic cool operations that I love with vim. Topics will include basic text operations, vimrc, creating color schemes, and using vim plugins. If you ever wanted to give vim a shot but didn't know where to start, then you can start here.
These are the slides I was using when delivering a short talk in Vienna PHP. The talk took place in Vienna on September 22th. More information about the PHP course I deliver can be found at php.course.lifemichael.com
Desde que empecé con Linux hace años, la consola, los scripts y yo nos hemos ido conociendo poco a poco hasta que ha surgido una bonita amistad. Hoy, en cuanto me surge la oportunidad juego con ellos para automatizar casi cualquier cosa de mi sistema operativo.
En esta charla quiero enseñar a programar scripts de Bash desde cero e ir subiendo la complejidad para terminar con AWK.
Originalmente es un taller que presenté en el t3chfest y que tuvo muy buena acogida, y que para el CommitConf he reducido y reestructurado como charla para que los que vengáis aprendáis los conceptos básicos de Bash y de AWK.
Presentation given at the Glasgow Perl Mongers a while ago, about how I sped up part of my Multi User Dungeon written in Perl, and some lessons learnt from it
Highlights a bunch of different Python tricks and tips - from the stupid to the awesome (and a bit of both).
See how to register a 'str'.decode('hail_mary') codec, call_functions[1, 2, 3] instead of call_functions(1, 2, 3), creating a "Clojure-like" threading syntax by overloading the pipe operator, create useful equality mocks by overloading the equality operator, ditch JSON for pySON and put together a tiny lisp based on Norvig's awesome article.
You believe in the power of JavaScript modules, but you have an existing app, stack or platform infrastructure to keep running. Between maintenance and new features, where do you carve out time to switch over? After a brief overview of modules and why they're great, we'll dig into how to actually migrate a code base, from plotting your approach to implementation tips.
Video: http://youtu.be/FbdcdC8mqwE?t=50m51s (watch the entire video from the beginning for other great talks about shadow DOM and competing task runners)
Talk from February 19, 2014 NYCHTML5 Meetup: http://www.meetup.com/nychtml5/events/160684962/
Learn how to write better code. Follow key software development principles like KISS, DRY, YAGNI, and SOLID. Know how to choose better names, structure your code, write methods, and design classes.
Desert Code Camp 2014: C#, the best programming languageJames Montemagno
Desert Code Camp 2014: C#, the best programming language.
Throughout the years many programming languages have come and gone, but C# is here to stay. It is everywhere and can run on over 2.5 Billion devices including desktop, web, servers, mobile devices, and game consoles! Come learn why I love C# so much and all of the amazing features it has to offer. This session will be action packed with so much live coding you will not know what to do!
How to improve your code quality? The answer is continuous refactoring. Learn more about refactoring. Know the most frequent code smells (antipatterns), telling when to refactor. Go through the catalog of well-known refactorings, telling how to improve your code.
"Writing Maintainable JavaScript". Jon Bretman, BadooYandex
There are lot of tools (CoffeeScript, Typescript, Dart, JSLint / JSHint etc.) that we can use to help us write better JavaScript, and many frameworks (Backbone, Ember, Angular etc.) that can help us structure large applications. But... what if you already have a large code base and are not able to re-write your whole application in a new way? What if your organisation does not want to depend on some open source or third party tool or framework? I am going to talk about some of the key things that most of these tools and frameworks do and how you can apply them to your existing or new project. Topics covered will include type checking, data hiding (public, private, static), inheritance, asynchronous code and performance.
Presented at LA Ruby Conf on February 8th, 2014. A high level overview of Go, golang, and how it relates to Ruby. Packages such as Martini, Lineman.js, sqlx, Ginkgo, and more are covered.
What is functional programming? This talk sets out to demystify the functional programming paradigm, debunk common myths, and reveal examples of why FP is advantageous compared to imperative programming.
RubyConf India 2019 - Confessions of a rubypreneurGautam Rege
Learn from mistakes from Gautam about starting up! This talks should be entertaining if not inspirational to all those developers who want to be future entrepreneurs
“CodeCuriosity is the Fitbit for Open Source”.
The sad part of open-source is that we have almost 99% developers consuming it and less than 1% actively contributing back. How do we change this and get more people to contribute back? What can be measured can be improved. We realised that the only way to increase open-source contributions is to make it fun, competitive and rewarding! What was initially a concept has now become a open initiative free platform to measure, compete and reward open-source contribution.
We all know that contributing back to open source is important but the ratio of consumers to contributors is vastly skewed; just like we all know running is good for health but ... ;)
If we can measure it, we can make it better! CodeCuriosity is the fitbit for Open Source contributors. It measures everything (commits and activities) and rewards everyone (newbies and experts).
codecuriosity.org
Affordable Smart Housing - The new revolutionGautam Rege
DIGIT-EMEA by Webit, Istanbul, 2015
Why don't we ALL live in Smart Homes if that was the way of the world? This talk discussed these points and introduces us to Affordable Housing (economical shelters for Below Poverty Line) and why it's important from a socio-economic point of view.
The REVOLUTION though is Smart Affordable Housing - where we use Smart Devices and IoT in affordable housing that can be entirely disruptive.
This is an straight from the heart experience report about software process evolution. This talk is a story of how we evolved from various testing tools and processes to one that cares deeply about clean code, test coverage, code quality and a modified agile project management.
It talks about choosing clients, tools and processes wisely.
This talks about the fear of talking at conferences and how to overcome them.
+ How to submit a proposal?
+ Content and tools for presentations.
+ Presentation Skills
+ Public Speaking skills
RedDot Ruby Conf 2014 - Dark side of ruby Gautam Rege
I love Ruby! But as in any relationship, to love means that you (often) have to accept the “dark side” too! Ruby is human in nature and has a lot of gotchas, tricks, weirdness and sometimes scary features that I plan to highlight. This talk aims to provide the “Ah-ha!” moments when working in Ruby.
This talk is for beginners and experts alike - in fact, I tag slides to mark their level and beginners can choose to tune out of the heavy stuff! My talk shall cover the dark side of the following features of Ruby (in no particular order)
Keyword wierdness
method missing
Module inheritance! (huh?)
Accessor righteousness
Curried Procs for the hungry
Base Conversions
Cherry picking module methods
Oniguruma games
Object id weirdness
procs, blocks and our friend stabby.
==, ===, eql? and equal?
and more…
As with most of my talks, humor plays an important role and I shall aim to get everyone high on Ruby with a deep dive!
I love Ruby! But as in any relationship, to love means that you (often) have to accept the “dark side” too! Ruby is human in nature and has a lot of gotchas, tricks, wierdness and sometimes scary features that I plan to highlight. This talk aims to provide the “Ah-ha!” moments when working in Ruby.
This talk is for beginners and experts alike – in fact, I tag slides to mark their level and beginners can choose to tune out of the heavy stuff!
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
Software Engineering, Software Consulting, Tech Lead, Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Transaction, Spring MVC, OpenShift Cloud Platform, Kafka, REST, SOAP, LLD & HLD.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaYara Milbes
Discover the transformative power of the WhatsApp API in our latest SlideShare presentation, "Top 7 Unique WhatsApp API Benefits." In today's fast-paced digital era, effective communication is crucial for both personal and professional success. Whether you're a small business looking to enhance customer interactions or an individual seeking seamless communication with loved ones, the WhatsApp API offers robust capabilities that can significantly elevate your experience.
In this presentation, we delve into the top 7 distinctive benefits of the WhatsApp API, provided by the leading WhatsApp API service provider in Saudi Arabia. Learn how to streamline customer support, automate notifications, leverage rich media messaging, run scalable marketing campaigns, integrate secure payments, synchronize with CRM systems, and ensure enhanced security and privacy.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
Launch Your Streaming Platforms in MinutesRoshan Dwivedi
The claim of launching a streaming platform in minutes might be a bit of an exaggeration, but there are services that can significantly streamline the process. Here's a breakdown:
Pros of Speedy Streaming Platform Launch Services:
No coding required: These services often use drag-and-drop interfaces or pre-built templates, eliminating the need for programming knowledge.
Faster setup: Compared to building from scratch, these platforms can get you up and running much quicker.
All-in-one solutions: Many services offer features like content management systems (CMS), video players, and monetization tools, reducing the need for multiple integrations.
Things to Consider:
Limited customization: These platforms may offer less flexibility in design and functionality compared to custom-built solutions.
Scalability: As your audience grows, you might need to upgrade to a more robust platform or encounter limitations with the "quick launch" option.
Features: Carefully evaluate which features are included and if they meet your specific needs (e.g., live streaming, subscription options).
Examples of Services for Launching Streaming Platforms:
Muvi [muvi com]
Uscreen [usencreen tv]
Alternatives to Consider:
Existing Streaming platforms: Platforms like YouTube or Twitch might be suitable for basic streaming needs, though monetization options might be limited.
Custom Development: While more time-consuming, custom development offers the most control and flexibility for your platform.
Overall, launching a streaming platform in minutes might not be entirely realistic, but these services can significantly speed up the process compared to building from scratch. Carefully consider your needs and budget when choosing the best option for you.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
7. Programming Paradigms
Imperative
Declarative
Procedural
Functional
Object Oriented
Symbolic
C++!
Java!
Python!
Ruby
Order of execution / steps One or more subroutines
8. Programming Paradigms
Imperative
Declarative
Procedural
Order of execution / steps One or more subroutines
Functional
Object Oriented
Symbolic
Pascal!
FORTRAN!
C
9. Programming Paradigms
Imperative
Declarative
Procedural
Order of execution / steps One or more subroutines
Functional
Object Oriented
Symbolic
Pascal!
FORTRAN!
C!
Go
12. Go Lang C on Steroids
• No more memory leaks. (Garbage collection)
13. Go Lang C on Steroids
• No more memory leaks. (Garbage collection)
• No more pointer de-referencing. (-> or . )
14. Go Lang C on Steroids
• No more memory leaks. (Garbage collection)
• No more pointer de-referencing. (-> or . )
• Support for maps, slices and channels.
15. Go Lang C on Steroids
• No more memory leaks. (Garbage collection)
• No more pointer de-referencing. (-> or . )
• Support for maps, slices and channels.
• Support for closures.
16. Go Lang C on Steroids
• No more memory leaks. (Garbage collection)
• No more pointer de-referencing. (-> or . )
• Support for maps, slices and channels.
• Support for closures.
• Concurrency: closures, channels & go-routines.
20. Go is different !
• No exceptions, only errors.
• Return multiple values from functions
21. Go is different !
• No exceptions, only errors.
• Return multiple values from functions
• Interfaces but no classes (only structs)
22. Go is different !
• No exceptions, only errors.
• Return multiple values from functions
• Interfaces but no classes (only structs)
• No inheritance but embedded structs
25. Duck Typing in Ruby
Programming convenience.!
Implicit Type Conversions.!
No complex Type Inference
26. Duck Typing in Ruby
Programming convenience.!
Implicit Type Conversions.!
No complex Type Inference
Don’t fight the Type System
27. Duck Typing in Ruby
Programming convenience.!
Implicit Type Conversions.!
No complex Type Inference
Don’t fight the Type System
Code First - Resolve Issues Later
40. To Duck or to Type
Light weight 1-level Type check
41. To Duck or to Type
Light weight 1-level Type check
type point int
!
func main() {
var i int = 2
var j point = 2
!
i == j
}
42. To Duck or to Type
Light weight 1-level Type check
type point int
!
func main() {
var i int = 2
var j point = 2
Variable name first, then the type
!
i == j
}
43. To Duck or to Type
Light weight 1-level Type check
type point int
!
func main() {
var i int = 2
var j point = 2
!
i == j
}
44. To Duck or to Type
Light weight 1-level Type check
type point int
!
func main() {
var i int = 2
var j point = 2
!
i == j
}
Error: invalid operation: i == j
(mismatched types int and point)
55. Programmer Awareness
Variable declaration and assignment
y := 2 // y is of type int!
y = "3"
COMPLIER ERROR!
cannot use “3” (type string) as type int in
assignment
56. Programmer ERROR?
Variable declaration and assignment
y := 2 // y is of type int!
y = "3"
As a programmer, we probably re-assigned
“y” to a String by mistake!
57. Programmer AWARENESS
Variable declaration and assignment
y := 2 // y is of type int!
y, _ = strconv.Atoi("3")
There’s always a right way to do things!
67. Programmer Awareness
Variable Re-declaration
import "os"!
Error: no new
!
variables on left
func main() {!
side of :=
! f, err := os.Open("somefile")!
! // handle error!
!
! f, err := f.Stat()!
} Hmm.. I think you re-used
the variable f by
mistake!
73. Lets Go a little more!
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Dimensions)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
Type Declaration
74. Lets Go a little more!
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Dimensions)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
Exported Array
75. Lets Go a little more!
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Dimensions)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
Exported Array
The size in Array is part of the type!
[2]float32 != [3]float32
76. Lets Go a little more!
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Dimensions)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
Embedding!
(Not inheritance)
77. Lets Go a little more!
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Dimensions)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
hotel.Dimensions and not
hotel.Hall.Dimensions
78. Lets Go a little more!
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Name)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
Dimensions)!
79. Lets Go a little more!
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Name)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
80. Programmer Awareness
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Name)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
81. Programmer Awareness
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Name)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
Which Name should
I use?
Error: Ambiguous
selector hotel.Name!
82. Programmer Awareness
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Name)Hall.!
Name)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
83. Programmer Awareness
type Layout struct {!
! Name string!
Capacity int!
}!
!
type Hall struct {!
! Name string!
! Dimensions [2]float32!
}!
!
type Hotel struct {!
! Location string!
! Hall!
! Layout!
}
func main() {!
! hotel := Hotel{}!
! fmt.Println(hotel.Hall.Name)!
!
! h := make(map[string]Hotel)!
!
! for name, _ := range h {!
! ! fmt.Println(name)!
! }!
}
84. Modules in Ruby
module Layout!
def manager!
p "Layout Manager"!
end!
end!
!
module Hall!
def manager!
p "Hall Manager"!
end!
end!
!
class Hotel!
include Layout!
include Hall!
end
def main!
hotel = Hotel.new!
p hotel.manager!
end
85. Modules in Ruby
module Layout!
def manager!
p "Layout Manager"!
end!
end!
!
module Hall!
def manager!
p "Hall Manager"!
end!
end!
!
class Hotel!
include Layout!
include Hall!
end
def main!
hotel = Hotel.new!
p hotel.manager!
end
Which language is
this dude?
87. Programmer Awareness
Iterating a Hash
hotels := make(map[string]Hotel)!
!
for name, _ := range hotels {!
! fmt.Println(name)!
}
88. Programmer Awareness
Iterating a Hash
hotels := make(map[string]Hotel)!
!
for name, _ := range hotels {!
! fmt.Println(name)!
}
Map of strings and Hotels
89. Programmer Awareness
Iterating a Hash
hotels := make(map[string]Hotel)!
!
for name, _ := range hotels {!
! fmt.Println(name)!
}
Easy iteration syntax!
90. Programmer Awareness
Iterating a Hash
hotels := make(map[string]Hotel)!
!
for name, _ := range hotels {!
! fmt.Println(name)!
} Blank Identifier - ignore value
91. Programmer Awareness
Iterating a Hash
hotels := make(map[string]Hotel)!
!
for name, _ := range hotels {!
! fmt.Println(name)!
}
92. Programmer Awareness
Iterating a Hash
hotels := make(map[string]Hotel)!
!
for name, _ := range hotels {!
! fmt.Println(name)!
}
Bad practice! !
I’ll randomise the
order!
110. package main
!
import (
"fmt"
"runtime"
"sync"
)
!
var wg sync.WaitGroup
!
/*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
111. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
112. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
!
baton := make(chan int)
wg.Add(4)
!
for i := 1; i < 5; i++ {!
go run(i, baton)!
}!
!
! ! ! // start the race!
baton <- 1!
!
// wait for relay to finish!
wg.Wait()!
}
113. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
!
baton := make(chan int)
wg.Add(4)
!
for i := 1; i < 5; i++ {!
go run(i, baton)!
}!
!
! ! ! // start the race!
baton <- 1!
!
// wait for relay to finish!
wg.Wait()!
}
A channel that accepts an int
114. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
!
baton := make(chan int)
wg.Add(4)
!
for i := 1; i < 5; i++ {!
go run(i, baton)!
}!
!
! ! ! // start the race!
baton <- 1!
!
// wait for relay to finish!
wg.Wait()!
}
Go Routine
115. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
!
baton := make(chan int)
wg.Add(4)
!
for i := 1; i < 5; i++ {!
go run(i, baton)!
}!
!
! ! ! // start the race!
baton <- 1!
!
// wait for relay to finish!
wg.Wait()!
}
Writing to a channel
116. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func main() {
runtime.GOMAXPROCS(4)
!
baton := make(chan int)
wg.Add(4)
!
for i := 1; i < 5; i++ {!
go run(i, baton)!
}!
!
! ! ! // start the race!
baton <- 1!
!
// wait for relay to finish!
wg.Wait()!
}
A WaitGroup - wait
for 4 events!
117. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
118. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
!
! ! // Massive CPU churn!
! ! for count := 0; count < 300; count++ {!
! ! ! for char := 0; char < 30000; char++ {! ! ! ! fmt.Printf("")!
! ! ! }!
! ! }!
fmt.Printf("Leg %d.. churned, waiting to !
! ! check_baton(leg, baton)!
}
119. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func run(leg int, baton chan int) {
defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg)
Done for WaitGroup
!
! ! // Massive CPU churn!
! ! for count := 0; count < 300; count++ {!
! ! ! for char := 0; char < 30000; char++ {! ! ! ! fmt.Printf("")!
! ! ! }!
! ! }!
fmt.Printf("Leg %d.. churned, waiting to !
! ! check_baton(leg, baton)!
}
120. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
121. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func check_baton(leg int, baton chan int) {!
! ! for value := range baton {!
! ! ! switch value {!
! ! ! ! case leg:!
! ! ! ! ! // pass the baton!
! ! ! ! ! fmt.Println("Finished leg ", leg)!
! ! ! ! ! if leg == 4 {!
! ! ! ! ! ! close(baton)!
! ! ! ! ! } else {!
! ! ! ! ! ! ! baton <- leg + 1!
! ! ! ! ! }!
! ! ! ! ! return!
! ! ! ! default:!
! ! ! ! ! // ignore!
! ! ! ! ! baton <- value!
! ! ! }!
! ! }!
}
122. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func check_baton(leg int, baton chan int) {!
! ! for value := range baton {!
! ! ! switch value {!
! ! ! ! case leg:Read !
or block on a
! ! ! ! ! // pass the channel
baton!
! ! ! ! ! fmt.Println("Finished leg ", leg)!
! ! ! ! ! if leg == 4 {!
! ! ! ! ! ! close(baton)!
! ! ! ! ! } else {!
! ! ! ! ! ! ! baton <- leg + 1!
! ! ! ! ! }!
! ! ! ! ! return!
! ! ! ! default:!
! ! ! ! ! // ignore!
! ! ! ! ! baton <- value!
! ! ! }!
! ! }!
}
123. Channels in action
p!ackage main import (
"fmt"
"runtime"
"sync"
)! v!ar wg sync.WaitGroup /*
* Each go-routine sleeps at random(1-5) seconds.
* This is simulating long working process
* Then we finish in order
*/
func check_baton(leg int, baton chan int) {
for value := range baton {
switch value {
case leg:
// pass the baton
fmt.Println("Finished leg ", leg)
if leg == 4 {
close(baton)
} else {
baton <- leg + 1
}
return
default:
// ignore
baton <- value
}
}
}! func run(leg int, baton chan int) {
! defer wg.Done()
fmt.Printf("Leg %d.. churningn", leg) // Massive CPU churn
for count := 0; count < 300; count++ {
for char := 0; char < 30000; char++ {
fmt.Printf("")
}
! }
fmt.Printf("Leg %d.. churned, waiting to exitn", leg) ! check_baton(leg, baton)
}! func main() {
runtime.GOMAXPROCS(4) ! baton := make(chan int)
wg.Add(4) for i := 1; i < 5; i++ {
! go run(i, baton)
} ! // start the race
baton <- 1 // wait for relay to finish
wg.Wait()
}
func check_baton(leg int, baton chan int) {!
! ! for value := range baton {!
! ! ! switch value {!
! ! ! ! case leg:!
! ! ! ! ! // pass the baton!
! ! ! ! ! fmt.Println("Finished leg ", leg)!
! ! ! ! ! if leg == 4 {!
! ! ! ! ! ! close(baton)!
! ! ! ! ! } else {!
! ! ! ! ! ! ! baton <- leg + 1!
! ! ! ! ! }!
! ! ! ! ! return!
! ! ! ! default:!
! ! ! ! ! // ignore!
! ! ! ! ! baton <- value!
! ! ! }!
! ! }!
}