Rupert Goodwins profiles five cutting-edge languages to suit every purpose and most skill levels
Choosing a new programming language to learn is much like choosing a new human language: you have to know why you want to do it to have a good chance of success. In this feature, we’ve picked five of the most interesting new languages to wrap your brain around – ones that have a good chance of remaining significant in five years’ time, and have features that promise intellectual stimulation and the best chance to explore new ideas.
If you’re new to programming altogether, then it’s best to start with a classic. C remains not only one of the most popular languages in actual use, but its spawn (C++, C#, Objective-C and so on) form a large part of the programming landscape in engineering, commerce and general applications. Getting acquainted with C is an excellent start: it is simple, fast and universal, and the concepts it teaches will serve you well in your programming career wherever you go next.
The major programming innovation since C was created in the 1970s is objects. C deals with code and data in a rather unrestrained way; in general, any code can work on any data, so changes in one area can have unexpected effects elsewhere. Object orientation (OO) combines code and data into objects that are protected, safe components of the larger program. Java is a good contender for a first OO language, as well as being a valuable commodity on the market.
And if you’re looking to learn a workhorse language for commercial use, JavaScript and Python are both excellent choices that use a mixture of techniques and philosophies from earlier languages. JavaScript is extremely fashionable and becoming more so; Python is quick to learn and can produce fast results due to huge, well-tested libraries of prewritten components. Both use lots of concepts from earlier languages, and both have an infinite number of good resources and expertise online to help you learn.
But enough of the sensible advice. Here are five of the up-and-coming contenders for the coolest, hottest new languages that are worth your consideration.
GO
BEST FOR BUILDING CLOUD/WEB SERVICES
Go is an open-source language from Google that’s approaching its sixth birthday, and has quite some momentum behind it. You can find it under the bonnet of some painfully trendy products, such as the Docker containerisation system.
Famously, Go came about because a small group of Google programmers decided they hated the baroque topiary of C++. Aiming for a stripped-down focus on speed and simplicity, Go features built-in support for concurrency, so a single program can do multiple things simultaneously.
It’s devoutly multiplatform – you can develop on Windows, Mac, Linux and BSD – and it supports Intel, ARM and Power architectures, so yes, it’s a good match for the Raspberry Pi. There’s Android support, of course, and an iOS port.
Like Swift (see overleaf), Go combines ideas from scripting languages with a basic structure and syntax largely derived from C. It drops the requirement to specify the type of variables when initialising them, so FRED=10 is used instead of INT FRED=10 and, like Swift, it isn’t fussy about end-of-line semicolons. The Go team at Google has a stated aim that the entire language definition should be small enough to read in a couple of hours and “fit in a programmer’s head”, although detractors say that too much has been lost regarding safety.
Concurrency supports multithreading and parallel processing, as well as asynchronous processes that are launched but have to hang around waiting for something to happen. The eponymous GO statement launches a new process, while CHAN creates a new channel that processes can use to talk to each other through the <- operator. The SELECT operator scans a set of channels, passing control on when one of them has data or a signal. These are all particularly apt for writing pipelines that efficiently process incoming data, network functionality and general server services, and Go has – unsurprisingly – very good web-service functionality, such as built-in HTTP serving and consumption support. It also likes large arrays of data and map functions.
This, combined with a lot of Google and third-party support for web services and database interfacing, has made Go popular for online service coding. People report it to be as quick to develop for as Python, with much better speed and lower memory requirements. Debugging Go code isn’t highly developed, with little
native support; some third-party tools such as Mailgun take the approach of adding debugging code to your source, but there’s no fully interactive debugger. Go does have native support for integrating and automating tests, versioning and repositories, app building and other features considered essential for production code and excellent discipline. You don’t have to use these, but this is the 21st century, after all.
With Go, you’ll have to choose your own work environment; there are various integrated development environments (IDEs) and plenty of third-party support tools, and the usual, highly emotive factional debates around them. It’s not as prepackaged as Swift, but it is more flexible: Apple versus Google in code form.
Go is still a divisive language with plenty of critics and, although it’s been around for more than half a decade, the ecosystem around it is still evolving rapidly. On the other hand, its proponents can point to a great deal of running code out there and a very good match for the needs of distributed programming at scale.
It’s probably not the ideal choice for your word-processing or mobile-gaming project, but if you want to do interesting things across networks... well, what else would you expect from a programming language that emerged from Google?
SWIFT
BEST FOR iOS/MAC DEVELOPMENT
There’s plenty of buzz about Swift. Introduced last year by Apple as a proprietary language for iOS and OS X, the company has recently pledged to release version 2 as open source to encourage cross-platform development. Currently, though, you’ll have to have OS X and run the Xcode development platform.
Intended as a replacement for Objective-C, Apple’s previous “standard” language, Swift inherits its libraries of useful components, and much of the syntax and structure of the earlier language. Many of the changes make things less fussy – the terminating semicolon on each line is now optional – or more flexible, such as the way variable names can now use Unicode. Yes, you can stuff code with emojis, if you absolutely must.
Swift also sidesteps many of the standard traps that even experienced C-class programmers stumble over. Swift on Xcode has advanced, interactive debugging techniques, with “playgrounds” where you can inspect and modify code as it runs, instead of having to edit, compile, load and run. In general, the process of writing and debugging takes a lot from scripting languages such as PHP or Perl; it’s less verbose than Objective-C, and does many things automatically that older languages required the programmer to attend to.
Swift has much to recommend it. Although large and complex, it is considerate of modern, web-based environments and the core business of writing actual code. It’s backed by Apple but without Apple’s “Sinatra Syndrome” (“You’ll do it my way...”) and, of course, it is highly focused on mobile platforms as well as the desktop. What’s more, the development environment, although currently Mac-only, is highly capable. Against that, Swift is very new and will develop quickly in the next year or so, so you’ll be chasing a moving target.
SCALA
BEST FOR JAVA PROGRAMMERSAND FUNCTIONAL PROGRAMMING
As with Go and C++, Scala is a language born partially of dissatisfaction, in this case with Java. Developed at a research university in Lausanne and part-funded by the European Research Council, it’s just over a decade old.
Scala’s Java heritage is considerable: it compiles to Java byte code, which runs on any standard Java virtual machine (JVM); its source code can be largely converted to Java source code; and it can use all Java classes. Its syntax and structure can look very similar to Java, but Scala code can be much more concise.
Unlike Java, everything is an object in Scala – including functions, numbers, operators... the works. So, functions can be used as arguments, stored in variables and returned as results to other functions.
Notably, Scala is multi-paradigm – it supports different styles of programming. This makes it possible for programmers to adopt Scala and carry on using their expertise from differing backgrounds. It does mean that it can be tempting to program in one way when another would be more efficient, however, which may have profound performance implications. But if you’re learning a new language to improve your mental tools, Scala will reward your efforts.
And because it’s designed to be scalable (hence the name) it’s very good for creating what are, in effect, new languages within itself, particularly domain-specific languages (DSLs). These are very good at doing one specific task – say, running a financial model – so if your long-term interests lie in that direction and you want a high-level language with the potential for high reliability, performance and configurability, Scala has a case.
What Scala isn’t is a language for beginners – even less so than Swift or Go. But Java knowledge will give you the basic framework to explore the rest of this language.
HASKELL
BEST FOR BOLDLY GOING INTO NEW REALMS OF PROGRAMMING
If Rust and Scala combine functional programming with other ideas, Haskell is having none of that nonsense: it’s full-fat, cask-strength, uncut functional programming. You can’t change variables. Everything is a function that will always return the same output for the same input. Go’s logo is a cartoon gopher seemingly drawn by a five-year-old; Haskell’s is the Greek letter lambda – for lambda calculus, the underlying mathematical basis of functional programming – overlaying the greater-than-or-equal operator (>=), because Haskell is not mucking about.
Forget about syntactical differences or which brackets are used where: Haskell forces you to think differently. It does so as gently as it can – Haskell programs don’t look as arcane as Lisp, and it knows how to interface to other languages – but you must be prepared to work at rebuilding your ideas about what programming actually is.
If that excites you, then Haskell will be an adventure. If it scares or bores you, Haskell will be a pointless exercise in frustration.
Why bother? Haskell proponents say that while you probably won’t use it to write a video game or a web server (“although you could!” they invariably add), you will acquire a whole new set of mental tools to program better. Haskell is fast and can produce remarkably compact yet powerful programs for data analysis, hardware modelling and so on. It has a presence in engineering, finance, design and aerospace. Once you get good at it, you tend to get very good, and people appreciate its productivity.
And it has a firm mathematical basis: you can write bad software in Haskell, but if you take the time to understand the concepts and apply the philosophies behind it with care, you can produce results that are exceptionally reliable. It’s not for everyone, but if you still have a love of computing as an intellectual amplifier, it can be enormously satisfying.
RUST
BEST FOR CONCURRENCY AND WRITING SAFER CODE
Rust is the newest language on the block, with version 1 appearing from Mozilla Research in May 2015. Like Scala, it’s multi-paradigm and designed to support functional and objectoriented, as well as older, models, and to be safe, fast and concurrent.
Rust spends a lot of time keeping memory safe from incorrect reading or writing, eliminating a vast range of cases where serious or even critical bugs have snuck into C and C++ code. In particular, Rust has a strong concept of ownership and lifetime, where variables and things that depend on them are only valid while the code that owns them is active.
Rust can launch threads that execute independently of the main code, and these can communicate through shared variables. But independent things with the right to change each other’s variables can be unsafe; Rust enforces strong rules here and won’t compile code that may be unsafe.
Such safeguards mean people new to Rust consider it overly restrictive and fussy. However, experienced users report that it encourages a greater understanding of safe coding, which carries across when writing in other languages.
ONLINE RESOURCES FOR LEARNING PROGRAMMING
All programming languages have a vast range of online resources, but no matter what language you’re looking at, the same tactics will quickly get you to places suited to your level of expertise and expectations. All languages have a homepage, but they also have online communities spread across sites such as Stack Overflow and Reddit (which belies its reputation for anarchism here – language subreddits are very well run) as well as various online forums. Most languages also have an IRC channel where experts, enthusiasts and users congregate for live chat – new learners are welcome, and these are ideal clearinghouses from which to find the best online tutorials, video demonstrations, tools and so on.