Category: Programming

Sad passing of Dennis Ritchie

Saw a tweet earlier on today and it caught my eye.

Then learnt that the creator of the C programming language and also Unix, passed away over this weekend.

RIP Dennis Ritchie.

On a more serious note, need to get this off my chest, and no dis-respect either in this regard to Apple’s Steve Jobs who also passed away last week, but…and this is what I find absolutely gob-smacked about, very little was mentioned of Dennis Ritchie (dmr). The twitter-sphere has been going on about Steve Jobs for the last week or so. The cruel twists of fate has been made… when you read on and realize…

But what the twitterers fail to grasp the concept and realization, there would have been no C language nor Unix for that matter, no applications/games that was possible in the 1980′s and 1990′s either, and no operating systems either.

When you think about it for a moment, the influx of different designs of operating systems was programmed in C, combined with assembler programming language.

Nor would the advancements  in chip design have been achieved, which is a catch-22 in this regard, some kind of a package to be able to program the logic flow of chips etc. Hell, even, there would be no mobiles/smartphones, no Android, no Apple OS….

Even in the telecommunications sector, without C, there would have been no improvements somewhat in the arena of phone switching etc, nor even a operating system to run, in the sense of to manage the telecommunications infrastructure either.

There would have been no internet (TCP/IP protocols which was formed on the backbone of the C programming language), or even would DARPA have existed only for that once when the gates to the internet world was opened up? What about web pages, blogs, Twitter, Facebook, the things that we take for granted now today in this electronic age where communication is even more emphasized.

And it was not Steve Jobs that is a legend either, for that matter, sure he pushed and raised the bar for Apple has become of today. No dis-respect to him either, without him, certainly, smartphones would not have been made possible in terms of features and raising of the bar for standards across the board.

The real legend was the quiet man who hacked away and coined the biggest revolution in his hands alongside with Brian Kernighan that totally changed the IT world forever.

You may object and say hang on… but I digress, sure it sounds a little one sided, but have you not thought of what the world would be like today without the Unix, C today.

What would have become if dmr did not pioneer  C, or Unix. What would the IT landscape be like without it, would Apple have existed, would Microsoft have existed, internet, tcp/ip protocols, Windows, you name it…

So for all people out there, I ask you to re-tweet a simple tweet of your liking to salute dmr for he totally changed and revolutionized the IT landscape right back in the late  1960′s/early 1970′s.

From me, who was a self-taught C programmer, and Linux fanatic, I salute you dmr, you’re the real legend!

Post to Twitter

Setting up your own GitHub

This article is about how to set up your own private github repository on Linux, in a few easy steps. I have tried a few packages that I personally, found, convoluted and complicated. Sometimes the simplest way is the best way. A few pre-requisites here needed:

  • A user id that has been created by root, make sure that the said user id does not have a login shell, in this case, call it gituser (This should create /home/gituser!)
  • A group id that, also, has been created by root, in this case, called it git. (The above two are for reasons of security to prevent exploits etc, should the Linux box be ever compromised)
  • That there is the latest git binaries or compile from source which can be found here from the main git site. And that it is installed, the installation path will vary depending on your Linux Distribution.
  • There is a super-internet daemon running, xinetd.
  • Optional: Open the port on your firewall, 9418 for the git protocol.

Now, root access is needed for the most part to get this set up and running.

The pre-requisites out of the way, let’s go ahead and create the github server.

  1. All the source code changes will be tracked and stored inside the /home/git/scm directory so create the directory. And this will be referenced by the super-internet daemon configuration.
  2. So. inside that directory /home/git/scm, create a directory for each git repo that you want to set up, for example, Kernels and inside that directory you would have different kernel versions, ending in .git. E.g. /home/git/scm/Kernels/2.6.32.9.git This will be perceived via way of git protocol as this: git://localhost/Kernels/2.6.32.9.git (See the tip below if you wish to make this accessible outside of the localhost address)
  3. Taking the above example, that the directory is created, issue the following command:
    1. git –bare init
    2. touch git-daemon-export-ok
  4. Now, still being as root, change the owner-ship of all of the directories/files within the /home/git/scm directory (chgrp -R git:gituser *).
  5. Edit the super-internet daemon configuration, found usually in /etc/xinetd.conf like this:

