When you learn Git, get it right

Git-Logo-1788C

Having used Microsoft’s Visual SourceSafe for source control and then Microsoft’s Team Foundation Server (TFS) for most of my software development career, I was recently exposed to the many wonders of Git (open-source, distributed-control, well-tested and fast). At a client site, our team workflow was switched to Git right in the middle of a very important project, probably not the most optimal time to introduce a new source-control workflow, but oh well.  It was high-time to learn Git – trial by fire!

Centralized vs Distributed (the newer paradigm)

I had known of Git as a distributed source-control “system” for quite a while, but was never exposed much to it until I had worked for this client and the team had an urgent need to switch over to Git from TFS in order to enable four teams to work on several parts of one project all at once without corrupting each others’ code.  Contrast that with Microsoft’s Visual SourceSafe (VSS), Team Foundation Server (TFS) or CVS, which are products designed to centralized source control on one server.

Git is a fantastic (double-underline?) source-control system & represents the best of the newer paradigm of distributed source-control.  There is a steep learning curve (in my opinion) and a price to pay (in time) for using it incorrectly or not learning how to use it on a very simple project first.  The compensating factors are that Git is free, open-source, world-class, and fast. Some of the cloud-side, server-side, and client-side tools that support it are not free (most are though).  Either way, you should be using it now or very soon as it’s the present and future of source control.

Here are a few learning resources for your benefit:

I am using:

…to manage my Git repositories (repos). BitBucket is free for individuals and teams of up to five people; GitHub is similar.  GitKraken and TortoiseGit are both free to individual developers on their home machines. Aside from that, the purchase prices are reasonable for all of the above if a purchase is necessary for legal compliance. I don’t work for or receive compensation or recognition from either firm.

Summary:  Learn how to use Git thoroughly on a small non-critical or personal project with at least one other code contributor before attempting to use it on a enterprise mission-critical project.  I cannot emphasize this learning approach enough to save you from time-critical error fixes and just the hassle of having to go through it.

SQL Server *Worst* Practices

Here’s a link to a great article I read recently that summarized in a concise package things not to do when using SQL Server as a data-persistence solution, which is almost more important than what to do.

Note: SQL cursors especially – please never use cursors of any flavor in your stored procedures. There is almost always a better set-based method to accomplish your end goal.

As it’s not mentioned in the following article, I will add that not making use of SQL Server metadata is a mistake I see very frequently. What is metadata?  It’s data that describes other data or data structures. It’s particularly easy to implement with SQL Server once you know what to do and how to use it. There is probably no easier way to document a database for all users or stakeholders involved than to implement/update SQL Server metadata, and there are no good reasons not to utilize it.  It’s easy and freely available – just waiting to be used.  I have a set of stored procedures developed that make the process absolutely painless for keeping SQL Server database metadata updated at the table, column, view, and function/param levels (all the places that really count!), and across all environments (production, pilot, test).

https://www.mssqltips.com/sqlservertip/1707/sql-server-worst-practices/

It might be time for VBScript to just fade away…

VBScript is not a programming language platform designed for production servers in large enterprises.

It’s a light-duty, interpreted scripting language for use on your home machine, personal web server, or two-server small business.  While I’m a fan of many Microsoft products, VBScript is not one of them.

My first major use of it was five years ago when I used it at a past employer because of an architectural decision made years ago to create and maintain a custom in-house enterprise “job-control” system based entirely on VBScript/WSH (Windows Scripting Host), calling in turn a library of other WSH files created with VBScript.  Most IT folks working there that had a reason to know had an inkling it wasn’t the most up-to-date technology choice, but they explained away the moving forward with it like this: “We were just mainframe programmers trying to replicate the mainframe jobs and report-generation scripts on Windows servers, and this was all we had available at the time.”

PowerShell had long been available upon my arrival, but the investment in VBScript development and deployment was so pervasive at that point that moving away from it would have been very expensive. I can respect a cost-based decision like that, even if the technology-side of it doesn’t work for me in the least.

If you are in a position of technology leadership, please don’t put your organization in that cradle of fragility on a very outdated scripting language.  As a result of that job, I’ve written far more VBScript code than I would ever care to admit or even bother to remember. Fortunately, you have choices in 2017 when it comes to scripting, and VBScript should be dead last on that list.

Anything VBScript (or it’s forgotten [but supported] cousin JScript) can perform against the Windows Scripting Host [engine],  .NET batch-jobs, Powershell or Python can generally do better:

  • with less code,
  • better testability,
  • far better error-handling potential,
  • less technical debt for others to deal with in the future when modifications/expansions are necessary,
  • better reference documentation,
  • far better third-party library/open-source support,
  • object-oriented class structures, and
  • better integration with OS libraries.

What’s my vote for the happy path?  From my perspective as a developer (not a sysadmin):

  1. .NET command-line executables
  2. PowerShell scripts (this should be the choice for sysadmins, in my opinion)

Fatal Flaws

