Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
78

What can I use to show the usefulness of functional programming? This is the wrong question, and by trying to answer it you're falling into a trap of accepting and reinforcing the students' misunderstanding of what university is. If I had applied that standard of value to the courses in the bachelor's degree I studied, I think I would only have attended 30 ...


57

There are beautiful answers to this question already here, and I will not try to reiterate any of the ground that has already been covered. However, something important that I have not seen here so far is that comparing OOP to FP is not actually terribly meaningful. It's a bit like comparing glass (the material) to tables (the furniture). They each have ...


36

Hughes is absolutely right, and the following paragraph from his paper hits the nail right on the head: Such a catalogue of “advantages” is all very well, but one must not be surprised if outsiders don’t take it too seriously. It says a lot about what functional programming isn’t (it has no assignment, no side effects, no flow of control) but not much ...


16

Here I will discuss Functional Programming (FP) and Object Oriented Programming (OOP) in a fairly pure form. Actual languages, however often make compromises to allow older forms as well as multi-paradigm programming. Both FP and OOP rely in the notion of program "State" but do so in different ways. In fact there are really two different things that go by ...


13

I think the real trick is in teaching the value of Functional Programming rather than trying to teach the value of Functional Programming Languages. The latter will fail the pragmatic approach in almost all cases. Why? Because functional programming languages intentionally restrict themselves in the name of purity, and then try to demonstrate that they ...


11

Consider what they are saying, discuss with the students, and agree with them that perhaps they are right. Its almost impossible to get anyone interested if they already know that they won't benefit (at least in the monetary sense) from it in the short and medium run. By agreeing with them, you take them into your confidence. Then, find ways to incorporate ...


10

Functional programming knowledge will definitely benefit your students. I think Martin Odersky explains it best here: https://www.youtube.com/watch?v=3jg1AheF4n0 He explains that there needs to be a paradigm shift in the way we think of processing data. As we progress with technology, we are reaching the limits of transistor size. Because of this, ...


10

I think it is pretty hard to convince students focused on the here-and-now of a lot of things. However, the teacher's job is to teach them what they need to know, not just what they want to know. There are two reasons for learning a functional language. The most important is that anything that gets you to think hard about something new will make you better ...


9

There are two types of learning The two types of learning that are useful are: to solve an immediate problem. as an investment, this is the type that you will mostly do at university. Although you will also practice the former, it is not for what you learn, but to learn how to learn. The language is irrelevant How many words are there in Python? About ...


9

There are already several good answers, but I'd like to add the following. Functional code is (at least in theory) more easily parallellized. This is important because we've about hit the limit of how fast we can run integrated circuits. (I know that's an oversimplification; I'm trying to keep it simple for the OP's audience's sake.) So, while you can't ...


9

