Familiar aspects of the Motoko language

Motoko was designed to be familiar not only to newcomers, but to a broad range of experienced developers from across the programming spectrum.

It would be interesting to hear which aspects feel familiar to those from an OOP background, and which are more familiar to those with a knowledge of functional programming languages like Haskell?

3 Likes

For those already writing functional code, are there any useful tricks or practices you might recommend OOP devs adopt when writing their applications in Motoko?

3 Likes

As someone who has previous familiarity with both paradigms, I think Motoko is an interesting intersection of the two! I appreciate the support for naive mutability which can be a hassle in pure functional languages like Haskell. I think it will make data modelling and updates a little easier. But I also heavily appreciate the absence of “null”, being substituted for sum/variant types. This means the compiler can identify and prevent common errors that occur in most OOP languages at runtime.

I’m not sure of the helpfulness of my own advice to OOP devs, but perhaps running through a few Elm tutorials would be useful? Elm is a pure functional language with a focus on learnability, and will definitely get you up to speed with the important concepts of the functional paradigm.

3 Likes

I agree @Nick! I know its been said by a lot of people (including myself) that Motoko is a functional language but the more I dig into it I’m realizing that it contains aspects of both.

It kind of reminds me of Javascript/Typescript where it is technically created to be a purely functional language but most savy developers know you can you can implement obect oriented practices with Javascript.

Also I think the people coming from an OO language should realize you can emulate functional practices within certain design patterns within an OO language. They are not as different as you may think. Like this guy describes here: http://codinghelmet.com/articles/what-makes-functional-and-object-oriented-programming-equal

4 Likes