How much math you need for programming

December 5, 2014 at 10:47 am | Posted in art, Hacking, Patterns, Programming | Leave a comment
Tags: , , , , , , , , ,

Whenever I wanted to learn Algorithms, Mathematics used there somehow seemed to be an obstacle. I admit my Math is not that good but it ain’t that bad either but this “ain’t bad” level of knowledge was not enough to compete in interviews with the Big Four when it comes to their level of Algorithms and the time and space complexities involved and comparisons of sorting and searching techniques. I needed to learn all these and in that search I came across several articles written on Mathematics required for programming. When it comes to programming, most loudly known math-proponent is Steve Yegge. Here is what I have found on Math required for programming:

  1. Steve Summit notes on Math (author of brilliantly written C-FAQs)
  2. Steve Yegge who has written two articles Math Everyday and Math for Programmers
  3. Eric S. Raymond talks about how much math you need to become a Hacker
  4. Paul Graham on Math
  5. Evan Miller’s article as reply to 3 authors above
  6. Steven Noble wrote an article as reply to Evan Miller’s example of calculating fibonacci numbers

If you do not read all of those above then you might miss the intent of my blog post. As per Steve Summit, Eric Raymond and Paul Graham, you do not need to focus much on Math to become a brilliant programmer, a hacker (Wikipedia definition and Eric Raymond’s article on definition of a hacker). Steven Noble says you should learn a little bit of Math and Evan Miller somehow seems to agree with all of them with a bit of twist. I myself started programming just for the love of it.

Since 2009, I am programming professionally mostly in C, sometimes in C++ and almost always on Linux and sometimes on UNIX. My passion for programming has made me read and write code in many different languages where I had to learn different ways of thinking. Writing code is easy, thinking along the lines of the paradigm on the top of which a particular language was modeled is a tough, daunting and very time consuming task. What I have experienced is: Computer Programming is not Math. Let me say it again, computer programming is not Math and will never be. You want to learn computer programming, then learn computer programming. Do not flip through Math books, read whatever is written on a particular newsgroup (comp.lang.c, comp.lang.lisp for example). Use a news reader like Pan:

http://pan.rebelbase.com/

Read about all the software that came from GNU and use Linux distro exclusively for everyday tasks (I prefer a distro with least amount of binary blob). If you are learning lot of Math because you want to learn computer programming then you are confused and headed in the wrong direction and you will not learn much of programming.

As computer programmers, we write programs, but why? We write programs to solve problems of this world. That is what computer programmers do, they solve problems.

Now what does does a mathematician do? He tries to understand nature and uses mathematics as a language to do that. Mathematics has helped solved many problems of this world. Look at what Quantum Physics, a branch of physics that has literally changed our millennia old assumptions about atoms, is heavily dependent on Math. Math is everywhere, from chemical industry to societal problems we use Statistics. Take any part of your daily life and you will see how deeply it is influenced my Math. Math has been used as the most prominent vehicle not only to understand nature but also to solve problems of this world. There is a reason for this, all these properties are just inherent in Math.

I was not good at Math, so I was trying to solve the problems I was facing everyday as a programmer using my intuition, common-sense, flow-charts and more other kinds of diagrams. This went on for few years and I came up with some rules and ideas on which I was building a model to solve problems. Building up this model had one aim: to be extremely clear and very brief on what the problem is and same for solution. I was creating a model, to which you will feed a problem as input and it will produce a solution as output using English language, flow charts and lot of other kinds of diagrams I created. This model had certain assumptions, rules and conditions, which again were very clear. Clarity and simplicity were high on agenda. It was a kind of a general, abstract mechanism to be applied to problems to get solutions. Now a few months back, after I read all these Math articles I came across one more article from Evan Miller titled Don’t Kill Math which was actually written in response to Kill Math by Bret Victor.