service git{

disable=no

type=UNLISTED

port=9418

socket_type=stream

wait=no

user=git

server=/usr/lib/git-core/git-daemon

server_args= --inetd --export-all --reuse-addr --enable=receieve-pack --base=/home/git/scm

log_on_failure += USERID

}

Now, restart the super-internet daemon and all should be okie. That’s the server side done and ready to accept files.

As a tip, instead of confining the github repository to be at just localhost, set it to the IP address of the actual linux box that you are hosting the repo at, for example, 192.168.10.1.

As an ordinary user, and have a need to check in the files into your private github, do the following:

  1. git init # This initializes the current directory to be used for git-tracking.
  2. git add * # This tells git to accept a list of files that needs to be tracked.
  3. git commit -a -m “Initial comment and initial version” # Tell git to store the commit message that is related to the the list of files added.
  4. git remote add origin git://localhost/Kernels/2.6.32.9.git # Tell git that we’re using the server side address that will be the centralized point of tracking changes. This is only done once!
  5. git push origin master # Tell git to push the list of tracked files and changes across to the server. Again, do this once, as it will be stored in the configuration within the directory and will remember next time, i.e. git pull, git push, git log, git status, etc.

Now, your own private github repository is working.

Repeat the steps for each repository/directory that you want tracked by git.

Happy Git’ting :)

Post to Twitter

Back and bad-ass

Well, after taking a hiatus from the blogging sphere for a while, I thought I’d send out my New Year Greetings to all readers of this blog, sure it’s being a while but over time I will tell what’s been happening…

Well, 2011 is here, this year is going to be exciting… there’s new things happening in the Samsung bada world, and also in the android world…

Will let you on to a secret, I am in love with Android… in a geeky nerdy way that one could describe, the beauty and simplicity of it plus the fact combined with the Linux kernel, this makes it a truly a geeky system, the joys of finding out so much on what can be done with it… over the coming few days I will be blogging about all sorts on Android, and not forgetting Samsung’s Bada…

Til then… have fun and practice safe hex \o/

Post to Twitter

Gameboy Emulation in JavaScript

Uh huh, yup, you’ve read that correctly. This is an excellent read and is very very interesting…it talks about using Javascript to emulate the CPU instructions that is found in the Nintendo Gameboy hand held console using the Zilog Z80 instruction chipset…

That is a worthy article that explains everything very well and could form the basis of the same principle for other emulators…

Thanks to Imran Nazar for the enjoyable read

Post to Twitter

Samsung Bada GCC toolchain

I have opened up the project on github that is a replacement bash script intended for Linux, to ease building the Codesourcery’s cross-compiler bada toolchain that targets the Samsung Wave. Read more »

Post to Twitter

Crazy is this?

Right – have been working flat out over the last week trying to get an open source scripting language ported over to Samung’s Bada – namely Python. There are a number of interesting aspects Read more »

Post to Twitter

A worthy insight into undefined behaviour

While reading this article about how undefined behaviour in the aspect of C and C++, which can cause headaches and aimless hours lost, by banging your head of the wall, on the nuances of the syntax which can throw you off completely… this article is a worthy read and ensures that code do not fall into the trap of producing “weird errors” or “it works fine on my dev machine/environment, but but…. on the production, it behaves strangely”….

Heh… this article shows a completely undefined behaviour here…

<pre><strong>$ cc test.c -o test
$ ./test
Formatting root partition, chomp chomp</strong></pre>

Well, not really undefined but… you get the drift… the author explains how certain compiler emitted code can cause “odd behaviour” which is the essence of  ’undefined behaviour’

Credit is due to this author of the blog, John Regehr, cheers for that article… thought provoking and interesting to read…

Post to Twitter

Fonts for coders

