Wednesday, February 28, 2007

some nagging c++ questions

C++ always has some tricks in there that you just don't know about. Here are a couple of features/issues that I've run into. Am sure this list is pretty huge but lets start with three of them and my explanations for the same.


a) using "using namespace" in your header files


I was once asked why I go ahead and take the trouble to do a std::string in my header files instead of just including the "using namespace std" statement and moving along. There are a variety of reasons why the former is considered to be a good practice. Some of those are written in Herb Sutter's More Exceptional C++ book and many newgroups have their own threads on this issue (see namespace pollution).

For me the main reason was because of the namespace pollution caused when I have some headers with the "using" statement and some without and then being included in a particular sequence in a third header file. This as I remember caused some collisions. Other than that it also causes problems when you go ahead and include all these headers in your own namespace, thereby also including the "using" statement into your namespace, more problems.


b) the need to have template class functions as inline


Template classes are essentially compiled on demand. Once the compiler seems a template instantiation it goes back to where the declaration was seen and generates the type specific code of the template class immediately. Now while doing so it needs to generate the entire object code for the class. If we go ahead and sperate our template class into a .h declaration and .cpp definitions files then the compiler is left with incomplete information about what needs to be generated for this class. This is the reason why most compilers will cribb here. But this is a compiler issue rather than the C++ standard itself.


c) template functions in tempate classes

yes it is possible to do that. you just need to be a lil carefull thats all.


template < class x >
class tclass
{
public:
x var;
tempate < typename y >
void func(y);
};

template < class x >
template < typename y >
void func( y fvar )
{ ... }

Thursday, February 08, 2007

Adding a second SATA disk

Here is the sundocs link that tells you what all is needed to be done for adding a new disk on your machine.

Step-by-Step:
- Connect your disk on your motherboard
- open a terminal and login as superuser
% format
(choose the new disk)
format> fdisk
(create your partitions here and save before exiting ie choose 5)
format> parition
partition> print
partition> modify
(modify your partitions and note down the serial numbers)
partition> quit
format> quit

Now you have the serial numbers of the disk that you just worked on
% newfs
% mount

Hope this helps... Now to playing with zfs

Wednesday, February 07, 2007

OpenCV on OpenSolaris

I had some problems getting OpenCV working on OpenSolaris.

Finally found a solution. Just do a
./configure AR=ar
else
./configure && make AR=ar

Couldn't find any link for OpenCV on OpenSolaris/Solaris so hope this helps people who are trying this out.

Technorati Tags: , ,

Monday, November 13, 2006

Sun GPL's Java

Well if you haven't heard this I guess you have been under a rock or are working at either Novell or Microsoft. Anyways Sun has just (as this is typed) released the entire Java source tree, atleast SE and ME, under the GPLv2 license.

I took a hard look at the comments on /. and frankly this is the first time that 90% of the comments seem to be positive. Now thats a major thumbs up, if releasing your IP as free software isn't enough to get your spirits high:)

Good luck Java.

Thursday, October 19, 2006

Coolest Looking Sun Product

By now all of us have heard about Project BlackBox and what it actually is. I don't know the product details and the specs as such but what strikes me with this product is that Sun has finally managed to get in some good product design engineers in place. This is by far the coolest looking Sun product I have ever seen. The color combination, plexi and everything in there is not just functionally necessary but also aesthetically well placed. Good job!

Technorati Tags:

Saturday, September 23, 2006

Google testing OpenSolaris

There are rumors running all over the place that Google is Testing Sun's OpenSolaris. In fact even digg featured the article and the comments are quite interesting. Now leaving out the Linux fanatics who seem to be blindfolded in their love for their OS the reasonable amongst them can argue about the benefits about it. Now that would be a really fruitful discussion, which unfortunately never happens. Most threads of this nature are dominated by the "I am good and all else is bad" comments.

But taking a look at this from an unbiased perspective (I am really trying to be unbiased here) Google can seriously benefit from a lot of what OpenSolaris has to offer.

OpenSolaris is a BSD variant
All Unix and Linux faithful can't deny the fact that the BSD variants are for some reason the more sturdier class of *nixes. Be if FreeBSD, NetBSD, OpenBSD, Solaris of Apple's Darwin all of these have been very successful on high end systems. And high end today does not mean high cost but its more in terms of their scale. The up times shown by Solaris servers are legendary in their own right. And ofcourse now OpenSolaris is Trusted by default.

OpenSolaris has the bells and whistles
Dtrace, Zones, Zfs, FMA, x64 support and a lot more. Sun has gone all out while developing Solaris and has gone ahead and released all of this as OpenSolaris. Yes they are currently using the same code base for both, Solaris and OpenSolaris. So someone like Google can benefit by using zfs and scaling their mhamoth data centers even further while running dtrace to figure out the real time patterns in usage and code segments. So catch those algorithms while they are lazing around or eating more resources and improve them.

OpenSolaris provides for binary compatibility
Now I am sure Linux guys dint know what that means but it has been an assurance given by Sun on all Solaris systems for nearly 2 decades or more now. And hey its not just OpenSolaris that will let you maintain binary compatibility but because of the way the code is structured there should be no reason why this guarantee shouldn't be maintained between OpenSolaris variants as well.

OpenSolaris is Open
Ignore GPL devotees. If you don't like CDDL tough luck. But even with CDDL in place Google can go ahead and create a custom version of OpenSolaris for themselves and deploy it all over and heck even redistribute it if they like. Golaris sounds kiddish but well you never know:)

Suggestion to Google: Use Niagara ie USIV+ processors
The Niagara family of processors are targetted at customers such as Google that need a higher throughput on their front ends. With 8 cores and 4 threads per core in the Niagara1 family these processors can go ahead and eat up web queries on the Google website while the back end servers churn up the results. And NO the cost of the Niagara based systems is not prohibitive at all. In fact you could compare them with many desktop processors while comparing the cost/GHz and well the beat all of them in the cost/watt category. Am sure Google will be thinking about energy costs in the huge facility that they are supposedly coming up with in collaboration with the US government.

Well Netcraft shows gmail running some servers on Solaris 8 already. So I guess in a couple of months we should know if these rumors have any meat in them at all. And yeah being realistic even if Google adopts OpenSolaris it will be for very specific reasons. Their deployment of Linux is humongously distributed and very customized, from what I have heard. So we wont see them going on OpenSolaris 100% in the near future. And of course they too will have to douse off the in house Linux flame throwers too right. That may be the toughest challenge!

Well moving to OpenSolaris will simply mean that Google is definitely not resting on its laurels and is in constant search of whatever will let it improve further.


Technorati Tags:

Tuesday, September 19, 2006

Nevada on VMWare

It's really exciting to see OpenSolaris build 46 ie Nevada running smoothly on my laptop inside a VMWare workstation environment. I have dedicated 8GB and 512Mb RAM to its running instance and hopefully it will suffice. The main idea here is to keep up to speed with the new features being constantly integrated into Nevada while still doing my routine job. It was so much more fun while doing all this on the 7th floor of Divyasree chambers (Sun Microsystems IEC Bangalore)

Anyways the setup procedure in VMWare turned out to be pretty straightforward. The only hiccup was when selecting the disk for the installation. You actually need to uncheck and recheck the box again and only then things go on smoothly.

I have used VMWare a couple of times before and it seems to work alright most of the times. However there is a new kid on the block called Parallels and there were these rave reviews about it some time ago. Hope I can check that out sometime soon too.

For VMWare there is this wonderful set of slides on how to go about doing this right here. So there is no reason not to be running OpenSolaris even if you can't dedicate a complete box for it. Get onto the train now!

Technorati Tags: