The Daily Parker

Politics, Weather, Photography, and the Dog

B is for BASIC

Blogging A to ZFor day 2 of the Blogging A-to-Z challenge, I'm going to talk about the first computer language I learned, which is still alive and kicking in the .NET universe decades after it first appeared on a MS-DOS 1.0 system disk: BASIC.

BASIC stands for "Beginner's All-Purpose Symbolic Instruction Code." The original specification came from John Kemeny and Thomas Kurtz at Dartmouth College in 1964. Today it's one of the core .NET languages included with Visual Studio as "VB.NET" (for "Visual BASIC," Microsoft's dialect of BASIC released in 1991).

Yesterday I showed you a "Hello, World" application written in C#. (You can download the source code here.)

Here's the VB.NET version:

Module Program

	Sub Main()
		Console.WriteLine("Hello, World!")
	End Sub

End Module

What's different? Well, a lot of things: no braces, no include lines, no semicolon line endings...and that's just for a 2-line program.

But look at what's the same. Because this is a .NET program, the actual guts of it look almost exactly the same. There are two calls to different methods on the Console object, and except for the missing semicolons, they are identical to the calls in C#.

Here's the IL:

.method public static void  Main() cil managed
  .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ) 
  // Code size       19 (0x13)
  .maxstack  8
  IL_0000:  nop
  IL_0001:  ldstr      "Hello, World!"
  IL_0006:  call       void [mscorlib]System.Console::WriteLine(string)
  IL_000b:  nop
  IL_000c:  call       valuetype [mscorlib]System.ConsoleKeyInfo [mscorlib]System.Console::ReadKey()
  IL_0011:  pop
  IL_0012:  ret
} // end of method Program::Main

Wow. The IL is exactly the same. So both the VB.NET and C# code compile down to functionally identical assemblies.

And that's one of the most important characteristics of .NET: it lets you write code in any language you want (as long as someone has written a compiler for it), and run it on any platform you want (as long as there's a CLR for it).

I worked with Visual BASIC from versions 1 to 6, and then did one project in VB.NET before switching to C# in 2002. You really would need to pay me a lot of money to go back to it. I believe C# is more expressive, more concise, and more able to reflect my intentions than VB.NET.

But there is nothing wrong with VB.NET. If you want to use BASIC, enjoy. With the .NET ecosystem, it's up to you.

A is for Assembly

Welcome to the Daily Parker's 2018 Blogging A-to-Z challenge!

Blogging A to ZWe're starting today with a fundamental concept in Microsoft .NET software development: the Assembly.

Microsoft defines the assembly as "a .dll or .exe file that can contain a collection of APIs that can be called by apps or other assemblies." In other words, an assembly is the basic unit of delivering .NET software to the rest of the world. An assembly "fully describe[s] and contain[s] .NET programs."

When you compile .NET source code, the compiler creates one or more of these files, each of with contains an Intermediate Language (IL) representation of your original code. You can then distribute the .dll or .exe files to any computer that has the correct version of the .NET Common Language Runtime (CLR) installed on it.

I've created a Visual Studio solution for this challenge. Today we're looking just at one small piece of it, which looks like this:

using System;

// ReSharper disable CheckNamespace
namespace InnerDrive.DailyParkerAtoZ.HelloWorld
	internal static class Program
		// ReSharper disable once UnusedParameter.Local
		private static void Main(string[] args)
			Console.WriteLine("Hello, World!");

If you're new to .NET, don't worry about all the pieces. This two-line program compiles into an assembly called HelloWorld.exe, which internally looks like this:

.method private hidebysig static void  Main(string[] args) cil managed
  // Code size       19 (0x13)
  .maxstack  8
  IL_0000:  nop
  IL_0001:  ldstr      "Hello, World!"
  IL_0006:  call       void [mscorlib]System.Console::WriteLine(string)
  IL_000b:  nop
  IL_000c:  call       valuetype [mscorlib]System.ConsoleKeyInfo [mscorlib]System.Console::ReadKey()
  IL_0011:  pop
  IL_0012:  ret
} // end of method Program::Main

Again—we're not going to get into a lot here. Suffice to say, that IL above is what actually lives in the assembly, and what the CLR will execute when you run the program. The assembly also contains a manifest, describing what it contains, and some metadata about its version, author, and whatever else the programming team has added to the assembly info file.

