Showing posts with label Coursera. Show all posts
Showing posts with label Coursera. Show all posts

Thursday, 21 September 2017

Google OnBoard - Google Cloud

“Almost all the successful microservice stories have started with a monolith that got too big and was broken up.”
- Martin Fowler1

On the 20th of September 2017, I enjoyed a full day at Eindhoven HighTech Campus listening to Google explain everything about their Google Cloud Platform (GCP)2. It's the 63rd or so time this workshop was given. (20.000 people 36 cities)

Of course, I needed to write some of the stuff down, so here's the stuff.

I liked the April fools joke shorts that were interspersed in the lecture.

The problem everyone seems to be facing is that everything needs to be done faster, and better and there needs to be more focus on building business value, instead of having to spent time administrating the hardware.

This can be seen in the fact that the most expensive item in your organisation are your engineers, and they need to be able to work as efficient as possible. Google noticed in the past that time spent doing things that ultimately were of little value can not be regained and is forever lost.

When it comes to the evolution of clouds, you see the following waves happen:

1st wave - colocation
your kit, someone else's building, yours to manage.
2nd wave - virtualized data centers
standard virtual kit, for rent, still yours to manage.
3rd wave - intelligent services automated everything
invest your energy in great apps

Funnily enough, I am noticing this same trend in my home hobbyprojects as well. It can be summarised as follows:

1st wave
I had my own computer, but to install it in a data centre, it needed a rack-mount. My hardware in somebody elses data center.
2nd wave
My computer now is a VPS that I rent.
3rd wave
I started moving small apps over to the Google App Engine.

For a lot of software companies (mine included) we are still only on the second wave. The products of lots of software companies do not require some of the advantages of the cloud and it therefore makes no sense to make the effort.

You can just assemble the google "hexagons" that your application is going to need. It takes a little work to find out what Google has and how it can be best applied to your situation. Because, everybody's situation is different.

Why choose google? If you do use google, you use the netwerk Google created (which is fast), to access other Google users (which use the same network), which are therefore only a hub away.

Googles network is divided in regions and zones. A region might for example be Europe, and a zone might be a data center in a specific region, for example West-1a.

The Google hexagons can be roughly categorized into four main groups, as displayed in the following most important sheet:

StackDriver

StackDriver is a company which was bought up by Google and it specializes in "supporting glue" for different components in an application:
  • Logging
  • Monitoring
  • Debug
  • Error Reporting
  • Trace

Philips Hue

As an example of what it can do, Philips was there to explain how they have been using the cloud along with their new Smart-bulbs in their home-automation project called Hue.

It is a long day to listen, luckily with the free trial version3 of the Google Cloud Platform, it was possible to follow the two gentlemen along in their path through the different components of the platform.

There were some lighter notes as well. For example the spot-the-security-guard in pictures of the Google Data Center. The Machine Learning demos were quite fun too.

I can highly recommend the workshop, for anyone who wishes to have an idea about what Google can do to help your application become great. The sheets alone give a good impression.

References

[1] Martin Fowler - MonolithFirst
https://martinfowler.com/bliki/MonolithFirst.html
[2] Cloud OnBoard - Learn how to Build What's Next with Google
https://cloudplatformonline.com/2017-onboard-benelux.html
[3] Google - Free Trial
https://cloud.google.com/free/
Google Developer Group Netherlands
gdgnetherlands.org
Google QwikLabs
google.qwiklabs.com
Measure your latency to GCP regions
http://www.gcping.com/
Coursera - Google Cloud Platform
https://www.coursera.org/googlecloud
Google Certified
https://cloud.google.com/certification/

Saturday, 19 July 2014

Successfully completed Functional Programming Principles in Scala

I earned 97.7% with distinction.

Evaluation

One can tell that the subject matter was Academic, with a firm grounding in Mathematics, which appealed to me.

The assignments provided a lot of information on what is expected, so there are no surprises, but you do need to read carefully.

The one assigment that provided the most difficulty was assignment 6, regarding the discovery of Anagrams of a sentence.

I had to wrestle a bit with the Scala syntax. It's new for me.

I especially found foldLeft and foldRight counter-intuitive sometimes.

I learned a lot on the following topics, in no specific ordering.
Scala Programming Language
by the creator, Martin Odersky, himself.
Functional Programming
one of the main subjects of the course
Domain Specific Language
Scala provides several ways to program according to a domain model2, instead of a technical/software model
Mathematics - Set Theory
the code is very close to the mathematical theory. Purposefully crafted that way, of course. It means we can actually use mathematical operators (some of the time).
Behaviour Driven Development
you can write tests that read more naturally
Test Driven Development
assignments had to pass certain tests (that are unknown), so your own tests had better be complete/sufficient
Recursion
we used a lot of recursion, you do not see that in "normal" programming languages.
It was a huge amount of fun to do, both to learn a new Programming Language1 and to learn a new Programming Paradigm.

