Move Blogging Platform

Continuing to hafizpariabi.blogspot.com.

Nant for helping happily forgetting something

What do people use Nant for?, it’s a build script, people use it to autmate build, of course. But one thing that it could be useful for (and any other script for that matter) : Let me forget things and not feel guilty about it.

When I need to do unit test in the project (it’s in CPPUnit for C++ to give you more background of all this hassle) I would need to go to the project dir (need to do a little searching of this in my brain) and run it there since it uses some relative paths to get some resources. Next, when I need to run some running-test, I would need to go that program dir if I don’t want to type long paths. And let’s just say I want to then update the doxygen-generated docs, I would then need to do some cd cd cd .. and also need to remember how to call related program with what kind of arguments… arrrrrggh.

Now, Ideally, I should have just need to go to root dir and type stuff like

nant cppunit
nant runmyprogram
nant doxygen

and let it do it’s stuff.

That’s one beauty of it. The other one is that the internals of the script serve as a note too, an executable one (it’s a miracle of the century fox!).

Here’s the “note” as doxygen task

<target name="doxygen">
<exec workingdir="dox" program="doxygen" commandline="myprogram.dox"/>
</target>

in english :

to generate doxygen documentation : go to dox dir and run doxygen with an argument myprogram.dox

I find it kinda nice. To take it further, the script could serve as starting point to the whole work on the project. What does this project produce? see/run target run in it, how’s the unit test? you could start by looking at the unittest target and start from the project/dir that is “documented” there.

Now, my brain doesn’t need to remember much and it could use it’s RAM for more processing instead of buffering facts.

In Coding as in Gaming : Save Often

You never know when the next extremely hard opponent will come and give you instant death. Save often. as rapidly as you can, so, when you need to reset you have less to redo.

You never know when several your changes to the code get t you to unsolvable mess, so commit to svn or backup often (zip it or make a copy) if the changes hasn’t worth committing.

When danger seems to be ahead, save. When changes will be catastrophic to your work or your mental health when fail, then commit/backup first.

C++ Development on Kubuntu

I have been working using C++ in windows environment lately and been wanting to know how it is on the linux side of things so far to see if there’s something interesting/valueable to learn. So, here goes my checking out on things on kubuntu.

Compiler is generally taken for granted in every linux system, so no need to discuss it here. So let’s …

Start witht the basics of the basics : the libs

I consider programming usinc C++ is now include using STLPort (STL in general, STLPort is just my prefered implementation) and Boost library. I won’t go into detail on it, but for short, it will just so much reinvention of the wheel I have to do without them. So, this is what I check out first, how smooth is it to have this installed on my system and ready to use for the battle.

It comes as a very nice surprise : I fired up adept and it’s all there. I just install them as I install anything else on kubuntu, a nice and easy apt-get (through adept in kubuntu-case). Only several minutes (most of which used for waiting the downloads) and some toy tests, I have them ready to use.

IDE

I left C++ linux development with the taste of vi in my hand, with my mind wondering when will I try that fancy-looking kdevelop. Now, I got my eye on eclipse-cdt. And, it turn out a very fun experience

  • Feature-rich IDE. Managed project (the eclipse take care of the Makefile stuff for you), outline (realtime class browser), go to definition, rename refactoring , svn integration. Simply said, coool!
  • Sloooow, got yoruself at least 1gb memory, period!
  • Distracting Stories. All the buzz around eclipse might turn people off on this otherwise good IDE. The official website doesn’t help much. But don’t let it distract you, just ignore the java and framework stuff for now, just focus on getting eclipse (the core) and it’s eclipse-cdt and get it running first. In kubuntu, just open the adept and it’s all there. However, I choose downloading the non-apt-get binary from the official site for the uptodateness.

I guess, that’s it just to get a taste of what currently available on linux. In short, it’s currently pretty comfortable to work using C++ on linux. I hope this means those C++ open source projects could produce more and more stuff (still waiting for a good moment/chance to contribute here).

Fromt this : something valuable for my work that I might try : experimenting on using eclipse for windows to build stuff on the office, someday.. maybe …

to Boost lambda from the cout problem of STL

I find myself using more and more using boost lambda these days. Anyone that start using STL will find that it’s full of potential until they meet with the requirement to use Functor to just print out the member of his beutifully-chosen container type. At this point he’ll said to himself

