create account

Learning some programming fundamentals by steevc

View this thread on: hive.blogpeakd.comecency.com
· @steevc ·
$12.71
Learning some programming fundamentals
I have been a professional programmer for several decades working in various languages, but my original degree was in electrical engineering. That course involved some programming (BASIC and Pascal), but that was more about getting results than studying the principles of programming in general. To try and remedy this I am doing some on-line courses. These are on Coursera and my employer is paying for them. There is a yearly fee for which you can take as many courses as you like. I have done some on specific aspects of Python, but the latest is just called [Programming Languages A](https://www.coursera.org/learn/programming-languages). It is the first of three related courses.

The instructor is [Dan Grossman](https://homes.cs.washington.edu/~djg/) from the University of Washington. He obviously knows his stuff, but I have a minor technical criticism that his audio is slightly distorted all through the course. The slides he uses are from 2013, but the material is still relevant.

![Video](https://files.peakd.com/file/peakd-hive/steevc/IMTo1RB7-image.png)

You might expect a course like this to use one of the propular languages such as Python or Java, but he opts for [ML (Meta Language)](https://en.wikipedia.org/wiki/ML_(programming_language)). which I would call a more purist language. I recently took [a look at Lisp](https://peakd.com/hive-169321/@steevc/developing-a-lisp) and ML seems to have some features in common with that in the way the code is structured and its use of lists. We actually used the [SML](https://smlfamily.github.io/) (Standard ML) variant.

I had not heard of ML, but I quite like it now. That said, I might not use it for general programming tasks that Python may handle better, but I could apply what I have learnt to other languages.

Some features of the language that are used in the course are:
* Static types. You cannot change use a variable that has been set as an integer in a context that needs a string.
* Immutable values. Stored values cannot be changed, or at least they should not generally. There are ways to work around this when required.
* Type inference. The language can work out what type a variable has to be, e.g. if used in arithmetic it has to be a number or if list operations are used then it must be a list. Variables can be 'polymorthic' in that it may be possible to pass different types of value to a function, but they may need to be consistent in relation to other values.
* Minimising side effects. Calling a function should just return a value without affecting other parts of the software.
* Recursion. Functions can call themselves.
* First class functions. Functions can be passed as parameters to other functions.

Excuse me if I am mangling terms, but I am still new to some of the concepts and terminology.

Here are some code examples:

```ML
fun fact (x) =
    if x = 1 then 1
    else x * fact (x-1)
	
fun swap (x,y) = (y,x)

fun count xs =
    case xs of [] => 0 
	    | x::xs' => 1 + count xs'
```

The first is the standard factorial function using recursion. In the whole course we did not use any of the regular loop structures that are commonly used in other languages. With recursion you need some way to exit and this does so when the counter reaches 1.

The second is a simple polymorphic function that swaps a pair of values around. It does not matter what the types of those values are. You can specify types in function definitions, but rarely have to unless you need to limit them.

The third function counts the items in a list. The case statement is powerful as it can match against patterns as well as values. The pattern x::xs' gives you the first item of the list as x and the remainder as xs'. You can define your own types that can hold different sorts of values then use this pattern matching to determine which you have in that instance.

That count function does not need to be written as it is part of the [standard library](https://smlfamily.github.io/Basis/manpages.html) along with lots of others, but it is useful to write functions like this yourself to learn the language.

The coursework consisted of some programming challenges to solve. You were given a script to test some values, but the grading was more intensive to catch edge cases. I found it challenging in some cases. There were one or two that I really struggled with and I dropped a few marks. There was a peer-review process where other students would look at your code to ensure you were using the sort of coding that had been requested as you could get the same results using functions that were not taught on the course and some approaches could be less efficient.

Another interesting aspect of the course was the use of the [Emacs editor](https://en.wikipedia.org/wiki/Emacs). This is quite popular in some fields of IT, but I had hardly used it. I can see it is very powerful even though I only used some basic functionality. One useful feature was the ability to run ML code within the editor. Making the most of it involves learning lots of key commands.

Although I found it hard work I did enjoy the course and will be continuing with part B, which uses the [Racket language](https://en.wikipedia.org/wiki/Racket_(programming_language)). That is another I have not heard of before. It is being used as an example of a dynamic typing language. The third part uses [Ruby](https://en.wikipedia.org/wiki/Ruby_(programming_language)) to demonstract object-oriented programming. I have heard of Ruby, but not used it.

These are not course to do if you just want to write a web app or a mobile game, but I think learning such fundamental aspects of programming helps you do a better job.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 123 others
👎  ,
properties (23)
authorsteevc
permlinklearning-some-programming-fundamentals
categoryhive-169321
json_metadata"{"app":"peakd/2020.08.3","format":"markdown","description":"My experience of a Coursera course on programming theory.","tags":["programming","sml","coursera","computerscience","stem","palnet"],"users":["steevc"],"links":["https://www.coursera.org/learn/programming-languages","https://homes.cs.washington.edu/~djg/","https://en.wikipedia.org/wiki/ML_(programming_language)","/hive-169321/@steevc/developing-a-lisp","https://smlfamily.github.io/","https://smlfamily.github.io/Basis/manpages.html","https://en.wikipedia.org/wiki/Emacs","https://en.wikipedia.org/wiki/Racket_(programming_language)","https://en.wikipedia.org/wiki/Ruby_(programming_language)"],"image":["https://files.peakd.com/file/peakd-hive/steevc/IMTo1RB7-image.png"]}"
created2020-09-03 13:41:48
last_update2020-09-03 13:41:48
depth0
children9
last_payout2020-09-10 13:41:48
cashout_time1969-12-31 23:59:59
total_payout_value6.498 HBD
curator_payout_value6.207 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,678
author_reputation1,379,810,279,014,719
root_title"Learning some programming fundamentals"
beneficiaries
0.
accountpeakd
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id99,428,344
net_rshares43,761,105,488,806
author_curate_reward""
vote details (189)
@bozz ·
$0.05
I wish I would have retained some of the programming knowledge that I learned in college.  We did a lot of stuff in C++.  I was never super good at it, but I was okay enough to pass my classes.  I remember going over pages and pages of greenbar output looking for my missing comma or whatever.
👍  
properties (23)
authorbozz
permlinkre-steevc-qg3i2y
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2020.08.3"}
created2020-09-03 18:30:48
last_update2020-09-03 18:30:48
depth1
children1
last_payout2020-09-10 18:30:48
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.024 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length293
author_reputation2,253,733,546,881,982
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,432,836
net_rshares277,408,921,744
author_curate_reward""
vote details (1)
@steevc ·
I've done some C++. Not my favourite language, but powerful in certain applications. If I don't work with a language regularly I forget stuff.
properties (22)
authorsteevc
permlinkre-bozz-qg3ld3
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2020.08.3"}
created2020-09-03 19:41:27
last_update2020-09-03 19:41:27
depth2
children0
last_payout2020-09-10 19:41:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length142
author_reputation1,379,810,279,014,719
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,434,011
net_rshares0
@cadawg ·
$0.08
> professional programmer for several decades

Damn, I'm probably right about now finished my first decade of programming. 

> Meta Language / Racket Language

I've never heard of them before either.

Thanks for posting into the programming community!
👍  
properties (23)
authorcadawg
permlinkre-steevc-qg3kqd
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2020.08.3"}
created2020-09-03 19:27:51
last_update2020-09-03 19:27:51
depth1
children2
last_payout2020-09-10 19:27:51
cashout_time1969-12-31 23:59:59
total_payout_value0.038 HBD
curator_payout_value0.038 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length251
author_reputation100,771,927,095,688
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,433,765
net_rshares441,959,441,384
author_curate_reward""
vote details (1)
@steevc ·
It's been an interesting trip, but there's still plenty I haven't done. I like that there are always new challenges.
properties (22)
authorsteevc
permlinkre-cadawg-qg3l7w
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2020.08.3"}
created2020-09-03 19:38:21
last_update2020-09-03 19:38:21
depth2
children1
last_payout2020-09-10 19:38:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length116
author_reputation1,379,810,279,014,719
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,433,945
net_rshares0
@cadawg ·
$0.08
Yeah, there's always something new to learn about even your favourite/most used languages.
👍  
properties (23)
authorcadawg
permlinkre-steevc-qg3lja
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2020.08.3"}
created2020-09-03 19:45:09
last_update2020-09-03 19:45:09
depth3
children0
last_payout2020-09-10 19:45:09
cashout_time1969-12-31 23:59:59
total_payout_value0.038 HBD
curator_payout_value0.038 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length90
author_reputation100,771,927,095,688
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,434,072
net_rshares436,649,365,843
author_curate_reward""
vote details (1)
@stav ·
$0.07
It's great to keep that grey matter going during these interesting times.  I've taken a week's break from the security stuff to spend some time with the kids and focus on a few other bits.  Looking forward to getting back into it next week; I'm not quite ready for the exam yet.
👍  
properties (23)
authorstav
permlinkre-steevc-qg3n5c
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2020.08.3"}
created2020-09-03 20:20:00
last_update2020-09-03 20:20:00
depth1
children1
last_payout2020-09-10 20:20:00
cashout_time1969-12-31 23:59:59
total_payout_value0.036 HBD
curator_payout_value0.037 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length278
author_reputation52,141,742,331,876
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,434,748
net_rshares424,343,839,934
author_curate_reward""
vote details (1)
@steevc ·
A break can be good, but I'm sure you will come out of this with a lot more knowledge.
properties (22)
authorsteevc
permlinkre-stav-qg3ovv
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2020.08.3"}
created2020-09-03 20:57:33
last_update2020-09-03 20:57:33
depth2
children0
last_payout2020-09-10 20:57:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length86
author_reputation1,379,810,279,014,719
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,435,484
net_rshares0
@vcelier ·
$0.05
> I have been a professional programmer for several decades working in various languages.

And it is only now that you are "studying the principles of programming in general"? ;-)

Me too, I have been a professional software developer for 2 decades (now fully retired), mostly in [Ada](https://en.wikipedia.org/wiki/Ada_(programming_language)).
I had learned about ML (a [functional programming language](https://en.wikipedia.org/wiki/Functional_programming_language)) and of course about Ruby, though I did not practice any of these two languages.
But I had never learned about Racket, which is not too surprising as it is a pedagogic language that has started to be designed 25 years ago.
👍  ,
properties (23)
authorvcelier
permlinkqg4ea0
categoryhive-169321
json_metadata{"links":["https://en.wikipedia.org/wiki/Ada_(programming_language)","https://en.wikipedia.org/wiki/Functional_programming_language"],"app":"hiveblog/0.1"}
created2020-09-04 06:06:03
last_update2020-09-04 06:06:03
depth1
children1
last_payout2020-09-11 06:06:03
cashout_time1969-12-31 23:59:59
total_payout_value0.026 HBD
curator_payout_value0.026 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length690
author_reputation471,651,021,631,730
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,441,168
net_rshares299,561,249,076
author_curate_reward""
vote details (2)
@steevc ·
Well I have some background in the principles, but this took it a bit further. A lot of programming is just joining library calls together, but I find the really fun part is coding up an algorithm, trying to make it efficient and elegant. I may go back to some programming challenges I did before for things like finding prime numbers. You could do those in ML.

I enjoy learning new things and want to experience more types of programming, even if it is just for fun.
properties (22)
authorsteevc
permlinkre-vcelier-qg4mlg
categoryhive-169321
json_metadata{"tags":["hive-169321"],"app":"peakd/2020.08.3"}
created2020-09-04 09:05:42
last_update2020-09-04 09:05:42
depth2
children0
last_payout2020-09-11 09:05:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length468
author_reputation1,379,810,279,014,719
root_title"Learning some programming fundamentals"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,443,013
net_rshares0