These two article hit me very hard. First, Bret was trying to do the same thing I was trying from few years, though he was more successful than me in producing something. I could never come up with some solid model which could have been used by everyone and here is Bret who has already done that. Was I happy, yes, because I found what I was looking for and I was ready to follow Bret’s footsteps but I never did. Why?

There was a reason I could never come up up with a solid model. I always thought it lacked something. No matter what I did and how much I worked on it, I always felt that something very fundamental and basic is lacking. Whenever I studied Schrodinger equation, Maxwell’s equation, Newton’s laws, Kepler’s laws, The Uncertainty Principle or Shulba-Sutras, I always felt that all those equations are complete but my model does not. Both of these articles Kill Math and Dont’ Kill Math made me realize what is that completeness. It is the properties of Mathematics mentioned in Don’t Kill Math. The questions Evan asked in this article and the way he has explained in very simple and basic details, concluded my search for a model. Math is a terse, succinct and concise method to solve problems and understand a phenomenon. These brutal characteristics are inherent to Math, just like soul is inherent to every being. With Math you can solve problems in a much shorter and better way than not using it.

This brings me to a very basic question: Why did I hate math? It was the way math was taught to me in school and college. I was taught rote-math, not real math. It is the fault of school, fault of our education system, not of the student. Coming back to the primary question of whether we need Math for becoming a great programmer, this is how tho world solved its problems in beginning:

math-1

Then came Math and this is what most mathematicians did:

math-2

And this what almost all computer-programmers/software-engineers/developers do:

math-3

Evan Miller says you can become first rate hacker without using a lot of Math and I think he is right and that is in agreement with all other authors. The point he stressed was role of Math in solving problems of this world, that Math is brutally efficient in solving real world problems. As programmers, we solve problems, but if we solve problems using Math and then apply programming solutions to the mathematical model of the solution, then we can have some amazing ways of providing better solutions that will make our lives easier as a programmer (kind of side-effect):

math-4

I conclude this blog-post with:

  • You do not need math to become a first-rate programmer because we do not use much of Math directly. If you want to become programmer then learn programming. Computer programming is very different from mathematics, and as a computer programmer you have to focus more on how to write better programs, how to think in a particular paradigm (e.g functional, OO, Generic, Procedural, logical, declarative etc), find better ways to create software, you need to understand design-patterns, not to mention learning and using C for few years will add new dimension to your thinking. All these are not related to math in anyway. You need to learn these first and it will take you few years before you get a grip at them and then you can learn Math if you want. Read Introduction to Progrmming using Emacs Lisp by Roberrt J. Chassell to know how the problem of creating a customizable, self-documenting, ever-extensible real-time display text-editor was solved. Read GNU Make Manual and find out why does it need M4 and Autoconf.
  • Math is the most widely used vehicle to understand the nature and solve problems of this world. We can learn more ways of solving problems by learning mathematical methods. I myself have started studying probability because like Steve Yegge said, once you understand Math then you can look at the problem and see whether it a probability problem, calculus problem or statistical problem etc. Math is related to the nature of the problem, not nature of software, software has its own methods and tools of solving problems, keep that in mind.

Copyright © 2014 Arnuld Uttre, Hyderabad, Telangana – 500017 (INDIA)
Licensed Under Creative Commons Attribution-NoDerivs 3.0 license (a.k.a. CC BY-ND)

The curse of QWERTY

August 6, 2014 at 6:37 pm | Posted in art, community | Leave a comment
Tags: , , , , ,

Two years back I started having pain in my hands, wrist joints, finger joints, neck and upper back. I searched about it and came to know lot of programmers face this and for some of them this pain turns into Repetitive Strain Injuries (RSI) or Carpal Tunnel Syndrome . This was serious . The height of chair and monitor and keyboard were pretty right and I did not feel any problem with that. Then the biggest surprise came in the form of DVORAK keyboard. I came to know that QWERTY keyboard was actually designed to slow down typing. There is an interesting web-site that has lot of good info on  DVORAK.

