Learning From Other Languages

Even if you only write code professionally in a single language, learning the concepts and idioms of other languages will make you a better programmer.

Learning From Other Languages

One of the best ways to grow as a software developer is to learn multiple languages.

The key is to learn not just the syntax of the language, but how to think in that language.  Programming languages have certain idioms and best practices that vary from one to another.  For example, error handling in VBA is much different than exception handling in .NET which is much different than returning errors in Go.  If you understand the pros and cons of each approach, then you can import that thinking into your "native" language in those places where it makes sense.

Here are a few examples from this blog to whet your appetite:

Python-Inspired Doc Tests

[Doc tests] support the concept of verifiable documentation.  You write usage examples alongside your function.  You can then run tests against those examples to verify they are correct.

Read more here.

LINQ-Inspired Fluent Interfaces

A "fluent interface" is one which uses method-chaining to call multiple object methods on a single line.  This can be used to create a very compact syntax.

Say we want to add a label to a form.  We want this label to be two inches wide, bold, italicized, with a 14-point Segoe UI font.  Here's how we would do this using a With ... End With block:

With CreateControl(CtlName, acLabel)
    .Caption = "My Label"
    .Width = 2 * TwipsPerInch
    .TextAlign = 2 'Center
    .FontSize = 14
    .FontName = "Segoe UI"
    .FontBold = True
    .FontItalic = True
End With

Here's how we might do the same thing using a class that implements a fluent interface:

fb.AddLabel("My Label").Width(2).Center.Size(14).Font("Segoe UI").Bold.Italic

Read more here.

Perl-Inspired Regular Expressions

Some people, when confronted with a problem, think "I know, I'll use regular expressions."  Now they have two problems.

Regular expressions are kind of like recursion for most programmers.

Mind-boggling at first.  

Then a period of, "I sort of get it, but when would I ever actually use this?"

Followed by the first time you stumble upon an otherwise intractable problem where it offers an elegant solution.

After which, you hoist your shiny new hammer above your head, bellow to the heavens, "THERE CAN BE ONLY ONE!" and stride off in search of more nails (or anything that even vaguely resembles a nail).  

Until finally, with a cascade of snapped screws and bent bolts in your wake, you place the now-rusting hammer in your toolbox where it belongs.

Read more here.

Every-Other-Language-But-VBA-Inspired Version Control

Using version control is the most impactful change you can make to improve the quality of your Microsoft Access applications.

Here is a quick list of just some of the benefits you gain using version control:

  1. A detailed history of what changes were made to your application.
  2. A detailed history of when those changes were made.
  3. A detailed history of why those changes were made.

Read the remaining top 10 reasons to use version control with Microsoft Access and then check out all my articles on version control.

Reader Submissions

What techniques have you borrowed from other programming languages over the years?  Let me know in the comments below.


Referenced articles

Python-inspired Doc Tests in VBA
Doc tests are not a replacement for unit or integration testing. But they do provide the best return on investment (ROI) of any type of test, mostly because the effort to write them is near zero.
Fluent Interfaces
It’s probably irresponsible of me to share the following technique with you because you’ll be so tempted to abuse it. But let’s do it anyway.
Now you have two problems
Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems. --Jamie Zawinski
Top 10 Reasons to Use Version Control With Access
Using version control is the most impactful change you can make to improve the quality of your Microsoft Access applications. Here is a quick list of just some of the benefits you gain using version control.

Image by Jan Vašek from Pixabay

All original code samples by Mike Wolfe are licensed under CC BY 4.0