While VBScript is better than using Windows shell command-line for some scripts, it’s fatal flaws are as follows:

  1. Very loose-typing of what would be baked-in primitive value-types in any other modern programming language.  What would be garden-variety primitive data-types (integer, decimal, char, et al) in VBScript are always an anonymous “object” type.  As such, any variable can take on any data-type at any time for the life of the object.  Type-safety is just not a thing in VBScript, hence it is error-prone and allows you way too much freedom as a developer.  The only way you can keep track of which variable should be handling a type consistently is to use a naming convenion like “intVariableName” for integers or “strVariableName” for strings, etc.
  2. Worst error-handling and debug support of any language I have ever used, without a doubt. You won’t even get an exact line-number from the scripting engine/interpreter 99% of the time, and you won’t know you have an error in your script until you run it.  Trying to develop a script hundreds of lines long with methods to boot? Good luck finding your syntax error, or data issue without outputting every little thing to screen output.
  3. Zero support for reference types (no custom OOP or .DLL support), other than what’s baked into the Windows OS frameworks and COM-visible to the script interpreter. There is a work-around for this using digital duct-tape and baling-wire, but it’s neither pretty, a widely supported idea, nor a good use of your time. I’ve written “classes” in VBScript out of need, in order to be able to reuse code structures, but it was a complete hack, and the time would have been much better spent writing a .NET utility and/or library class to accomplish the same thing with a command-line executable. The class worked, but it was definitely a hack for which the language was not designed.
  4. No facility for multi-threaded execution.
  5. Industry-wide lack of code-editor / IDE / syntax support (ever heard of Intellisense?). There is a third-party editor you can buy that will give you something reasonably approximating Visual Studio’s Intellisense, but it’s a one-off solution that you will have to buy yourself. Not even Microsoft’s Visual Studio has had support for VBScript since Visual Studio 2005. That is, the company that created the language only bothered to offer support for developing it in their IDE for a few years, then dropped it cold-turkey.  If Microsoft doesn’t care about VBScript, and advocates against its use in favor of Powershell, why should you or I care when so many better alternatives exist?
  6. It’s a Microsoft-proprietary and niche technology with neither open-source nor wider industry support. Development/expansion on it as a scripting language ceased long ago. There is zero support from Microsoft or its vendors for VBScript – that well dried up many years ago.  The script interpretation-engine was never open-sourced, presumably because it’s on every Windows distro, and hasn’t been actively developed since…I think it might have been last updated to version 5.8 during the WinXP years.
  7. Close to zero vendor library support, unless you count random blog entries with sometimes untested code from ten plus years ago from random hobbyists or admins who are dabbling with it. Additionally, there is zero open-source library support for VBScript.
  8. It’s not DOM-aware like Javascript is in modern web browsers, so don’t even bother with browser-scripting, not even for firewalled intranet sites with an exclusive IE-based browser audience. No browsers except very outdated versions of IE even support it for browser-based scripting. VBScript was relegated to the trash heap of classic-ASP web page development years ago, and no-one really wants to admit that they ever had a hand developing web-pages with that technology, lest they be put in charge of the conversion away from that stack (been there, done that).
  9. Potential for misuse. It’s a scripting language, not a programming language.  If the only reason you use it is to call batch/command-line  executables – written in any language – then ok. If you are using it for anything more than that, then you might need to rethink your job-control architecture and move it gradually to a newer platform with a function/routine library backing it up.  .NET C#/VB.NET, Python, Go, and C++ are all good choices for batch program writing.  I’m sure there are many other good choices depending on your surrounding architecture.
  10. Do we need more reasons not to use VBScript in the enterprise environment?

I am just not a VBScript fan, for the quantifiable reasons above. I was skeptical when I first started using it (forced to use it), and as time wore on I came to know that I was really wasting my time and the company’s resources by using it further, and only adding time/expense to a future enterprise technical-debt burden that would take years to unwind and mitigate. I have no interest in extending it’s lifespan through usage, even though every version of Windows, client or server, supports it use.  If a client specifically needed it, I would code with it, but very, very reluctantly, and not without generous discussion, dissuasion, and dissent with an eye to a much better solution alternative.

PowerShell is what you need

Use Powershell if scripting “jobs” for Windows servers. Powershell has been around for at least a decade now – if not more – and has well proven it’s suitability and efficacy for enterprise scripting and job control with library support from Microsoft and a huge community of sysadmins who are eager to help you find the solution you need.

VBScript (along with JScript, not JavaScript) came to life in the late 1990’s with the introduction of Windows 98/Windows ME and was first popularized for use with Windows Server 2000 (circa 1999) and WSF (Windows Scripting Foundation).  I’ve always thought JavaScript was a badly designed language – and it leaves much to be desired – but it’s nowhere near as bad as VBScript.  Just walk away from the VBScript (or JScript, which accesses the same limited COM object model as VBScript), and walk quickly please.

Almost twenty years has passed since it’s introduction as the darling of sysadmins, and much, much better alternatives for administrative and browser-scripting have evolved in that time.