“why do I bother learning this new containers and stuff when just to print the members I have to get back using for construct? writing Functor just to do this is conterproductive!”.

Then came Boost’s lambda to the rescure. Those elegance-crazed progarmmer could now call this

   1:
   2:for_each(myCoolContainers.begin(), myCoolContainers.begin(), 
   3:    cout << _1);
   4:    
   5:    

simple, elegance although not neccessarily more comprehensible (at least for those never heard of lambda function yet).

And this cout thing is a starting for most programmer in finding more interesting stuff on boost’s lambda such as boost::lambda::bind and the rest of boost library.

Why C++

  • powerful languegue to exploit native things. All integration, look and feel, speed, special api, will available to c/c++ programmer where any other programmer would only have access to subset of it. Of course, it’s for better or worse
  • powerful tools for serious programmer -> you don’t get stuck in vm/interpreter behavior. Not like something in vm/interpreted -> extend it natively
  • a better discipline. No language force you to be discipline like cpp does (unless you enjoy fighting the language).
  • a better programmer -> knowing how the machine itself will execute your code (assuming you know that mastering c++ means knowing what the compiler produce out of your code)
  • a very good foundation for learning other language. Many other language syntax are derived from c/c++. And c++ is multiparadigm language with high flexibility to be (forced to) fit to even recent programming paradigm (so far).

It’s not for everybody, but it’s sure worth learning at least.

But that’s just the upside, I don’t want to start with the dark side yet. It’ll be quite scary things to start :) .

Windows “hacks”

Useful/Interesting “hacks” on using MS Windows. Below are not some Big Appslike IDE or word processor , but those in supportive nature.

Desktop

  • flyakite : So my desktop less M$-Window$ looking, better visually and more “rebeliously-cool”. The downside is that the java app looks screwey, so I defaulted to the metal theme which fortunately could blend quite well.
  • cygwin. Much powerful shell than windows’s cmd.
  • timeleft : replace small standard windows clock with more bigger, useful one. I used to Clock tray in KDE, so I search around for something like it. The bonus : some countdown things which use to remind me to stretch.
  • TaskSwitchXP. Useful for better switching than standard Alt-Tab when I open lots of windows.

Browsers, Mails, Calendar

as we all know, the great mozilla family

Sunbird, is still early releases, but I find it already useful for daily usage.

Productivity

  • Freemind : multipurpose tree-based editor. Useful for mindmapping, tracking current task which branch out another subtask, subsubtask, with cross-reference, links, etc… I’ll go nuts without this.
  • JEdit. Powerful text editor.

Support

  • foobar mp3 player. Small, light, straightforward but powerful mp3 player.
  • GoogleDesktop : I rarely use start menu anymore, replaced with addictive Win+G shortcut.
  • avg free. Free version of AVG Antivirus, updated very often.

So, there they are. (Free) Stuff that I find essential to add to be able to conviniently start working on (Non Free) windows.

When to “Go Public” in C++

I usually faced with a situation in coding a class where I need to choose whether a member variable should be public private or protected. This is an area where some debates are sometimes heated to boiling state. There are fans of get set functions, there are properties built in into a language to support this natively, but there are also the “hardcore” programmer, who probably used to be do lots of C thus has some emotional and/or historical/experiential attachment with struct (I use hardcore loosely here, you can choose whatever meaning you see you, so you don’t need to start definition debates).

But when to use it exactly?. Well, in C# you might be happy with properties, in Java you have lots of help from IDE to happily forget that get and set methods can add more stress to your already-highly-abused-finger. But for C++ programmer, which those lucky or unlucky programmer currently working on, the things seems not that open for extravagant behavior.

The users of this easy-to-shoot-yourself-on-the-foot-and-blow-the-whole-city-in-the-process language are trained to not overspend their resource and complexity budget otherwise they will find themselves miserable with slow performance (which main reason of many who use C++, so if this off you better claim your defeat to those virtual machines and garbage collectors) and has low maintanability as a bonus. So, what’s the guideline to get acceptable tradeoffs in this language?.

I realize some guideline are useful for Java or C# could be useful, but since it’s more urgent and contextual for me to see how things in C++, so you Java guys could sit back (and watch if you want) for now.

My path is to look back on why people do encapsulation and how can we get those but still get maintanable and fast code (or at least to get a view on where the optimal balance lies). So, let’s take a look on ..
(more…)

