Tuesday, February 23, 2010

Yahoo Mail: Classic versus Ajax

Yahoo not only provides search and email, it also offers a ton of developer tools.
Unfortunately Yahoo is often it is eclipsed by Google. Yahoo tools are very worth exploring: http://developer.yahoo.com/everything.html.

One particular useful set of library is the Yahoo UI: a javascript libary. Though it takes a bit to get used to the javascripts but it can get you results quickly.
Need a widget like dialog, menu, calendar or tree? Just go to example, view in new window, View Source and voila. Nicely documented (unlike things like dojo)

For a full demo of what Yahoo UI can do: go to the All-New Mail in Yahoo.
Ooh, the tabs, the ajax involved, etc. etc. Of course, LEARN the BACK button won't work because you're using AJAX.

Ok, here is a problem. Why something happens in AJAX, like when I reply a mail. Boom. light-blue <DIV> tag of death. Come on.
Classic view doesn't have this problem. I don't have problem with refreshing the whole page in classic way.

If one day I must use yahoo all-new mail and it gives me light-blue DIV of death again,I must dump you, yahoo.

Tuesday, February 16, 2010

For-Each and For Every

Year of the Tiger is here. I suddenly remember Java 1.5 has code name of Tiger.
Well, 1.5 is long while ago in the past (1.7 is coming soon). Of course, Sun codename does not follow the Chinese Zodiac.

