Intro
Intro CDK is an opinionated framework for developing aws infrastructure as code.
It is an abstraction on top of AWS Cloudformation that enables developers to write infrastructure as code in their programming language of choice (Typescript, Python, .NET, Java etc.)
Getting started npm install -g aws-cdk cdk --version npx npm-check-updates -u Hollo World! App mkdir HelloApp && cd HelloApp
cdk init --language typescript
set an outDir in tsconfig.json before running cdk diff or deploy.
When coding in any language, more often than not, you might be interested to see how long a particular function or whole program takes to execute. This can be done in one of the two ways in for a Go program
To see how long a program takes: time go run src/main.go Not specific to GO but this easier measure any cli command.
To see how long a particular snippet takes: func main() { startedAt := time.
With Scala and Go becoming my more used language these days, I am trying to compare and contrast some of the language features and how we do some of the common things on both. I will use the most popular libraries in scala/go to demo these features.
Variable declaration Making Http Calls JSON parsing Scala: Circe is good lib for doing Json Parsing in Scala
// build.sbt val circeVersion = "0.
Use expressions, not statements(telling the computer what to do) Don’t tell it how to // Don't do this def findPeopleIn(city: String, people: Seq[People]): Set[People] = { val found = new Mutable.HashSet[People] for (person <- people) { for (address <- person.addresses) { if(address.city == city found.put(person) } } return found } // do this def findPeopleIn(city: String, people: Seq[People]): Set[People] = for { person <- people.toSet[People], address <- person.addresses if address.
Side effects Simply put side effects is when you update a value of a variable/global variable after its been set.
var result = 0 def add(a:Int, b:Int) { result = a+b //side effect } def add(a:Int, b:Int) = { return a+b //no side effect. no mutation happens here } Referentially Transparent This is an awesome thing!. Its more or less like Idempotency. Anytime you call a function with same params it should always return the same output.
My experience trying to learn Functional Programming was painful. Reading blogs after blogs makes it more and more confusing. So I took the practical approach to learn and this is my effort to create a reference and make it easier for anyone who passes by my blog. As shopping cart is a common appl, I have used it as the basis for these examples
in FP we try to decouple data from behaviour model your domain using ADT’s(Algebraic Data Types) Sum => choice or union using sealed abstract classes or trait eg: sealed abstract class CartStatus case object InProgress extends CartStatus case object Purchased extends CartStatus case object Dropped extends CartStatus Product type => case class eg:composition saying we have a and b and c case class Checkout( item: Items, cartNumber: CartNumber) Use type system to your advantage // anyval means value class.
I’ve acted as a dev lead for a few teams and recently been a tech lead for a fantastic project with some awesome people. This is a reflection of few traits I’ve picked up over the course of my experience.
Be an advocate for change Always, try to make it a better work place and push for an ego free culture for your team so that everyone can freely share opinions.
We have all done it, atleast in some point in time of our career. But it was a awkward when we think about testing in production in a financial system, As it involves a lot of side effects to the existing data, credit, debit, available balance, allowed credit balance.
If we are releasing a new feature how do we know that its working always. If you get bombarded with calls from clients or see a number of texts from clients just after feature release/ feeling anxious afterwards.