Karl's Report

Welcome to my blog, my very own corner on the internet. Here you'll read about my struggles and successful ventures as a professional full stack engineer, alongside some hacks I've found over the years. Dive in and I hope you find it entertaining and instructive.
PHP 8.0 Highlights

PHP's been the corner-stone of web development since 1995. With that being said, the latest version of PHP 8 comes to change the scene and offer an entirely different perspective from its previous face 7, extending crucial components, methods and performance by providing robust execution times and cleaner syntax. The first major improvement's the elegant syntax of the constructor property promotion. Once we initialize an object of a given class we call its construct method and by default we may or may not set up some of the object's properties using the reserved word e.g $this to set the values. This particular middle step may become really hectic if we have several properties passed and we're called to set them up manually.

PHP8 came to remove this unecessary middle step and auto promotes the values to the corresponding properties, via definition. Observe:

class Base {
public int x;
public function __construct(int $val){
$this->x = $val;
With PHP8:
class Base {
public function __construct(public int $val = 10){ }
As you can see, there's plenty of time left for some other stuff if you follow this approach and most importantly you don't have to worry about definitions and initialization of properties. Another great improvement that simplifies the overall boilerplate of your code's the nullsafe operator. There are several times that we may need to validate variables and to do that efficiently we apply if-clauses coupled with null-conditional expressions. That's ancient history with PHP8 since now you can easily produce a one liner for such concerns. Suppose we're given the following code:

$last = null
$users = ['Karl G'];
if ($users !== null){
$last =$users[0];
One liner:
$last = $users?->$users[0];
This logic can be used as a fail safe for chained conditions as well, ensuring that no condition will break for it will terminate the whole block.

One other really exceptional tool for people who mess around with string operations, such as myself, are the three string-manipulation functions (str_contains, str_starts_with and str_ends_with). Those treasures, no doubt, remove literally the pain of finding lengths, positions, things you need usually to determine where the change should be made. Str_contains() makes it easy for you to get a boolean check of existence providing a substring:

str_contains("world", "orl");  /* returns: true */
str_contains("theway", "zzz"); /* returns: false */
The two other functions make it pretty easy for you to get feedback in case you need to know how a string starts or ends without giving too much work into it. No more strlens, messing around with indices or using explode/implode to get array representations. I am convinced that PHP8 was been created to give life to the saying "Work smart, not hard." I strongly suggest for y'all to study the official documentation and prepare to be amazed.

Karl G.

Using edX to Improve My Study Habits

EdX changed my life, and now it’s a part of who I am. I’m so happy be among the 5,000,000 edX students worldwide. All the edX courses I’ve taken have taught me something new and useful that I can apply to advancing my career and studies. Each one provided me with an amazing “toolkit” – methodologies which improved my way of learning or reshaped it completely, which I’ll use for the rest of my life. One of my favorite courses so far was Introduction to Aerospace Engineering: Astronautics and Human Spaceflight, with Professor Jeffrey Hoffman and Professor Chelsea Curran, offered by MITx. Not only was it challenging and quite engaging for newcomers, it also had an incredibly helpful staff and active community. I enjoyed every minute of it.

My latest course, HarvardX: Principles of Biochemistry with Professor Alain Viel and Professor Rachelle Gaudet, was very interesting. They presented the course material in an indescribably spectacular way: the material was so well-organized that even someone with no background in the subject, such as myself, could gain significant ground and complete the material with ease. Both courses also improved my ability to focus my concentration, and gave me new ways of studying a new subject in a unique and simple way. The truth is, every course I’ve taken had an amazing community, no matter the subject. I don’t think I’ll ever stop taking courses from edX. Soon after high school, I came to realize that the only way to stay active with concepts and methodologies was learning on my own.

I’m currently studying Computer Science and Engineering at my local university, and am still planning to take CS50x on edX in the future. My goal is to work as a Software Developer. EdX has done exceptional work so far and shows that education isn’t a privilege: education is a necessary component for the future, of shaping a better human being through unique educational experiences. I salute edX for that and I support your vision, deeply. It is my honor being a part of the community. To every new student out there: Completing my edX courses was well worth the time and the outcome. You can learn anything, just don’t give up.
Read more from edX Blog


Python 3 - Tkinter & Dialog Tutorial - Simple GUI

This is a simple app implementation in Python 3.6 for tkinter and messagebox library. I explain the simple non-object oriented way. I don't explain how to call functions or what an object is. All these are covered in other tutorials, go check them out.


Python 3 - Format Tutorial - How to properly format and display output

This is a video explaining how to use the format function. Formating numbers, strings and applying left, right and center alignment. Consult Python docs for more information.


Python 3 - Tkinter Tutorial - Object Oriented Approach - Simple GUI

This is the object oriented way of making a simple GUI app using Tkinter in Python 3.6. Tkinter is already included with every python's iteration, so you can just import the corresponding library and write some magic.


© Karl G. Zafiris