Beginning serverless computing, book review

beginning_serverless_computing-Book_Cover

Published on: 01.07.2018

Number of pages: 199
Written by: Maddie Stigler
Publish by: Apress

Conclusion
Interesting read, it shows the current state of AWS, Azure, and Google Cloud.

Review

Chapter 1 is explaining what is serverless computing.

The second chapter gives an overview of the current market.

Next three chapter give example how to implement it in AWS, Azure, and Google Cloud.

The last chapter is demonstrating the agnostic approach.

Serverless computing is the topic that interests me a lot.

I see more advantages than disadvantages with serverless setup, especially cost (if I am charged by used resources and not by subscription) and scaling.

Exercises for Programmers, book review

exercises-for-programmers-Book_Cover

Published on: 15.06.2018

Number of pages: 118
Written by: Brian P. Hogan
Publish by: The Pragmatic Bookshelf

Conclusion
Book has good (real life) exercises that can be applied to learn a programing language.

Review
This book will not teach you programming but have 57 exercises that you can do in any language.

Each exercise has few additional challenges, so there is enough material for practice.

The only way to learn new programming langue(or your fist) is to make something concrete and this book can provide that.

Flowcharts are also shown in the book, I think that is cool.
Today flowcharts are mostly forgotten but are useful to know.

If you are not experienced programme (I do have 15+ years of development) my suggestion is to first solve an exercise by any means necessary and after you can do it with constraints and lastly also challenges from the book.

If some exercise is too hard (you have spent few hours and still no progress) just go to next one.
You will have more motivation to learn if it is fun and not dreadful.
After you finish some other exercises and get more experience, you can come back to old ones.

The best part about exercises in this book is that they are pretty close to real life programming, so you are not wasting your time (like on Codility) solving some problems that you will never encounter in real life software development.

My solutions can be found at https://github.com/sasa-buklijas/57-challenges-to-develop-your-coding-skills/.

What programming language should you learn?

This is written for persons that do not know any programing language and they are thinking what programing language they should learn first.

Altho, I think that reasoning behind decisions in this article can help you with choosing your next programing language also.

If you want to do something, first know why you want to do it

What are you trying to accomplish?

Same is with learning programming language.

I have listed few main reasons why persons want to learn a programing language:

  • get a job (on-site or freelance)
  • make some software app/website/web app
  • just to learn to do programming

I want to learn programming to get a job

Programming jobs (and salaries) are location dependent, due to this reason do research which programming languages job are available in your area.

If you plan to move/migrate do same for that area.

Check the local programming jobs listing to get a clue.

It is good to visit local programming meetups, if you plan to be a professional software developer start on your networking also.

Meetups are also a good way to see who is hiring.

If you plan to do freelance then you are not location depended.

What, I would argue, is even making thing more difficult, because you do not have location constraint.

Anyway do cost/benefit analysis and pick some language that makes sense according to your own constraints.

I want to learn programming to make software

You want to make some software (desktop app, website, web app, mobile app, etc).

You could pay profession to do it for you, but for some reason (eg. you are still in high-school, etc) you want to do it by your self.

Do research and find out what programming language is best for software that you plan to build.

I personally optimize for time to market.

If you plan to make a web app, there is no reason for you to learn C++, believe me, there is not.

Currently, in the year 2018, there are already known programming languages (tools) for most of the use cases.

But you also need to be careful, because most software developers will suggest programming languages that they know.

So, do not ask just one person but at least few dozens.

And always ask them what is the reasoning behind their decision.

I want to learn programming just to know how to programme

You do not want a job, you have no idea what to make with programming, you just want to learn programming.

Then you can pick any language, altho my suggestion is to pick something that does have some real-life usage and it is not complicated for beginners.

My humble suggestion is to choose Python “… is easy for beginners, practical for professionals, and exciting for hackers …” from Fluent Python.

Conclusion

Know what are you trying to accomplish and pick programing language for that purpose.

Python Testing with pytest, book review

python_testing_with_pytest-Book_Cover

Published on: 15.05.2018

