# Thursday, February 28, 2008

It is sometimes said that the reason Soviet Union has produced so many outstanding scientists is that a lot of attention was being paid to introducing kids to science early and in a way that kept them interested. Indeed, a large amount of popular science books has been printed over the years as well as translations made of the best ones offered in the rest of the world. Martin Gardner and Richard Feinman, absolutely fascinating Robert Wood biography, Smullyan, Soviet authors Perelman and Makovetsky - all of those made me fall in love with physics, mathematics, mechanics, chemistry as a kid. And of course these books were fairly accurate as they were either authored or reviewed by respected professionals.

Times change and these days people find that you cannot blindly trust books you buy. Quite recently a very lively discussion took place in one of the LiveJournal communities (very popular in Russia). It was about a book recently printed in Moscow called "Unabridged Encyclopedia of Astronomy". The book that contains 25000 articles, has many entries that make even a casual student of science do a doubletake (some of it could be explained by the fact that the entire author team somehow did not have a single specialist in astronomy or even general physics among them).

Here are some gems (translated from original Russian as closely as possible)

"Gravitational waves - are emitted by electrical charge oscillating in space"

"Barnard star - a stationary star with visual magnitude of 9.5m... Known for being fast-moving..."

"Visible radiation - radiation that is not only visible to the naked eye, but to the special astronomical equipment and devices..."

"Visible light - light being radiated by a heated body..."

"Escape velocity - [is] defined as speed required for a man-made satellite to reach the Earth orbit. Equals 12km/s"

"Galactic Cannibalism (Extragalactic Astronomy) - a part of Astronomy dealing with celestial bodies (stars, galaxies, quasars etc) that exist outside our Galaxy"

"Ultraviolet radiation - radiation emitted by the Sun and stars"

"Interference - wave oscillation produced by the light source generates so called spherical wave fronts"

"Polar Star - the main star L of Ursa Minor constellation and the brightest star of the northern hemisphere"

"Rigel - the brightest star in the constellation of Orion and in the entire sky"

"Lynx - one of the constellations of the southern hemisphere"

"Triton - a constellation discovered by Lassell in 1846. It's mass is calculated at 2.14x10^22 kg"

The next one is tricky. It makes no sense at all in Russian, so be prepared for the same in English translation.

"Phase angle - an angle situated at a distance from the Sun to the Moon as well as from the Moon to the Earth"

"Fundamental Astronomy - modern physical-mathematical discipline growing interdependent with advances in science and technology"

Fortunately, some astute readers (one of them employed by Moscow planetarium - must know her astronomy, eh?) were able to spot it and raise some ruckus. As they were not able to get any response from the publisher, someone suggested to make a formal complaint to the russian authorities, invoking Consumer Protection Act. We'll see how it goes.

Life | Rant | Science
Thursday, February 28, 2008 3:22:35 AM (Pacific Standard Time, UTC-08:00)  #    Comments [3]  | 
# Monday, October 02, 2006

I have a lot of respect for MSDN technical articles. They are more often than not a source of knowledge one would be hard pressed to obtain from official documentation. Kraig Brockschmidt's treatise on OLE internals, Nancy Winnick Clutz explanation of TAPI, Icon internals by John Hornick - all of these are precious gems of knowledge. Heck, I even wrote a few myself. Over the years there were some that are brilliant and concise, other that were less interesting. Almost every article there had some code posted with it. The code samples would also vary in quality, but not so much as to raise an eyebrow.

On several occasions I had this conversation with my teenage daughter, the gist of which was that even though the Algebra lesson is not an English lesson, it does not mean she can disregard the grammar completely, while doing her math homework. Apparently it was not obvious to her, that writing properly is not something you do only when you absolutely have to. Similarly, I suppose when you write code, even throwaway code, you should still be conscious of how you do it.

When I first came across this, my first reaction was - this is good stuff. It'll teach developers not to use an old, outdated control and show, how to replace it with alternative modern controls. And then I saw the following gem:

If you must search compiled code, you can look certain patterns that represent the GUIDs. For example, the following GUID:

{ABCDEFGH-IJKL-MNOP-QRST-UVWXYZ012345}

becomes the following hexadecimal sequence in binary:

GH EF CD AB KL IJ OP MN QR ST UV WX YZ 01 23 45

 

Er, what hexadecimal sequence?
But following it was a code sample

// Compile and execute:  "FindGUIDs YourApplication.exe"
using System;
using System.Text;
using System.IO;

namespace FindGUIDs {
class Program {
  static void Main(string[] args) {
    FileStream    fs = File.OpenRead(args[0]);
    StringBuilder sb = new StringBuilder();
    do {
      Int32 b = fs.ReadByte();
      if (-1 == b) {
        break;
      }
      sb.AppendFormat("{0:X2}", b);
    } while (true);
    fs.Close();
    String s = sb.ToString();
    if (s.Contains("E0A58D4371F1D011984E0000F80270F8"))
      Console.Out.WriteLine("GUID for TriEditDocument Class detected.");
    if (s.Contains("DFA58D4371F1D011984E0000F80270F8")) {
      Console.Out.WriteLine(
        "GUID for ITriEditDocument Interface detected.");
      }
      if (s.Contains("0002362DF5FFd1118D0300A0C959BC0A")) {
        Console.Out.WriteLine("GUID for DHTMLEdit Class detected.");
      }
      if (s.Contains("91B504CE1F2Bd2118D1E00A0C959BC0A")) {
        Console.Out.WriteLine("GUID for IDHTMLEdit Interface detected.");
      }
    }
  }
}

