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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Elixir: First impressions

6 点作者 antifuchs超过 12 年前

2 条评论

metajack超过 12 年前
I don't think Erlang's syntax is at all inconsistent; it's just different.<p>Once you understand what periods, semicolons, and commas are actually doing, there is no confusion. In the same way an English writer doesn't get confused about when to use periods, Erlang's periods become invisible before long.<p>That's not to say they are awesome. They cause some issues with refactoring. Moving a bit of code might involve also changing its ending punctuation. This is also true in JavaScript, Python, and Ruby in list/map syntax. You just run into it more with Erlang since there is more of it.<p>Pattern matching is also one of my favorite things about Erlang, especially the binary syntax.<p>One example I particular like is the binary digest to hex representation[1]:<p><pre><code> hexstring(&#60;&#60;X:128/big-unsigned-integer&#62;&#62;) -&#62; lists:flatten(io_lib:format("~32.16.0b", [X])). </code></pre> [1] <a href="http://www.enchantedage.com/hex-format-hash-for-md5-sha1-sha256-and-sha512" rel="nofollow">http://www.enchantedage.com/hex-format-hash-for-md5-sha1-sha...</a>
rdtsc超过 12 年前
&#62; I was always scratching my head over why this place needs a period and that place doesn’t<p>I like Fred Hebert's (author of <a href="http://learnyousomeerlang.com/" rel="nofollow">http://learnyousomeerlang.com/</a>) explanation of syntax on his blog:<p><a href="http://ferd.ca/on-erlang-s-syntax.html" rel="nofollow">http://ferd.ca/on-erlang-s-syntax.html</a><p>At least the "template" explanation is most helpful to me.<p>&#62; then there was just plain weird stuff like one-based indexes.<p>Interestingly, I don't think indexing is really that common in idiomatic Erlang. In other words when processing lists, one can split them into head and tail [H|T] or uses folds and maps.
评论 #5086307 未加载