zoukankan      html  css  js  c++  java
  • vala 语言

    http://live.gnome.org/Vala
    Vala is a new programming language that aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C.
    目标是把现代语言的特性带到GNOME开发上,不需要附加的运行时。

    valac, the Vala compiler, is a self-hosting compiler that translates Vala source code into C source and header files. It uses the GObject type system to create classes and interfaces declared in the Vala source code.

    valac 是vala的编译器,它是一个“自编译”的编译器,可以把vala源代码翻译成c源代码和头文件,使用GObject类型系统。


    The syntax of Vala is similar to C#, modified to better fit the GObject type system. Vala supports modern language features as the following:

    • Interfaces
    • Properties
    • Signals
    • Foreach
    • Lambda expressions
    • Type inference for local variables
    • Generics
    • Non-null types
    • Assisted memory management

    • Exception handling
    • Type modules (Plugins)

    Vala的语法与C#类似。

    示例代码:

    Vala List Example

    This sample uses the List class from GLib. There is also various container classes in libgee, which are often easier to use or more powerful. See ../GeeSamples

    Toggle line numbers
       1 public static int main (string[] args) {
    2 List<string> list = new List<string> ();
    3 list.append ("one");
    4 list.append ("two");
    5 list.append ("three");
    6
    7 stdout.printf ("list.length () = %u\n", list.length ());
    8
    9 // Traditional iteration
    10 for (int i = 0; i < list.length (); i++) {
    11 stdout.printf ("%s\n", list.nth_data (i));
    12 }
    13
    14 // Comfortable iteration
    15 foreach (string element in list) {
    16 stdout.printf ("%s\n", element);
    17 }
    18
    19 return 0;
    20 }

    Compile and Run

    $ valac -o list list.vala
    $ ./list
    当前版本,Vala 0.7.4 ,但大部分功能已实现,预计在(2009-09-14)发布Vala 1.0.0。在GNOME下,大有替代C之势。
    来段代码对比:


    性能对比:
    http://code.google.com/p/vala-benchmarks/wiki/BenchResults
    性能与C接近,文件尺寸略大。
  • 相关阅读:
    一个统计代码行数的简单方法
    关于string的对象引用
    mysql连接的一些问题。
    linux环境初始化 用户问题
    php null o false ''
    php支付宝在线支付接口开发教程【转】
    模拟支付宝服务窗环境
    ctags
    校验全球电话号码 正确性 库 正则表达式
    php短路与 短路或
  • 原文地址:https://www.cnblogs.com/zhongzf/p/1527884.html
Copyright © 2011-2022 走看看