September 30, 2019

Immutable Go Object

Every Go programmer knows about the receiver in go, which be declared as: type X struct {} func (receiver X) doThing() {...} We have two types of receiver in golang, which is Value receiver and Pointer receiver. Basically, the receiver in golang could be map to self in other programming languages and the function which uses the receiver will be pointed from struct type of the receiver. So, what does this means, anyway? Read more

September 17, 2019

Imperative vs Functional

Difference between Imperative languages and Functional languages: Imperative languages are based on assignment sequences whereas functional languages are based on nested function calls. In imperative languages, the same name may be associated with several values, whereas in functional languages a name is only associated with one value. Imperative languages have fixed evaluation orders whereas functional languages need not.(1) In imperative languages, new values may be associated with the same name through command repetition whereas in functional languages new names are associated with new values through recursive function call nesting. Read more

August 15, 2019

Boundaries for algorithm analysis

Some boundaries you should know to approximate time and space complexity of your algorithm. $2^{10} = 1,024 \approx 10^{3}, 2^{20} = 1,048,576 \approx 10^{6}$ 32-bit signed integers (int) and 64-bit signed integers (long long) have upper limits of $2^{31} − 1 \approx 2 \times 10^{9}$ (safe for up to $\approx 9$ decimal digits) and $2^{63} − 1 \approx 9 \times 10^{18}$ (safe for up to $\approx 18$ decimal digits) respectively. Read more

July 10, 2019

Migrate to NoSql

Một điều được nhắc đến rất nhiệu khi chuyển từ sql sang nosql là cách để lưu trữ quan hệ giữa các đối tượng trong database. Một đối tượng thường rất ít khi tồn tại độc lâp trong một hệ thống mà nắm giữ 1 phần thông tin được sử dụng để tạo ra một đối tượng khác. Các dạng quan hệ chính giữa các đối tượng có thể lưu được trong cơ sở dữ liệu quan hệ bao gồm Read more

March 25, 2019

Type embedding not inheritance

Since we don’t have classes in go, you can say struct will do a job to make objects. So how 4 principles of object-oriented programming represent in golang? In this post, we will discuss about the principle of OOP that make golang more better than other object oriented programming language: inheritance. A simple question, how does Golang represent inheritance principle even if it doesn’t have extends? We can easily find out the answer of this question: embedding type Read more

© khanhtc 2019