One feature of 1.5 is the for-each loop, which dares to challege the "thou must have two semicolons in the for loop" dictated by C. Other language (such as C#) defines the keyword foreach. Well, C's for loop is "syntactic sugar" for the while loop. Now it is a different story. Note Sun's example. It is merely trying to confuse you by coding a while loop in the for-loop.
I never confuse myself and my code readers with ugly for loops. I only use for-loop when I need to loop something a specific number of times.

Instead of a for-loop, I would code a straight forward while loop.
Iterator i = i.iterator();
while (i.hasNext()) {
TimerTask t = i.next();
t.cancel();
}

and I always put {} around my blocks, even if there is only one statement.

The foreach loop reminds me of the "univeral quantification" in math, the upside down A, meaning "for every".

Monday, February 15, 2010

Fax is still alive

Oh, the fax industry is still alive. News says.

Well it is internet fax. I don't have need for a fax machine, I rarely ever need to fax. Even my very old computer can send a fax via the lowly modem and phone line. Go to your local office store you aren't going to find many fax machine models. Gone are the smooth fax papers. If you really need a fax machine get a laser one.

In my old work place, my phone number may be 1 digit away from a fax machine. Sometimes when it rings, I am greeted with BEEP BEEP BEEP GRRRA (sound of modem and fax). I reply with "dammit I am not a fax machine!" but the fax sender doesn't know.

No More Anonymous Comments

This blog originally allows anonymous comments--anyone can write feedback. In general, any writers/bloggers welcome feedbacks. Unfortunately if you allow anonymous comment, evil spiders and program can come in and automatically inject comments with links to unwanted things and fake pills that some are too embarassed to buy.

People can still program bad messages, I just made it not as easy by turning off anonymous comments.

Thursday, February 11, 2010

C++ revisited

In the old days there was C. Yes, it has just-a-little-arcane syntax such as && and ||.
One obstacle for many students is that you have to deal with the address of variables a lot because there is no pass-by-reference, such as scanf("%d",&i);
Forget the ampersand? instant "segmentation fault" or "general protection fault", you may even get a freeze up.

The fashion item of those days were C++ and OOP. My college professors themselves were new to C++ && they are making a living teaching it. Everybody embraces the ultra boring "The C++ Programming Language" by Bjarne Stroutroup. Thanks to K&R, the trend for any new language is a book named "The Whatever Programming Language".

"+" is a symbol that operating system reserves (so you can't use it as filename). So the file extension is usually CPP (which some people may confuse with the C Pre Processor). I have also seen CXX. You gotta tilt your head 45 degrees to see the +. Just the // comment itself makes it "a better C". Ah, objects are made with adding methods to structs, label it public, private and call it a class! Waita minute, there IS a difference between structs and classes (and students ought to know).

My first complain of C++ was dumping the good old stdio's printf with cout and the wacky stream operator <<. I hate this stupid syntax. Also, pointers are already confusing, and adding reference type with that ampersand doesn't help. Copy constructors are quite ugly if you ask me.

They NEED to learn algorithms and stuff, not objects in the beginning.

The power of C++ (and OOP) comes in when you are using other people's objects!

Someone programmed a windowing form? boom. subclass it you got yourself a form (theoretically)
Someone wrote some useful classes? You can just the methods within. A good string class is God-sent relief for C programmers.

Inheritance is of course important concept of OOP, but if you let people do multiple inheritance, people WILL go wild and descend from 10 parents (no kidding, I've SEEN such thing)

However, C++ then unbearably evolved. See C++ 0x. Templates are yucky. I love Java's solution with descending everything from Object but yikes, people WANT templates (generics) in java too. STL is for those who don't have enough of angle brackets. I still don't understand why take out the .h in #include statements. Now there are all sorts of keywords and syntactical things that I can't comprehend easily.

Ah, lamda from the functional programming world is now in C++.
OMG, now there is [[base_check]] and [[override]] attributes?
This is getting unbelievably complex (and ugly).

C++ can grow as complex as Stroutroup want, but compilers may not support it, especially Microsoft's compilers.

The programming world is so relieved with Java, grew out of frustration of C++.
In the programming world, if you are frustrated you can create something new. You don't have to conform.
Languages need to be SIMPLE to be effective.

Tuesday, February 9, 2010

Funny Newbie Post

So I am just googling around programming sites and saw this funny newbie question post Help with hello world, I keep getting error!! .

Help with hello world, I keep getting error!!
Heres the code I put in....


int main()
{
cout << "Hello people and world"; end1;
cout << "I want to be a programmer"; end1;
cin.get()
}

In the error it is saying it needs a ";" after < in iostream


I go ROTFL.

First, where are those #include? Then this person is a victim of fonts. It is not end-one, it is endl, that is, the lowercase letter l, meaning end-of-line. I myself has been bitten by l vs 1 before. But that's not so funny yet.

Ok newbie programmer, what do you think or want end1 will do for you? It is a character (Read your book!) and you want to pipe it to cout like your strings. So pipe it with cout << "Hello people and world " << endl;

That cin is to read a variable, should you pipe it to something?
You probably want the good old getchar() to read a key.

Happy Programming.

Monday, February 8, 2010

《 超級巨聲 》沉寂終結

I agree so much with this author.

This is a half year long music talent contest. A bit too long. I am amazed with the talents of most of the contestants. Maybe 3 months is good enough.

However the rules of game changes on the fly, especially bad when inserting contestants from outside Hong Kong.

After the contest, who gives them a platform to sing? Given the bad music economy when people simply download and never buy anything, these very talented contestants better think other main careers.

Thursday, February 4, 2010

Sad about Toyota

I am saddened by all the Toyota problems. New problem: Prius brakes.

I loved the Corolla: gas saving, sleek design. I like the RAV4: nice looking SUV (better looking than the CRV or others). Prius: the hybrid that helps save the earth.

This is just very unfortunate.

One problem can destroy decades of reputation. Like one wrong chess move ruins your game.

Tuesday, February 2, 2010

Book of Jobs

The Economists magazine features Steve Job and his iPad.

Ok, from the cover, obviously these Economist guys confuse Job with Moses. Job was the extreme unfortunate guy in the Bible who lost everything and had done no wrong.
Moses was the guy who got the tablets containing the 10 commandments.
As far as I know halos are never mentioned in the Bible.

I never share enthusiasm with Mac products. Macintosh: How do you eject that disk? drag it to the garbage can? My head is continously smacked by exploding rectangles directed at my head.
IPod: can *I* control which song to download? ITunes will download everything from my music. IPod, ITouch, IPad: no one ever thought about covering it? How about a flap or something.

Ok I haven't played with an iPad yet. I'll let you know if I like it if I get my hands on it. Finally people have something like what people imagined in Star Trek long ago. If I can't type fast on it without a keyboard, it is a video player (or a digital photo frame)