GoLang_System_Essentials_Notes_Chapter_1

Why Go

Apart from easy to read code and simple learning curve which encourages everyone to quickly adopt the existing code system, Go has a very strong concurrency model.

Concurrency defines throughput of your system. When a task is waitnig for I/O resources, if you can code like other task can leverage the idle CPU, then throughput of your entire program will be increased.

Go uses channels for communicating between threads and go follows CSP when it comes to implementation of threads and thread communication.
There is an excellent paper written on same. https://www.cs.cmu.edu/~crary/819-f09/Hoare78.pdf

And another prinicple, share memory not by locks but by communicating. We can write a lot about go concurrency, but lets see in practicals.

Go in-built tools

go build main.go to generate go binary
go test to run tests
go run main/hello.go to run your program but no binary generation
go vet filename.go to check errors in your code.
go fmt file.go to format your go code.

Cross platform development

two main env variables, GOOS and GOARCH
GOOS for OS Target
GOARCH for CPU arch, amd64, darwin etc
Linux build command
GOOS=linux GOARCH=amd64 go build
For Mac
GOOS=darwin GOARCH=amd64 go run

We can also add build tags for specific platform

// go:build windows
package main
import "fmt"
func main() {
    fmt.Println("This is Windows!")
}
// go:build linux
package main
import "fmt"
func main() {
    fmt.Println("This is Linux!")
}
GOOS=windows go build -o app.exe
GOOS=linux go build -o app

Linux: Firefox in Debian+I3m taking a lot of time to load

 Recently, Firefox in my Linux setup( Debian + i3wm) taking a lot of time to reload. Upon searching I came to know that its caused by xdg-desktop-portal package. From Arch docs I understand that its for opening the application in a sandbox environment for better safety and then I thought no security needed for Firefox if its not there for Chrome. 

So I remove it. 

 
  sudo apt-get remove xdg-desktop-portal
 

Hope it helps.

How to fix Microsoft Blue Death Of Screen(BDOS) issue ?

Many Microsoft Windows users are experiencing Blue Screen of Death (BSOD) errors following a recent CrowdStrike update.

1) Boot Windows into Safe Mode

2) Navigate to the directory C:\Windows\System32\drivers\CrowdStrike

3) Locate the file matching C-00000291*.sys and delete it

4) Boot the host normally

Note: You can also boot in Windows Recovery Environment (WinRE)


Notes - Kevlin Henney - The Case For Technical Excellence

 Ref: https://www.youtube.com/watch?v=LLEXAdO3X1o

Agile: able to move quickly and easily, quick movement

- Prioritising business goals over technical excellence

The over-engineered Agile approach is gonna spoil both Business Goals and Technical Excellence.

Agile - And if your application architecture sucks - code quality drops

Agility is an observation, can I move the code quickly and easily?

The software where you are working on, is it agile?

Feature work vs. technical Work: people create this, this is a false dichotomy

Feature work is technical work. People don't think like this.

Features are made of software which is technical work.

You need to figure out business value, which varies from context to context.

Business value and also varies by time, when thinking in the perspective of business value, you should think on business value over a day, over a week, a month, an year, a decade

Challenge Somebody on business value.

prioritise by business value -> prioritize the backlog 

No Product Owner / No Business owner knows the business value. The only way you know the business value is by building it, shipping it and observing the value generation over time and then comparing it with our initial assessment. 


Prioritize by business value estimate(d). Semantics means meanings. Actuals not an estimate. There is vagueness in the lang we speak i.e we dont know the stuff. 

"Architecture represents the significant design decisions that shape a system, where significant is measured by cost of change" by Grady Booch

Where do you spend time and money. Less 


What effect does ignoring quality have in the long term ?

- It has no effect? : Well its impossible answer, someone gave this answer ? interesting

- It reduces the cost? probably in the term, then mark it for later review

- It increases the cost ? then pickup immediately and reduce the cost


Technical debt is an effect, what is the cause of this ?

We distracted by wrong thing, what is the cause by debt ? 

Technical Neglect: 

tech debt - legacy code

Practical Example: A boat on the water, people are throwing the water outside instead of fixing the whole from where water coming to the boat. This is technical debt. 

As an evolving program is continually changed, its complexity, reflecting deteriorating structure, increases unless work is done to maintain or reduce it. By Meir M Legman

Legacy born in 1989 in software world.

maintenance -> deteriorating the code -> by adding a new feature -> then you should maintain the structure of the program

Time Is Money -> We are lending money and converting that into money

Arguments is war

Arguments are buildings

Love is journey 

Happy is up, sad is down 


To be considered good, a metaphor has to offer a number of points of useful correspondence with what is being described.

Another quality is good metaphor is that it should not have too many obvious points of conflict

The Third quality of a metaphor that makes it effective is familiarity to its audience


Martin Flower: Technical debt is a wonderful metaphor developed by Ward Cunningham, in this metaphor, doing things the quick and dirty way sets us up with a technical debt, which is similar to a financial debt.


Shipping first time code is like going into debt, A little debt speeds development so long as it is paid back promptly with a rewrite.

Create a thing - get the feedback - respond - add a feature -> deliver - > get the feedback

A structured debit is good, its not bad like a house loan.

Bad Science : You cant convert technical debt into financial debt, its unmanaged technical debt.

Technical debt is not the cost of repaying the debt: it is the cost of owning the debt. These are not the same. 


In summary in my words

  • Technical debt is not something that we think is technical debt
  • technical debt cant be converted into money
  • you should convert the value lost due to technical debt as its technical debt
  • you should always follow the structure of your architecture to avoid more technical debt
  • If you are working on something always ask, is it adding any value? 
  • A value by fixing a debt in terms of loss might approach by not fixing it. 
  • if your developers are spending a lot of time of understanding the past code instead of adding new features then you are not adding much value. 
  • Here the point is, why your developers are spending time to understand the code, why cant the developers who have idea on the code can't fix it while the new developers can work on features




Git: How to set set default branch as master?

 



  root@arch-host ~ ✖ git config --add --global user.name "<username"
  git config --add --global user.email "email@yahoo.com"

  root@arch-host ~ ➜  git config --global --unset rerere.enabled
  git config --global init.defaultBranch master

    

root@arch-host ~ ➜  cat ~/.gitconfig 

[user]

        name = rxxxx

        email = xxxxxx@yahoo.com

[init]

        defaultBranch = master


root@arch-host ~ ➜  

How to solve PGP signatures are corrupted in Arch Liniux ?

 This is the most irritating error for me, after trying multiple solutions, finally this is what worked for me, make sure you execute all these commands as sudo.

rm -rf /etc/pacman.d/gnupg
pacman-key --init
pacman-key --populate
pacman -Syuu
pacman -Sy archlinux-keyring

Hope it helps.