9,042 reputation
63782
bio website
location
age
visits member for 3 years, 7 months
seen 19 mins ago

0x2B | ~0x2B


1h
comment Does functional programming increase the 'representational gap' between problems and solutions?
@RobertHarvey: Ok, so you mean there can be business problems whose solution requires higher mathematical abstractions. I think I understand now. I might have been a bit biased because often mathematical abstractions are considered non-relevant for real-world problems. Thanks for updating your answer.
1h
comment Does functional programming increase the 'representational gap' between problems and solutions?
@Doval: Regarding the expression problem, each paradigm makes it easier to extend you code in a certain way, and needs to use a more complex solution otherwise, or am I missing something? This is why (as you say) the choice for one of the two views depends on the problem you are solving, e.g. programming a GUI (OOP) or an interpreter for a programming language (FP). Regarding values versus side-effects: I would say side-effects characterize the imperative approach, i.e. not only OOP, but also the procedural paradigm.
1h
comment Does functional programming increase the 'representational gap' between problems and solutions?
So, maybe it is only a matter of terminology: I do not consider computing a paycheck or reorganizing bookmarks as mathematical problems, even though I can write FP programs using monads and other abstract concepts (mathematically oriented solutions, if you want) solving them.
1h
comment Does functional programming increase the 'representational gap' between problems and solutions?
@RobertHarvey: Maybe it is just a matter of terminology. An example of a mathematical problem could be something like: decompose a number into prime factors. A more business-related problem could be: produce a report of all worked hours of an employee and compute her paycheck. You can solve both using pure functional programming (and, if you want, monads). You can then argue that this FP solution uses a lot of mathematical concepts, and I can agree. But even if the solution methods use concepts from mathematics, the second problem is not a mathematical problem.
5h
comment Does functional programming increase the 'representational gap' between problems and solutions?
@Euphoric: I have not looked into the details, but the FP counterpart to the visitor pattern should involve an Other variant / constructor in your data type, and an extra function parameter to be passed to all functions to handle the other case. It is, of course, awkward / less natural with respect to the OOP solution (dynamic dispatch). In the same way, the visitor pattern is awkward / less natural than the FP solution (a higher-order function).
5h
comment Does functional programming increase the 'representational gap' between problems and solutions?
@Hey: Have you read the chapter of SICP I have suggested. There is worked out example there. Anyway, suppose you have a function that scales an image (changes the resolution). This function will start by identifying the format of the image and then dispatch to the proper implementation for that image format. If you add a new image format, you have to change the code that identifies the image format to handle the new format. You have to do this for every other function working on images: non local change.
9h
comment Does functional programming increase the 'representational gap' between problems and solutions?
@Hey: Your entry point function still needs to pick the right converter function according to its input. The point is how you organize your dispatch: in FP each function has the responsibility of dispatching according to its input, in OOP each object (piece of data) contains the information that is used to find the correct implementation of an operation.
10h
revised Does functional programming increase the 'representational gap' between problems and solutions?
deleted 1 character in body
10h
answered Does functional programming increase the 'representational gap' between problems and solutions?
10h
comment Does functional programming increase the 'representational gap' between problems and solutions?
"Accordingly, the problems that are most suitable to solve using functional programming are essentially math problems.": I do not agree with this statement (see also my previous comment), at least I do not see why it should be true or what it actually means. You can see traversing a directory structure as a math problem and implement it with a recursive function, but since the customer does not see the source code, you are just solving a practical problem like finding a file somewhere in the file system. I find such a distinction between math and non-math problems artificial.
11h
comment Does functional programming increase the 'representational gap' between problems and solutions?
@Fuhrmanator: I would rather say that the FP approach to solving problems uses Mathematical concepts. However, you can apply it also to non math problems. For example, I have used Haskell to write programs that (1) analyze log files in a production environment, (2) organizes my files by helping me find duplicates, (3) helps me organize my web browser bookmarks, and so on.
21h
comment Does functional programming increase the 'representational gap' between problems and solutions?
@thepacker: You do have state in functional programming. Only the representation is different: in OOP you use mutable variables whereas in functional programming you can use infinite streams of states that are created on the fly when the program needs to inspect them. Unfortunately, state is often identified with mutable variables, as if mutable variables were the only way to represent state. As a consequence, many believe that a programming language without mutable variables cannot model state.
1d
comment Why do mainstream OO languages not have immutability on class-level built-in?
@Philipp: What do you mean by whole class? Are you referring to the possibility to change a class at runtime, e.g. adding new methods?
1d
comment Why do mainstream OO languages not have immutability on class-level built-in?
"If you dig deep enough, every programming language mutates state under the hood, because that's how the processor instructions are designed.": If a programming language does not allow mutation, the fact that its implementation does use mutation is irrelevant for the programmer.
1d
reviewed Leave Open Why do mainstream OO languages not have immutability on class-level built-in?
2d
comment Situations when O(n^2) better than O(n*log(n))
@Useless: This does change the fact that the above statement is incorrect.
2d
comment Situations when O(n^2) better than O(n*log(n))
"Quicksort has (if naivelly implemented) square complexity": quicksort has worst-case complexity O(n^2), no matter how it is implemented.
2d
reviewed Leave Open Attributes of an Ethical Programmer?
Jan
21
comment Scala and exception handling
You probably know Robert Harper better than I do. I only read the book I cited and I find it a very good reading. Of course he has his own views, which I cannot judge, since I am not an expert in FP, even though I like the subject a lot.
Jan
21
comment Scala and exception handling
@Doval: ;-) I somehow remembered you were an SML fan. True, Java's checked exceptions are a nice alternative. But again, once you decide that something is an error, I think you should model it with an exception. If it is a 0-1 result, I think it should be an option.