Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 20

Advance Computer Programming – GO

Lecture – 01
Introduction and Background of GO language

Instructor: Syed Mujtaba Hassan


Email: mujtaba.hassan@riphah.edu.pk
Session: Fall 2022
Riphah School of Computing and Innovation (RSCI)
Riphah International University, Lahore
Course Overview

Go (sometimes called Golang) is one of the most popular languages today, and is a
key part of many enterprise tech stacks. Many developers prefer Go to other
languages like C++ and Scala because of its memory management model which
allows for easier concurrency.
In this course, you will learn the core constructs and techniques of the language.
After going through the basics, you will then learn more advanced Go concepts
like error-handling, networking, and templating. You'll learn how to program
efficiently in Go by gaining knowledge of common pitfalls and patterns, as well as
by building your own applications.
Course Objectives

 In this course, you will learn the core constructs and techniques of the
language. After going through the basics, you will then learn more advanced
Go concepts like error-handling, networking, and templating etc.
 You'll learn how to program efficiently in Go by gaining knowledge of
common pitfalls and patterns.
 Building your own applications.
 Exposure to current trends in Go programming and development.
Expected outcome

On successful completion, students will be:


 Analyze the impact of Application, Web development, Operations and
infrastructure and Clous native structure etc.
 Demonstrate the knowledge Golang platform and architectures.
 Describe Golang work environment.
 Measure Golang performance.
 Apply knowledge to build, implement and evaluate a computer-based
program to meet desired needs.
 Build fast and efficient Golang based applications.
 And so many more…
Policies:

Quizzes Policy
o Quizzes will be conducted either in the start of class or at the end of class.
o There will be no makeup for quizzes.
Assignments and Project submission policy
o Assignments and project deliverables should be submitted on the specified dates.
o Late submission of assignment and project deliverables is strictly discouraged.
o It will result in a penalty of 25% for each day. After 2 days late assignment or
project deliverable will not be accepted.
o Copying / Plagiarism are strictly forbidden. Any student involved in copying will
be awarded grade ‘F’ in the course. The minimum possible penalty is negative
marks equal to the maximum marks in assignment / quiz / project.
o In case a student has taken / stolen submission from the other, both of the
students will be penalized.
o Same policy is applicable on project deliverables as of assignments.
Origin and Evolution of Go
Introduction
Also known as Golang, Go is a programming language designed by Robert
Griesemer, Rob Pike, and Ken Thompson. It is an open-source programming
language that makes it easy to build simple, reliable, and efficient software
solutions. Go is a statically typed and compiled programming language. Statically
typed means that variable types are explicitly declared and thus are determined at
compile time. Whereas, by compiled language we mean a language that translates
source code to machine code before execution.
History
Go’s year of genesis was 2007 at Google, and it was publicly launched in 2009
with a fully open-source BSD-style license released for the Linux and Mac OS
platforms. The first Windows-port was announced on November 22 of the same
year. Go 1.0 (the first production-ready version) was released in March 2012.
Since 2012, Go has grown from version 1.1 to 1.12 (March 2019), and work for
Go 2.0 is underway!
Continue…

The below figure shows the Go development timeline starting from its genesis
to the year 2019.
Continue…
Programming language hall of fame

Go initiated a lot of stir after its public release in January 2010. In 2009 and again
in 2016, Go was pronounced language of the year by Tiobe, which is well-known
for its popularity ranking of programming languages. In this ranking, it secured the
10th place in November 2018, with a popularity of nearly 2.5 %. The Programming
Language of the Year award is given to the programming language rated the
highest in that year. Hall of fame is given below:
Continue..
Continue…
Reasons for Developing Go

We'll cover the following


Languages that influenced Go
 Why a new language?
Evolving with computing landscape
Need for faster software development
Need for efficiency and ease of programming
 Targets of Go
Support for network communication, concurrency, and parallelization
Support for excellent building speed
Support for memory management
Languages that influenced Go
Go belongs to the C-family, like C++, Java, and C#, and is inspired by many other
languages created and used by its designers. The resemblance with the syntax of C
language was maintained to gain an advantage of familiarity among developers.
However, compared to C/C++, the syntax is made more incisive (concise).
Additionally, Go has the features of a dynamic language, so Python and Ruby
programmers feel more comfortable with it. The following figure shows some of
the influences on the Go programming language:
Continue…
Why a new language?
 Following are the reasons that led to the development of Go:
• Evolving with computing landscape
• Need for faster software development
• Need for efficiency and ease of programming
Evolving with computing landscape
 Programming languages like C/C++ did not evolve with the computing
