Monday, December 14, 2009

Wacky C#: the ?? operator

The "??" is an operator. Yuck. Ugly syntax. What is in the mind of the designers??
See here for details.

Sure it doesn't encourage readable code. It IS ok to use an if statement for more readable code, or use the good old "?:". I can comprehend 1 question mark, but not multiple.

You decide which is more readable
1. foo ?? bar
2. (foo == null) ? bar : foo
3. (foo != null) ? foo : bar

Thursday, December 10, 2009

"var" ought to stay in Javacript and Pascal

Strongly typed language is an evolution step forward. Ok, in reality, there is only ONE type: bits and bytes. See, it is abstraction that makes programming easier. In there beginning there are number type, then string type aand of course now structs and all sorts of classes that built upon strong types.

Perhaps a decade ago there is COM in Microsoft thing and all these variant types, types are no longer so explicit. Yuck.

Look at this thing in C#. The implicit variable declaration var. C# stole this from javascript! Look, javascript is a script, intended just to add some power to plain o HTML. It is ok to have weaker types there.

"var" is of course the variable declaration section of Pascal. VB stole so many things from Pascal.
For example, Dim i as integer looks just like var i: integer?

I see 0 advantage of the "var".

C# has even more fun construct: the lambda.

Wednesday, December 9, 2009

Documentation: Javadoc vs MSDN

Javadoc was the revolutionary documentation tool that Sun themselves used to generate documentation for its API. Brilliant idea of the comment /** */ that anybody can use to generate their own documentation.

Ok, later on that annotation thing @ got into java and alas annotation has got into the language and (polluted the simplicity of Java since 1.5.

On the Microsoft programming world there is MSDN. Sure MSDN, contains a lot of info but it is inferior compared to javadoc in presentation quality. Javadoc is so clear about what's in a package, and what are the fields, methods of a particular class.
MSDN has that too but isn't so clearly layed out. (Javadoc wins)

Most of MSDN has sample code too, but yikes, sometimes those are too long and too complex to demonstrate a concept, sometimes the sample code is incomplete, formatted incorrectly and just too big too wild.

Ok, java API lacks sample code, but you can almost google any Java thing in question for an example.

When Microsoft copies Java into C# how come it doesn't copy this useful feature?

* * *

Waita minute, C# actually can generate documentation, but not good old HTML but XML.
(Did I say how much I hate XML?)

Here is the MSDN documentation. Some of the links on this page are BROKEN!
Look for /doc for documentation generation.

The world's biggest software monopoly can't even maintain its own documentations.

Monday, December 7, 2009

杯水車薪

Here is a good use of "杯水車薪", in a news item about the climate summit. Who is going to give up profit for good of mankind? Will such meetings ever accomplish anything. Even if the president signs something is it really going to help the environment?

A carload is on fire, and you got 1 cup of water.

The world can only be saved if people are financially motivated to reduce CO2. How? reward industry with $ for improvement? If I know I would be the speaker a the conference.

I live near a park and in there. Once upon a time, there was a recycle bin. I dump used plastic bottles in there. Whoa! One day it is gone! I am now forced to dump it as regular trash. Who stole it?! Should I ask Daley to give the park another one?

My (new) workplace has such bins, but whoa! people put regular trash in there too! HOW DARE. If I am the office manager I FIRE anyone who misuses recycle bins.

Tuesday, December 1, 2009

Want to attend Harvard?

I saw this ad on the CTA:



That lady in traditional clothing seems to be learning computer graphics on C++. That cout thing... that matrix, and the wording that says "digital media art."

cout is a unique beast of C++. No other languages have this << pipe thing. printf of C makes a comeback in the latest Java.
cout writes to the console. The computer class this lady is taking is a toy class that teaches you basic things but charges you hefty tuition. Graphics apps ought to jump out of that console.... In a semester or two, your school (even Harvard) isn't going to teach you some Windows API or Unix graphical environment API to draw cool things, but merely teach you some theories. Matrices is such important tool for computer graphics.

To most people, computer graphics means rocking great things you see in movies. Schools in a semester or two can't teach you that. It can teach you foundations such as turning 3D into 2D and that mathematics is too tough for most people. Bezier curves, I am sure, will scare the daylight out of most people.

Another meaning of computer graphics is able to tweak pictures with difficult-to-use programs such as Photoshop. I suppose the guys who tweak with photoshop does not need to know the math behind Bezier curves.

So is it a rewarding experience to take a class or two in software engineering and computer graphics? yes.

Are you going to find computer graphics work just by knowledge obtained in the classes? no.

Computer graphics work (there are almost non-existent) means very good art skills and able to use those that professional graphics memory-hog software. It means ultra smart programmers who are much better than the average guy doing database and simple web programming.

That matrix stuff are very interesting math topics, however, modern computer graphics engines such as OpenGL actually does all that work for you and your less math capable classmates don't have to know any of that.