Tag Info

New answers tagged

1

It is certainly possible to program in a purely functional style in an imperative language. In fact, if you look at books like Effective Java or Java Concurrency in Practice, much of the advice in those books basically boils down to "don't use mutable state", "don't use side-effects", etc. However, it may not always be a pleasant experience, and you may not ...


11

If by functional programming you mean programming only with immutable values, sure, you can do that. But it's going to be painful. In a lot of cases you don't get to take advantage of: First-class functions with lexical scoping (a.k.a. closures) Functions with identifiers that are mostly special characters Infix functions Type inference Tail call ...


0

I'm learning Scala right now, and it allows for both. You can either write imperatively using standard curly braces like C, or you can omit the braces and write functionally. Obviously the functions you use decide whether or not you'll be able to write it purely functionally, but it is possible. If I think of a good comparative example, I'll edit it in when ...


0

I'm not an absolute expert on functional languages and paradigms; however, I do know that compilers have the job of translating their native language (C, Ada, Prolog, Java…) to a machine language (x86, JVM, sparc, amd64…). Since both functional and imperative languages can be translated to machine code, given that they are both Turing-complete and not domain ...


1

... intuitive for developers to use, so the code itself explains and forces developers to use it in certain way... It's a myth that OO bits can be intuitive unless they are trivial. like the most fundamental framework elements. LOB objects are the opposite of that. They need good documentation and examples demonstrating all the functionality you'd hope ...


0

The only reason to care when a side effect free (aka pure) function is evaluated is for performance reasons. But assuming that it is being evaluated because the result is needed, the net effect should be neutral as it won't take longer to calculate just because it's done at a different time. What you may have to be concerned about is perceived performance ...


8

So this is actually a referenced to a paper by Meijer and a few others called "Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire", the basic idea is that we can take any recursive data type, like say data List = Cons Int List | Nil and we can factor out the recursion into a type variable data ListF a = Cons Int a | Nil the reason ...


0

Having learned encapsulation from Borland C++ after learning C, when Borland C++ lacked templates that enabled generics, the object orientation paradigm made me uneasy. Somewhat more natural way to compute seemed filtering data through pipes. The outward stream had separate and independent identity from the inward immutable input stream, rather than be ...



Top 50 recent answers are included