Balancing getting things done and learning

I have just finished reading “Psychology of Programming” by Gerald M. Weinberg. There are various gems I pick along the way. This is a hugely interesting books. It’s oooold, but things are still relevant, only some minor differences in context and tools. Quite scary though, does it mean we don’t change much after all these decades?. Anyway, Here’s an interesting one about how amateur and professional view on problem solving (emphasis added).

The amateur, being committed to the results of the particular program for his own purposes, is looking for a way to get the job done. If he runs into difficulty, all he wants is to sur- mount it–the manner of doing so is of little consequence. Not so, how- ever, for the professional. He may well be aware of numerous ways of circumnavigating the problem at hand. He may even employ one of them for the immediate purpose of getting the job done. But his work does not stop there; it begins there. It begins because he must understand why he did not understand, in order that he may prepare himself for the pro- grams he may someday write which will require that understanding.

The amateur, then, is learning about his problem, and any learning about programming he does may be a nice frill or may be a nasty im- pediment to him. The professional, conversely, is learning about his profession–programming–and the problem being programmed is only one incidental step in his process of development.

I usually don’t like using name calling, amateur vs. profesional, mortal vs. immortal. But this distinction of amateur from professional worth using, at least for self-examination. I am sure will remember a lot the emphasized-quotation above “The professional, conversely, is learning about his profession–programming–and the problem being programmed is only one incidental step in his process of development”. I’ll probably make this into wallpaper or somekind :) .

It’s not as simple as it sound though. On appropriate times (like going through new interesting tools) I feel like browsing through mans, infos, docs, helps, papers for purely exploration purpose or on times when I feel like learning from the “hack” I just did or some old code I ported succesfully but not grasp all it’s internal logic but sometime on the context of get things done I held myself from digesting it too long to stay focus on the (next) work at hand. However, the substance most probably in the quote above, that is to put it simply “to care about our craft/profession and take them seriously”. People who take certain things seriously would investigate it deeply and won’t be satisfied until he feel comfortable enough that he got all he can extract on that special occasion which he can use to larger his understanding and be a better/more skillful person. The game thnn is two games : get things done and increase our capacity to get even better/faster/more things done in the future.

Programming is not all life, of course, but what I experience so far is that having seriously study certain field/skill the basic principle that works usually are general in life, will be useful and enrich our perspective on our other parts of life.

Tools in the eye of Professional

Programmer have lots of tools in their daily work, stuff from IDE to compiler. But how professional programmer approach them?. I don’t think they would use an IDE and use the whole feature available on IDE for his work even if it is seemingly relevant. He would put more trust on his skill, experience and common sense rather than what IDE proposals on how to do things or what to use. “Wow, this IDE has unit tests framework, I’ll just use this to have more integrated feel of development”, “Hey, what’s this, Class browser? nice, I won’t need to look around my .h .cpp files anymore, I’ll just click stuff around in this nice browser, very cool!”. Those probably an euphoria fresh programmer would fall into.

Professionals knows what is needed to get things done in it’s substance and not on what to use or how. They would see tools just like any other tools, the tools don’t need to brag a lot about it’s feature, he’ll say “silence you mere tool!, let me see what you got, I’ll use whatever useful from you the way I wanted to use you, there are other tools I have tried and there will a lot more to come, you’re not that special”. Poor tools.

You don’t see professional preoccupying themselves with their tool. They may have favorites, but when it gets down to the real work they usually do, it’s what “fit” in his hand and mind best that he’ll pick. You see them saying stuff like “when you are in flow your racket/stick/keyboard is the extension of yourself.”

Professional has his own set of speed tricks that might or might not be substituted by newly-coming tools. When it fit his way of working he might use the tool when it’s appropriate but when it’s not, he’ll just use his old sacred way. It’s like when you learn certain part of math in school very deep and you come up with your own personal ways for solving problems beyond what the book or teacher can taught. You will only substitute your own way for the tools/way that can match it, has more to offer and most importantly won’t make a lot of mess in his personal set of tools/tricks/concepts. New tools that might work better/faster but don’t get along well with our already existing set of tools/tricks will only be more trouble than it’s worth. Tools, for professional, isn’t just about to be “used” but it is to be “installed”, means it will be an integrated part of solution framework in his mind which should get along well with the rest of the system.