Posts Tagged ‘programming’

Characteristics of a great programmer

July 3, 2020
  1. Meticulous: no detail is too small or unimportant. Most bugs are due to programmers skipping over the small details.
  2. Laser-focus: can remain focused on the task for long periods of time. Not tempted to constantly check email, Facebook, Twitter, or whatever.
  3. No ego, humble, good listener: able to set aside one’s own plans when someone comes up with a better plan.
  4. Willing and eager to learn the domain: many programmers just want to do the cool techie stuff and don’t want to “waste time” learning the domain when they could be learning new techie stuff. Bad attitude. Without learning the domain, one cannot know the constraints, co-dependencies, and plain ‘ole weird stuff in the domain. One will be doomed to write buggy, mediocre code.
  5. Can see the big picture: can take a complex fog of concepts and see through to the simple underlying structure.

Advice to people getting a degree in computer science

June 18, 2020

Programming is relatively easy. The hard part is understanding the domain.

The worst computer science people are those who just know computer science, they don’t know any domain. Consequently, when confronted with writing a program for a domain problem, they don’t understand the terminology or the concepts or the co-dependencies. They are doomed to write mediocre and buggy software.

Getting a computer science degree? Get a dual major – computer science plus a degree in some domain. For example, if you’re interesting in music or acting, then get a degree in music or theater. Interested in fitness or sports? Then get a degree in physiology. Interested in anti-aging? Then get a degree in biology or pre-med. Interested in aircraft and flying? Then get a degree in aeronautics.

Writing and writing programs

December 12, 2019

The following is from the book, Computer Power and Human Reason by Joseph Weizenbaum, page 108. I think it’s great.

“Often when we think we understand something and attempt to write about it, our very act of composition reveals our lack of understanding even to ourselves. Our pen writes the word ‘because’ and suddenly stops. We thought we understood the ‘why’ of something but discover we don’t. We begin a sentence with ‘obviously,’ and then see what we meant to write is not obvious at all. Sometimes we connect two clauses with the word ‘therefore,’ only to then see that our chain of reasoning is defective. Programming is like that. It is, after all, writing too. But in ordinary writing we sometimes obscure our lack of understanding, our failure in logic, by unwittingly appealing to the immense flexibility of natural language and to its inherent ambiguity. The very eloquence that natural language permits sometimes illuminates our words and seems (falsely, to be sure) to illuminate our undeserving logic just as brightly. An interpreter of programming-language texts, a computer, is immune to the seductive influence of mere eloquence. And words like ‘obviously’ are not represented in the primitive vocabularies of any computers. A computer is a merciless critic.”

I will strive to live the life of an artist

February 11, 2016

From this day forward I am an artist. At least, I will strive to live the life of an artist.

My interests revolve around reading, writing, working with data, and programming. Thus, my “canvas” will be my books, my words, data, and programs.

If I am not expressing and seeking beauty in my interests, then I am not living properly. The purpose of my life is to express and seek beauty …….. This is an astonishing insight for me.

I feel a great sense of relief and peace. Till this day I have approached life like a person swimming upstream: always striving to achieve something important, always fighting to rise the ladder, compete, excel. Approaching life from the perspective of an artist focused on expressing and seeking beauty … well, that makes a huge difference to me, in my mind and in my emotions.

The beauty and clarity that arises from being totally immersed in something

January 17, 2016

I’ve discovered that something magical occurs when I am deeply immersed in a problem. I enter into a different state of consciousness. My brain opens up and I see things that were once hidden. Beauty is revealed to me. I long to have the experience again – it is addictive.

Recently I’ve heard other people express similar sentiments:

Last week I heard on NPR someone talk about freediving.  The person being interviewed said that once he became immersed in the sport, something clicked inside him and a whole new, beautiful world opened up for him:

