2

再见 Golang, 你好 Rust

 1 week ago
source link: https://www.v2ex.com/t/1037766
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

再见 Golang, 你好 Rust

V2EX  ›  Rust

再见 Golang, 你好 Rust

  proxyai · 12 小时 49 分钟前 · 2438 次点击

原因: 不想考虑数据竞争的问题了, 因为人永远考虑不周全, 所以让机器处理才是合理的

15 条回复    2024-05-05 22:18:19 +08:00
thinkm

thinkm      12 小时 46 分钟前

不用 Golang 的人,注定只能度过一个相对失败的人生
williamshan

williamshan      12 小时 37 分钟前 via Android

@thinkm 怎么讲
sherlockwhite

sherlockwhite      12 小时 19 分钟前

有什么数据竞争的实例吗
sherlockwhite

sherlockwhite      12 小时 18 分钟前

想不通从一个相对简单的语言转到一个复杂的语言就是因为数据竞争,不太懂是什么逻辑
march1993

march1993      12 小时 7 分钟前

让机器处理太简单了,所有数据加个锁就完事儿了,但是这样做性能太差了。golang 的套路是让你通过 chan 去通信、同步,而不是靠 sync.*。并且 rust 也没有在语法层面提供同步的办法啊。
proxyai

proxyai      11 小时 54 分钟前

@march1993 加锁当然可以, 但是我觉得 golang 的处理方案很凑合, 而且你能保证你永远都会在有需要的时候把锁都加全吗? 是不是感觉非常别扭?
chaleaochexist

chaleaochexist      10 小时 41 分钟前

这种帖子吧。。。 就是收币的, 得,5 铜币奉上, 不谢!
minami

minami      10 小时 32 分钟前

这么不喜欢锁怎么不去写单线程的 js ,是不喜欢吗
smallboy19991231

smallboy19991231      10 小时 13 分钟前

@williamshan 有句原話是 不用 Mac 的人,注定只能度过一个相对失败的人生
march1993

march1993      9 小时 19 分钟前

@proxyai 所以 golang 套路是让你用 chan 而不是让你加锁啊
standchan

standchan      7 小时 51 分钟前

用 chan 去通信,而不是传统的锁。
xwhxbg

xwhxbg      7 小时 14 分钟前   ❤️ 1

冷知识,chan 内部自带一个锁
lsk569937453

lsk569937453      6 小时 56 分钟前

@proxyai
rust 不是银弹。
我在用 rust 实现 redis 的过程中对比了 mpsc::channel 和 Arc::Mutex 的性能。
单线程下,两者性能差不多的。
多线程下,全局 Arc::Mutex 对数据加锁的性能还比 mpsc::channel(多生产者单消费者)好一点

https://github.com/lsk569937453/rcache/tree/main:全局锁
https://github.com/lsk569937453/rcache/tree/0.0.1:mpsc::channel 实现的多生产者单消费者模型
ShuWei

ShuWei      1 小时 54 分钟前

你确定自己能受得了 rust 的折磨?
fregie

fregie      1 小时 18 分钟前

这有什么好选的,本身就是为了不同场景而设计的不同语言,在不同领域各有优势

关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2453 人在线   最高记录 6543   ·  

创意工作者们的社区

World is powered by solitude

VERSION: 3.9.8.5 · 27ms · UTC 15:36 · PVG 23:36 · LAX 08:36 · JFK 11:36
Developed with CodeLauncher
♥ Do have faith in what you're doing.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK