Writing standalone GUI applications with Visual Basic.NET is easy. What isn’t so easy is using a VB.NET application to modify the behavior of some other running application. If the other application happens to be MS Word, MS Excel, or MS Access, you can use Visual Basic for Applications (VBA). Otherwise, unless the other application exposes it’s own API, you’re typically stuck trying to use so-called “hooks“, which will quickly get you under the hood of the Windows OS to a depth where, trust me, you don’t want to go unless you’re prepared to spend a lot of time poring over Microsoft’s incomprehensible documentation trying to figure out how to build something that won’t ever work quite right no matter what you do, and will have a high likelihood of not working at all after the next Windows update. More »

Most folks who use computers a lot are aware of the difference between word processors and text editors. Text editors represent the data as pure characters — no formatting, no margins, no bold or italic.  The better text editors (Notepad++ is my current favorite) have lots of useful features, and typically can handle Unicode and Asian fonts, but when you save a document, what you’re really saving is a long list of binary numbers, each representing one character, and that’s all.  Word processors are different: in addition to the encoded characters, there are codes to indicate formatting, rendering of non-text elements like images or equations, and lots of other things that you usually can’t decipher because saved documents are compressed using proprietary algorithms. Open a MS Word doc as text, you get gibberish.

It’s often useful to be able to write programs that manipulate text. Python is ideal for applications that only need to read a text file, process it, and write it back out. But if the user needs to be able to interact with the program, it’s usually desirable to have a graphical interface, so Visual Basic.NET is the environment of choice. Among the available GUI controls, VB.NET does provide text boxes, which are adequate for displaying and editing pure text, but what if you need to be able to display more than just plain text? For example, what if you want to be able to highlight words found in a search? There is a solution: VB.NET also provides  a RichTextBox control that displays rtf format, which supports most common formatting and allows images. The downside: the RichTextBox control is  very finicky and hard to use. So I finally wrote a kind of wrapper for it which implements a lot of the functionality that you would think they would have built into RichTextBox but didn’t. I have posted the code on github here, together with a Windows installer for a simple word processing app based on it. In a future post I will describe a useful note-taking app that I built on top of it. More »

Back when I was teaching Java programming, I wrote a demo program that involved balls moving around and colliding with each other in a box. It was designed as a game, inspired by “Maxwell’s demon“; the box was divided into two parts by a barrier, and the barrier had a gate that the player could open or close, the objective being to try to get all the balls into one compartment. The balls would bounce around, and the idea was to operate the gate so as to let balls through in one direction but block them from getting back out. Needless to say, it did not turn out to be the next Angry Birds. It was written as a Java applet, and, as I have grumbled about elsewhere, the fine folks at Oracle have essentially killed applets dead, breaking zillions of web apps in the process, so I can’t post  a working version, at least not in that form. However, I have coded up a modified version, converted to javascript and running in a web page, here. This version is not a game, it’s a simulation of particles of gas in a box, for the purpose of trying to get a feel for some basic principles of thermodynamics.

The motivation for this simulation (apart from a continuing effort to get more comfortable writing javascript apps) relates to another “hobby” of mine, which is trying to fill some gaps in my grasp of basic physics. Meaning, in this case, the Maxwell-Boltzmann distribution, which (to oversimplify a bit) gives the breakdown of speeds of individual particles in a gas. To understand how this works, suppose you measured the speed of each of 1000 cars on the freeway. Then you could count how many are going between 45 and 50 kph, how many between 50 and 55 kph, and so on, and you could plot the results as a histogram. That’s what a Maxwell-Boltzmann distribution gives you — it’s for molecules of gas bouncing around in a box instead of cars on the freeway, but it’s exactly the same idea.

More »

I rewrote the math game that I posted a week or so ago, in javascript. The javascript version runs in any reasonably up to date web browser, which has several advantages:

  1. It avoids the deployment hassles described in my previous post.
  2. An end user can run the game simply by going to a web page and clicking the ‘Start’ button — no local installation is required. This is important, I think. Many users are quite hesitant to install programs from sources that are not big companies like Microsoft or Apple. For Windows users the risk is more theoretical than real, in my opinion, assuming they have Microsoft Security Essentials installed and working, and assuming they aren’t installing programs from links on Estonian porn sites. But whatever one may think of the risk, it’s a fact that the harder you make it for a user to try a program, the less likely they are to do it.
  3. The updating problem goes away — all the developer has to do to fix a bug is fix the code on the server. The program gets reloaded every time the user reloads the page, so updating is automatic.
  4. It makes the program accessible to a much wider range of devices. The VB.NET version from my previous post can only run in a .NET environment, which, as a practical matter, means Windows. (Yes, I know, Mono, etc., I’m a big fan, but realistically, for most users, .NET means Windows.) Whereas javascript will run on any device that supports a browser — Windows, Apple, Linux, Android, tablets, phones, and whatever next year’s new must-have platform is.
  5. It’s better suited for apps that need to interact with a server.

There are also a few disadvantages: More »

It may be a Law Of Nature regarding the evolution of software that every popular software tool eventually increases in complexity until it becomes so complicated to use that the only users who can deal with it effectively are those who use it as a full time job. In fairness, that’s in large part because they’ve evolved to do some very complicated things, but it does have the effect of squeezing the amateur out of the game.