Number of pages: 220
Written by: Brian Okken
Publish by: The Pragmatic Bookshelf

Conclusion
The only book about pytest.

Review
If you want to learn how to use pytest for testing Python programs, this book will be useful to you.

I did not know much about pytest, before reading this book, except that it was related to unit testing in Python.

So, I was very surprised to learn that it much more (fixtures, plugins, configuration, etc) than just better unit testing for Python.

The largest expense for the programmer

I will talk about largest expense from somebody who is developing software (primarily writing code) but from the business owner perspective (not from employe perspective).

I got this idea after starting to develop my own software products, not at the time when I was writing code for others.

The topic could be rephrased as “The largest expense for the business owner who is also the sole developer”.

But, I also think that it is correct for software development in general.

Time is not on your side

After prolong thinking about a subject, I have come to conclusion (of course I can be wrong), that largest expense is time.

By the time I mean how much time you will spend to make some software.

One can argue that this is also the only expense (with some hardware, room, and electricity).

So, next question is on what activity in software development is most of the time spent(or wasted).

Hardware is cheap

Better hardware (SSD, more RAM, faster CPU, etc) will reduce time in development and you should use it.

But hardware price is relatively cheap against other time expenses.

Let’s say that by using SSD you will get 10 more minutes of work per workday (altho I would argue that it is at least double).

Multiplying by 260 workdays per year, that is 2600 minutes or 43h.

1 TB SSD is 400$, so even if you only bill 10$ for your working hour, ROI is one year and this is no brain investment. (the number can change, but you get the point)

Anyway, moral of the story is that hardware is cheap.

The largest expense is learning how to do something new

Most of the time is spent on learning how to do something new.

New programing language, new frameworks, new libraries, new tools, new new new …

The endless supply of new things thing that needs to be learned.

Somebody could come to the conclusion learning how to learn fast is the solution.

Certainly learning fast is useful, but it is not the solution, because there are more things to learn that there is time to do it.

Temporary nature of the knowledge capital

And also, in software development, you have additional problems of “temporary nature of the knowledge capital”.

Basically, what you learn today, probably will not be useful in 5 years.

Maybe it will not even exist anymore.

So far this is nothing new, anybody, who has been programming for more than 5 years have practical experience that technologies (languages, frameworks, libraries, tools, etc) go away, new ones come and now you need to spend the time to learn new ways to do the old things.

What is new, or at least what I am trying to argue in the essay, is that from the business standpoint, we should look at it as an expense.

Especially as the largest expense in software development.

Somebody can say: “Hey douchebag, I like learning new technologies and using them in my job. You are just some old dinosaur who does not like programming and probably was never good at it.”

Well, I can agree that 35 I am certainly not young anymore.

But my age does not change the fact is that learning something is not same as doing something.

If I want to do something, first I must know how to do it, and to know it, you need to learn it.

So, learning is an expense to doing.

And if for everything that you need to do, first, you need to learn, that is a lot of learning (and big expense).

Is programming is young man game?

I would say that part of the problem is that most programmers are young and do not have much life/work experience.

Statistic from StackOverflow 2018 Developer Survey Results support that calim.

30% have only 2 years of professional coding. That is one third.

57.5% have only 5 years of professional coding.

In some work field, even after 5 years, you are still considered just a beginner.

And only 12,7% have more than 15 years of professional coding.

Hobby or business

Also 81% of professional developers code as a hobby.

I do not think that this is a bad thing.

But at the same time, if you consider something a hobby, then you will not treat it as a business.

In business, there is income and expense.

And by subtracting expense from income, you get profit.

And you should have some if you expect for your business to survive.

In the hobby, there is only fun.

That is why it is called the hobby.

And hobby is the expense, from the bookkeeping perspective, but everybody is considering his/her hobby as fun, not as the expense.

These two reasons, probably more the second one, are probably main reasons why most programmes do not see learning as the expense.

At least, until they have burnout and then they switch to something else, like project management (real job title should be: project reporting) or leave software development completely.

Looking from the previously mentioned statistic only 6.9% of developer are older than 45 years.