So even for me, who’s really comfortable in the water, it took a lot – a long time. Maybe I’m more neurotic than most. But it took a long time for me to get comfy. But then I had this one moment where it clicked for me. And I was down at about 20 meters, about 66 feet. And I didn’t have any urge to breathe. And all around me was this beautiful blue world. And I came up, and I felt so relaxed. And for that whole day, like, I’d close my eyes and I would just see that blue world. It was just something that was in my head. And I woke up the next morning just wanting to do it again. And I eventually got to a hundred feet, or 30 meters, during that course. And – but that’s something that stays with you. And that’s just me, an entry-level – that’s a level 2 free diver. I think that the effects are even greater. I know that they are even greater for these athletes that go to 100 meters. I mean, I can’t even imagine that. But they get to a place – it’s like part athletic, part spiritual. And it’s definitely addictive ’cause it’s so beautiful.

One of my favorite TV shows is Elementary (Sherlock Holmes and Watson). I think the show’s writers are geniuses. In last week’s episode Sherlock listens to a short audio clip over and over (hundreds of time perhaps). At some point in listening, something clicked inside him and he was able to recognize a new meaning from the inflection in the voice of the person in the audio clip (this enabled him to solve the mystery).

Recently I have been writing a software program. For the first few days it was frustrating. But after looking at the problem, over and over, from every conceivable angle, something clicked inside me. The frustration lifted and a calmness settled in. Things became clear in my mind. The problem, my solution, became beautiful. I thought to myself, “I can see how programming can be addictive.”

Now I realize that this sense of clarity and beauty arises whenever one completely immerses oneself into a problem, whatever the problem might be. I’ve also realized that, to experience this altered/heightened state of consciousness requires long periods of uninterrupted focus.

 

Why are there no comments in DNA?

December 12, 2015

In Computer Science one is taught early on that sprinkling comments liberally throughout code is a good thing. Comments enable the writer to remember what was done and readers to understand the code.

If comments are so useful to understanding, then why do biological systems have no comments? For instance, there are no comments in DNA. Wouldn’t comments make it easier to unravel the mysteries of DNA?

Suppose there were comments in DNA. What language would the comments be written in? It doesn’t seem reasonable that comments would be written in English (or French, German, etc.) since those are relatively recent languages whereas DNA has been around much longer. If DNA did have comments they would likely be written in a language that we don’t understand. Unraveling that language is likely to be as difficult as understanding DNA itself. In other words, comments probably wouldn’t help.

Consider this thought experiment: suppose one day we humans receive a message from an advanced civilization from another planet. People tell me that the message will likely be in a formal language such as mathematics. Will the advanced beings include comments in their message? Or will it be written purely in a formal language? As with DNA, it’s likely there will be no comments as any comments would most certainly not be a language that we humans use or understand.

So it seems that for a thing that must span the ages, such as DNA, and for a thing that must span civilizations, such as a message from an alien planet, the thing itself must be understood and comments are useless.

The formal structure/language must speak for itself.

A programming language that makes you smarter

July 12, 2015

A programming language is, well, a language.

It is a formal, structured language.

It has been my experience that if one immerses oneself in a language — any formal, structured language — it influences the mind.

Hypothesis: some languages influence the mind more positively, beneficially than others.

What programming language do you feel has the most positive, beneficial influence on one’s mind and thought process?

A very nice way to write applications

June 21, 2015

Recently I have been reading about the UNIX philosophy for writing programs and applications. [1]

Their approach is to create small, simple programs (exe files) that can be flexibly composed using a scripting language. Here’s an example: ls is a program that lists the content of your current folder, sort is a program that sorts its input. Most scripting languages have a pipe ( | ) operator. We can use pipe to send the output of the ls program into the sort program:

ls | sort

That results in outputting the content of your current folder, in sorted order.

The UNIX people have been following this kind of assemble-from-small-programs approach for decades and it has been phenomenally successful. Many of their programs were written in C. But today a lot of their programs are written in Python [2]. A really awesome thing is that C programs and Python programs can be mixed-and-matched. I wanted to see how this works so I wrote a simple Python program, mesg.py, which outputs a message (Hello, World) and a simple C program, id.c, which reads input and outputs it. The two programs are completely independent (two exe files). Then I used a scripting language to compose the two programs:

