This is a blog for reflection on Programming Language part 1 at coursera produced by UW(Universit Washington). The design for this course is to help developer better understand what is the programming language and how does functional programming differs from object-oriented programming. And in the first part, we will use a language called SML(Standard ML).
mut in rust. It just doesn't have the concept of assignment on value. Instead, it introduces another concept called shadowing and binding. In this case, binding works for binding a specific value to a variable and shadowing is for re-binding a value on a existed variable(such process is quite like assignment). And due to this feature, the
= can perform the role of binding value(if the right is a value) and the role of judging value equality(if the right is variable). And this is quite confusing when I first time touched this language.
In addition, this week, it also introduces some basic thinking in the functional programming and
let ... in ... done syntax. The
let ... in ... done may look familiar if you have tried pascal. Basically, it allow you to introduce some local variable and function into the current scope. The most important thing this week, is the recursive way of solving problem. This might be the most trick part, since recursion might be abstract in some cases. And in such a language that does not have any loop feature(so far from what I know), it forces you to rethink all the patterns you have built in the past coding life. Like, we all know we can step through an array using recursion by passing its sub-array. Such operation seems to go against the OOP(Object-oriented programming) thinking.
On more thing, is the list operations. In the first week, it introduces operations:
hdthat will return the first element in the list.
tlit will return a new list with every element but the first
e1::a1that can add one element
e1to the head of
a1@a2that can append
a2to the tail of
a1. Note: we can use this operation to achieve
appendin python. If we want to append
e1to the tail of
a1, we can use
At the end, about the first assignment, it is not so hard once we can the sense of recursion. Here is the link for the first assignment.