Read on...
1. Use lots of global variables.
2. Give them cryptic names such as: X27, a_gcl, or Horace.
3. Put everything in one large .h file.
4. Implement the entire project at once.
5. Use macros and #defines to emulate Pascal.
6. Assume the compiler takes care of all the little details you didn't quite understand.
7. Rewrite standard functions and give them your own obscure names.
8. Use obscure, proprietary, non-portable, compiled library packages so that you never have to move from the platform you love so well.
9. Use very descriptive comments like /* printf("Hello world\n"); */ before each function call.
10. REMEMBER - Carriage returns are for weenies. Tabs are for those who have not reached weenie-dom yet.
11. Include LOTS of inline assembly code.
12. "User Interfaces" are for morons. "Users" have no business interfacing with a professional product like yours.
13. If you are forced to comment your code (in English), then borrow comments from somebody else's code and sprinkle them throughout yours. It's quick, easy, and fun to watch people's expressions as they try to figure it out.
14. Remember to define as many pre-processor symbols as possible in terms of already defined symbols. This is considered 'efficient use of code'.
Friday, January 16, 2009
How to debug in C :-) :-)
After reading this, I'm sure you won't ever have problems debugging again!!!!
1. If at all possible, don't. Let someone else do it.
2. Change majors.
3. Insert/remove blank lines at random spots, re-compile, and execute.
4. Throw holy water on the terminal.
5. Dial 911 and scream.
6. There is rumor that "printf" is useful, but this is probably unfounded.
7. Port everything to CP/M.
8. If it still doesn't work, re-write it in assembler. This won't fix the bug, but it will make sure no one else finds it and makes you look bad.
9. Since you got it to compile, the problem must be in the Other Guys Code.
10. If it's all your code then the problem MUST be in those unreliable Standard Libraries. See '1'.
11. Claim the bug reports are vicious lies meant to tarnish your sterling reputation as a 'C' programmer (well aren't they ?). After all, those who wrote the reports couldn't even read your code. How could they possibly know if there was a bug or not?
12. If they could read your code, review "How to program in C", above.
13. Claim that there wouldn't be a problem if this stingy Company/School/Wife/etc would spring for a copy of C++.
1. If at all possible, don't. Let someone else do it.
2. Change majors.
3. Insert/remove blank lines at random spots, re-compile, and execute.
4. Throw holy water on the terminal.
5. Dial 911 and scream.
6. There is rumor that "printf" is useful, but this is probably unfounded.
7. Port everything to CP/M.
8. If it still doesn't work, re-write it in assembler. This won't fix the bug, but it will make sure no one else finds it and makes you look bad.
9. Since you got it to compile, the problem must be in the Other Guys Code.
10. If it's all your code then the problem MUST be in those unreliable Standard Libraries. See '1'.
11. Claim the bug reports are vicious lies meant to tarnish your sterling reputation as a 'C' programmer (well aren't they ?). After all, those who wrote the reports couldn't even read your code. How could they possibly know if there was a bug or not?
12. If they could read your code, review "How to program in C", above.
13. Claim that there wouldn't be a problem if this stingy Company/School/Wife/etc would spring for a copy of C++.
Saturday, January 10, 2009
Bob: Hello, Pete: Aloha, Bob: Whats up dude?...
Tutorial: Creating your own Grade-I VoIP network so that you can Voice Chat with your buddies. [Part I]
What you need:
1. A computer (obviously!).
2. A softphone application (I suggest X-Lite, just go to www.google.com and search for X-Lite download).
3. A Soft-PBX (go to http://www.freeswitch.org and download).
4. A DNS name for your system (go to http://www.dyndns.org and register for a free account).
The 'Low-Down' on Voice Chatting:
I will explain the basics here because I feel that if you have a little background on the subject, it would be much more easier to have your voice chatting service up and running.
Okay, so here goes....
I must admit, this was a very 'Non-Technical' introduction, but you don't need ALL the details to do it practically. Nevertheless, I will write a post highlighting the technical details.
Well, so much for this post. I will write the exact process in a later post. This series is going to be quite a long one, so, till then...
What you need:
1. A computer (obviously!).
2. A softphone application (I suggest X-Lite, just go to www.google.com and search for X-Lite download).
3. A Soft-PBX (go to http://www.freeswitch.org and download).
4. A DNS name for your system (go to http://www.dyndns.org and register for a free account).
The 'Low-Down' on Voice Chatting:
I will explain the basics here because I feel that if you have a little background on the subject, it would be much more easier to have your voice chatting service up and running.
Okay, so here goes....
- To voice chat with your buddies, you must have a way of identifying them independently of their IP and port address combination. This is where a server comes in. Basically, all your buddies register on the server. They obtain identifers of the form 'user@domain'. (We will be using FreeSwitch, also known as FS). Note that the 'user' part is an extension number. You use this when you dial a friend.
- The server functions as a 'registrar', meaning that people register here, and it stores a database mapping the users current IP and port to the identifier.
- Once all your buddies are registered on the server, they must use a 'Softphone' application. This is software that can make and recieve VoIP calls. Technically, it is known as a SIP UA.
- To make a call to a friend, all you have to do is dial his extension and Hey Presto!!!, you are calling your friend.
I must admit, this was a very 'Non-Technical' introduction, but you don't need ALL the details to do it practically. Nevertheless, I will write a post highlighting the technical details.
Well, so much for this post. I will write the exact process in a later post. This series is going to be quite a long one, so, till then...
Sunday, January 4, 2009
Java for the iPhone (without jailbreaking)
I bet you must be thinking, "What???, How is this is possible." I too was thinking the exact same thing when I came across this project. Running Java on the iPhone, or rather, building apps for the iPhone using Java is part of a larger project known as XMLVM (http://www.xmlvm.org) that utilizes XML as an intermediate language for cross-compiling at the byte-code level. Note that this cross-compilation is NOT at the source level. XMLVM cross-compiles byte code instructions from Sun Microsystem's virtual machine and Microsoft's Common Language Runtime. XMLVM can be used to cross compile .NET CIL, Ruby YARV and Java Byte Code to JavaScript, Python and Objective-C/C++
Details on Java for iPhone:
XMLVM operation begins with the byte code outputted from a regular Java compiler. Then, an XML version of the byte code is produced. This is then transformed into Objective-C using transformations on the original XML with the help of XSLT. What results is the same, functionally equivalent code in Objective-C. This can then be linked with libraries for UI (Cocoa) etc. to produce a native iPhone app.
XMLVM goes one step further. They have implemented Java counterparts of the Cocoa library components. This makes it possible to develop apps for the iPhone on Windows. The XMLVM project offers an iPhone emulator which is actually a Java Applet.
Example of the classic Hello, World app for the iPhone using Java:
Details on Java for iPhone:
XMLVM operation begins with the byte code outputted from a regular Java compiler. Then, an XML version of the byte code is produced. This is then transformed into Objective-C using transformations on the original XML with the help of XSLT. What results is the same, functionally equivalent code in Objective-C. This can then be linked with libraries for UI (Cocoa) etc. to produce a native iPhone app.
XMLVM goes one step further. They have implemented Java counterparts of the Cocoa library components. This makes it possible to develop apps for the iPhone on Windows. The XMLVM project offers an iPhone emulator which is actually a Java Applet.
Example of the classic Hello, World app for the iPhone using Java:
public class HelloWorld extends UIApplication
{
public void applicationDidFinishLaunching(NSNotification aNotification)
{
CGRect rect = UIHardware.fullScreenApplicationContentRect();
UIWindow window = new UIWindow(rect);
window.orderFront(this);
window.makeKey(this);
window._setHidden(false);
rect.origin.x = rect.origin.y = 0;
UIView mainView = new UIView(rect);
window.setContentView(mainView);
UITextLabel _title = new UITextLabel(rect);
_title.setText("Hello World!, This is Earlence");
_title.setCentersHorizontally(true);
mainView.addSubview(_title);
}
public static void main(String[] args)
{
UIApplication.main(args, HelloWorld.class);
}
}
(adapted from XMLVM project site)
As you can see, development for the iPhone just got a little easier.
Friday, January 2, 2009
Programming, Programming, Programming...
Aah!, The word has a merry ring to it!, but alas, not all people think alike!!!. I would like to share a few thoughts of mine about programming in this post.
We have all heard the phrase "Programming is an Art and not a Science". I, for one, feel that it should be "Programming is an Art and not a Science, BUT it becomes a Craft with experience". It is very true that when one starts out initially, everything is a challenge, and hence programming is perceived as an Art, but this is only half the picture. As a person gains experience, he gains the mental facility to express his ideas in a programming language with ease. Hence, programming becomes a craft.
If you are a keen reader, you would have noticed something about the previous paragraph. I gave some insight into what separates average programmers from the so called "Virtuosos". They very fact that I used the word "Craft" and "Experience" says that excellent programmers mostly aren't born with the ability, instead, their skill is a result of a lot of hard work. I can give an example here. It is a common fact that a person can learn to play the Guitar to any skill level he/she desires. The only catch here, is practice, and practice translates into experience. The same is true for programming. I've been wanting to avoid the cliche, "Practice makes Perfect", but please, do not be mistaken, these words are very true indeed!!!
So, you might be thinking, "Cool!, so What can I do to improve my skills?". Well, I have a few pointers that I found very helpful when I was starting out.
Well, I would like to end this post by saying that it doesn't matter how many languages you know. What matters is whether you are able to express your ideas in the language effectively and Nothing Else Matters!!!
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
--Brian Kernighan
We have all heard the phrase "Programming is an Art and not a Science". I, for one, feel that it should be "Programming is an Art and not a Science, BUT it becomes a Craft with experience". It is very true that when one starts out initially, everything is a challenge, and hence programming is perceived as an Art, but this is only half the picture. As a person gains experience, he gains the mental facility to express his ideas in a programming language with ease. Hence, programming becomes a craft.
If you are a keen reader, you would have noticed something about the previous paragraph. I gave some insight into what separates average programmers from the so called "Virtuosos". They very fact that I used the word "Craft" and "Experience" says that excellent programmers mostly aren't born with the ability, instead, their skill is a result of a lot of hard work. I can give an example here. It is a common fact that a person can learn to play the Guitar to any skill level he/she desires. The only catch here, is practice, and practice translates into experience. The same is true for programming. I've been wanting to avoid the cliche, "Practice makes Perfect", but please, do not be mistaken, these words are very true indeed!!!
So, you might be thinking, "Cool!, so What can I do to improve my skills?". Well, I have a few pointers that I found very helpful when I was starting out.
- Don't think of programming as a burden, think of it as a recreational activity.
- Pick a language you are comfortable with. Note that this post isn't about learning a language. I feel anyone can learn a language. Its how you translate your ideas into the language. Logic matters!!!
- Start off by solving relatively easy problems. Don't pick anything too hard.
- Remember how you solved earlier problems. You should be comfortable with the idea of resuing the ideas you used to solve earlier problems. With time, one almost gets a feeling of deja-vu "Hey, I think i've done this before!!". This will greatly help your abilities related to intergration of solutions.
- Try to read the book, "Structure and Interpretation of Computer Programs", by Alan J. Perlis.
- If you choose to program in C initially, read the book by Kernighan and Ritchie and the book "Programming in C" by Venugopal Prasad.
- Listen to music while you program!!!. Well, I don't know whether this will be helpful to everyone, but it sure as hell helps me out.
Well, I would like to end this post by saying that it doesn't matter how many languages you know. What matters is whether you are able to express your ideas in the language effectively and Nothing Else Matters!!!
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
--Brian Kernighan
The First Post
Well, guess what??? This is my first post!!! I bet you couldn't figure that one out, eh? :) Just Kiddin'!!!!
This blog is my resolution for the year 2009. This is a place where I write about my passions in life, namely, Computer Technology, Guitars and Rock Music.
I use the word Computer Technology because I focus on a wide array of fields ranging from Artificial Intelligence to Systems Programming. (well, I wanted it to be an A to Z, but I couldn't find anything with a Z!!!)
Anyway, I hope you enjoy reading my blog and for all the "Tech Geeks" out there, hope you have a blast reading this blog.
Cheers,
Earlence Tezroyd Fernandes
This blog is my resolution for the year 2009. This is a place where I write about my passions in life, namely, Computer Technology, Guitars and Rock Music.
I use the word Computer Technology because I focus on a wide array of fields ranging from Artificial Intelligence to Systems Programming. (well, I wanted it to be an A to Z, but I couldn't find anything with a Z!!!)
Anyway, I hope you enjoy reading my blog and for all the "Tech Geeks" out there, hope you have a blast reading this blog.
Cheers,
Earlence Tezroyd Fernandes
Subscribe to:
Posts (Atom)