loading...
Cover image for Try these 4 languages from 4 corners of Programming

Try these 4 languages from 4 corners of Programming

itsjzt profile image Saurabh Sharma ・3 min read

There are thousands of programming languages, all having features unique than others. There are some more readable, others more performant, some are simple, others are complex. Here I'm presenting you 4 different programming languages from 4 different sides of programming. I invite you to try each of them, enjoy their strengths, find their weaknesses. Each one of them is very different than the others. They each are better for some kinds of problems. They will teach you the same problem in different ways.

1. C

While working on the Unix operating system at Bells Lab, Dennis Ritchie wanted a language that will suit the task of writing parts of the Operating System. He wrote C language taking inspiration from BCPL and B.

A lot of C's syntax maps directly to machine code. C has the power of assembly but unlike assembly, it is cross-platform, If you wrote your code with portability in mind then it can work on multiple OSes and CPU architecture without much code changes.

When you want to talk directly to the machine, removing all the abstractions in between you and the machine, then C is the language for that kind of tasks.

Here is some C code

int square (int number) {
    return number * number;
}

and here it the assembly code generated by the compiler

square(int):
        push    rbp
        mov     rbp, rsp
        mov     DWORD PTR [rbp-4], edi
        mov     eax, DWORD PTR [rbp-4]
        imul    eax, eax
        pop     rbp
        ret

2. Smalltalk

When I made up the term object-oriented, and I can tell you I did not have C++ in mind.
-- Alan Kay

Smalltalk was created to teach kids programming. Creator Alan Kay had revolutionary ideas about how programming should be done. He pioneered the idea of individual units communicating through message passing. He believed that languages should be built around a generalized concept. Smalltalk and Object Oriented Programming revolutionized the world of programming but certainly not a good way, the world misunderstood the whole idea of Object Oriented Programming. Classes became the epic center of Object Oriented Programming.

here is some smalltalk code:

"Return the weekday of a date"
'2013/5/7' asDate dayOfWeekName

"Save the HTML source of a web page to a file"
'http://www.pharo.org' asUrl saveContentsToFile: 'page.html'

"Count the number of, or show the leap years between two years"
(1914 to: 1945) count: [ :each | Year isLeapYear: each ].
(1895 to: 1915) select: [ :each | Year isLeapYear: each ].

If you already know ruby, smalltalk will not take a lot of time to grasp, but its live debugger is something from another world.

3. Lisp

“Lisp is a programmable programming language.”
— John Foderaro, CACM, September 1991

If you are looking for a language in functional programming world, there is a good chance you will hear about lisp. Lisp is a minimalist kind of programming language. Its has virtually no syntax. Lisp is one of those languages which is enlightening. Currently the most popular lisp variant is Clojure.

Lisp is programmable. which means if you don't like any constructs of of the language, you can override it with what works better for your team. Imagine if javascript was lisp we could fix a lot of its bad parts.

here is some clojure code:

;; define a var
(def a 42)
;; => #'user/a

;; call a function named `+`
(+ a 8)
;; => 50

;; call a function named `even?`
(even? a)
;; => true

;; define a function that returns the remainder of `n` when divided by 10
(defn foo [n] (rem n 10))
;; => #'user/foo

;; call the function
(foo a)
;; => 2

;; if else 
(str "2 is " (if (even? 2) "even" "odd"))

4. Haskell

Haskell is the language grown out of mathematics world, It is a statically typed (perhaps the best kind of static typing), functional programming language. Unlike most mainstream static typed languages it has strong type inference so you don't have to write types everywhere but you still get type safety.

If you are writing in statically typed language, you should try Haskell, it has very strong type inference. You can see the below code which has type safety but I didn't wrote any types.
Haskell has pattern matching, recursion, list comprehension, first class functions and all the other cool stuff of functional programming languages.

-- Using recursion (with the "if then else" expression)
factorial n = if n < 2
              then 1
              else n * factorial (n - 1)

cover image credits: Thanks to Ian Schneider for sharing their work on Unsplash

Posted on by:

itsjzt profile

Saurabh Sharma

@itsjzt

Web development React.js GraphQL Typescript JavaScript Design SEO

Discussion

markdown guide
 

Great recommendations!

I would add one more to the list: prolog.

It’s a logic, fact based programming language that has interesting concepts beyond procedural and functional. Sure, it comes from academia and is still not used outside of it but I recommend people to try it.

 

I had to learn prolog for one of my lower div classes and at the time, I spent hours pulling my hair out over this "useless" programming language. While it's not really used for real world development, I think it's a really good tool to demonstrate something like theoretical computer science topics.

Edit: RegEx and Context free languages are concepts that can be demonstrated pretty well with prolog

 

We made a text based adventure using prolog in university. The whole lazy evaluation is neat. For sure different then most languages.

 

Pretty neat!

While in the uni I made a prolog program to rank texas holdem poker hands.

 

Lots of recommendations for prolog

 

Actually prolog was on my list. But since i didnt tried it yet so didnt write about it

 
 

