V strong language summit GitHub TOP1, the intention of seizing Go and replaced?

640?wx_fmt=gif

This combined with the new language V Go and Rust characteristics, officially released the first version available.

640?wx_fmt=jpeg

Finishing | Guo Rui

Exhibition | CSDN (ID: CSDNnews)

For a long time, the programming language in terms of grammar, semantics and standard library, etc. There are vastly different, so that programmers had to face the choice of differentiation and other problems. Under natural selection, there will be out of the old languages (PHP was an accident, still exist) and the birth of a new language. In "JetBrains recently released 2019 developer ecosystem status quo ," the report, Java, Python, C / C #, JavaScript and other mainstream programming language after practice after the test is still good developers heart.

Python would be arrogant person! Overpaid to find a job so simple?

https://edu.csdn.net/topic/python115?utm_source=cxrs_bw

The protagonist V language of this article, after the long-awaited, finally recently open sourced, and officially released the first version available (pre-built binaries coming soon)! One was released, the summit will be a strong GitHub TOP1, lead developers of hot crowd.

 

640?wx_fmt=png

(https://github.com/vlang/v/releases/tag/v0.0.12)

 

According to introduction, V is a new statically compiled language, it can "fast compiler, and secure, and C / C ++ converter", which provides a convenient, fast and safe programming language and toolkit can also be well positioned to serve block chain technology.

 

640?wx_fmt=gif

 

V language of Reishi Saza says that it is a very simple language, see the official documents 30 minutes to fully grasp. Moreover, its compiler is only 400KB, without any third-party dependencies.

 

640?wx_fmt=jpeg

(Application Example of display: V language established macOS Demo)

 

V 的核心 CPU 每秒可以编译大约 120 万行代码,这种速度是通过生成的机器代码和强大的模块化来实现的,但是目前仅支持 x64/Mach-O,预计到今年年底才能足够稳定。而在性能表现上,V 可以做到和 C 一样快,且能够翻译整个 C 或 C++ 项目,实现高达 400x 的编译速度。

 

 
std::vector<std::string> s;s.push_back("V is ");s.push_back("awesome");std::cout << s.size();mut s := []s << 'V is 's << 'awesome'println(s.len)
s.push_back("V is ");
s.push_back("awesome");
std::cout << s.size();

mut s := []
s << 'V is '
s << 'awesome'
println(s.len)

 

目前,整个 V 语言及其标准库小于 400 KB,开发者在 0.4 秒内就可以构建它。并且到今年年底,这个数字还将下降到大约 0.15 秒。

 

此外,开发者们还在官网上放出了部分示例代码。更多编译器函数介绍可参见官方网站:https://vlang.io/。

 

1、数据库访问:

 

 
struct User { /* ... */ }struct Post { /* ... */ }struct DB   { /* ... */ }struct Repo <T> {    db DB}fn new_repo<T>(db DB) Repo {    return Repo<T>{db: db}}fn (r Repo) find_by_id(id int) T? { // `?` means the function returns an optional    table_name := T.name // in this example getting the name of the type gives us the table name    return r.db.query_one<T>('select * from $table_name where id = ?', id)}fn main() {    db := new_db()    users_repo := new_repo<User>(db)    posts_repo := new_repo<Post>(db)    user := users_repo.find_by_id(1) or {        eprintln('User not found')        return    }    post := posts_repo.find_by_id(1) or {        eprintln('Post not found')        return    }} /* ... */ }
struct Post { /* ... */ }
struct DB   { /* ... */ }

struct Repo <T> {
    db DB
}

fn new_repo<T>(db DB) Repo {
    return Repo<T>{db: db}
}

fn (r Repo) find_by_id(id int) T? { // `?` means the function returns an optional
    table_name := T.name // in this example getting the name of the type gives us the table name
    return r.db.query_one<T>('select * from $table_name where id = ?', id)
}

fn main() {
    db := new_db()
    users_repo := new_repo<User>(db)
    posts_repo := new_repo<Post>(db)
    user := users_repo.find_by_id(1) or {
        eprintln('User not found')
        return
    }
    post := posts_repo.find_by_id(1) or {
        eprintln('Post not found')
        return
    }
} 

 

2、网络开发:

 

 
struct Story {    title string}// Fetches top HN stories in 8 coroutines fn main() {    resp := http.get('https://hacker-news.firebaseio.com/v0/topstories.json')?    ids := json.decode([]int, resp.body)?    mut cursor := 0    for _ in 0..8 {        go fn() {            for  {                lock { // Without this lock the program will not compile                     if cursor >= ids.len {                        break                    }                    id := ids[cursor]                    cursor++                }                resp := http.get('https://hacker-news.firebaseio.com/v0/item/$id.json')?                 story := json.decode(Story, resp.body)?                println(story.title)            }        }()    }    runtime.wait() // Waits for all coroutines to finish } 
    title string
}

// Fetches top HN stories in 8 coroutines 
fn main() {
    resp := http.get('https://hacker-news.firebaseio.com/v0/topstories.json')?
    ids := json.decode([]int, resp.body)?
    mut cursor := 0
    for _ in 0..8 {
        go fn() {
            for  {
                lock { // Without this lock the program will not compile 
                    if cursor >= ids.len {
                        break
                    }
                    id := ids[cursor]
                    cursor++
                }
                resp := http.get('https://hacker-news.firebaseio.com/v0/item/$id.json')? 
                story := json.decode(Story, resp.body)?
                println(story.title)
            }
        }()
    }
    runtime.wait() // Waits for all coroutines to finish 

 

当然,目前V 语言的开发仍处于早期阶段,很多方面还不够完善,尤其是内存管理上还面临着与 Go 和 Rust 同样繁琐的生命期管理问题,但对比 C++ 等手动和半自动的管理方式还是更省心一些的。

 

那么开发者们怎么看?

 

 

@三川走刀口:还是要得到开发者认可,但是对于安卓开发好像没用?

 

@淡定的龙哥:Go语言同父异母的弟弟?

 

@Heisenber哥:语言特性只是一方面,生态也很重要。

 

@王的凝视:这个新语言提出来是为了解决什么问题?每种语言都有适合场景,如果没有合适场景迟早也要被淘汰。

 

@楚小欢:执行效率比C高应该不可能,C现在都被认为是汇编语言,本身语义也十分接近汇编。别的语言只要有高级点的特性,效率就不可能超过C。

 

总之,这个新生的 V 语言还是需要不断的发展,得到开发者的广泛应用才能焕发生机,也才能有望助力程序员做到真正的“人剑合一”。

640?wx_fmt=png

CSDN 5G 沙龙来啦!

6 月 29 日,微软(中国)首席技术官韦青、北京邮电大学信息与通信工程学院多媒体技术教研中心主任/博士生导师孙松林、金山云 AIoT 事业部高级研发总监肖江、爱立信中国研发部多天线高级专家朱怀松、爱立信中国研发部主任系统工程师刘阳等行业内顶尖的领军者、资深的技术专家们共聚一堂,共同探讨 5G 在物联网中的巨大潜能。

扫描下方二维码,马上预约直播!

640?wx_fmt=jpeg

 Thermal paper  recommended 

write code is not strict, I do not deserve to be a programmer?

Beijing University of Posts and Telecommunications, Dr. Wan word text communication with you know sec 4G / 5G difference!

programmers is how off single? | Programmer something to say

5G era, Microsoft has gone a step of chess!

LinkedIn latest report: block chain to post the fastest-growing areas of demand, the desire of the people in these areas to block the chain the highest ......

rolling Bert? What "Tu list" of XLnet mean for NLP tasks

vomiting blood summary! 100 Interview Questions Python Collection (on)

2019 years of technical inventory of container articles (a): Listen UCloud talk about wind and water K8S | hardcore programmers evaluation

17-year-old programmer tell you 7 important lessons about programming!

☞ "is! Internet since there is no BAT!"

640?wx_fmt=gifClick to read the original, live appointments.

640?wx_fmt=pngYour point of each "look", I seriously as a favorite

Guess you like

Origin blog.csdn.net/csdnsevenn/article/details/93679131