TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A Conversation About OOP vs. FP Turns Constructive

73 点作者 svanderbleek超过 8 年前

8 条评论

wangchow超过 8 年前
At this day and age people should be familiar with multiple paradigms. Whether procedural, functional, or Object-Oriented they are all useful. This is why you see languages like C++, Java, and C# adding support for them all.<p>It is useful to express a particular problem domain in a way that is efficient and makes sense.<p>I would be more interested in a discussion about concurrency because it becomes more relevant across the programming-language or paradigm barrier. Because at the end of the day we are confined by how the hardware operates and concurrency is very much a modern way of thinking as developers.
评论 #12471108 未加载
评论 #12470070 未加载
评论 #12469997 未加载
johncolanduoni超过 8 年前
I think the OOP vs FP debate misses the real asset that functional programming offers us, and it&#x27;s not writing everything in [your favorite functional language]&#x27;s typical style. Look at a language like Idris; a formal definition of its unsugared semantics would fit on half a page easily. However it still manages to give us all kinds of goodies, like effect tracking, compile-time checking for virtually any condition you can write a decision procedure for, and design-by-contract on steroids.<p>These features are useful whether the code you&#x27;re writing is pure, stateful, object-oriented, functional, and&#x2F;or whatever paradigm you write up tomorrow. Forget aesthetic arguments about elegance; where else can you build so much without ad-hoc concessions to individual language features? As far as I know, there&#x27;s no other method that lets you treat powerful language features as libraries without either (a) making a mish-mash when they&#x27;re used together like compiler plugins do (b) making debugging your compile process a full time job like various strongly-typed macro systems tend to.<p>Why not use FP to form the fundamentals of our languages, something where as of yet it has no equal, and build up the structures we need (regardless of programming tradition of origin) on top of that?
评论 #12470606 未加载
ebbv超过 8 年前
This conversation is awful. This seems like a bunch of armchair developers with really strong opinions and no real world experience.<p>No experienced developer I want to work with has the kind of dogmatic views that most of the people in this chat log have. FP and OOP are both just tools, how you use them is way more important than which tool you choose.
评论 #12470128 未加载
评论 #12470057 未加载
评论 #12470031 未加载
评论 #12470503 未加载
fowlerpower超过 8 年前
I really believe the future is a mixed OOP and FP world. I think we will see industry use languages like Scala and F# more and more.<p>In mission critical portions of systems people will use a functional style and try to isolate state, while most things in an OO style will be just fine.<p>I also believe the crazy complexity of OO languages like Java is slowly being reigned in. With other languages like Go explicitly making trade offs towards simplicity.
评论 #12470028 未加载
评论 #12470117 未加载
评论 #12470134 未加载
评论 #12470118 未加载
musesum超过 8 年前
From Bill Gathan: <a href="http:&#x2F;&#x2F;www.codenewbie.org&#x2F;blogs&#x2F;object-oriented-programming-vs-functional-programming" rel="nofollow">http:&#x2F;&#x2F;www.codenewbie.org&#x2F;blogs&#x2F;object-oriented-programming-...</a><p>Michael Fogus, author of “Functional JavaScript”, suggests in his blog post “FP vs OO, from the trenches” (<a href="http:&#x2F;&#x2F;blog.fogus.me&#x2F;2013&#x2F;07&#x2F;22&#x2F;fp-vs-oo-from-the-trenches&#x2F;" rel="nofollow">http:&#x2F;&#x2F;blog.fogus.me&#x2F;2013&#x2F;07&#x2F;22&#x2F;fp-vs-oo-from-the-trenches&#x2F;</a>) that when he deals with data about people, FP works well, but when he tries to simulate people, OOP works well.<p>I wonder about shape of the data as it moves from domain -&gt; range? How would they map to machine and biological models for learning? First guess is the that ML maps well onto FP; for CNNs, the data progresses synchronously from one layer to the next. For Bio, state is asynchronous; neurons, after firing have an efficacy period. Maybe super-fine-grain objects? Petri nets are interesting in that they can feedforward state asynchronously.
nitrix超过 8 年前
A few incorrect points during the discussion as well as poorly approached. The only thing beneficial that I see from it is people trying to better their skills and Haskell gaining traction.<p>I personally would recommend #haskell-beginners on freenode IRC as well as <a href="http:&#x2F;&#x2F;haskellbook.com" rel="nofollow">http:&#x2F;&#x2F;haskellbook.com</a> for the ones interested.<p>For everybody else, well I&#x27;m not a sale person and my job isn&#x27;t to convince you. If it takes you 30 years to (re)discover Haskell, so be it.
评论 #12469963 未加载
评论 #12470027 未加载
评论 #12470499 未加载
rjbwork超过 8 年前
Most statically typed programs&#x2F;systems these days (Java, C#, even C++ if you wish) these days, use DI via IoC containers as the mechanism for constructing objects and choosing which code to run. You can even do it with dynamic languages like JS&#x2F;Python if you wish, though many argue it being dynamic means you don&#x27;t need to use a container - which is pretty true.<p>This approach is equivalent to a family of functions (with side effects), one family per class, each with N(c) + N(m) arguments, where N(c) is the number of constructor arguments, and N(m) is the number of method arguments. Upon object construction, these families are partially applied to construct a new family of functions that contain only N(m) arguments. You can think of a constructor as a functor, that returns a number partially applied functions - the methods on the classes.<p>This is how I actually think of my OO programs these days. I also make liberal use of the actual functional tools made available to me. For instance, my bread and butter is C#, and LINQ heavily promotes a purely functional style when manipulating collections of data, though side effects are possible.<p>At a system level, I also tend to think of my data pipelines as functional transformations as well - their being written as an OO program is of little actual consequence.
评论 #12472822 未加载
gfunk911超过 8 年前
Put it in a more readable format here: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;mharris717&#x2F;cb2111a4f74ea1ef7f3a5de90ae4a468" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;mharris717&#x2F;cb2111a4f74ea1ef7f3a5de90...</a>
评论 #12470514 未加载
评论 #12470139 未加载