STcover

The problems with QWERTY keyboard are mentioned at so many places on internet that it is impossible to read them all.  QWERTY is such a pain and I am amazed that with so much advancement in technology we still manufacture QWERTY keyboards. I came across so many different keyboard layouts: Colemak, Workman and Norman among the popular ones. I like to improve myself and the pain in hands, finger joints, neck and upper back was a motivation to try something. I chose DVORAK above Colemak and Workman because latter two were based on QWERTY. I think one can not design a better model to solve a problem if its design is based on a faulty old model. Norman layout I could not find on Arch Linux. In India only QWERTY keyboards are available (hardware). So the only option was to change software and Linux has so many possibilities and options that it made me more happier. You do not need to change hardware, just some settings as per your distro. I have logitech wireless K260 motherboard and I decided to change the placement of keys on keyboard manually to DVORAK along with software settings. This is how it looks like:

Photo0016

Photo0020

Photo0024

As you can see every key was a fit for every other socket except these four: F, U, J and H. These four keys were fitting only in their original positions, I don’t know why. Hence I put handmade stickers on them and this is how my keyboard looks now:

Jpeg

Using this for 3 months now and pain in hands and finger joints is gone. Neck and upper back pain have reduced to a much larger degree but not totally gone. All these parts pain a lot if I sit for longer hours in front of computer (6-9 hours or more). I am not a doctor and you should consult a doctor if you are experiencing pains then please do not postpone a medical checkup. Here are some points that may help:

  1. Make sure monitor is at a height where your neck is straight when you look at it
  2. Make sure your chair has cushion and flexible back support. You can adjust the height of your chair to a comfortable level.
  3. Keyboard and mouse need to be at comfortable height and distance

The best option is to find a good computer table according to your height and build. It is very easy, you know your comfort level within few seconds of sitting on that chair and putting your hands on table. Please do not type (for desktop computer) while sitting on bed. It will cause lot of discomfort for many days.

There are many scientists/researchers/government-organizations who after doing lots of research have concluded that all these alternatives like DVORAK, Colemak, Workman, Norman etc do not offer any advantages over QWERTY because human mind can adapt to any random pattern of keyboards, that a person can type as fast on QWERTY as on any other random pattern. Well that may be true and I can agree to that and I do not give much damn if my typing speed is 20 wpm or 50 wpm but what about RSI and Carpal Tunnel Syndrome? I am using DVORAK from 3 months now and one day I just wanted to try QWERTY again to see how it feels. It was horrible experience to use QWERTY again. My hands were literally moving from one corner of keyboard to another (diagonally) causing much stress and pain in fingers. With DVORAK most of the words (of English language) exist on Home Row and hence there is not much diagonal movement of hands when you type. My mind did not forget the QWERTY layout though but that one hour was torture. I switched back to DVORAK and till date never tried that again. Though I face problems because keyboard is changed at Operating-System level(software level) than hardware level. So, when I have BIOS or a boot-loader at my disposal then it behaves like QWERTY keyboard because this is what it is as per hardware construction. But this is a minor issue compared to 99% of my time which I spent in OS.


Copyright © 2014 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)

Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.

Coding Horror

June 3, 2012 at 2:17 pm | Posted in art, Programming | Leave a comment
Tags: , , ,

Recently I was reading an article on coding horror which mentioned that most of the software developers who come for interview can’t even program and later I came across another article regarding phone screening interview and he mentioned Steve Yegge’s 5 essential phone screen questions. I looked at them and I thought .. whoaaa.. so easy. I was with my friend on his Windows machine and did not have access to some Linux machine. So I downloaded Bloodshed’s Dev-C++ compiler and typed this code and ran several tests, all in 20 minutes. (Bloodshed Dev-C++ version 5.2.0.2). I worked through several problems, enjoy my C code 🙂

