Irony of language fondness

There is an irony about fondness of language in a programmer’s life. I am not very particular about any programming language, I can read and understand and code in quite a few of those. But, my affection is not same for every language I know, and there is the irony.
My favorite language is C++. It is one of the most powerful languages that we have in the industry. It is multi-paradigm and can be used to solve many, if not all, programming problems. Most importantly, to me, C++ sounds very sweet.
On the other hand, there is C#. It has a very strong affiliation with Microsoft and Windows platform and people are prejudiced about it. Nevertheless, it requires proprietary .Net framework to run on top of. Despite these, C# is an amazing language. Its creator had the opportunity to look back into a long history of many languages and decide very carefully from the experiences we had in last half century. So, C# ended up accommodating a plethora of language features, both in terms of capabilities and syntax. I am very fond of C#.
My current job requires me to program in Java. When, I was first introduced to Java when I was a sophomore I became very fond to it. But, then I learned about C# and C++’s wonders kept on unraveling to me. So, I distanced myself from Java, for more than four or five years, until my MS coursework required me into using it. Now, here is the irony! I started my new job here, in Long Island, and my day to day primary language is now Java. I kept rediscovering a lot of facts about Java, and I started to like it again. Specially, Java 8 brings a lot of things I’d like a high level programming language to have. I am learning new things everyday, and would keep learning about them.
So, the irony is, C++ is my favorite language, I admire C# and my primary language is turning out to be Java. Behold, that is not the end of it. I also have to know JavaScript and Python and PHP and happen to like all of them, more or less. And off course, all these languages have their own utilities.
In the end of the day, it occurs to me that, fondness of languages do not matter after all. Every languages have a lot of things to know about and I’d like to be fluent in at least one of them. I just don’t know which one it is going to be!

Originally posted as a Facebook Note. Continue reading

List methods from a source file

Sometimes source files can become quite large. This is common mostly in C. But this may happen in other languages too. It makes working with these files particularly hard. Off-course there are IDEs which lists method and properties and what not. But there is a fun way to do the same stuff using python. The regex for the signature of Java methods is, (public|protected|private|static|\s) +[\w\\[\]]+\s+(\w+) *\([^\)]*\) *(\{?|[^;]) You can use this regex in python and have some fun summarizing your Java source files. Here is the script: on Github and via Gist, Cheers!


git push heroku master; server sent publickey

Recently I have been having some trouble with heroku git push from my Windows PC. Whenever I run,

> git push heroku master

I an stung with this message:

PuTTY Fatal Error
No supported authentication methods available (server sent: publickey)

I have tried several things like adding keys with heroku keys:add etc.
Finally, following helped:

> heroku git:remote -a appname

Apparently, meta about remote was corrupted, and executing this command fixed it.

What is linked list and how pointers work?

Today, I was talking with one of my friends about how we studied data structures in freshmen/sophomore years and how some troubled in understanding pointers. Joel probably says that, it is an aptitude that not everyone can have. So, just then an analogy for linked list hit in my imagination and my friend told me to write about it.

Think of a treasure hunt:
– You are given an address of a house, you should start by visiting there
– In each house you will find an address to another house, you have to visit that house next
– At some point you will reach a house which do not refer to a next house; your treasure is in that house

Traversing a (singly forward) linked list works exactly the same way.

Hope this analogy helps.

Read_file_bytes

Yesterday, I needed a tool for reading files as bytes. Hexdump programs generally do some formatting and stuff. I did not want that. I wanted to have a straight forward, simple sweet tool, that simply reads a file and prints it’s bytes. Time required for searching such a tool is indeed greater than the amount of time you can simply write a tool by yourself. I wrote the following:

/* read passed file and show bytes in hex val, consicutive each byte */
/* Released in Public domain by nafSadh.khan */
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	FILE * pFile;
	int c;
	int n = 0;
	if (argc < 2) return 0;
	if (strlen(argv[1]) < 1) return 0;

	pFile = fopen(argv[1], "r");
	if (pFile == NULL) perror("Error opening file");
	else {
		while ((c = fgetc(pFile)) != EOF){
			printf("%02x",c);
			n++;
			if (n % 32 == 0) printf("\n");
		};
		fclose(pFile);
		printf("\n");
	}
	return 0;
}

Next time, I am not re-writing this same program though.

PostgreSQL as Object Database

