当前位置:网站首页>Rust versus go (which is my preferred language?)

Rust versus go (which is my preferred language?)

2022-07-07 07:54:00 Xijing swordsman

Rust Versus Go

Link to the original text : https://dormoshe.io/trending-news/rust-versus-go-52434

After learning these languages from the following author's book , I have been using it for the past year Rust and Go.

Herbert Wolverson’s Hands-on Rust:
Ricardo Gerardi’s Powerful Command-Line Applications in Go:

Over the past year, colleagues and colleagues have been asking ,Medium Articles and Reddit Rust and Go A big problem that seems to appear in the forum is ,“ Which is better? ?” There is really no answer to this question , Because it is a very subjective decision . Almost all these articles and posts are written in “ As the case may be ” ending . But since engineers prefer absolute decisions , This is not a satisfactory answer . So a better question is ,“ Which one do you prefer ?” After using these two languages in various scenarios , My default preferred language is ……Go.

Why Go?

I'm not a system programmer , I spend most of my time with DevOps Related work .Go Is for DevOps The design of the , This is in Docker、Grafana and Kubernetes Wait for all DevOps It is obvious in the application centered on . I have no patience to compile for a long time , I just found that the failure of the build was due to some slow errors , Sometimes it takes me hours to figure it out . Just like those who have read my new book or in recent Changelog Podcast As everyone who listens to my interview knows , I use it at home Raspberry Pi. Try compiling a ratio “Hello, World!” Longer Rust Applications stay Raspberry Pi On . If you're lucky , Assuming there are no compilation errors , It will be finished in an hour or more .

**Go The embedded runtime that carries every executable with you , But compared with the overall benefits of compilation speed and portability , It's relatively small .** Although both languages have many dependencies , But in recent months ,Rust It has become a bigger target of supply chain attack , This may be due to its growing prominence in the community , Because it is accepted as Linux kernel . image System76 Such companies also say , They intend to make use Rust To build Pop!OS desktop.

performance

In terms of performance , I find - For my micro project , Both are similar . I'm not building large-scale parallelism PB Level architecture , It's about building small... That can do a specific task well 、 Stable procedures .

If Want to keep things simple and don't care about performance , that Python Scripts will do . however ,** If you want higher performance and a fairly small native executable , that Go Is my main language choice .** Of course , The language has no official GUI Support , but Rust So it is with . Although both languages exist based on Webkit Of GUI project , But I don't have enough interest in them to learn them .

Command line program

actually , Due to the nature of its terminal centric output , These languages let me rediscover the fun and speed of non bloated command-line iterative programs . for example , I am here Go Write a custom Twitter client , It highlights the key theme labels and people I care about in different colors , So that I can quickly 、 Visually identify interesting posts in my feed . It is used on the back end Redis cloud , So every time I run tw when , It will be synchronized between the various operating systems I run it . I use Go It took less than an hour to write the code , Even in my Pi Zero It took less than a few seconds to compile on . Although I have thought about using Rust Rewrite it just to practice my language ability , But time goes on , Only so many hours a day can be spent on study and experiment .

Rust Do you have a chance ?

If so Rust You can reduce the compilation time to a more reasonable time , And provide less stupid error messages when compiling interrupts , I may reassess my major language choices . But for now , When I need to quickly create and deploy new programs ,Go It is the first choice of my coding list .

原网站

版权声明
本文为[Xijing swordsman]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070421032621.html