/* (1) Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the
number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

 (2) Write function to compute Nth fibonacci number

 (3) print all odd numbers between 1 and 99
 */

#include <stdio.h>

enum { LIMIT = 100 };

void fib(const int n);
void print_odds(const int limit);
void print_fizzbuzz(const int limit);

int main(void)
{
	print_fizzbuzz(LIMIT);
	printf("\n\n");
	print_odds(LIMIT-1);
	printf("\n\n");
	fib(20);
	return 0;
}

/* No int/unsigned-long overflow check */
void fib(const int n)
{
	unsigned long f0 = 0;
	unsigned long f1 = 1;
	unsigned long fnum = f1;
	int i;
	if((0 == n) || (1 == n))
	{
		printf("fib(%d) = %d\n", n, n);
		return;
	}
	for(i = 2; i <= n; ++i)
	{
		fnum = f1 + f0;
		f0 = f1;
		f1 = fnum;
	}

	printf("fib(%d) = %lu", n, fnum);
}

void print_odds(const int limit)
{
	int i;
	for(i = 1; i <= limit; i = i + 2)
	{
		printf("%d\t", i);
	}
	printf("\n");
}

void print_fizzbuzz(const int limit)
{
	int i;
	for(i = 0; i <= limit; ++i)
	{
		if((0 == i%3) && (0 == i%5))
		{
			printf("fizzbuzz\t");
		}
		else if(0 == i%3)
		{
			printf("fizz\t");
		}
		else if(0 == i%5)
		{
			printf("buzz\t");
		}
		else
		{
			printf("%d\t", i);
		}
	}
	printf("\n");
}


Copyright © 2012 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)

Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.

Copyleft Logo (Hebrew)

September 1, 2007 at 7:57 am | Posted in art | Leave a comment

I have created a new Copyleft Logo by using the Hebrew Language. In Hebrew Language, the English alphabets C and G are represented by one letter named Gimel. I reversed the Gimel, just like reversed C in Copyleft logo 🙂 and here is what I designed then:

Copyleft_Hebrew - white Copyleft_Hebrew - transparent Copyleft_Hebrew - patters-plywood-LIGHT Copyleft_Hebrew - patters-plywood-BLUE

Copyleft_Hebrew -  3 colors Copyleft_Hebrew - green-on-blue-pattern Copyleft_Hebrew - green-on-blue-pattern-STONES

I will publish more logos created in several different languages 🙂



Copyright © 2007, Arnuld
Uttre, #331/type-2/sector-1,
Naya Nangal, Distt. – Ropar, Punjab (INDIA)

any work on this page falls under one of these 2 categories: either “text” or “art”.

for “text work”, Verbatim copying and distribution are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.

“art work”, falls under Free Art License. read this:

Copyleft: this work of art is free, you can redistribute it and/or modify it according to terms of the Free Art license. You will find a specimen of this license on the site Copyleft Attitude http://artlibre.org as well as on other sites.

Copyleft Logo

September 1, 2007 at 7:31 am | Posted in art | 2 Comments

This is the modified Copyleft Logo. I got the original one from Wikipedia . There are 2 versions, black & green and both are in public domain. So I took the liberty to apply some designs and patterns I like 🙂 and here is the output:

Copyleft tiger-white-blue Copyleft trio Copyleft trio-TEXT Copyleft trio-TEXT-rotated

 


 


Copyright © 2007, Arnuld
Uttre, #331/type-2/sector-1,
Naya Nangal, Distt. – Ropar, Punjab (INDIA)

any work on this page falls under one of these 2 categories: either “text” or “art”.

for “text work”, Verbatim copying and distribution are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.

“art work”, falls under Free Art License. read this:

Copyleft: this work of art is free, you can redistribute it and/or modify it according to terms of the Free Art license. You will find a specimen of this license on the site Copyleft Attitude http://artlibre.org as well as on other sites.

Next Page »

Blog at WordPress.com.
Entries and comments feeds.