lundi 27 avril 2015

Why do I want to join the best

I love programming, programming is not only a job for me, but it is also a passion. The good thing about programmers is that we love our jobs. Anyone who loves their jobs can excel at it, they can become better than others at doing it. In our field, there are people who study computer science not because they love it, in fact, some programmers tell me that they want to program only for a few years and then become a team leader and stop with programming. However, I can't imagine myself in their position.

I imagine myself in another 30 years or so, I'll be still programming. You can never stop doing something you love. As a proof of your love for something, you have to be the best in it. Another good thing about that is that you never got bored of it. This is especially true for us as programmers. Every day, there is something new out there, and every time there is a new technology, a new framework, you'll have the pleasure of discovering it, and if you spend a good amount of time learning it, you will even have another pleasure, which is teaching it, by writing about it so that other people can learn it.

The social side about programming is one of the aspects that make it really fun. For example, participating in a forum like stack overflow allows us to reach many people. That's another reason to want to be the best, when you are the best, there is a lot of developers you can help, and every time you help a developer, you will improve something in the world, the app that developer is working on.  So the better a programmer is, the more impact he has on the world, and applying to toptal will give me the opportunity to be a better programmer.

samedi 6 septembre 2014

paradigm shift

What is a paradigm shift?


Paradigm shift is something like a revolution. As Thomas Kuhn describes it in his book the Structure of Scientific revolutions, it's a change that has been driven by the emergence of an idea which challenges an existing orthodoxy. 
Initially, the two ideas compete while the old order maintains its dominance. Over time, the strength and popularity of the new idea grows, until it begins to displace the older order: This is what Thomas Kuhn calls a paradigm shift.

That's how all great ideas come into existence. It's not easy to think of something that can cause a revolution, something that can change history as well as existing patterns of thoughts. People are usually resistant to change, a new idea is not necessarily well accepted most of the time. Thus, when thinking of a new revolutionary idea, one must have enough resolve and keep on holding onto their own ideas. We have to think different, think outside the box, in order to be able to change the world. And as a programmer, it's not enough to have an idea, we must make the effort to implement this idea, turn it into something concrete.

How did fortran (and modern programming languages) come into existence

Excerpt from stanford C++ course (cs106b)

In the early days of computing, programs were written in machine language, which consists of the primitive instructions that can be executed directly by the machine. 
Machine-language programs are difficult to understand, mostly because the structure of machine language reflects the design of the hardware rather than the needs of programmers. In the mid-1950s, a group of programmers under the direction of John Backus at IBM had an idea that profoundly changed the nature of computing. Would it be possible, they wondered, to write programs that resembled the mathematical formulas they were trying to compute and have the computer itself translate those formulas into machine language? In 1955, this team produced the initial version of Fortran (whose name is an abbreviation of formula translation), which was the first example of a higher- level programming language. 

I guess that this bright idea was what brought the modern programming languages into existence. After all, it's possible to express any mathematical formula with an instruction or two in any programming language. Programming requires logical thinking, which is something mathematicians are good at. It might not be always the case, but I think a good mathematician can be a good programmer. However, a good programmer is not necessarily good in mathematics.

samedi 30 août 2014

Beware of command substitution in bash

It's dangerous to use a loop with ls results in your bash scripts:

for i in $(ls)

Unix/Linux allows for almost any character in file names, including new lines and spaces. Then, what happens when there's a file with a space in its name:

╭─mansuro@localhost  ~/workspace/new_dir 
╰─$ touch some\ file
╭─mansuro@localhost  ~/workspace/new_dir  
╰─$ ls
some file
╭─mansuro@localhost  ~/workspace/new_dir  
╰─$ (for i in $(ls); do echo $i; done)
some

file


 As you can see, the file was treated as two different arguments, and that would have undesirable effects in your bash scripts.
How can we fix this? We could change 

for i in $(ls)

to

for i in *



╭─mansuro@localhost  ~/workspace/learning/Terminal/new_dir  
╰─$ (for i in *; do echo $i; done) 

some file

And you're done, your bash script works the way you want it to.

vendredi 1 août 2014

Vim persistent undo

Starting from Vim 7.3, it's possible to keep your "undo history". Even after closing and reopening the file, you can still use u and ctrl+r in order to go back to changes you made before closing the file.
In order to enable this feature, all you need to do is to set the properties undofile and undodir in your .vimrc file
set undofile
set undodir=$HOME/.undodir

Don't forget to create the directory undodir, or else this won't work
You can find more information about this feature here: Vim documentation: undo


lundi 21 janvier 2013

The expr command

The expr command is used to evaluate an expression and output the corresponding value. It could be used for example to use the terminal as a calculator:

    $ expr 80 - 25
    55
    $ expr 80 / 25
    3
 
Note that there is a space between the different arguments, otherwise the expression might not be evaluated properly.
It can be used as well for string operations and boolean operations

    $ expr length "abc"
    3
    $ expr 1 "&" 0
    0

vendredi 18 janvier 2013

Working with multiple files in vim

There is a couple of useful commands that can be used to work with multiple files as tabs. I've mentioned them in a stackoverflow answer:
http://stackoverflow.com/a/14395583/612920

  • Open a file in another tab

    :tabe filepath
  •  
  • save the current session in order to be able to open the same set of files again

    :mksession session_name.vim
  •  
  •  navigate between different tabs

    gt: next tab
    gT: previous tab
  •  
  • close all tabs at once

    :qa
  •  
  • open a saved session

    vim -S session_name.vim