References

[1] Coursera - Functional Programming Principles in Scala, by Martin Odersky
https://class.coursera.org/progfun-004
[2] Wikipedia - Domain Model
http://en.wikipedia.org/wiki/Domain_model

Wednesday, 25 June 2014

Scala: π and Streams

I finished my course of "Functional Programming Principles in Scala" at coursera1.

Go me!

Wikipedia3 has an article on how to compute π. The series is provided below (using MathML2, which might not work as it should in some browsers) originally proposed by Srinivasa Ramanujan.

1π=2⁢29801⁢∑ k=0∞4k!⁢1103 + 26390⁢kk!4⁢3964k

Factorial

To compute the equation above, I'm going to use BigDecimals5 and I shall have to define some math operations.

So let us start with the Scala version of Factorial, which is equivalent to the Java Version of Factorial of my earlier blog post4.

Notes on Scala

I really like how Scala almost always infers the correct type automatically and can redefine common math operators for classes like BigDecimal. When dealing with BigDecimals, this is great. It makes it ideal for DSL, Domain Specific Languages. Compare the factorial calculation with BigDecimals below in Java and Scala for example:
Java:
return factorial(accumulator.multiply(n), n.subtract(BigDecimal.ONE));

Scala:
factorial(accumulator * n, n - 1)
I also like the fact I can define Worksheets in Scala, that are evaluated by the IDE upon saving, printing the results at the end of the line. For mathematicians it's the computerized equivalent of paper napkins in Restaurant, only better.

Square Root

There is a Square Root function available in the math library of Scala6, but it doesn't work with BigDecimals (def sqrt(x: Double): Double).

A way to compute a square root is using "Heron's method"7. That one can also be defined using recursion, similar to the Factorial above.

It is quite obvious that there is a problem in the code above. It is recursive, and the recursion never stops, leading sooner or later to a nice StackOverflow Error.

Some ways to solve it is to limit the number of iterations, or stop once the precision is adequate. An example of the first is seen below, where the number of iterations is 100.

But, it is slightly ugly. During the course, I learned that Scala tries to adhere to the Rules of Mathematics more than to the Rules of Programming. We should be able to define a pure function, without having the computer explode.

Streams

Scala has several ways in which functions get evaluated:
strict evaluation
Functions get evaluated immediately. For normal parameters and val definitions. This is the default.
lazy evaluation
Functions get evaluated when the function is called for the first time, and the value is cached and not recomputed.
by-name evaluation
Functions get evaluated each time the function is called. For "def" functions.
Streams are a way of creating data structures that are not evaluated immediately. An example of the use is shown in the following implementation of squareRoot:
The above example, barring the Stream calls, is equivalent to the first example of the squareRoot. Thusly we have defined something much more equivalent to an infinite series.

As you can see squareRoot(2) will get evaluated to Stream(1, ?). So only the head is evaluated, the first guess, and the rest is deferred, visible by means of a "?".

In order to force the evaluation of the rest, you can try for example squareRoot(2).take(5).toList, where take creates a new Stream that has a fixed length of 5. The toList forces the evaluation, as a list only knowns strict evaluation.

Now we should have all the ingredients to implement the equation visible at the top of this blog.

Computing π

In the example above, the actual number of terms in the series is 5, which is sufficient as the series converges extraordinarily rapidly to π.

In the example above, we are also using our new squareRoot function, this time with the number of iterations set to 120.

Of course, actually producing the exact result is impossible, but in Mathematics, I find that in most cases the definition is the important part, in order to reason about it.

References

[1] Coursera - Functional Programming Principles in Scala
https://class.coursera.org/progfun-004
[2] MathML
http://www.w3.org/Math/
[3] Wikipedia - Approximations of π
http://en.wikipedia.org/wiki/Approximations_of_%CF%80
[4] Recursive Factorial in Java
http://randomthoughtsonjavaprogramming.blogspot.nl/2014/05/tail-recursion.html
[5] scala.math.BigDecimal
http://www.scala-lang.org/api/current/index.html#scala.math.BigDecimal
[6] Scala Math Package
http://www.scala-lang.org/api/current/index.html#scala.math.package
[7] Wikipedia - Methods of computing square root
http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
Wikipedia - Arbitrary precision arithmetic
http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic

Thursday, 24 April 2014

Coursera - Functional Programming Principles in Scala

On the 25th of April, meaning this Friday, I start my course on Scala.

I found Coursera1, an education platform that partners with universities to provide courses online for free.

I am really excited in finding out how Scala differs from Java, and what new programming methods I'll learn.

The fact that the Course2 has been set up by the creator of the language, Martin Odersky of École Polytechnique Fédérale de Lausanne, is a big plus.

I hope I can meet the deadlines.

References

[1] Coursera
https://www.coursera.org/
[2] Coursera - Functional Programming Principles in Scala
https://www.coursera.org/course/progfun