2 ms·
There is a reason that research into functional languages is limited to an old or new functional language. Without syntax and compiler support you don't gain a
by Retric 17y ago
There is a reason that research into functional languages is limited to an old or new functional language. Without syntax and compiler support you don't gain any power to offset the limitations.
Anyway, the power of OOP is creating intelligent data. You can "automatically" do things with a Point that you need to explicitly do with integers. If you start dealing with a Fixed_Point objects, and Mobile_Point object, you now have bloat with little gain. It's far better to have a "Final" flag on your point, so it will toss an error when you try to change it vs. trying to maintain 2 separate classes. That way if you suddenly need to change your point you have to refractor less code.
Granted, if Java's foreach would automatically make helper threads to speed things up then there would be an advantage. But, changing the form without compiler support is pointless.
PS: Feel free to test your ideas, but allocating memory is still the enemy of speed. When you create a temporary object outside of the stack it really does slow things down.
- KirinDave 17y agoI am glad to see someone else equally irritated by this "fashion statement" that people engaging in, abusing their languages to ape other languages. Even worse, most don't really understand the benefits of the languages they copy, they pull the iconic cases and then pretend that languages aren't a teepee of features that cannot stand when just a few poles are pulled in isolation.
- gdp 17y agoHuh? Are you suggesting that people use functional programming languages such as Haskell or ML because they are fashionable? Where on earth are you living such that they are fashionable? I wanna live there.
- KirinDave 17y agoPlease reread what I said. The fashion statement is using a non-functional language and adopting some functional mores.
- gdp 17y agoI see. I'm still not sure how you justify your (revised) statement. What's fashionable about it? You don't think people do stuff because they think it makes them better programmers, rather than because of some perceived fashion trend? Similarly, you don't think the tendency for most non-functional languages to adopt features and techniques from functional languages is because those ideas are inherently valuable? Sometimes a good idea is a good idea, and I think functional programming is an idea whose time has finally come. Maybe what you're labeling "fashion" is actually just a natural progression towards acceptance and adoption that started several decades ago. Personally I think the trend towards selectively adopting functional features (if there is one!) could only be positive. If more programmers become comfortable with the concepts underpinning FP, then making the jump to using plain ol' FP (rather than <insert your language here> with anonymous first-class functions bolted on etc) will likely be much easier. Maybe it'll lead to wide-spread adoption!
- KirinDave 17y agoI did not revise my statement. You simply read it incorrectly. To directly answer your question, I think that the merit of functional programming techniques is in their application as a whole. Sniping high-profile individual techniques does not bring a proportional benefit. It is simply cargo culting. It is "fashionable" to mention "functional" programming and to butcher the concept of referential transparency when writing code in Java, C++ and C# these days. All it does is create a new style of obfuscation for these languages.
- gdp 17y ago> There is a reason that research into functional languages is limited to an old or new functional language. Without syntax and compiler support you don't gain any power to offset the limitations I don't understand what this means. > If you start dealing with a Fixed_Point objects, and Mobile_Point object, you now have bloat with little gain Why would you not have a single point class implementing multiple interfaces? Surely if they do the same thing, you wouldn't bother. Good design would dictate that if they do similar things (but not the same), they should probably share an abstract parent class anyway. > It's far better to have a "Final" flag on your point, so it will toss an error when you try to change it And check this at runtime for every access!?! Why on earth would that be more efficient than static checking at compile time?
- Retric 17y agoI don't understand what this means. EX: Tail recursion (http://en.wikipedia.org/wiki/Tail_recursion http://en.wikipedia.org/wiki/Tail_recursion) will be optimization if your code is a specific form AND your compiler also supports transforming to into loop. However, if you use the form without compiler support you are killing the stack and should manually convert your code to a loop by hand. Edit: Tail recursion really is just another loop; it's often used as a backhanded way to have mutable variables in a functional language, but in Java you might as well just have a loop. And check this at runtime for every access!?! Why on earth would that be more efficient than static checking at compile time? You only need to check it when you are updating a member variable not when you read it. Note: it does not save you from updating the variables inside the class if you bypass the getters and setters, but that’s a side issue. Anyway, if you check it ~50 times vs. creating one extra object you should come out ahead in speed. More importantly you will have far less and more maintainable code. PS: Using multiple interfaces to the same class is a reasonable option, with some tradeoffs. You still need to maintain more code, but it is pure fluff so not that big a deal. However, that's not what he did.
- gdp 17y agoDo you have any figures to back up the claim that memory allocation for small, short-lived objects consisting of final members is actually as slow as you claim? My understanding is that it isn't.