5 First Programming Languages You Should Learn

So you want to learn programming, but aren’t sure which programming language you should learn first? In this article, I’ll try and help you pick a language. There are certainly plenty to choose from.

Back before the web came along, that decision over languages was much easier to make. There was no web or mobile development, so the choices were pretty much C, BASIC, Pascal, or C++ (and maybe Fortran or Cobol for legacy systems).

These days, on the other hand, you are faced with a dazzling selection to choose from. There are the legacy desktop languages: Delphi (which is Pascal), C++, and, believe it or not, Fortran and Cobol (still around, yes!). For desktop languages, you now have C# and VB.NET on Windows; on Linux/Mac, there’s C, C++, and Python. You can run C# applications on Linux, and Python runs on all platforms (though I find it best on Linux).

For mobile development, you have the native languages: Swift and Objective-C for iOS, and Java or Kotlin for Android. For cross-platform mobile development, you have C# with Xamarin, JavaScript with various frameworks, and newcomer Dart (with Flutter). JavaScript can also be used with various frameworks for hybrid development; it looks like a native application and can leverage features such as GPS.

For web development, you have PHP and C#/ASP.NET, Ruby, Python and Java. That’s the backend; for the front end, there really is only JavaScript, though there are several alternatives that produce JavaScript as an output (these include Microsoft’s Typescript and Dart). If you go down the web route, you will have to learn HTML and CSS; HTML is pretty easy but mastering CSS takes a bit more effort.

So let’s narrow this down to five languages that you can choose from, and why I’ve picked these five:

  • Python
  • JavaScript
  • C#
  • Swift
  • Java

Python

In my opinion, Python is the easiest to learn of the five languages listed here. You don’t have to worry about types, and there are no curly braces needed for identifying blocks—instead, you just indent by four after a colon. It’s a very well-designed language, but also very powerful.

There’s the older Python 2 and the newer Python 3. You can learn either (or both), but Python 3 is the future and the recommended version. Here’s a code sample below; it’s a function that recursively calculates and prints the first Fibonacci numbers:

def rec_fib(n):
    if n > 1:
        return rec_fib(n-1) + rec_fib(n-2)
    return n
	
for i in range(10):
    print i, rec_fib(i)	

 

In terms of actual programming jobs, Python isn’t that common as a primary language—but it’s one that’s valuable to know, as it does pop up with fair frequency.

JavaScript

The only language on this list that runs in a browser, JavaScript is easy to get started with—after all, everyone has a browser on their PC. It’s also a powerful language.

Once you’ve learnt the language, you’ll have to learn the ecosystem. There are frameworks and libraries galore. Do you go down the path of Angular or Ember, or maybe React? Perhaps you just want to stick with jQuery. It’s a very deep rabbit hole!

JavaScript has been slowly evolving from ECMAScript 5 to ECMAScript 6, with most browsers compatible with the latter. You can check browser compatibility on Kangax.

Just for comparison with Python, here’s a recursive Fibonacci program in JavaScript:

function fibonacci(n) {
   return n < 1 ? 0
        : n <= 2 ? 1
        : fibonacci(n - 1) + fibonacci(n - 2);
}

console.log(fibonacci(10));

 

An alternative method for using JavaScript: Node.js, a JavaScript runtime. You shouldn’t learn it immediately, but if you are considering a career in developing websites, it’s a technology to seriously consider adding to your portfolio.

C#

If you want a language that can be used to create desktop applications, mobile cross-platform applications, and websites, then C# should be your choice. It’s also pretty easy to get into; the Visual Studio 2017 Community version is free, and includes C# for desktop Windows development, ASP.NET for websites, and Xamarin technologies for mobile.

C# and Java (see below) are very similar, though the similarity has faded a bit in recent years as C# diverged from Java. If you learn ASP.NET MVC for doing the backend of websites, you’ll find plenty of jobs.

C# is now up to version 7.2; the version I suggest you learn is C# 6.0 or higher for one reason alone: interpolated strings, which reduce the amount you have to write by quite a bit.

Here’s a recursive Fibonacci program in C#:

static void Main(string[] args)
{
    int number = 10;
    fibonacci(number); 
}

static void fibonacci(int n, int a = 0, int b = 1)
{
    if (n == 0) return;
    Console.WriteLine(a);
    fibonacci(--n, b, b+a);
}


Swift

If you have an interest in developing for iOS—and you probably should, considering the revenue that iOS app developers can potentially earn—then Swift should be near the top of your programming-languages-to-learn list.

Version four of Swift was released in September 2017, with improvements in string handling, collections, stability and more. Although designed to replace Objective-C as the primary language for iOS development, Swift has increased its scope to include system and desktop programming (it’s also been open-source for quite some time). Swift can also be used in apps for macOS and watchOS, making it essential if you’re interested in Apple’s broader ecosystem.

Here is a Swift recursive Fibonacci implementation:

func fibonacciRecursiveNum1(num1: Int, num2: Int, steps: Int) {

    if steps > 0 {
        let newNum = num1 + num2
        fibonacciRecursiveNum1(num2, num2: newNum, steps: steps-1)
    }
    else {
        print("result = \(num2)")
    }
}
fibonacciRecursiveNum1(0, num2: 1, steps: 10)

Java

Java is now 22 years old and firmly established, although poor security features have led to a decline in desktop-related usage. Compensating for that dip, however, has been an accompanying rise in mobile development, thanks to Java’s use in Android.

Here is the recursive Fibonacci function in Java:

public class MainClass {

  public static long fibonacci(long number) {
    if ((number == 0) || (number == 1)) 
      return number;
    else
      return fibonacci(number - 1) + fibonacci(number - 2);
  }

  public static void main(String[] args) {
    for (int counter = 0; counter <= 10; counter++)
      System.out.printf("Fibonacci of %d is: %d\n", counter, fibonacci(counter));
  }
}

Conclusion

I’ve excluded functional languages such as Lisp, Scheme, Haskell and F# as first languages; for people who aren’t specialists (and many entry-level tech pros aren’t specialists quite yet), they’re not suitable.

I came close to including PHP, which is only used for website development, and it’s definitely worth a mention. The easiest and cheapest way to get a website live is to host on a Linux platform with shared hosting using PHP. For instance, WordPress, Drupal and Joomla are all programmed in PHP. If building websites interests you, learn how to use PHP for the backend, in addition to JavaScript for the front end.

Post a Comment

Your email address will not be published.