But it is well known that programming is mostly young man game, probably due to “temporary nature of the knowledge capital”.

How to reduce your largest expense

I think that specialization is the large part of the solution.

Find your niche and stick to it.

Then you can reduce (or even completely eliminate) the expense of time spent on learning how to program something and can acquire domain-specific knowledge.

When to learn new things

I am not saying that you should never learn new things.

Not at all.

Just do cost/benefit analysis before.

I will use my own experience as an example.

I do/did a lot of web scraping.

First I have done it with Beautiful Soup and a lot of custom code.

I wrote my own caching, ORM, etc.

In web scraping, the easiest part is to write XPath selectors, there are a lot of other things and over time I have made my own small framework for all of that.

And with each new website that I scraped I had to and new features or improve old ones.

And this was taking larger and larger percent of my time as I was scraping more and more challenging websites.

After some time I decided to try Scrapy .

To scrape the first website with Scrapy I need around one week, with 90% of the time was spent on learning Scrapy (learning how to do the old thing with the new framework).

If I have used my custom old framework I would be finished it in 3 days.

But I would have to write more code than with Scrapy.

Currently, with Scrapy in one day, I can do scraping that I needed at least 3-4 days with my old custom framework.

This is the example when learning new framework was useful.

Conclusion

In software development business for a software developer, the largest expense is time spent learning new technologies.

Reduce it by finding your niche and specializing.

Use cost/benefit analysis to determine should you use learn some new technology.

RS232 sniffing with Python

Published on: 15.04.2018

My motivation for monitoring RS232 with Python.

I had PC and LG TV screen communicating via RS232 cable.

PC was turning TV screen on and off via RS232 commands.

But TV screen was not acting normally, it was always in standby mode.

So, either PC was not sending RS232 commands or TV screen was not responding to them.

In order to diagnose the problem, I decided to spy on their communication.

half-duplex and full-duplex RS232

There are two types of communication in RS232: half-duplex and full-duplex.

In half-duplex while one device is talking another one is listening, just like people communication should be.

In full-duplex both devices are talking and listening at the same time, people think that they can do this also, but it is not working in practice.

Hardware

The first step was to make special half duplex RS232 spy cable because I did not have software access on PC.

So the only solution was to sniff communication between PC and TV.

Schematics are available from https://www.lammertbies.nl/comm/cable/RS-232-spy-monitor.html.

On the same website, there are also Schematics for full duplex RS232 spy cable.

Software

For redirecting, all communication data from the RS232 compliant serial port device into a text file Eltima RS232 Data Logger can be used.

The program is working fine, the only problem that I had was that there is no output on screen just to text file.

No real-time watching of communication data was possible, due to that I decided to make my own program for viewing RS232 communication data in real-time.

Python to the rescue

The best thing about Python program language is that there is a package for everything.

For access to the serial port in Python, there is pySerial package.

My Python program was reading communication data and showing it on screen in real-time with timestamps of reading, and time difference between the last read.

Python source code for RS232 sniffing:

Fluent Python, book review

Fluent_Python-Book_Cover

Published on: 01.04.2018

Number of pages: 792
Written by: Luciano Ramalho
Publish by: O’Reilly Media

Conclusion
The book is good for advanced Python, it covers a lot of and in details.

Review
This book is for developers who want to get their Python skills to advance level.

It is not for beginners, for beginners in Python I recommend Automate The Boring Stuff With Python.

Book Effective Python also covers advanced topics, but this one covers in more details.

Both books are good, I would recommend this one because it describes topics in more details, but that is why this book has much more pages.

How to find all emails on the web page ?

Published on: 15.03.2018

Conclusion

Use get_emails() from webscraping Python package.

Python strength

The best thing about Python is huge numbers of 3rd party packages.

With a lot of them, you can solve your problems with just a few lines of code.

Let’s say that you want to find all emails in some HTML document, either for an offline or online web page.

This can be done with webscraping package.

First, install it with:

Code for finding all emails on the single page is:

Line 1 is importing download and alg from webscraping package that you have just installed.

Line 3 is creating download.Download() object and calling it D.

