TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Functional programming for Object Oriented programmers

75 pointsby lifebeyondfifeover 13 years ago
With the continuing popularity of functional programming, it doesn't look like it's ever going away. Here's is an introduction to functional programming in F# written with the object oriented (C#) programmer in mind.

6 comments

AndrewDuckerover 13 years ago
My problem with these things (and I'm not picking on this particular article, just on introduction to functional programming articles in general) is that they always tell you how awesomely easy it is to make lists, or calculate the fibonacci sequence, two things I never have to do in the office.<p>What I want to know is whether functional programming languages would help me to write UIs better than C# does, to create XML documents from data, to retrieve data from web APIs and then display the results, etc.<p>These are things I have a need to do on a daily basis, and I'd like to know if F# is the tool for them, or if I should stick to C# unless I'm writing a list processor or calculation engine.
评论 #3275798 未加载
评论 #3274859 未加载
评论 #3274849 未加载
评论 #3274839 未加载
评论 #3275131 未加载
评论 #3274929 未加载
评论 #3274899 未加载
Zakover 13 years ago
The article says<p><i>List.map function list - Invokes function on every item within list and returns nothing.</i><p>which isn't what map does in other functional programming languages. Applying a function and returning nothing isn't a very functional thing to do in general, as whenever possible functions should be called for their return values, not anything else they might do[0]. Map normally returns a list of the function applied to every element of the list. I looked up the documentation for F#'s map, and it appears to do the same thing:<p><a href="http://msdn.microsoft.com/en-us/library/ee370378.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ee370378.aspx</a><p>[0] And when possible, a function should <i>only</i> return a value, not do other things.
评论 #3275095 未加载
评论 #3275042 未加载
xentroniumover 13 years ago
I would recommend "Why functional programming matters"[1] paper to anyone struggling to understand the purpose of functional programming. It's only about 20 pages.<p>[1] <a href="http://web.mst.edu/~tauritzd/courses/cs347/whyfp.pdf" rel="nofollow">http://web.mst.edu/~tauritzd/courses/cs347/whyfp.pdf</a>
评论 #3276492 未加载
mjbellantoniover 13 years ago
"Functions are invoked without using brackets or commas"<p>Is this really a strict property of functional languages? :)
评论 #3275959 未加载
marshallpover 13 years ago
One thing missed in a big way by this article and other newbies when it comes to (static) functional programming is the centrality of types. It really is what makes ml-derived languages special and it's a shame it's not promoted to non-functional programmers more. Most of your work is related to specifying your types, the rest falls into place naturally, and is why you can think and write code elegantly (and is super fun).
评论 #3274809 未加载
评论 #3275259 未加载
josh5555over 13 years ago
great article...very useful. tyvm!