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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Why don't we listen to Occam's Razor when it comes to programming languages?

6 点作者 LightMachine超过 9 年前
Repeatedly through the history of humanity, huge advancements came from the conception of simple systems that replaced complex systems. An example is the decimal system itself. It does essentially the same that roman numbers do, except much better, <i></i>for being simpler<i></i>. And that very fact opened doors for science to progress much faster, because we weren&#x27;t busy spending evenings multiplying numbers. This is one of countless examples that show there is a great benefit in pursuing the simplest alternative.<p>When it comes to programming languages, we didn&#x27;t learn that lesson. Each other day someone develops a new fancy programming language with X more features, not realizing that all those features are already present on the simplest languages. The λ-calculus - a 70 year old system - already does everything that all those do, simpler and faster (compiling to Haskell, it already runs an order of magnitude faster than the average Python program). We treat PLs like products, but in reality they&#x27;re just mathematical objects. Imagine if each other day someone created a new fancy numeric system? <i></i>Why, instead of designing hundreds of fancy, complex programming languages, aren&#x27;t we focusing in studying how those features manifest on the simplest languages, and implementing faster evaluators for them?<i></i><p>Here is Euler&#x27;s 1st problem solved on the Caramel syntax for the λ-calculus:<p><pre><code> euler1 = (sum (filter (either (mod 3) (mod 5)) (range 1000)))</code></pre>

4 条评论

theWold超过 9 年前
I would think that Simplicity would also have to include &#x27;readability&#x27;. In other words Simple for humans Write and Read.<p>You give a great example of Euler&#x27;s 1st problem (<a href="https:&#x2F;&#x2F;projecteuler.net&#x2F;problem=1" rel="nofollow">https:&#x2F;&#x2F;projecteuler.net&#x2F;problem=1</a>) but if someone wasn&#x27;t given the context of the problem, or even if they were are unfamiliar with the syntax you used, they would not call you solution &#x27;simple&#x27;.<p>That being said transfer of knowledge is a key component when reading. Going to your point about the decimal system (which I believe you were talking about the arabic numberals (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Arabic_numerals)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Arabic_numerals)</a>). Sure it is faster and shorter to use than Roman Numerals, but then again the knowledge transfer that you could do with Arabaric numerals is much greater than Roman.<p>I would say for programming languages, ever time we, programmers, innovate on one we are trying to make a process simpliar to the user (I believe &#x27;abstraction&#x27; would be an appropriate word to use).
评论 #10708098 未加载
评论 #10708086 未加载
CyberFonic超过 9 年前
Why Caramel? Why not just Lisp&#x2F;Scheme? for the example.<p>Funny you should ask this question on HN. Have you read PG&#x27;s essays on Lisp and the competitive advantage it granted his team in developing ViaWeb?<p>Your question might be about PLs, but in effect you are asking why somebody would prefer one abstraction over another.<p>Personally, I find it difficult to read and grok math. But if I write out stuff in Lisp s-exprs and use meaningful names for functions, etc, then I generally can understand a little bit better. Being able to &quot;execute&quot; such descriptions helps further.<p>Languages such as Lisp, Scheme, Smalltalk, Self (of the ones I&#x27;m familiar with) have simple syntax and powerful abstractions. They failed to gain &quot;market share&quot; due to perceived failings. However, they adhered to the philosophy of Occam&#x27;s Razor.<p>I&#x27;ll probably get flamed for saying this ... when you look at systems written in Lisp, the debates tend to boil down to people arguing over whether their abstraction is better than the other guy&#x27;s. With a powerful language you can do anything in any way you choose. So the abstraction becomes the differentiating factor. Hence the emergence of not invented by me syndrome.
评论 #10708206 未加载
评论 #10708207 未加载
gonyea超过 9 年前
<a href="https:&#x2F;&#x2F;mobile.twitter.com&#x2F;wm&#x2F;status&#x2F;7206700352?lang=en" rel="nofollow">https:&#x2F;&#x2F;mobile.twitter.com&#x2F;wm&#x2F;status&#x2F;7206700352?lang=en</a><p>I love programming, but in the context of building great products. Languages are just a choose-your-compromise adventure, except JavaScript was chosen for you (it&#x27;s fun!).<p>If Lisp powered Salesforce, I&#x27;m not sure anyone would describe that sausage as elegant. I&#x27;d love to see it consume a SOAP API... Or talk to a Mainframe (lol).<p>I use a lot of languages in every project and it&#x27;s great. Purity is boring.
评论 #10719051 未加载
an_ko超过 9 年前
Surely binary is simpler than decimal, and yet humans rarely use it. Purity is nice, but there&#x27;s a tradeoff with needing to get stuff done so you can pay the rent.
评论 #10708112 未加载