Basically, what's happening here is that the application is trying to find occurences of a GUID in a binary file. I've seen many approaches to searching a binary string in a file. Some were simpler to implement, the other are more efficient, but harder to understand. This one takes the cake. In a nutshell, this code reads a binary file, byte by byte, and converts each byte into its string hexadecimal represenation. Then this string is appended to a StringBuilder. Once the entire file is loaded into StringBuilder (consuming filesize * 4 bytes of memory), the StringBuilder is used to produce a string (another memory allocation of the same size edited: no, this is actually done in place. Thanks, Dunkan!) and the string is being searched for a GUID substring.

I won't even go into the efficiency of string search as used above. My point is that you either do things right, or you sidestep the whole issue by not providing the code sample (not really needed in the context of this article) and leaving it as an excercise for the reader.

Some screens later in the article we find the following gem of regular expression (JScript, searching an HTML document for tag):

var rex = new RegExp("]*>", "i");

Er, what happened to the non-greedy qualifiers? What is that \s doing inside []? This feels like something written by a person, who does not use javascript day-to-day.

Please, please let's keep MSDN technical library standards high. After all we all benefit from better written code.

Monday, October 02, 2006 1:23:53 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [3]  | 
# Thursday, October 27, 2005

In what is widely regarded as a shrewd move a popular low-cost brokerage firm Charles Schwab started a new advertising campaign clamoring for customers to “Talk to Chuck”. I think not. This is if you ask me a clear case of sheer idiocy. “Charles Schwab” sounded respectable, somewhat European. Now, why would I want to have a broker whose name is Chuck? Why not Billy Bob?

In entirely unrelated news: a popular low-cost chain of kiddie restaurants in an attempt to bolster its image has renamed itself to “Charles E. Cheese”

Thursday, October 27, 2005 11:58:24 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]  | 
# Wednesday, October 12, 2005

I've been reading about the new Microsoft Streets and Trips 2006 and came across a feature comparison chart

This reminded me of one of the reasons why I dislike marketing people. Here are 10 rules “How to create a favorable comparison chart“

  1. Pick your competition wisely. If possible, compare to unrelated products
    or products marketed for a different niche
  2. Try limiting your comparison to only those features that exist in your
    product. Never mind the competition has something that you don't - you are
    playing on the home field and you are setting the rules.
  3. Never hesitate to use meaningless "features" as sales points. "Only our
    product is built on the powerful XYZ technology". So if the competitor used ZYX
    technology, that's his problem. We are not here to discuss whose technology
    is better. Suffice it to say that they did not use ours.
  4. Be charitable. If you can throw in a few features that exist in all
    competing products do it, but do it sparingly. You are not going to look
    good if there are too many of those.
  5. "New!" next to the feature description works very well. It is especially
    good when done in red bold font with a little star ornament. And no, you do
    not have to explain that "new" refers to something that is new to this
    release of *your* product, even if competition had it for ages.
  6. It really helps to compare your almost released product to competitor's
    last year release even if they just announced a new version. After all you
    haven't seen it - it may very well not exist. Remember, other people create
    vaporware - we have bold plans and imminent upcoming releases.
  7. If you can't think of 10 rules, make it 6.
Wednesday, October 12, 2005 5:55:39 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]  | 
# Friday, July 01, 2005
Looking at the flash animation - "How it works" for Verizon in-home fiber-optic internet service... They offer speeds up to 30Mbps down/5 up
At some point they go to explain why is their service so fast (compared to traditional broadband providers). Apparently it is because "the light travels so quickly". Of course! Silly me. I totally forgot that an average speed of an electron in a copper wire is about 1.5 mm/s. That explains my sluggish internet connection.
 
On a related note. SBC at some point announced the plans to deploy fiber connectivity option to the consumers. The deployment project was called "Project Lightspeed". Catchy... Then they announced plans to accelerate the deployment (after FCC lifted some restrictions). Ars Technica suggests that the project should be now named "Project FTL"
Computers | Life | Rant
Friday, July 01, 2005 4:20:32 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [27]  | 
# Wednesday, March 09, 2005

Preface:
===========================
The President: C'mon, let me nuke that bastard.
Commander Gilmour: Are you suggesting that we blow up the moon?
The President: Would you miss it?
[looks around the table]
The President: Would you miss it?
============================ [Austin Powers, The Spy, Who Shagged Me] =========

The programming world has its panties in uproar. In just over two weeks Microsoft ends the support cycle of the VB6 and VBA products. A group of MVPs has initiated a petition asking Microsoft to stop this insanity. Not only they want for MS to rescind the end-of-support decision, but they actually demand continued development and, unbelievably, integration of VB6 into Visual Studio product alongside with .NET languages. I probably would not be able to state my opinion on this better than Geoff Appleby did, so I'll just say nothing. Except of maybe this.

What support? The VB6 support has been lately done by the MVPs - the people who have drafted and  signed the aforementioned petition. They are absolutely free to continue to do so. The future security patches will necessarily cover the VB components. But no new development (see preface).

I am not a VB-hater (does such category even exist?). But I know from my own newsgroup support experience the amount of harm a loose, poorly structured language like VB brings. I wrote my share of VB6 code and the company I work for uses it extensively, but I moved on and the company is moving on. Hey, I love my car, but I realize one day I will have to buy a new car.

Get over it. And learn some new tricks along the way. World does not stand in place. It moves along.

Wednesday, March 09, 2005 11:14:57 PM (Pacific Standard Time, UTC-08:00)  #    Comments [26]  |