mesg | id

That results in outputting the message.

In general, with this approach we can compose any number of programs:

A | B | C | …

Each program can be written in Python or C (increasingly programs are written in the Go programming language).

Interested in learning more about how I implemented my mesg-id application? See here [3].

[1] These are fantastic books: (1) The UNIX Philosophy by Mike Gancarz, and (2) The Art of UNIX Programming by Eric S. Raymond.

[2] See this Stack Overflow question: Modern-day Unix tools are written in what programming language? (http://stackoverflow.com/questions/30830759/modern-day-unix-tools-are-written-in-what-programming-language)

[3] I initially implemented both the mesg program and the id program in Python. I’m a Python newbie so I asked a question about this on Stack Overflow: How to compose Python exe programs using pipes? (stackoverflow.com/questions/30956979/how-to-compose-python-exe-programs-using-pipes) Later I implemented the id program in C and then used a scripting language to compose the Python mesg program to the C id program. This is a very nice way to write applications!

Skills required by knowledge workers

January 11, 2014

Job requirements: a good ability to visualize, some programming experience, and the willingness and patience to follow non-trivial examples.

Learning for the sheer love of it … determining the number of edges in a complete graph

September 7, 2013

As I noted in an earlier blog, even little discoveries makes one feel wonderful. Today I solved a small problem (i.e., made a little discovery) and I feel wonderful.

I am reading a wonderful book, Introduction to Graph Theory. I am at the part where it describes complete graphs. A complete graph is one where each vertex is connected to every other vertex. The author asks, How many edges are in a complete graph with N vertices? I took this as a challenge to use my reasoning skills to figure it out.

Here are three examples of complete graphs and the number of edges in each graph:

Three examples of complete graphs and the number of edges in each graph

Let’s arbitrarily choose one vertex. It must connect to the other (n-1) vertices. For example, in the complete graph with 4 vertices, the vertex will connect to the other 3 vertices:

A vertex connects to n-1 other vertices

The remaining vertices must form a complete graph amongst themselves. Ah Ha! Now we have a simpler problem: find the number of edges in a complete graph of n-1 vertices.

I now switch on my programmer hat. I smell recursion (which I love):

numEdges (N) {
    if (N == 2) then return 1
    else return (N-1) + numEdges (N-1)

Let’s check that program:

if N = 2, then num edges = 2
if N = 3, then num edges = 2 + 1 = 3
if N = 4, then num edges = 3 + 3 = 6
if N = 5, then num edges = 4 + 6 = 10
if N = 6, then num edges = 5 + 10 = 15
if N = 7, then num edges = 6 + 15 = 21
if N = 8, then num edges = 7 + 21 = 28

Wow! That is cool.

One problem, however. What are the number of edges when, say, N = 1000?

I could implement the above program and set it to solve N=1000. But I know the mathematicians would tell me: Find a formula.

Okay, let’s see … to find the number of edges in a complete graph with N vertices, I must add these numbers:

(N-1) + (N-2) + (N-3) + … + 1

or equivalently:

1 + 2 + … + (N-1)

I remember from school days a formula for the sum of the first N integers:

n(n+1)/2

Of course, I want the sum of the first N-1 integers, so I substitute “n” with N-1:

(N-1)((N-1)+1)/2
= (N-1)(N-1+1)/2
= (N-1)(N)/2
= N(N-1)/2

Let’s check:

if N = 2, then 2(1)/2 = 1
if N = 3, then num edges = 3(2)/2 = 6
if N = 4, then num edges = 4(3)/2 = 6
if N = 5, then num edges = 5(4)/2 = 10
if N = 6, then num edges = 6(5)/2 = 15
if N = 7, then num edges = 7(6)/2 = 21
if N = 8, then num edges = 8(7)/2 = 28

Yea!

I am pretty proud of myself. I solved it, not because it was a homework problem or a work problem. I solved it purely for the love of learning. I figured it out by simple reasoning.

I feel wonderful.