Many newcomers what to know which language they should learn. Since learning a programming language takes time, they want to make sure they pick the best language possible.
While there is really no perfect, the following are good starting points for beginners.
My basics course uses Javascript. Below I’ll talk about some pros and cons for each of these languages.
If you want a quick summary, here is a tl;dr:
For each of the languages below, I’ve provided some example code that generates the nth term in the fibonacci sequence. This is to give a little taste for what each language feels like, but also to help illustrate how similar these languages are in practice.
Javascript is a language that was originally created for adding scripts to webpages. Today, Javascript can run outside the web browser, and is popular for building web based services with the help of Node.Js. Several sites including Netflix and Ebay both use Javascript.
function fibonacci(n) {
if (n < 2) {
return 1;
} else {
return fibonacci(n-1)+fibonacci(n-2);
}
}
Python is another popular language for beginners. It is quite popular today for data analysis and AI. It is a general purpose language like Javascript, and can be used for many other purposes as well. Python uses spacing as part of the program, which can make programs easier to read.
def fibonacci(n):
if n < 2:
return 1
else:
return fibonacci(n-1)+fibonacci(n-2)
Lua is a popular embedded language, which means it is easy for other programs to run external programs written in Lua. This has lead to widespread use for scripting in game development. Many notable games let you include Lua scripts, including World of Warcraft and Roblox.
function fibonacci(n)
if (n < 2) then
return 1
else
return fibonacci(n-1)+fibonacci(n-2)
end
end
Lisp is not often recommended for beginners anymore, though it has many properties that make it excellent for learning. It was originally developed in the 1960s and heavily used in logic based AI programming. MIT previously taught its introductory class using Lisp, since the entire language can be taught in an evening, leaving time to focus on problem solving. Recordings from these classes are freely available online.
(define (fibonacci n)
(if (< n 2)
1
(+ (fibonacci (- n 1))
(fibonacci (- n 2)))))