Astrila!

[On The Run Mix]

Subscribe

Thursday, December 26, 2002

Why VB.Net Is Better Than C#
[Warning: This blog contains programming lingo which may not be suitable for all audience]

Seven years ago, a candidate appearing for his first job interview right after school was put up with cold stare and a question: "So, what you know in C?". The candidate kept his reply short with similar cold stare: "everything". While candidate got the job very next day, the reply was unusual for interviewers because C was notorious for being deceptively complex language and it was believed that only few knew it's real innards. So for decades, for most hard-core programmers, it had been a passion to meet every challenge and master it's every intricacy. And still many of them knew it was becoming increasingly impractical to use it and compete against new RAD stuff like Delphi and VB. Even if we'd adapt to (some call it give in to") RAD which had much weaker languages, we always kept our secret hidden love for C++ in our heart and hoped that our darling would be reincarnated one day to be back with us again. When I saw C# spec in .Net beta I was thrilled. The re-incarnation was finally happened. The C# is probably the best programming language yet that is modern, sophisticated, sexy and yes, has true RAD vision behind it. For more than a year, I'd aggressively fought to choose C# in anything I was doing until I started comparing it with VB.Net from good 'ol productivity point of view. And this is really bad... VB which I thought will be dead in coming years, seems to be winning again. I'm still reluctant to give final verdict and you are invited to pour in your opinions. While
the entire book is already devoted on this subject, here's one of the most complete list of reasoning I've compiled from several sources and my observations on VB.net and C# pros and cons:


  • Direct copy paste of large amount of existing VB6 code in to your .Net projects. I did this so many times until I realized what if I'd been writing code in C#?

  • Option Strict can be turned on or off at will in VB.Net. With C# it's not in your control. This is really helpful to reduce unreadable ugly type casting when using COM interops

  • You can use either traditional On..Error or Try-Catch. With C# you only have later choice

  • With VB.Net you can have "modules" which is little cleaner then static classes.

  • Easier way to resize arrays in VB.Net and other functions like IsDbNull and exponentiation

  • More granular way to shadow methods in derived classes

  • No automatic indentation and removal of extra spaces. This slows you down plus your code looks little ugly.

  • No automatic statement completion (for example VB.Net IDE automatically completes constructs like If-Then-Else)

  • No automatic casing. How many times your compilation failed because of stupid upper case/lower case mistakes?

  • No redundant ";" after every statements. We originally loved this as C programmer but think about it: How many times you combined two statement in single line? Isn't new line enough to mark end of 99% of the statements you usually write?

  • Auto completion of "()". As usual, I love all kind of auto completions. Code must flow with speed!

  • Have to use escape sequences for "\" in XPath and file paths. This native C feature really becomes cumbersome and even worse can produce hard to find run time errors.

  • Microsoft.VisualBasic namespace provides for missing .Net functionalities like case insensitive string replace. While you can use it in C# also, it's bit natural to use in VB.Net

  • VB.Net wires events in forms transperently (you can delete the event handler without compilation error)

  • VB.Net allows optional parameters



Said that, C# also has it's own share of advantages:

  • Much powerful and flexible language constructs

  • Can do Operator overloading

  • You can use real memory pointers for performance code!

  • Lots of original Microsoft and 3rd party code will be ported to C# rather than VB.Net. For example source code for DevXpress grid and many other is available only in C#

  • Better looking type cast statements

  • Much of Java, C++ Builder and VC++ code may be re-used - but with comparitively more care and may need more changes than using VB6 code in VB.Net

  • The Shared Source CLI code is in C#

  • New language features are announced for C# but not for VB.Net

  • Multi line comments

  • C# can use native unsigned data types in .Net framework

  • Allows XML documentation of code

  • The great Using keyword in C# allows to do "deterministic finalization" in easy readable way for objects implementing IDisposible.

Five Good Books On Microsoft .Net Framework
[Warning: This blog contains programming lingo which may not be suitable for general audience]

In a programming world, to do a criticism against anything and everything Microsoft does is like putting up a fashion statement by beautiful models with their useless cloths. But after spending years in intensive computer programming, Microsoft .Net seems to be the best computer programming environment human kind can possess at this point of time. It's simply just too perfect (if you forget the stupid ".Net" name tag i.e.) converging several good stuff from lots of things that existed ranging from non-proprietary C++, rival Java, Microsoft's own VB and my old favorite Borland Delphi. I was kind of surprised at this level of perfection when I first used it and amazed at the numbers of human years that might have been spent to achieve this level of skills to do something this sophisticated flawlessly. So how do you get started? After going through details of more then 200 books, purchasing 10s of them, returning back many out of dissopointment, here's the 4 winners that has finally emerged. These books are probably all you need to learn almost everything you might need to develop advanced applications. I assume good familiarity with VB6, little more then intermediate programming experience and a desire to know low level details.