Yes, constraint satisfaction is often overlooked.

 

My favorite programmings languages are:
F# for functional programming.
Lua for an embedded scripting language.
Python (3.x) for general purpose scripting language. Also my recommendation for the best programming language to learn as your first programming language.
D as a "better C++ than C++" language.

My "on the horizon" languages I'm keen on are:
Elm as a web language.
Rust as a potentially "the next mainstream language".
Swift as the language for Apple platforms.

The language I use day-in and day-out is C++.

 

Always wanted to learn F#! Looks nice.

 

The Book of F# by Dave Fancher is a great introduction and tutorial to F#. I've read many F# books, and that was the only book that I'd recommend. (I just started reading Expert F# by Don Syme this weekend, I'm on chapter 1, so I cannot recommend nor criticize.)

 

lua was the first language i ever tried and i was obsessed with it since i was 11 but was always overwhelmed with it. I learned JS and perhaps I will revisit it.

 

Look for luawinmulti on GitHub. It will instruct you to install mingw, then guide you in installing Lua. It supports 5.1, 5.2, and 5.3. You'll end up with a Lua environment that runs out of a standard Windows command shell.

 

10 years and Python and finally, back to Haskell (I learned concurrency with Haskell documentation) because 99% of my time, I write Python like functional programming.

I'm looking on Elm but I still look at Swift because we can use it on cli and server-side (Vapor or Perfect or another framework) also on Linux system.

 

If you want a language with strong server side support, compiled and static typed

Try Golang

 

I tried because I need to adapt Hashicorp Vault but I still prefer Haskell or Python with functional programming way.

Now, I'm sure that I lost 10 years with object oriented programming… no wayback machine to avoid this lost of time

 

I'm most interested in (in no particular order):

Idris
Elixir
Elm
Haskell
Julia
Python
Wolfram Language

 

I have tried elixir and python.

Idris and Elm looks instresting.

 

Thanks Saurabh!
My addition: If you struggle with Haskell and like frontend work, try elm-lang.org/ instead. Much more approachable IMHO.

 

For something completely different, try an RTL hardware design language like VHDL or Verilog. Always parallel, all the time. Changes the way you think about "programming" and I think should be mandatory for any budding developer.

 

Yeah, it is something completely new

 

Java, C#, Scala, Go. My 4 favourites. Honestly I use many more and I think every GPPL is fun and you need to understand which one is the best for your goal.
When I studied OpenGL I spent more time to experiment with different programming languages than effectively learning OpenGL

 

Looking through the discussion —

As far as reactive web development goes, Svelte is a great tool to try if Elm is too radical of a paradigm shift from the Javascript, HTML, and CSS realm.

Definitely recommend it as an alternative to React, Angular, or Vue if you’re interested in learning any of those

 

I also recommed svelte to anyone intrested in web development.

 

Most people, myself included, probably won't find the time to literally follow the advice in the post. I think you gain some context just from reading this.

...But if your take away is that you will take this and literally make a small program in each one of these languages, you'd probably level up as a programmer that very day.

 

Actually picking new languages isnt that hard. 4 - 5 hours is enough to get the basics,

then you can solve project euler problems for practice.

 

I have been programming in C since 1981, though for the first 10 years or so I thought in pdp-11 assembly language while doing so.
I learned lisp in college, wrote a small lisp interpreter with the primitives in pdp-11 FORTRAN-IV and assembly and the rest in lisp in college. Have not used it much since then.
Wrote a smalltalk interpreter in C some time in the 1980s or 1990s. Switched to much better open source implementations later.
Haven't tried Haskell yet.

You missed SNOBOL, TCL, and FORTH. All of these are very different than the usual fare.

 

Yeah I agree I left a lot of languages. Maybe I will do a second part

 

I tried to understand smalltalk but I didn't. C syntax looks easy here, the snippet doesn't show what makes C different. Closure? It's just different from normal programming languages, I was happy when I wrote fizzbuzz with it. As for Haskell, it looks interesting.

 

the snippet doesn't show what makes C different.

imo the part of C is its syntax maps directly to assembly

 

Really want to learn Smalltalk this year. It seems to pop up a lot as a 'proper' oo language.

 

It's got a few things that make it intriguing: a pure object-oriented environment (literally everything is an object), OOP implemented as "message passing" (Alan Kay's vision), and an IDE with integrated tools, refactoring, debugging, and search (it's very reflective/introspective). Download Pharo Launcher & try it! It's a lot of fun to program with!

 

I actually wanted to give the squeak implementation a try. They also have a GraalVM support, which opens up a lot of possibilities.
Bit if there are good reasons to prefer Pharo I love to hear them.

 

Smalltalk is a new world in its own

 

To investigate Smalltalk, check out Pharo. It's the modernized descendant and quite effective as a development environment. My other languages of choice are Lua and LabVIEW.

 

Yeah Pharo is the recommended flavour of smalltalk. I have used pharo in smalltalk's code example

 

Ballerina (ballerina.io/) if you do microservices development.