当前位置:首页 > 开发 > 编程语言 > 编程 > 正文

The Eight Myths of Erlang Performance

发表于: 2011-12-01   作者:bookjovi   来源:转载   浏览:
摘要: erlang有一篇guide很有意思: http://www.erlang.org/doc/efficiency_guide 里面有个The Eight Myths of Erlang Performance: http://www.erlang.org/doc/efficiency_guide/myths.html   Myth: Funs are sl

erlang有一篇guide很有意思: http://www.erlang.org/doc/efficiency_guide

里面有个The Eight Myths of Erlang Performance: http://www.erlang.org/doc/efficiency_guide/myths.html

 

Myth: Funs are slow

Myth: List comprehensions are slow

Myth: Tail-recursive functions are MUCH faster than recursive functions

Myth: '++' is always bad

Myth: Strings are slow

Myth: Repairing a Dets file is very slow

Myth: BEAM is a stack-based byte-code virtual machine (and therefore slow)

Myth: Use '_' to speed up your program when a variable is not used

 

另一篇文章http://www.erlang.org/doc/efficiency_guide/listHandling.html#id209936

里面提到了List comprehensions的实现,List comprehensions在erlang中被compiler转换成fun,如下:

[Expr(E) || E <- List]

将会被compile成下面的fun

'lc^0'([E|Tail], Expr) ->
    [Expr(E)|'lc^0'(Tail, Expr)];
'lc^0'([], _Expr) -> [].

 

里面有提到了另一种转化形式:

[io:put_chars(E) || E <- List]

'lc^0'([E|Tail], Expr) ->
    Expr(E),
    'lc^0'(Tail, Expr);
'lc^0'([], _Expr) -> [].
 因为此种情况下compiler可以知道List comprehensions的结果没有被使用,所以直接优化成尾递归。

 

The Eight Myths of Erlang Performance

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
had tested a hello world web server in C, Erlang, Java and the Go programming language. * C,
Myths, Lies, and Truths about the Linux kernel Hi, as Dave said, I'm Greg, and I've been give
Myths, Lies, and Truths about the Linux kernel Hi, as Dave said, I'm Greg, and I've been give
Have you ever gotten that classic job interview question, "where do you see yourself in five
Member Today’s task Tomorrow’s task Note Rui 719: Implement the add function 719 continued
内存管理 一.分配动态内存的几个函数 用户空间内存分配:malloc、calloc、realloc 1、malloc原型如
Any system that logs vast amounts of information, needs to think about performance. The activ
epmd进程和Erlang节点进程如影随形,在Rabbitmq集群,Ejabberd集群,Couchbase集群产品文档中都会有相
 转载自http://www.cnblogs.com/me-sa/p/erlang_notes_129.html Adding special-purpose proces
[Note]: The oirginal link of the article:http://www.guardian.co.uk/technology/gamesblog/2009/
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号