As with all of the topics for this year's A-to-Z challenge, I'm only scratching the surface. There is a ton more to read online and in some solid books on the market. The best information about assemblies I've found is in Jeffrey Richter's CLR via C#.

Note: the Visual Studio Solution for this challenge requires Visual Studio 2017 and the .NET Framework v4.7. ReSharper is also recommended.

April come she will

Blogging A to ZThe A-to-Z Challenge starts tomorrow, and I'm all set to go with a list of 26 topics on programming with Microsoft .NET.

Now I just need to write the actual posts.

It's interesting to me how vacations don't actually lend themselves to much productivity, even when that's the explicit purpose of the vacation.

Anyway, if I do my job today, the first post will hit at noon UTC tomorrow. If I don't do my job today, it'll hit sometime later than that.

This guy again

Longtime readers know how much I loathe Eddie Lampert, who represents to me everything that is wrong with the adolescent philosophy emitted years ago by Ayn Rand.

Well, in next month's Vanity Fair, William Cohan sits down with the child king of hedge funds and hears him out:

[Lampert's] triumphs are largely obscured by his worst mistake: the 2005 merging of Sears, the iconic retailer whose doorstop mail-order catalogue was once a fixture in nearly every American home, with the downmarket Kmart chain, which he had brought out of bankruptcy in 2003. Twelve years on, this blundering into retail has made him a poster boy for what some people think is wrong with Wall Street and, in particular, hedge funds. Under his management the number of Sears and Kmart stores nationwide has shrunk to 1,207 from 5,670 at its peak, in the 2000s, and at least 200,000 Sears and Kmart employees have been thrown out of work. The pension fund, for retired Sears employees, is underfunded by around $1.6 billion, and both Lampert and Sears are being sued for investing employees’ retirement money in Sears stock, when the top brass allegedly knew it was a terrible investment.

The vultures are circling, waiting for Lampert to throw in the towel so they can try to make money by buying Sears’s discounted debt. But Lampert continues to claim that’s not going to happen if he can help it.

Treasury secretary Steven Mnuchin “has been a shareholder and a member of the board of directors of Sears Holdings from the day that the combined company was formed [until becoming Treasury secretary], so he spent 11 years at Eddie’s side. . . . [With] all of Trump’s focus on jobs, job preservation, job creation, somebody ought to ask his secretary of the Treasury what his involvement has been for 11 years in the destruction of well over 100,000 jobs at Sears.” (A spokesman for Mnuchin declined to comment.)

Cohan treats Lampert fairly, I think. I didn't learn a lot, though. And Lampert still runs Sears, and still will find some way to make back most of the money he, personally, has invested in it. Too bad not enough of the right people think what he did to Sears and its employees is criminal.

Staycation: Day 1

Man, I've needed this for a while.

It's 11:15 on a Monday, after doing nothing of commercial or professional value for an entire weekend, and I'm finally at Inbox Zero for the first time in months.

My to-do list currently has 30 items (plus 6 already finished) ranging in complexity or duration from "set up coffee with so-and-so" to "45,000 steps." Inbox Zero was not on the main list, but my inbox is itself a to-do list, so that counts too. In a few minutes I'll have finished with the physical items on my desk that need sorting, and then...breathe in.

Meanwhile, Parker is still not putting weight on one of his legs. We'll be stopping by the vet this afternoon. His giardia has cleared up (I think; I haven't looked that closely), and despite whatever is wrong with his leg, he's happy to walk on the three that still work properly.

Also, just a little blog housekeeping: the A-to-Z Challenge starts Sunday, so over the next week I might have fewer general posts so I can get a head start on the longer posts for April.

Blogging A-to-Z Challenge Topic 2018

Blogging A to ZAs I mentioned a couple of weeks ago, The Daily Parker will participate in this year's Blogging A-to-Z Challenge. Today's the official Theme Reveal day. My topic will be: Programming Concepts using Microsoft C# .NET.

My topics will include:

  • Compilers vs Interpreters
  • Generics
  • Human factors (and errors)
  • LINQ
  • Polymorphism

...and will finish with a real-world practical example on April 30th.