Here’s a nice font – called Anonymous, a fixed width sans font for coders like you and me….

Thanks to Mark Simonson for releasing it. :)

Post to Twitter

Recursive main outside of C

I posted an interesting question to StackOverflow about this code

#include <stdio.h>
static int n=0;main(){
void (*fn)()=&main;printf("%d\n",n++);fn()return 0;
}

It should be noted that the question was edited and hence the code was deemed ‘not of standard C’, this code above was the original prior to the edit..

The results are interesting to look at…C ya…

Post to Twitter

Paul DiLascia (R.I.P)

I did not know about this, but I was fond of reading his articles on the MSDN magazine and coined the infamous comment found in his code, more on this in a minute, he passed away in Sept, 2008, my humblest and belated condolences.

His list of articles he wrote for MSDN can be found here, titled ‘C++ at Work’.

His infamous comment, which is put into all of his source code that would highlight and answer a MSDN reader’s question…

// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.

Bless him.

Post to Twitter

Amusing Code comments

While on StackOverflow, there was an amusing collection of code comments that programmers have seen when working on the code or maintaining some one else’s code.

My favourites has to be this


/* You are not expected to understand this */

try{

....

}catch{

Exception up = new Exception("Something went wrong");

throw up;

}

That made me laugh when I saw it and the bittersweet irony in behind the code…

The first comment, that was highlighted in Dennis Ritchie’s page here. (The co-author/inventor of C programming language and Unix)

There is also insight into the rumoured story about the Windows 2000 source code that was leaked into the wild…I cannot fully say if the page here is authentic enough to validate the author’s opinions on the source.

Post to Twitter

Sudoku solver in Awk

Now, I’ll admit, I go soft in the knees for Sudoku, you have heard of this infamous puzzle…there is something about using logic to solve the puzzle.

This email popped into my in-box where there is a Sudoku solver written in the infamous text processing language, found commonly under Unix and Linux and Cygwin, called Awk. Yip, you have read that correctly. Head on over thegeekstuff.com to see the code in its full glory.

All in all, a measly 144 lines of code…wow! Pretty neat I must say and it looks deceptively simple but the algorithm is one of a back-tracking algorithm which is not easy to understand as the theory behind it is deep.

Now, where did I leave that unsolved Sudoku….

Post to Twitter

Hello World

Heh! Fancy taking a peeksy at the simplest program to display ‘Hello World’ in more than 400 programming languages (yup!…who has the time to put this together….)

There’s bound to be something in there, also, I recall visiting a site that displays the ’99 bottles of beer’ in different dialects, take a peeksy here…(The address is quite ummm… obviously ‘http://99-bottles-of-beer.net/‘) !!!!

Be prepared to read some amusing code….

Post to Twitter

Evils of C

Yup! You have read the title correctly…I stumbled across this site while someone on StackOverflow posted a question ‘Strangest language feature‘, it was very interesting to see what other people have answered to that!

Nonetheless, the link to the site on the ‘Evils of C‘ was very enlightening and makes you think twice before submitting to the International Obfuscated C Code Contest (IOCC) and come up with some hacked up code that demonstrates how the C language can be abused and emit an act of defiance against the C Compiler that you have in your toolbox and yet works…

Enjoy.. :)

Post to Twitter

Programming Languages Beacon

I came across a very interesting question posted on StackOverflow, the poster was trying to find out if the programming language C++ is still used, have a look here on the above site. And one of the answers contained a link to this site aptly titled as the same as this blog entry. And I had to glance at it and read it through, it is interesting to see the evolution of writing software from C to C++. (Or should that be a C++ sorry for the pun!)

What a list. It is interesting to note that in the list, Windows was developed in C++, whoa! Now we know why the DLL’s and the core system are so bloated with too many inter-dependencies.. ;)

Nonetheless, it makes an interesting read…like I did not know Google was written in C++ – in fact, to be honest, I thought it was C for it’s versed prowess in speed and size…oh well..Look at IBM’s DB2 and Informix, makes you wonder about the whole thing on databases – I do know from experience, that DB2 is extremely powerful and fast – now, I am not knocking other database vendors and open-source databases either..but there seems to be a plain fact that anything written in C is guaranteed to be much faster!