I wouldn’t expect to find a comparison table because OOP and FP are not mutually exclusive concepts. OOP is about encapsulating data in objects behind interfaces and using inheritance to build objects in re-usable pieces. FP, however, is about not changing states or having side-effects. You can have an OOP program with immutable objects. (You can clone an ...


9

FP and OOP are both tools in the box, none of them is better or worse. The same way you would not ask whether to use a hammer or a screwdriver to put in a nail, you should not ask whether to use FP or OOP. The question should be: what is the best way to solve your problem at hand? OOP excels when you need to describe abstract objects with code (hence the ...


7

Any true paradigm shift requires literally re-wiring the brain. Thinking functionally is not the same as thinking procedurally (for example). The neural pathways of the brain need to be connected appropriately for the new paradigm to become natural. When you were a kid you were, if typical, used to walking and running. Then you probably got a bicycle (or a ...


7

As the kids these days would say, you're doing it wrong. Let me explain. As I've commented elsewhere, every "full language" has a whole bunch of things that educators would find inconvenient or undesirable. Your Haskell students can use monadic state or UnsafePerformIO too! So Haskell is "just as bad" in principle. That's why Racket (in an explicit ...


7

This is a very broad question, so I'm going to point you to a couple places and then give a really short explanation. Wikipedia on paradigms: https://en.wikipedia.org/wiki/Programming_paradigm I'm linking to the main article, but linked at the bottom you should definitely check out the "Comparison" article as well as the specific sections and links to ...


7

I suspect there'll be more universities switching from Scheme to Haskell for introductory functional programming (FP) courses, mainly for the 'real world' appeal of Haskell. I see 15 mentions of Scheme and 16 of Haskell in the recent SIGCSE programming language poll results, although Scheme (as Racket) still has the edge in introductory courses. We've a ...


7

The why isn't necessarily related to the relative quality or benefit of the various approaches to the first courses. But some of the comments given to the question capture part of the reasons. First, FP isn't precisely mainstream in industry. Most programming in the real world is now is done in Dijkstra-derived languages, not McCarthy-derived ones. This ...


5

Give them the following task to implement in plain old Java: Given is a list of Students with their name, area code and average test score. Write a program that calculates and prints out the average score of all students by each area. Example input: final List<Student> students = Arrays.asList( new Student("Meyers", "12345", 2.3f), new ...


5

It is difficult to put this into a form that inexperienced undergraduate students will appreciate, but well... "It is commonly the case with technologies that you can get the best insight about how they work by watching them fail" - Neal Stephenson, In the Beginning was the Command Line Since OOP is the 500lb gorilla of the programming world and FP the ...


5

As I read your post, I see your question as simply this: where might I find a thorough comparison between the two [OOP and FP], which can explain which should be used for some kinds of tasks\projects? The best explanation I have seen is in the context of the Programming Languages MOOCs offered through Coursera modeled after this course at UW. The ...


5

The ideas in your question are far too difficult, for a one hour introduction. Yesterday I had a look at Haskell and learnt some. I have over 30 years programming experience (20 years professional). Have experience with functional programming. Yet it took me several hours, and did not get far enough to be able to do your suggestions. Mathematics You say ...


5

Focus on the idea that the sets can be finite. They don't need to be defined by a formula. Any set of ordered pairs is a relation. If there is a unique second element for any given first element then it is a function. For example, the set of pairs {(5,2), (5,4)} is not a function, since the value associated with 5 is not unique. This is a relation: a set of ...


4

I undertook this study myself about a year ago. I started working through the Programming Languages MOOCs on Coursera (Part A Part B Part C), which are based on a UW course of the same name. I didn't really know what I was getting into, but it sounded interesting. Before I knew it, I was learning a radically different approach to programming first with SML ...


4

Truth be told you will never truly understand the difference until you actually learn and use both a functional and an object oriented language. I say that as someone who has learnt both object-oriented languages (C#, C++, Java) and functional languages (Haskell). I will however attempt to explain the crux of it. My answer will be looking mostly at ...


4

There is a really good teaching point here. Ideas often arise repeatedly in different contexts. That includes the ideas behind Functional Programming. We also all know how fast computing changes. Your job is to teach them computing, and its up to them to choose how to use it and the specialist areas they need most, which they probably don't yet know as ...


4

Actually, I think a better choice would be a true functional language (Scheme, ML, Haskell) rather than a multi-paradigm language. Of course it depends on your goals. If you really want them to learn the functional programming mindset then don't use a language that lets them escape to other paradigms so easily. F# permits programming in many ways, ...


4

Actually they are not the same thing at all. In mathematics a function consists of a univalent map between a domain and a range this is a subset of a cartesian product or just as you have described, a table. The continuous case is an extension to infinate domains and ranges, usually over the real numbers. Functions in computing do not always behave this way....


3

I would start by distinguishing between the claims Functional programming is useless., and Functional programming languages are useless. It's likely that when students say the former, they actually mean the latter, and the latter is more likely to be true (or at least valid) from the perspective of their goals. Regardless of whether functional programming ...


3

Just a couple of ideas here for an easy intro to Scala, though not very deep. Note that there is an online Java to Scala converter. The first idea is to translate (offline) something you are currently doing in Java into Scala and show it to them. The converter will make this trivial. They are already familiar with the code's structure. The second idea, ...


Only top voted, non community-wiki answers of a minimum length are eligible