Freigeben über


A Case for Insensitivity

This is Day 6 of 30 Days of Small Basic Part 1.

As with all great things, there is a pun afoot! (No the pun is not a foot.) You see, this topic is about Case Insensitivity and about a Case for Case Insensitivity. Thus, it’s punny! (But not funny.)

Case Insensitivity is when a programming language or other software does not care whether you’re using capital letters or not. Case Sensitive is the opposite… you better be using the correct capitalization or else it’s not going to work.

Examples of Case Sensitivity

  1. Passwords – Most all password systems are case sensitive. It’s gotten to the point where it’s such a big deal so that if your Caps Lock is on (on your keyboard), then Windows, IE, or another browser or operating system, will tell you that All Caps is on! It’s become so common for people to accidentally have Caps Lock on and, thus, not be able to get their passwords to work!
  2. Strings – In all programming languages, strings are case sensitive. That makes sense, because you want your program to display what you type and specify for it!

Here’s an example from Small Basic:

 TextWindow.WriteLine(“Hello Oblate Spheroid”)

If that string (“Hello Oblate Spheroid”) had some funky capitalization (like “HeLlO oBlAtE sPheRoId”), then it would display with the casing that you wrote for it!

Examples of Case Insensitivity

  1. Emails – All emails default to lowercase, so it really doesn’t matter if you include capital letters in your email. Which also goes for…
  2. URLs – All the web addresses use capital and lower case letters as the same, and so either one will mean the same as the other!
  3. Identifiers – Small Basic is Case Insensitive; so that means that objects, methods, and keywords are all insensitive.

Here’s an example from Small Basic:

 TextWindow.WriteLine(“Hello Oblate Spheroid”)

Those identifiers could be written with different casing and produce the exact same results. For example, TEXTwinDOW.wRiTeLiNe(“Hello Oblate Spheroid”)wouldn’t change anything!

Why so Insensitive?

And that begs the question… why would you want to be case insensitive? Because the Small Basic creators (mostly Vijaye Raji) made a clear decision to design Small Basic as a case insensitive language!

Well, for starters, Small Basic exists to teach programming to the youngest possible audience (being a code-writing language, not like Scratch, Alice, or Kodu). In order to do that, Vijaye and team chose to make it as small, as simple, and as basic as possible. They also carefully crafted it to be as fun as possible. That’s why there’s an ever-present Help area, why the syntax coloring is so thorough, why the IntelliSense was re-designed into a big wheel menu with integrated assistance (descriptions of each identifier), why as many complexities were stripped out as possible, why the UI is mostly just a toolbar with a few big buttons, and why Go To was used… all to teach quickly, easily, and simply. And to do it in a way that’s FUN!

And, honestly, it’s not so fun if you accidentally write up “Textwindow” instead of “TextWindow” and have to deal with each of those errors when trying to compile your program. That can slow down the joy of the experience.

Build Good Habits

However, you better believe that we’ll encourage you often, passionately, and thoroughly to try to get the caps right when you type them.

Why should you get used to typing the right casing? Because you’re building a good habit! Other languages are far more sensitive and moody neighbors (they’re case sensitive), and they’ll yell at you for playing on their lawn (you’ll get errors for the wrong casing when you compile). So if you get used to typing the cases, you’ll save debugging time in the future!

Small Basic’s more like a friendly neighbor who won’t yell at you (case insensitive) and will even offer you ice-cream (IntelliSense auto-corrects your casing for you)!

We also provided IntelliSense to give you the right capitalization for free:

  1. You type.
  2. IntelliSense suggests.
  3. You double-click what you want. (Or double-tap, or press Enter.)
  4. IntelliSense drops in the identifier with the casing auto-corrected for you!

That’s right, if you type the wrong case, but you use IntelliSense, then IntelliSense will correct you and give you right casing!

And why do we want you to get used to typing in the right casing? Because you’re building a good habit! Other languages are far more sensitive and moody (a.k.a. case sensitive), and they’ll yell at you for playing on their lawn (for getting their casing wrong). So we want to make sure that you get used to typing in those cases. It will save you from lots of annoying debugging in the future! (Or it won’t; one of those options.)

Learn more about Small Basic:

https://blogs.msdn.com/b/smallbasic/

 

Have a Small and Basic day!

 - User Ed

 

This is Day 6 of 30 Days of Small Basic Part 1.

Comments