What struck me, in the irony of it, was that Microsoft’s own .NET Visual Languages (yes, VB.NET and C#) – written in C++, that’s some irony!!

Oh and by the way, it cannot be disputed but just look at the web-servers themselves, yet Apache powers about 45% of web-sites…draw your own conclusions there in comparison to Microsoft IIS!!

A very thorough reading and one that makes you ponder….

Post to Twitter

Cdecl ahoy

While hanging out and monitoring the stackoverflow.com (SO), it is absolutely fascinating to see the faceless crowd contribute their bit towards in helping other flummoxed people with programming questions that they cannot understand or decipher.

Especially C, ahhh…the true beautiful language that has been around since 1970′s when Brian Kernighan and Dennis Ritchie invented the language. To this day, it has morphed and transcended all languages, to C++, C#. I love and admire how incredible the language is and have no doubt that it will join the ranks of programming languages that refuses to die, like COBOL.

For me personally, the C programming language is like my first love ever since I came across it when I was a lanky, gawky, nerdish teen!

There is a site that caught my eye when monitoring the SO forum, that there is a web site designed for C programmers, cdecl which has been written countless times, from the command line, to the web. Cdecl is the code that understand all C declarations and such obfuscated declarations, for an example:

void (*bsd_signal(int, void (*)(int)))(int);

Now how’s that for a C declaration which gets translated into

declare bsd_signal as function (int, pointer to function (int) returning void) returning pointer to function (int) returning void

Until then my fellow C-amigos! :)

Post to Twitter

Public Forums

You can see from my badge below on the right hand side of this site, that is my StackOverflow reputation. Yes, it is a public forum for discussions on all things to do with programming. There is Serverfault.com and Superuser.com, now a new cream of the crop, in similar spirit to StackOverflow, packetdrop.net

That looks interesting and might be worth your while to post answers while sharing knowledge which is what I am doing!

Post to Twitter

History of Programming Languages

A hilarious take on the above subject matter, referenced else where but titled originally ‘Brief, incomplete and mostly wrong history of programming languages‘, by James Iry…a disclaimer here…it aint true but enjoy reading it:)

If you are the type that likes coding, take a break and read it up to give yourself a smile!

Thanks James Iry for his posting!

Post to Twitter

Nice font Inconsolata

I was reading Computer Active magazine, and there was a small article detailing downloads to try out, and this one caught my eye, a nice mono spaced font called Inconsolata by Ralph Levien. I downloaded it and installed it, went into VS, set the font, and I have to say, it is neat and looks easy on the eye, clear and readable.

Now, every programmer has their own personal opinion and I shall not spark a flame-war on what is the best font to use, but however, the one big thing that I look for in a font designed for doing programming is:

  • A slash through the zero to distinguish it from uppercase O, some fonts are bad at this!
  • The digit one and the lowercase l, it can be misleading with other fonts which makes it look near alike to the naked eye. This font has a nice slope to make a one look like a one instead of lowercase l.
  • Mono spaced, and of course fixed width.

This font Inconsolata satisfied my requirements and fair dues to Ralph for his work, and by the way it is free. Incidentally, at the bottom of the page at his website is a link to the top 10 programming fonts. Also, it is on CodeProject’s Hans Dietrich writes about the different fonts used for the job in programming – go on, take a look and see for yourself.

Aye, free as in free beer!

Post to Twitter

About writing Unit Tests

I was reading this blog entry by Chris Ashton about “It’s Ok not to write Unit Tests“. It was an interesting read about testing in the domain of programming. I am for all, believe in testing the code throughout all stages of software development…but… unit tests…come on…that is from the holdover days of when Java was peaking in popularity…hmmm… Read more »

Post to Twitter

WordPress Themes

Bad Behavior has blocked 2027 access attempts in the last 7 days.

Stop SOPA