I will also keep up my annoying political and Parker posts through April. And, full disclosure, many of the 26 A-to-Z posts will be technical and more involved than just linking to a Washington Post article. Because of that, and because I want a consistent publication cadence, I'm going to write them ahead of time, even if it's just the night before.

A-to-Z posts will start at noon UTC (7am Chicago time) on April 1st and continue through the 30th, with Sundays off. You can find them directly through their A-to-Z Tag. Enjoy!

1.5 Gs

As of just a few moments ago, I passed 1.5 billion seconds old.

Yes, this is a thing most people don't really think about, but as someone who works in software, this actually has some significance—and another Y2K problem that will occur just a few months before I get to 2.0 Gigaseconds (Gs) in 2038.

The problem is a thing called the Unix epoch. Computers can only count as high as they have bits to count. Unix computers, which include Macs and most of the infrastructure of the Internet, count time in seconds from 1 January 1970 00:00 UTC, which was (at the moment I'm typing this) 1,521,383,994 seconds ago.

Everyone knows computers can count to awesomely huge numbers. But you need to give them enough bits to do that. Unix time is measured by a 32-bit number, which can count up to 232-1, or 4,294,967,295 (in binary, a 32-item string of 1s), which is enough seconds to count just over 136 years.

But you sometimes want to measure things that happened in the past, so Unix time takes the first bit of the 32-bit number and makes it a sign. If the first bit is 0, the time is in the present. If it's 1, the time is the number of seconds before the beginning of the epoch. So this cuts the measurable period in half, to 68 years. Specifically, Unix time rolls over at 3:14:08 on 19 January 2038.

The fix is simply to use a bigger number. Today, 64-bit numbers are no big deal, and they give you 263-1 (9,223,372,036,854,775,807) seconds to work with in either direction. That's roughly 292 billion years, which is sufficient to measure most human-scale activities.

So, knowing all this, and knowing that I was born in the first year of the Unix epoch, it wasn't difficult to figure out my "epoch" birth moment at 9:12 CDT this morning.

But there's a catch. As I mentioned, computers count by 2s, not by 10s, so this entire post is a lie. I'm not 1.5 Gs old; I'm just over 1,500,000,000 seconds old. 1.5 x 230 (i.e., 1.5 giga anything) is 1,610,612,736, so I won't be 1.5 Gs old until Unix moment 1,631,995,056, which will be 18 September 2021 at 19:57:36 UTC.

So check back in three and a half years. I'm sure I'll have another post about this nonsense then.

(For those of you keeping score at home, I was 1.0 Gs old on 13 September 2004 at 20:09:04 CDT, during a lull in blogging. Else I'm sure I would have mentioned this then.)

Ides of March reading list

I'm writing a response to an RFP today, so I'll have to read these when I get a chance:

There were two more stories in my inbox this morning, but they deserve their own post after lunch.

Function following forms

Designer Josh Gee spent two years trying to put Boston city government forms online:

Getting city workers to accept online submissions rather than traditional paper ones is the bulk of this work. On average, it took me about 30 minutes to make a digital form and five weeks to meet with, earn the trust of, and get buy-in from the employees who would use it. Even if they were excited, the nitty gritty details took a lot of back and forth.

While I avoided a bunch of process change, there were some takeaways that I think are useful for anyone working to move government forms online:

  • There is huge demand to move forms online — I had expected to drag departments online kicking and screaming. Instead, the majority of departments were eager to move things online and thrilled to have a partner with the technical knowledge, mandate, and tools to do that.
  • Flexibility about form structure and questions — I initially thought there would be a strong demand for submissions that look exactly like current paper forms. That hasn’t been the case. In all but one or two cases, I was not only able to move forms online, but also suggest changes that made forms shorter, more clear, and more accessible.
  • Excited about future change — Early on I began to notice a pattern. A few weeks after I moved a form online, some departments would to reach back out and ask for tools to help them manage digital submission, “This has been absolutely amazing. It would be great if I could approve it and then send it to Steve for his signature”. I thought a lot about the phrase salami slicing. If I tried to change everything about the way these departments worked right off the bat, they would have resisted every step of the way. Moving just a part of their workflow online made them eager to go completely digital.

This is close to home as my company is right now engaged in an effort to do this sort of thing for the U.S. Military Enrollment Processing Command. It's not easy.

Mid-week link roundup

Lots of things popped up in my browser today:

And now, back to work.