I have been a huge fan of Microsoft Visual Basic, once it became a full-fledged language under .NET. I have written many thousands of lines of code in a variety of programming languages, and taught college level CS-1 courses in five of them (C, C++, Java, Visual Basic, and Perl). Of those five, Visual Basic (in my experience at least) is by far the easiest learning curve for students. And for any program requiring a GUI, Visual Basic is by far the quickest of the five for getting a working prototype up and running, and always my first choice (Python would be first choice if all I need is a console program). Microsoft has made things even better by opening up the full, non-crippled version of Visual Studio 2013 for free.

There is, however, one aspect of the Visual Studio experience that hasn’t improved, in my opinion — in fact it’s gotten worse. And it’s a big enough issue that I’m probably going to hold my nose and switch to single page javascript apps as my go-to platform for quick and dirty GUI programs. I’m referring to the problem of deployment.

More »

This post is about a simple children’s math game that I coded, which anyone interested is welcome to download. I’ll get to that momentarily; first a word about why it seemed worth doing.

One of the most glaring failures of public education is its inability to impart even basic math skills. There is a reason why we don’t succeed in teaching math: it’s impossible, the way we try to do it. All the children in a class in school are expected to do the same assignments, in the same book, in the same order, at the same time. When the book moves on to the next topic, every child in the class has to move on, whether he or she has mastered the current topic or not.

That doesn’t work at all with math because math builds on what has already (supposedly) been learned. You can’t successfully teach a math topic to a child who hasn’t already mastered all the basic skills that led up to it. If a child is weak on even one of the previously covered skills, he or she will flounder, most likely from then on. In elementary math, if you want a child to succeed, you do not move on to topic N + 1 until the child can execute topic N, consistently, quickly, with no false moves, and no mistakes. You don’t have to take my word for that — precisely that concept is the foundation of the only truly effective children’s math curriculum I’m aware of — the highly successful (and expensive) Kumon Math after school tutoring program.

Our two nephews who live with us (ages 9 and 14) go to a private (Catholic) school here in Davao (Philippines). Both are bright kids; both struggle with math. They get passing grades, but that’s mainly because schools find ways to let kids get passing grades without actually being able to do math. If they didn’t do that, everyone would be stuck repeating fourth grade forever, since, as already noted, it isn’t possible to learn math this way. More »

I don’t know much about global climate science. I’ve read a few papers and listened to a few lectures, but it’s not something I’ve ever studied in enough depth to have any business commenting on.

I do know a bit about computational modeling, though, and I also have some experience with argumentative overreaching (having spent 20 years as a litigator).

It’s fairly easy to fool oneself with computational models. Models have parameters that have to be “tuned” to fit the data, and given enough parameters (it doesn’t take very many) you can make a model fit just about anything.

In fact, I would go so far as to offer the following conjecture:

Conjecture: For any model of a complex system where a set of parameters determines the fit of the model to training data and the model generates a binary prediction A, there exists an alternative set of equivalently plausible parameter values that produces no worse fit to the training data and generates the opposite prediction (i.e. ‘not A’).

More »

In the continuing saga of me trying to bludgeon WordPress into doing what I want it to, I took a shot at coding a simple widget. You can see it there on the right — it shows the local time here in Davao, Philippines, and a quote taken at random from a text file.

Widgets, for the uninitiated, are separate programs that “plug in” to (in this case) a WordPress page. There are thousands of WordPress widgets out there, and most of the ones you see on blogs are “canned” widgets — you just download them, drag/drop them onto your page, perhaps specify a setting or two.

Or, you can write your own. It isn’t difficult, but it does require some basic familiarity with at least PHP and preferably also javascript. More »

Often when reading a patent the focus is not so much on what the patent says, it’s on being sure about what it doesn’t say. If an examiner has cited a patent as prior art, and you want to argue that it’s different from the claimed invention because the claimed invention includes some feature that the cited reference doesn’t disclose, you need to satisfy yourself that the feature is not in the cited reference anywhere.

That can be a very tedious undertaking. The particular reference that finally overcame my inertia and got me to scribble up the python script that is the subject of this post is a patent application, cited as a prior art reference in an office action in one of my cases, that is 76 pages of two-column fine print.  No way does the client want to pay me for the hours it would take to read it in detail. More »

I finally bit the bullet and set up a WordPress blog, having been reluctantly convinced that the ease of posting more than compensates for the disadvantages, which in my opinion are many, but I won’t go into them here, except to the extent that some of them are apparent from what follows.

I figured that I would start by moving a few older posts from my old blog.

Back when I was still teaching Java, I wrote a simple applet demo program that computed and displayed the evolution of one-dimensional cellular automata, using the 8-bit rule scheme described by Stephen Wolfram in A New Kind Of ScienceI described it in a blog post at the time, with a link to the Java source code and the applet running embedded at the end of the post.

Java applets were never a very satisfactory way of embedding functionality into a web page. There were always just too many ways for them to not work in a particular browser running a particular version of Java.

Now, however, it seems Oracle has raised its game — now applets don’t work in any browser. I discovered this when I went back to the original post and found that instead of the applet, what appears is a message that “Your security settings have blocked an untrusted application from running.” More »