Line 4 is saving the web page from where you want to find all emails in html variable.

Line 6 is finding all emails from your html variable and saving all emails in emails Python list.

Line 8 is showing all emails that have been found on the screen.

This will work for a single web page.

How to find emails on the whole site

If you want to search the whole website for emails, not just one page, you can use following code.

With max_depth, max_urls, max_emails parameters you can define how long your searching should be.

Happy spamming.

P.S. just joking 🙂

Hackers and Painters, book review

hackers_and_painters-Book_Cover

Published on: 01.03.2018

Number of pages: 272
Written by: Paul Graham
Publish by: O’Reilly Media

Conclusion
One of the classics book for hackers (software developers).

If you are just in the business of software, I recommend that you read it.

Review
The book is composed of 15 essays:

Why Nerds Are Unpopular
Hackers and Painters
What You Can’t Say
Good Bad Attitude
The Other Road Ahead
How to Make Wealth
Mind the Gap
A Plan for Spam
Taste for Makers
Programming Languages Explained
The Hundred-Year Language
Beating the Averages
Revenge of the Nerds
The Dream Language
Design and Research

Most of them are available on Paul Graham blog.

My personal favorites are Mind the Gap and How to Make Wealth.

Should you learn C/C++ in 2018 ?

Published on: 15.02.2018

Conclusion

I would not recommend learning C/C++ as your first programing language just for learning to programme, better go with Python.

Also, if you do not know why you want to learn C/C++, better do not spend time on it.

My C/C++ background

Most of my professional programming career, around 10 years I have spent writing C/C++ programs.

By professional programming career, I mean that other people have paid me to write code.

I have spent more time in C/C++, altho I would say that I know Python better than C/C++.

My knowledge of Python is better because Python has fewer features than C/C++ and you do not need to do memory management.

Why C/C++ is hard

IMHO C/C++ is hard due to many features and memory management.

By the time you understand memory management, you can learn 80% of Python.

Just look at this image of code that is concentrating 2 strings in C vs. Python.

Yes, there can be less C code (error checking, free, few const less) and the code would still work.

But then I would be showing bad C production code and not be demonstrating how real-world C code should be written.

It is not fun to debug segmentation fault and that is what you get if there is no proper error checking in C.

Python code could, and in real life should also have if __name__ == "__main__":, but I have removed it to because it is not necessary like in C.

Point is that higher level programing language (Python in this example) is doing a lot of low-level things automatically.

So, you need fewer lines of code, what means fewer possible bugs, resulting in increased developer productivity.

The tradeoff is more CPU and memory for faster time to market.

C and C++ are two different programming languages

Here I am using a language construct C/C++.

Because most of the code bases (at least that I have seen in a corporate environment) are some hybrid of C and C++.

My theory is that the older code was written in C and then later they added object-oriented programming (C++).

But C and C++ are not the same programming languages, mental programming models are quite different.

C code is about structure, functions, and pointers.

In C++ you have object-oriented programming and lot of other features.

In the real world, you need to know C and C++, so that is why I use C/C++.

When you should learn C/C++

The only positive thing that I can see that person will learn from learning C/C++ is manual memory management and pointers.

Basically better understanding how the computer (on software level) is working.

If your only reason is to have a better understanding how the computer (on software level) is working, better learn C programing language.

C has fewer features than C++.

It is easier to learn C++ if you know C because then you should know manual memory management and pointers.

But for anything else than few niches (system, embedded, banking, game engines, etc), I do not see a much practical use of C/C++ in the year 2018.

Probably you ain’t gonna use C/C++

I am not saying C/C++ is not in use anywhere in 2018.

I personally (almost every month) get some interview requests for C/C++ positions.

Usually, they are either for embedded software (C) or banking industries (C++).

I am just arguing that beginners (persons that do not know any programing language) should not start with C/C++.

The only exception is if you are planning to get a job (or start your business) in C/C++ environment.

If it is not for the job/business, I do not see why you should learn C/C++, except for hobby.

But even then, get a better hobby 🙂.

P.S. If you, dear reader, think that I am missing some point, please add it in comments.