[List arranged by order of importance]

  1. Programming Microsoft Visual Basic .NET - Francesco Balena. This one is an absolute must and covers almost everything in single volume. Fun to read and goes deep in to details. This is your ideal starting point if you were a VB6 programmer.

  2. ASP.NET Unleashed - Stephen Walther. The ASP.Net is the most changed part between transition from VS6 and it's the most exciting one. This book, I've found, is the best on the subject.

  3. .NET Common Language Runtime Unleashed - Kevin R. Burton. Haven't read this one yet but it looked really cool with MSIL and other low level stuff.

  4. Compiling for the .NET Common Language Runtime - John Gough. You don't know it until you get dirty with details and this book gonna take you in real details. I bought it to understand MSIL, virtual machine, common language issues and in future to make my own compiler for RPL.

  5. Microsoft ADO.NET - David Sceppa. The ADO.Net is the center of almost any large scale app and you need to know every little thing about it. While I've included this book in the list, I must admit that this one was a disappointment when I tried to find details on some advanced level stuff I was doing for real world application. But still it clears up lots of basics on concurrency handling, typed datasets etc.


So, What's not included in above books? First, the C# language spec is not included because you better off reading it from MSDN. General tasks that you might perform every now and then are at Quickstart tutorials (the HowTo index). However, none of the books that I came across really contains good application architecture strategies that you can use in real world. For this subject, you should check out articles at DevX, Fawcette, asp411 and asp.net. This might be your best bet when it comes to putting principles in to practice.

Finally, here's the books I returned: Instant ASP.NET Applications, ASP.NET Tips & Techniques and Programming Windows with C#. Beware!

Monday, December 16, 2002

Book Find - Complications By Atul Gowande
This book I'd bought for my brother who is a doc by profession but unfortunately he has to now wait until I finish reading it. While the lingo of biological sciences usually tends to scare us, I'd always a fascination for doctor's life and this book is about it and more. The author takes you in the real stories that happened in his career as a trainee surgeon with a style that might put a fiction writer to a shame. The real beauty, however, is in the microscopic details. The philosophies involved in medical profession is embedded here with the wit and sharpness of a logician and that's another stronger side of this book. Click here to have a look.

The Better Giving
A year ago it took me around 6 months before I felt it was the perfect gift to give it to my cousins. But the trouble was that by the time they received it they got confused whether it was for last year's occasion or coming year's! It's an art to find a gift that's unique, hard to find, memorable and the one matching with person's personality and need. Here are some of those tips and places that I came across over time to help you out this holiday season.

1. The premier destination to get the unique gift idea is surprise.com. A must visit if you are still in the complete darkness.
2. Check out my collection of gift links. You will find things ranging from Kamasutra weekender kit to Astronomy's cool gift ideas.
3. To find out what's latest and coolest, check out Scientific American's Top SciTech Gifts of 2002. This one is a real good contemporary compilation.
4. If you still didn't found you were looking for, view my collection of shopping links. Specially check for Diversity Stores section.
5. Instead of giving gifts to someone who already has too much, you might want to ask them if it's ok to give some donations to non-profit organizations instead of giving them yet another gift that would be anyway useless to them. Click here for some charity organizations in my links collection.
6. Finally here are my personal favorites and non-favorites for this year: Quicktionary, Book light (both are perfect if a person is an avid reader), external hard drive (perfect for heavy laptop users because they always run out of space), handheld GPS (for outdoor person), Lego Mindstorm robot kit (absolute perfect gift for kids), DVD/MP3 players, HP49 calc (perfect for mathematicians), model air plane kit (prefer unassembled ones). And now the things that sucks as gifts: fragrances, cloths, pocket PCs and palms, organizers, CD players, pocket MP3 players, RC cars, PS2. These gifts totally suck.

Finally it's not necessary to go overboard. Infect being a follower of 'Grinch philosophy' I'm supposed to hate all give and take of gifts. May be it's just enough to send a web card with few clicks to let someone know that you still remember.