landscape, so there is a need for a new systems language, appropriate for the
needs of our computing era.
Need for faster software development
 In contrast to computing power, software development has not become
considerably faster or more successful (considering the number of failed
projects), whereas applications still grow in size. Therefore, a new low-level
language was needed, equipped with higher concepts.
Continue…
Need for efficiency and ease of programming
Before Go, a developer had to choose between fast execution but slow and
inefficient building (like C++) or efficient compilation but not so fast execution
(like .NET or Java), or ease of programming but slower execution (like dynamic
languages such as Python, Ruby or JavaScript). Go is an attempt to combine all
the three wishes: efficient and fast compilation, fast execution, and ease of
programming.
Targets of Go
The main target of Golang’s design was to combine the efficacy, speed, and safety
of a statically typed and compiled language with the ease of programming of a
dynamic language to make programming more fun again.
 Some other targets that Go was meant to meet were:
• Support for network communication, concurrency, and parallelization
• Support for excellent building speed
• Support for memory management
Continue…
Support for network communication, concurrency, and parallelization
To get the most out of distributed and multi-core machines excellent support for
networked-communication, concurrency, and parallelization. Golang was expected
to achieve this target for internal use in Google, and this target is achieved through
the concepts of goroutines.
Support for excellent building speed
There was a growing concern to improve the building speed (compilation and
linking to produce machine code) of C++ projects, which are heavily used in
Google’s infrastructure. This concern gave birth to the idea of developing the Go
programming language. In particular, dependency management is a very important
part of software development today. The “header files” of languages caused
considerable overhead leading in order to build times of hours for the biggest
projects. Developers felt the need for clean dependency analysis and fast
compilation, which Go language provides with its package model.
Continue…

The entire Go standard library compiles in less than 20 seconds. Typical projects
compile in half a second. This lightning-fast compiling process is even faster than C
or Fortran, making compilation a non-issue. Until now, this was regarded as one of
the great benefits of using dynamic languages for development because the long
compile/link step of C++ could be skipped. However, with Go, this is no longer an
issue! Compilation times are negligible, and we have the same productivity as in the
development cycle of a scripting or dynamic language. In addition to this, the
execution speed of the native code is comparable to C/C++.
Support for memory management
Because memory problems memory leaks are a long-time problem of C++, Go’s
designers decided that memory management should not be the responsibility of a
developer. So although Go executes native code, it runs in a small runtime, which
takes care of an efficient and fast garbage collection. Go also has a built-in
runtime reflection capability.
Top Characteristics of Google’s Go
Open-Source
The foremost characteristic of Golang programming language is that it is open-
source. That means, anyone can download and experiment with the code to bring
better codes into picture and fix related bugs.
Static Typing
Go is a statically typed programming language and works with a mechanism that
makes it possible to compile code accurately while taking care of type conversions
and compatibility level. This gives developers freedom from challenges associated
with dynamically typed languages.
Concurrency Support
One of the prime characteristics of go programming language is its concurrency
support.
Golang, unlike other programming languages, offers easier and trackable
concurrency options. This makes it easier for app developers to complete requests
at a faster pace, free up allocated resources and network earlier, and much more.
Continue…
Powerful Standard Library and Tool Set
This programming language also comes loaded with a robust standard library. This
libraries offer ample components that gives developers an escape from turning
towards third party packages anymore.
Also, it offers a wider range of tools that makes development process efficient.
This includes:
• Gofmt: It automatically formats your Go code, which eventually brings a major
impact on readability.
• Gorun: This tool is used to add a ‘bang line’ in the source code to run it, or run
a similar sode code file explicitly. It is often used by Go developers when
experimenting with codes written in Python.
• Goget: The Goget tool downloads libraries from GitHub and save it to your
GoPath so that you can easily import the libraries in your app project.
• Godoc: The tool parses Go source code, including comments and creates a
documentation in HTML or plain text format. The documentation made is
tightly coupled with codes it documents and can be easily navigated with one
click.
Continue…
Testing Capabilities
Go language also offers an opportunity to write unit tests along with writing the
app codes. Besides, it avails support to understand code coverage, benchmark
tests, and write example codes to create your own code documentation.
Garbage Collection
The programming language also offers exceptional power of garbage collection.
Meaning, developers need not worry about freeing up pointers or the situation
associated with dangling pointer.
Because of these characteristics, the language has gained attention of various
popular brands.
Environmental Setup

See the Lab Manuals for setup installation in detail.

You might also like