The D Programming Language

 前段时间在打算写一个分布式组件平台的时候,一直想改写C++,无奈C++太复杂了,也因为精力有限,就放弃了这个项目.不过倒是发现了一个新的语言, D语言,这个语言出来也有好长的一段时间了.只是国内关注的人不多.今天有空就贴出来.和大家分享一下.
 

What is D?


 D is a general purpose systems and applications programming language. It is a higher level language than C++, but retains the ability to write high performance code and interface directly with the operating system API's and with hardware. D is well suited to writing medium to large scale million line programs with teams of developers. D is easy to learn, provides many capabilities to aid the programmer, and is well suited to aggressive compiler optimization technology.

D is not a scripting language, nor an interpreted language. It doesn't come with a VM, a religion, or an overriding philosophy. It's a practical language for practical programmers who need to get the job done quickly, reliably, and leave behind maintainable, easy to understand code.

D is the culmination of decades of experience implementing compilers for many diverse languages, and attempting to construct large projects using those languages. D draws inspiration from those other languages (most especially C++) and tempers it with experience and real world practicality.

看个例子.
import std.file;

int main (char[][] args)
{
    int w_total;
    int l_total;
    int c_total;

    printf ("   lines   words   bytes file/n");
    foreach (char[] arg; args[1 ..  args.length])
    {
        char[] input;
        int w_cnt, l_cnt, c_cnt;
        int inword; input = cast(char[])std.file.read(arg);

        foreach (char c; input)
        {
            if (c == '/n')
                ++l_cnt;
            if (c != ' ')
            {
                if (!inword)
                {
                    inword = 1;
                    ++w_cnt;
                }
            }
            else
                inword = 0;
            ++c_cnt;
        }
        printf ("%8lu%8lu%8lu %.*s/n", l_cnt, w_cnt, c_cnt, arg);
        l_total += l_cnt;
        w_total += w_cnt;
        c_total += c_cnt;
    }
    if (args.length > 2)
    {
        printf ("--------------------------------------/n%8lu%8lu%8lu total",
            l_total, w_total, c_total);
    }
    return 0;
}

http://www.digitalmars.com/d/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值