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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

The Complexity Trap: Think Before You Leap

120 点作者 chedine超过 6 年前

12 条评论

afpx超过 6 年前
As one who frequently deals with Scala code, I have to say that this guy is right: the Scala community in particular seems to relish in complexity.<p>Scala is a wonderful language and well-designed, especially in contrast to Java. The learning curve requires a good deal of effort, but with experience, it becomes incredibly fun to write Scala code. Once I got past the learning curve, Scala became my go-to language.<p>That said, there’s an underlying arrogance of Scala developers who, in my experience, tend to often abuse the language to show off their cleverness at the expense of users and maintainers. I don’t know why this is. I suspect it’s because Odersky set the bar so high with his obvious brilliance that some feel insecure.<p>One take away quote for me:<p>“Unfortunately, we don’t like boring. We like to take the language and the compiler to their limits. We also like to adopt the latest fad. But the software systems we work on in our jobs should not be a playground or a test bed for the latest fad.”<p>Scala developers aren’t doing anything new here. People have abused fads in programming for decades. “Design Patterns” and “Test Driven Development” and “RESTful” come to mind. However, it’s unfortunate that Scala developers in particular do this. Because, Scala seems to be a language specifically designed to avoid past mistakes.
评论 #18656222 未加载
评论 #18655932 未加载
评论 #18663463 未加载
评论 #18657052 未加载
评论 #18656239 未加载
titzer超过 6 年前
“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you&#x27;re as clever as you can be when you write it, how will you ever debug it?”<p>--Brian Kernighan<p>How many times have I bitten myself this way? Dear past me: stop being so smart.
评论 #18656309 未加载
评论 #18660620 未加载
Verdex_3超过 6 年前
I really like it when people become concerned about cognitive complexity. I think it&#x27;s one of the significantly ignored concepts in our industry and if we ever find a way to address the issue (either with some sort of cognitive complexity solution or some sort of big oh like math framework that describes how things are complex) then the future generations of software engineers will look at what we&#x27;re currently doing now the same way we look at how people used to do alchemy for our lack of being able to handle cognitive complexity.<p>Personally, I want a mathematical structure of &quot;problems&quot; such that we can track when we&#x27;re actually making things more complex or less complex. In the article, removing boilerplate was a problem because internal domain models were being exposed publicly. But what I really want to know is &quot;what are we actually gaining by removing the boiler plate and what are we losing by exposing domain models&quot;. In like a general mathematical sense such that if everyone about programming changes (maybe suddenly we switch to APL or something), the lessons we learned are still valid.<p>So far the best I&#x27;ve managed is [1]. I&#x27;ve done a bunch of refinement in the last year and a half, but the general structure is about the same. I&#x27;m not suggesting that what I have is complete or even necessarily the right direction to go for this sort of thing. But what I am saying is that in order to make definite statements about how the problem and&#x2F;or code you&#x27;re dealing with is complex (that don&#x27;t rely on appeals to authority) then you probably need to have done at least as much &quot;work&quot; as I have (if that makes any sense).<p>[1] - <a href="https:&#x2F;&#x2F;www.sep.com&#x2F;sep-blog&#x2F;2017&#x2F;04&#x2F;25&#x2F;objective-code-quality-blog-series&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.sep.com&#x2F;sep-blog&#x2F;2017&#x2F;04&#x2F;25&#x2F;objective-code-quali...</a>
评论 #18656718 未加载
kreetx超过 6 年前
Has somewhat similar intro to the Rich Hickey&#x27;s famous &quot;Simple made easy&quot; talk. A good read nevertheless.
评论 #18655408 未加载
评论 #18663415 未加载
jondubois超过 6 年前
&gt;&gt; Hence, we try to isolate business logic from effects and implement the former as pure functions.<p>This is a valuable insight. Especially if your main programming language supports both functional and procedural and&#x2F;or OOP approaches; This statement offers a good guideline as to where the boundary should be.<p>I find that functional programming is great for business logic but not as great for more concrete logic where performance is important. For example, when dealing with low level concrete objects like sockets.
divan超过 6 年前
It&#x27;s a refreshing read even for non FP&#x2F;Scala development world.<p>It&#x27;s not hard to see that modern software engineering is cherishing accidental complexity, and as it comes from the &quot;tools we use&quot;, the fair share of problem is in the languages, frameworks and tools we use. Unfortunately, there are very little of them that really take a tough stance on fighting complexity, instead of adding more features. Actually I can think only of one such language – Go, and, unsurprisingly, it&#x27;s critizised heavily in many circles exactly for the lack of accidental complexity.<p>Tony Hoare wrote this in 1974: “But the pursuit of simplicity is one of the most difficult and challenging activities of the human mind. Progress is likely to be extremely slow, where each complexity eliminated must be hailed as a breakthrough. We need not only brilliance of intellect but breadth of experience, nicety of judgement, excellence of taste, and even more than our fair share of good luck.“<p>I was quite impressed after reading this essay (it&#x27;s from &quot;The software design: a parable&quot; [1]) – written almost half a century ago, and there seem to be a little progress, if not negative. So books and talks are unlikely to change anything – we, people will still use the path of least resistance and always will be subjected to congitive biases – so probably only tooling can make a change. Go, for example, simply doesn&#x27;t allow you to do many overly complex things (on purpose) and it results in extremely readable codebase – chances that you open random piece of Go code on internet and will not be able to understand it are almost zero.<p>I find it a terrific achievement, and wish other (future) languages could embrace the importance of it.<p>[1] <a href="https:&#x2F;&#x2F;people.dsv.su.se&#x2F;~jpalme&#x2F;s1&#x2F;hoare.pdf" rel="nofollow">https:&#x2F;&#x2F;people.dsv.su.se&#x2F;~jpalme&#x2F;s1&#x2F;hoare.pdf</a>
Ericson2314超过 6 年前
Scala is an especially messed up situation. Everything is either overengineered or simplistic; there is no good middle ground because the language is a mess.<p>This is a little-acknowledged industry-wide problem that extends beyond hot-shot overengineering to reems of banal code too, so I would rather it be written from a less expected perspective.
lmm超过 6 年前
&gt; Doing that certainly means that you scrap quite a bit of boilerplate and reduce the complexity in your code. However, if you look at the bigger picture, this is the opposite of removing complexity. Exposing your domain model like this almost always leads to strongly coupled systems that are very difficult to evolve. If you ask me, this is one of the most promising ways to create a distributed monolith. It really amazes me how many people are totally okay with simply making their internal model their public API, especially since functional programmers are usually crazy about abstractions.<p>Good functional programmers are happy not to introduce an extra layer of indirection yet, because they know that their code is easy to refactor. The article itself seems to come to that point later, yet it gets it completely backwards here.<p>Generate JSON formats the easy, zero-boilerplate way for now. <i>As and when</i> you have a requirement for a JSON representation that looks different from your domain representation - perhaps because you want to evolve your internal domain model while keeping the JSON representation the same - you can introduce manual JSON codecs (or DTOs, or whatever you prefer) at that time.<p>&gt; Object-oriented programmers call this technique stubbing, and they get mocked for doing it, mostly by people like us.<p>They get mocked for doing it because it breaks all the rules of the language. It usually relies on reflection, bytecode manipulation, or other such horrors. It&#x27;s often thread-unsafe. Having tests that you can&#x27;t refactor the way you normally refactor code is a huge, mostly-hidden cost.<p>&gt; But you have no clue if your production interpreter, which is talking to an external system, is working correctly at all. So abstracting over the effect monad and using the Id monad in tests doesn’t even help you to write meaningful tests.<p>Tests need to be decomposed like any other code. There&#x27;s a huge value in testing your business logic separately from testing your interactions with external systems. Functional core, imperative shell achieves that, but at a higher cost: you can&#x27;t interleave your interactions with external systems and your logic in the natural way in code, you have to explicitly, manually push all the interactions to the edge instead.<p>&gt; What if we did server-side rendering of HTML instead? There wouldn’t be any need to design an evolvable JSON API, which, unlike simply exposing your domain model, is not trivial, and there would definitely be no need for defining any JSON codecs. And that’s just what you get on the server side. On the frontend side, you would have one piece of software less to maintain, you’d get faster load times and you could get rid of duplicated business logic.<p>You&#x27;d get slower load times as you had to do page transitions, and more duplicate logic as things like form validation had to be done on the frontend and backend with separate code.<p>&gt; At some point, we realize that we have an architectural problem at the macro level. Maybe, if we continue to ask why long enough, we will come to the conclusion that all these services we need to communicate with exist in exactly this way because of how the company is organized.<p>And which is easier to fix? At some point you decide that the entirety of western civilization is fundamentally flawed, and you can either start ranting about how we need to rebuild society from the ground up, or you can put a bit of complexity in your software and make something actually useful.<p>&gt; I was recently talking to someone about Rust, and that person said, “A language without higher-kinded types is completely useless!”. Yes, certain abstractions are not possible without them, but I have never seen a project fail due to a lack of higher-kinded types.<p>That may have been me, and I absolutely have seen projects fail due to lack of higher-kinded types. Not in an obvious way; rather it felt like a general sludginess to development, a need to repeat the same tasks over again, until the project eventually dies from a thousand cuts. (Hell, for all I know the company I left several years ago may still be trying to make that project work).<p>&gt; Projects fail because the problem domain is not well understood, or because the architecture is not a good fit for the requirements. They also fail because of how the organisation is structured and because of politics, be it intra- or inter-organizational. Projects fail because of people, and because of people not talking to each other.<p>This is facile. Projects fail because of people talking to each other too much. Projects fail because people tried to fix their organisational politics instead of implementing technical workarounds. Projects fail because the technology choices were simply bad.<p>Reading this article was weird, because I found myself nodding along with most of the woolly principles but then massively disagreeing with every single example. It makes me think the article is arguing at the wrong level of abstraction somehow: no-one thinks you should use a complex solution when a simple one will do. Very few people will claim that the problem with today&#x27;s software is that programmers think things through too much and should rush to write code instead (though for the record I think that&#x27;s actually the case). But those consensus principles don&#x27;t actually help us at all when it comes to discuss specific decisions.
评论 #18656876 未加载
评论 #18656782 未加载
monksy超过 6 年前
I was pleasantly surprised to read an article like this. Less surprised that it came from Daniel Westheide. He know&#x27;s his stuff.<p>What I was expecting: I was expecting the fad pushing an article about how too many people push components together and then they&#x27;re trying to sell some kind of microservices nonsense.
bg4超过 6 年前
See also: <a href="http:&#x2F;&#x2F;www.lihaoyi.com&#x2F;post&#x2F;StrategicScalaStylePrincipleofLeastPower.html" rel="nofollow">http:&#x2F;&#x2F;www.lihaoyi.com&#x2F;post&#x2F;StrategicScalaStylePrincipleofLe...</a>
rue超过 6 年前
Scala is for people who weren’t around for C++ template metaprogramming.
leowoo91超过 6 年前
tl;dr <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Chunking_(psychology)" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Chunking_(psychology)</a>