While concurrency and parallelism may sound similar (and in fact, are sometimes used interchangably both in normal and in computer contexts), the two terms actually are not the same. In this post, I will explain each of the terms’ origin, how different they are and why are they oftenly used incorrectly.
By its definition, a computer is a machine which computes, so it’s not a surprise that the CPU, which stands for central processing unit (and which we normally refer to as a computer chip) is the most important element of the machine. The part which deals with computational tasks inside a CPU is called the ALU (Arithmetic/Logic Unit), which basically computes everything in binary logic by lighting up some of its light bulbs and shutting down the others. It’s quite a simplified explanation of how CPU works, but the part we’re interested here is that at one particular time, it can only handle one computation, hence it computes and transfers the data back-and-forth to the memory (either the chip’s cache or the RAM) continuously. That means that by design, CPU computation is consequentially, and there’s no way we can expect to run two computations in the same CPU at the same time.
Some weeks ago, I wrote a post called Life is a Big Game, in which I described some lessons I learned from playing the video game The Witcher. Some time has passed since then and my “journey” in the game has also progressed; hence I find a couple of more things from doing quests in the game that I would like to share. The thing I wanna talk about today is how (and why) to tackle “big monsters”, i.e. the kind of game’s monsters that are over your league, which you’re advised to only fight when you’re at a higher level, or not to fight at all.
Today we’ll discuss a somewhat technical issue that I bumped into a few days ago: what is the optimal way to check if at least one element in a list satisfies some condition?
Let’s take a real example. We will use python, but in general the problem can be solved similarly in many other languages:
number_list = [2, 5, 8, 3, 6, 20, 34, 68]
def larger_than_twenty(number):
return number > 20
How should we check if at least one element of the number_list
satisfies the larger_than_twenty
condition (i.e. larger_than_twenty(element) == True
)?
I’m on vacation this week, and similar to vacations of everyone else living in a semi-lockdown pandemic state, it turns to be a stay-cation, in which instead of travelling to a far unknown and adventurous land, or sun-bathing on a nice beach next to a big coconut decorated with a funny hat and a colorful straw, I stay home and do random things. To be fair, there are tons of projects I should be working on (like finishing some draft posts I started in this blog), but since it has been quite rough few weeks, I decided to take it easy and do something fun. Netflix works at first, but after a while I realized it got quite boring: there are so many choices, yet the decision-making process (choosing what to watch next) became a pain; also, most of the animes I would like to watch are only available in Netflix North America, so since I don’t live there (and am too lazy to set up a VPN just for that purpose), I don’t really want to keep watching Netflix after one day or two. That’s when it hits me: there’s a whole entertainment system lying in my living room, under my TV for a while, which I should be using as much as possible before it becomes too old and outdated: my (actually, my wife’s) PS4. (My wife bought it last year, after watching the ads about a game that she really wanted to play. The device was nice and we both had our funs with it, but after one or two weeks, as we both get busy, our interests in it droped, and it has mostly been lying there and catching dust.)
Hi,
Sorry for having been deferring this project for quite some time, I just moved to a new apartment, and there have been quite many things running lately.
This post is just a short update on the project:
wav
file in Go
(unlike pygame
). I will probably need to write a whole new article (or edit this one) to describe the situation some time, but long story short, I ended up deciding to write a Go library for this use. To be exact, I didn’t write it from scratch, but to replicate someone else, but for a Go’s newbie like me, it was actually quite a big step, so just want to share it with you guys: https://github.com/lthh91/wavPlayerThat’s all for now. Peace,
The featured image of this post is the Hainanese Chicken Rice I made right after watching a Youtube tutorial
There are two “major” skills that I have (kind of) successfully learned since I decided to leave my parents’ home in Vietnam and come to a whole different country, thousands of miles away: One of them is definitely coding, and the other is cooking (of course, there are more skills I mastered, you’re not likely to survive independent life with just two new skills, but those two are the ones I am most satisfied with). From the look of them, the two skills don’t have many things in common: one deals with computers and sciences, the other with food and spices; one wrecks your brain out, the other helps nurturing it, etc., however, what I unexpectedly found out is that the experience I get in learning one thing turns out to be very useful for the other. In this article, I’m gonna point out these similarities of the two journeys, which hopefully can help you guys transform the experience you have in mastering anything else into the same experience with any new field you are trying to master (like coding). Without further ado, let’s start!
I hope that by trying removals and changing parameters, you have figured out what these lines of code do:
op := &ebiten.DrawImageOptions{}
op.GeoM.Translate(-float64(frameWidth)/2, -float64(frameHeight)/2)
op.GeoM.Translate(screenWidth/2, screenHeight/2)
In case you haven’t, let’s quickly check the Cheatsheet for ebiten.DrawImageOptions
type DrawImageOptions struct {
// GeoM is a geometry matrix to draw.
// The default (zero) value is identify, which draws the image at (0, 0).
GeoM GeoM
// ColorM is a color matrix to draw.
// The default (zero) value is identity, which doesn't change any color.
ColorM ColorM
// CompositeMode is a composite mode to draw.
// The default (zero) value is regular alpha blending.
CompositeMode CompositeMode
// Filter is a type of texture filter.
// The default (zero) value is FilterDefault.
Filter Filter
}
And here is Cheatsheet for ebiten.GeoM
Last time, we stopped at mentioning that there are three functions needed for the game loop: Update()
, Draw()
and Layout()
, of which all are functions of the Game
struct. According to the cheatsheet, the whole Game
struct is an instance of the Game
interface, as follow:
type Game interface {
// Update updates a game by one tick. The given argument represents a screen image.
Update(screen *Image) error
// Draw draw the game screen. The given argument represents a screen image.
//
// (To be exact, Draw is not defined in this interface due to backward compatibility, but RunGame's
// behavior depends on the existence of Draw.)
Draw(screen *Image)
// Layout accepts a native outside size in device-independent pixels and returns the game's logical
// screen size. On desktops, the outside is a window or a monitor (fullscreen mode)
//
// Even though the outside size and the screen size differ, the rendering scale is automatically
// adjusted to fit with the outside.
//
// You can return a fixed screen size if you don't care, or you can also return a calculated screen
// size adjusted with the given outside size.
Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
}
If you have a background of C, C++, Java and the like, concepts of interface (and struct) might be familiar to you, but in case they aren’t, here are my quick explanations:
This weekend I decided to start another tutorial series in this blog, as I did learn a lot during making the last one. This time I decided to up the ante by picking up on a language that I am not very familiar with: Go Programming Language, or Golang. If it is the first time you heard of it, Go is a language designed at Google, is syntactically similar to C and is very well-designed to support concurrency. One of Go’s authors, Ken Thompson, was also one author of B language (together with Dennis Ritchie) (B was the direct predecessor of C Programming Language).
Yesterday I was watching this TEDx video by Mark Rober about something he called “The Super Mario Effect”. It is a great sharing of tricking your brain (and others’) into learning (hard) things, by “Focusing on the Princess and not the pits, to stick with a task and learn more”. I’d recommend everyone to watch the video to learn more about this “effect”, but this post isn’t supposed to talk about it. What I want to point out from the video is this experiment that Mark showed at the beginning of his talk.
Lately, keywords like Machine Learning, Artificial Intelligence (AI), Deep Learning (Neural Network), etc. have become familiar with most of us, but as I observe, not everyone understands it, hence many of us are under a big illusion about computers’ intelligence. Some of my facebook friends even expressed that they’re scared computers will overcome us soon after reading Dan Brown’s novel Origin, which was published some years ago. In this post, we will start exploring this mystery of artificial intelligence, by understanding what “Machine Learning” means.
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
So a few weeks ago, I had a wild idea to explore Emacs, after watching this hilarious clip from one of my favorite show Silicon Valley. For a long time, I have been curious what Emacs is, and why so many people claim it’s better than VIM (to be fair, there are also many people who claim Vim is better than Emacs), the only reason I did not try Emacs was just because I liked how easily it gets to move around and edit things in VIM, and I heard that Emacs doesn’t work that way. Luckily, after some research, I found out about Spacemacs, and later on, Doom-Emacs, both of which are built by ex-VIM users and have an Evil Mode, which provides VIM-like editing powers for Emacs. So I decided that it’s time to make that bold movement to Emacs, and, actually, was even looking forward to see how it goes. As I expected that by using Emacs, my productivity level would temporarily decrease, I made a promise to myself that no matter what happens, in at least two weeks, I won’t use any other editors but Emacs (and I did keep that promise).
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
Though I am not a hard-core Manga or Anime fan, I’m a big fan of Naruto. When I was a kid, I could only watch a few episodes that were broadcast-ed on TV, and that was one of my favorite shows at the time. Unfortunately, the show was cut off (from Vietnamese TV) after about 200 episodes, so I could not watch the rest of Naruto and the whole Naruto Shippuden. I tried reading some manga online, too, but my English was pretty bad, so I could not understand everything.
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
This is one part of a multi-part tutorial. To see other posts in the same series, please click below:
This is one part of a multi-part post. To see other posts in the same series, please click below: Part 1 Part 2 Part 3
This is an important point: Programming is not about remembering all the little detail about your language of choice, nor it is about reading a lot of books or watching several tutorial videos. It is about mastering some tools so that you can make things you want to make.
After the short introduction of VIM, I hope I did persuade you to start using this awesome editor to replace any bloated software you have been using. However, I understand that it can be difficult to get started, and the vimtutor
might not work for everyone.
Back when I first started using VIM, I was in the same position, and the only thing that kept me from giving up on it was simply because I couldn’t run VSCode or Atom on the remote super computer at work. Long after that, I realized that there is a simple secret that, if I had known from that beginning, would have dramatically eased the path into VIM. That secret is indeed very important, but for some reason, vimtutor
seems to expect us to figure it out on our own. The secret is:
In this blog, so far I have talked about minimal software, about command line interface, and most importantly, about how not using your mouse is good for productivity. cased those “principles” that (I hope) we’ve come to an agree, now is the time to discuss something more practical, starting with: what text editor we should use? In this post, I want to introduce to you a little bit about one of the best options you can go with: VIM.
In the post about command-line interface, I discussed briefly on the slowness of computer mouse in comparison with using keyboard, and argued that your workflow would be much more smoothly and faster if you could ditch your mouse and work fully using your keyboard. Well, one could say it is a unrealistic and stupid idea: mouse was invented for a reason, and that reason is that you can’t do everything with your keyboard.
In the last post, I briefly mentioned how much bloated general software have become over the years. Let’s talk about it in details to see the whole situation.
To be clear, I’m not criticizing the big tech companies for any of their work: as businesses they need to generate profits, and their work benefits other people, too. No matter what their reasons are, what they do creates a world where the efforts we need to use technology is minimized, and that’s a good thing. They are also leading the world’s technology with providing newer solutions for our problems, and they wouldn’t be able to do so without generating profits from these new technology. What I’m trying to do here is to provide some view of the situation.
Hi, today I want to talk about a topic that is quite commonly discussed everywhere nowadays: minimalism. Well, not the minimalist lifestyle in general, but about minimalism in software.
According to Wikipedia, minimalism in computing refers to “application of minimalist philosophies and principles in design and use of hardware and software.”
The result of applying minimalism in software design is applications that are lightweight, fast and reliable.
Today I would like to present to you about the power of command-line interface (CLI), as a better alternative to the graphical user interface (GUI) that everyone uses every day (well, maybe not exactly everyone, we have to subtract people who are too old, too young, in comma, etc., but you know what I mean), by giving you a simple example. This is the first in a series that I tend to write about cli application, and how they will help you become more efficient in your tasks. Hopefully it will raise your interest towards it, and we’ll have some fun talking about this hard but simple way of working with computers.
This is one part of a multi-part post. To see other posts in the same series, please click below: Part 1 Part 2 Part 3
One of the things that everyone should know but have almost never been taught at school is the skill to acquire knowledge. Instead, we were taught how to pass the exams by cramming into our mind a bunch of cr*p that, most of the time, have no practical values. (Even now, whenever I think about my “lessons” in school, the thing that I remember most is how exhausted I was every time I had an exam.)
A buddy of mine from college just started learning programming in Python, and he told me that it was “very complicated” and there are too many things to remember, which he normally mix up. As someone who just started teaching himself to code a few years ago, I understand the feeling, and for that reason I would like to write this post to share some of my experience. Hopefully it will have the chance to help some of you guys out there, who, like my friend and I, want to learn programming but find it too challenging.
A few days ago, while we were having dinner, my wife suddenly told me:
“You know, almost everyone I know has some sort of talents. It’s just me that don’t.”
As you may have imagined, I didn’t expect to hear anything like that at all, so I responded with a question:
“What kind of talents are you talking about?”
“Well, all those kinds of arts or science things: some are good at singing, some at drawing, others at math, etc. I just don’t feel like I’m really good at anything.”