JA7. FP¶
Statement¶
The Learning Journal is a tool for self-reflection on the learning process. In addition to completing directed tasks, you should use the Learning Journal to document your activities, record problems you may have encountered and to draft answers for Discussion Forums and Assignments. The Learning Journal should be updated regularly (on a weekly basis), as the learning journals will be assessed by your instructor as part of your Final Grade.
1. Describe what you did, You need to describe what you did and how you did it¶
This was the 7th week of this course; it was about the concepts of functional programming. I started by watching attached videos and reading the text; The discussion assignment asked about the concepts of Higher order functions, currying, and lazy evaluation.
2. Describe your reactions to what you did¶
I enjoyed this week’s content as I am interested in functional programming and there was some attempts to learn it in the past but I failed to do so. I am glad that I am learning it now.
But this does not rule out the fact that I am still confused about functional programming and everyone I know is also confused as it ia a difficult concept to grasp.
3. Describe any feedback you received or any specific interactions you had. Discuss how they were helpful¶
I did not receive any interesting feedback that worth mentioning.
4. Describe your feelings and attitudes¶
I have mixing feelings as stated earlier, I’m happy that I am learning functional programming but I am also confused about it and found it difficult to grasp.
5. Describe what you learned¶
The text started by explaining what is functional programming and the difference between it and imperative programming. It then explained the concepts of higher order functions, currying, lazy evaluation, Referential transparency, recursion, tail recursion, pattern matching, and Haskell.
The main idea of functional programming is the absence of side effects, assignment statements, and mutable data. Any function is pure and its value will never change (for the same arguments); thus it is possible to replace a function call with its value without changing the meaning of the program (Ben-Ari, 2006).
6. What surprised me or caused me to wonder?¶
I always though that functional programming is about using functions instead of objects and classes, but it is more than that. It is about pure function, data immutability, and absence of side effects.
7. What happened that felt particularly challenging? Why was it challenging to me?¶
The concept of currying was quite challenging to me, and I still do not understand it well. I think that always did some currying in my code without knowing it.
8. What skills and knowledge do I recognize that I am gaining?¶
I am gaining the knowledge of functional programming and the skills of using Haskell. Haskell is a good example in explaining functional programming concepts; however, its syntax is very weird compared to the C-like languages that I am used to.
9. What am I realizing about myself as a learner?¶
I realized that I don’t know much about functional programming and that I need to learn more about it. But I also realized that I’m using some functional concepts like higher order functions, recursion, and currying without knowing it. I usually use currying to reduce the number of arguments in the final function call as there are some shared arguments between the functions.
An example of currying in TypeScript:
const shouldCheckIssue = (issue: IssueType, ignoredIssues: Issue[], checkIssues: Issue[]) => {
if (ignoredIssues.some((ignoredIssue) => ignoredIssue === issue)) {
return false;
} else if (checkIssues.some((checkIssue) => checkIssue === issue)) {
return true;
} else {
return true;
}
};
const audit (params: {
ignoreIssues: Issue[],
checkIssues: Issue[],
}) => {
const shouldCheckIssue = (issue: IssueType) => shouldCheckIssue(
issue,
params.ignoreIssues,
params.checkIssues
); // currying
// loop over issues and check if they should be checked
for (const isType of issueTypes) {
if (shouldCheckIssue(isType)) {
// do something
}
}
}
10. In what ways am I able to apply the ideas and concepts gained to my own experience?¶
As stated in previous journals; we follow functional programming concepts in our codebase. We use pure functions, immutable data, and absence of side effects. We also use higher order functions, recursion, and currying. I had little knowledge about each of these concepts but now I have a better understanding of them that allows me to be useful team member.
11. Describe one important thing that you are thinking about in relation to the activity¶
I would like when I have more time to try and play with Haskell and build some side projects with it. I think that it is a good language to learn functional programming concepts.
References¶
- Ben-Ari, M. (2006). Understanding programming languages. Weizman Institute of Science.