• 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接近,文件尺寸略大。
  • 相关阅读:
    8 盒子模型
    7 display属性
    如何提高运维价值体系
    Python学习之OS模块初识
    7、MongoDB学习之游标
    Python 学习之文件对象的属性和方法简介
    Python集合set()操作详解
    Python中的字典介绍
    Python序列之元组
    Python序列之列表
  • 原文地址:https://www.cnblogs.com/zhongzf/p/1527884.html
Copyright © 2020-2023  润新知