This is a live blog (i.e. I’d be updating this post time by time.

I am starting to use PostgreSQL as Object Database, mainly as a part of my course project. Object oriented extension of SQL is quite interesting – I, kinda, am loving it. However, all object oriented extensions are not yet implemented by vendors. PostgreSQL lacks a lot of them. Here, in this post, I am going to put notes about what I encounter.

I am using PostgreSQL v9.3.0.

No type inheritance

I tried to use the cool feature of SQL with the keyword under, which was supposed work like extend keyword for type inheritance. e.g.:

CREATE TYPE StudentType UNDER PersonType AS (
    Id INTEGER,
    Level CHAR(2)
)

However, table inheritance is still available, e.g.:

CREATE TABLE Students(
    Id INTEGER,
    Level CHAR(2)
) INHERITS (Persons);

List all tables

select * from information_schema.tables

Computer Science Brain Hammers

I’m writing here after pretty long while. Several times I felt like writing, but could not do it altogether. Life seems a bit busier. It is almost just a “get up from bed – go to job – drink movie – sleep” cycle. By the way, in a discussion with my colleagues I found myself trying to remember some textbook names that I studied in the univ as an undergrad student.

You know, computer science is lot more about science than just about engineering and programming. Even though, I studied this subject in an engineering university I had no option to go away from the science and arts those lie (or may possibly lie in future) behind the screen (and cpu, gpu, ram, those programs u r running for ages, the shiny new app u r proud of, the new thing Steve Jobs announced about, the market’s hot new technology everyone is dreaming to buy blah blah and blah…). You want to graduate in computer science from a school, I assure you, it is just not learning some tools and languages. In fact, may be you are very capable of using WordPress, codex, Joomla and jQuery… you call yourself a php expert… ok! you are really a very kewl guy – I admit; but yet you are not a computer graduate… you may claim yourself to be very geeky but you are not amongst those geeks and nerds who turn the world into a new one everyday. To be a computer graduate, to become a software engineer or an embedded system architect you have to know a lot of things that are taught in all but many computer graduate schools. let me list some core courses you’ll see in Computer schools:

  • Basic programming
  • Discrete mathematics
  • Object Oriented Programming
  • Data structures
  • Algorithms
  • Numerical Methods/ Analysis
  • Applied statistics
  • Computer Organization and Architecture
  • Digital Logic Design/ Digital System Design
  • Microprocessor, Peripherals, Interfacing…
  • Computer Networks
  • Database
  • Operating System
  • Automata theory/ theory of computation
  • Compilers
  • Information System
  • Software Engineering
  • Artificial Intelligence

There are also some advanced subjects those you or your school may chose, including: Computer Graphics, VLSI design, Computer and Info Security, Machine Learning, Pattern Recognition, Neural Networks, Distributed Computing, Parallel Computing, Image Processing, Bio Informatics, Biomedical Engineering, Wireless networks, Digital Signal Processing, Decision Support System, Modeling and Simulation, Computational Geometry, Multimedia Technology, Computer Gaming, Augmented Reality,  Computer Systems, Embedded Systems, Data Mining, Cryptography, Natural Language Processing, Principles of Programming Languages, Machine Vision, Human machine Interfaces etc.

All these subjects there are to hammer your brain to shape it into a sharp and shiny piece of tool to do smart thinking. But still you are confined in a little world, you should also know the basics of some other engineering subject like basic engineering drawing. Many schools will also ask students of Computer Science and Engineering to acquire basic knowledge on related Electrical engineering and electronics subjects. for example:

  • Electrical Circuits (a.c. & d.c.)
  • Basic Electronics, Analog and Digital electronics
  • Basics of Signals, Filters, Pulse techniques
  • Electrical Machines
  • Basics of Power Electronics
  • Electrical Measurement and Instrumentation
  • Data Communication
  • Basics of Communication Engineering

Nevertheless, you will have to do a lot of mathematics and study a little bit of physics, chemistry and even sociology. Industrial Management, Accounting, Economics are those three subjects that might seem as pain in your a** in the graduate school, but u’ll really need them in real life (at least to manage your wealth and handle your boss… in cases what you’ll study in school will seem inadequate).

I started to write this blogpost aiming at making a list of important text books I read in my undergrad school and started to list some of the important subjects. But now as I’m feeling bit sleepy (Oh! God! I’ve remembered the names of a lot of subjects those made me sleep) I hope to make the list in a later post. Off the record: to make this list I’ll have to search the names in the deep corners of my natural neural network and also into the paper and electronic documents I’ve with around me. Wish me luck in this 🙂