rt
我觉得golang中的基本类型不附加并发安全性完全可以理解,但pkg中的高层API是否可以尝试提供这样的保障。比如,我现在不能使用container包,就有点遗憾了
2014-12-04 3:14 GMT-05:00 hyper-carrot <free...@gmail.com>:
> 其实,之所以Java如此流行且学习门槛很低,就是因为它的标准库中提供了大量的便捷工具,这可以大大降低应用开发者的成本从而在侧面提高开发效率。我觉得这是极好的。我之所以说不是***不是重点,是因为Go语言设计者还没有精力或不屑于做出这些并发安全的数据结构。你回复的那些内容我只在心里默念了没写出来,对不起楼主。总之,我觉得Go的这种策略无可厚非,但是对于面向用惯了锁的开发者们的语言推广工作没什么好处。
并没有说不用锁啊。只不过Go建议用户自己在结构体里加锁,而不是在基本容器里加锁。事实上,对所有容器加锁这个做法已经是公认的一个java标准库里的问题了。
>
> 在 2014年11月21日星期五UTC+8下午4时58分49秒,minux写道:
>>
>>
>> 2014-11-21 3:37 GMT-05:00 guagua <bette...@gmail.com>:
>>>
>>> 我觉得golang中的基本类型不附加并发安全性完全可以理解,但pkg中的高层API是否可以尝试提供这样的保障。
>>> 比如,我现在不能使用container包,就有点遗憾了
>>
>> 你应该重新读哦的回复。高层和底层数据结构不提供并发访问的支持都是为了给用户最大的选择。
>> 如果你想使用lock-free甚至wait-free的数据结构,godoc.org 上有很多。(实现 lock-free/wait-free
>> 数据结构用 Go 是很合适的,类似,它有 GC,对于绝大多数 lock-free/wait-free 算法,GC都是必
>> 须的,否则很难保证内存不泄露;其次,它又能让用户精确地控制内存布局,类似C/C++,这对于
>> 实现 lock-free 和 wait-free 算法也是很重要的(举个例子:绝大多数情况下,为了避免 false sharing,
>> 结构体需要对 cache line 对齐,在 Java 里这是不可能的,总得借助别的机制),Go 的 sync/atomic
>> 提供了足够多通用的原语,也可以满足需要,不像C/C++,如果不用最新的标准,那就得用不可移
>> 植的编译器扩展或者内嵌汇编)
>>
> --
> --
> 官网: http://golang-china.org/
> IRC: irc.freenode.net #golang-china
> @golangchina
> ---
> 您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
Java里又不加锁的,也有加锁的。开发者也可以随意选择,这种便利性不言而喻。Go语言的标准库也很丰富,但是在这方面还有所欠缺。当然了,现在有比这更重要的事要做,而且Go语言还很年轻,不急于这一时,让开发者自己去创造也OK。想当年Java也是在诞生N年后才开始丰富这方面的类库。
>> > 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
>> >
>> > 要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/golang-china/d47047d9-4ae9-4bc9-8c61-60a6cbc3c35d%40googlegroups.com。
>> > 要查看更多选项,请访问https://groups.google.com/d/optout。
>
> --
> --
> 官网: http://golang-china.org/
> IRC: irc.freenode.net #golang-china
> @golangchina
> ---
> 您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
rt
>> >> > 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
>> >> >
>> >> >
>> >> > 要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/golang-china/d47047d9-4ae9-4bc9-8c61-60a6cbc3c35d%40googlegroups.com。
>> >> > 要查看更多选项,请访问https://groups.google.com/d/optout。
>> >
>> > --
>> > --
>> > 官网: http://golang-china.org/
>> > IRC: irc.freenode.net #golang-china
>> > @golangchina
>> > ---
>> > 您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
>> > 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
>> >
>> > 要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/golang-china/7fbf4eaf-b2cd-4ac8-b03c-fb9323b1032e%40googlegroups.com。
>> > 要查看更多选项,请访问https://groups.google.com/d/optout。
>
> --
> --
> 官网: http://golang-china.org/
> IRC: irc.freenode.net #golang-china
> @golangchina
> ---
> 您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
你的意思是不是说希望在标准库的基础上提供一些像concurrentmap这样的库?
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
争这个没用啊,我没说基本数据结构上要加锁,我还没见过哪个语言在基本数据结构上搞并发安全的,我说的是标准库或者扩展库,像container这类的包,麻烦您仔细看看我上面所说的。
>> >> >> > 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > 要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/golang-china/d47047d9-4ae9-4bc9-8c61-60a6cbc3c35d%40googlegroups.com。
>> >> >> > 要查看更多选项,请访问https://groups.google.com/d/optout。
>> >> >
>> >> > --
>> >> > --
>> >> > 官网: http://golang-china.org/
>> >> > IRC: irc.freenode.net #golang-china
>> >> > @golangchina
>> >> > ---
>> >> > 您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
>> >> >
>> >> > 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
>> >> >
>> >> >
>> >> > 要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/golang-china/7fbf4eaf-b2cd-4ac8-b03c-fb9323b1032e%40googlegroups.com。
>> >> > 要查看更多选项,请访问https://groups.google.com/d/optout。
>> >
>> > --
>> > --
>> > 官网: http://golang-china.org/
>> > IRC: irc.freenode.net #golang-china
>> > @golangchina
>> > ---
>> > 您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
>> > 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
>> >
>> > 要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/golang-china/34e80370-e871-4d55-b16e-e48defd137c8%40googlegroups.com。
>> > 要查看更多选项,请访问https://groups.google.com/d/optout。
>
> --
> --
> 官网: http://golang-china.org/
> IRC: irc.freenode.net #golang-china
> @golangchina
> ---
> 您收到此邮件是因为您订阅了Google网上论坛上的“Golang-China”群组。
> 要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
@hyper-carrot我觉得你也可以举个例子来说明一下吧,只用 Go 现有的东西需要怎样,如果有了你希望的扩展又会如何方便,这样那样的。这样讨论起来也更具体一点儿。
--
--
官网: http://golang-china.org/
IRC: irc.freenode.net #golang-china
@golangchina
---
您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china...@googlegroups.com。
要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/golang-china/CAFK4q9zxPpMEU3%2B%3D%3DC6n9nBZyUNMttfUUw%3DipJHsVyN032tHqg%40mail.gmail.com。
要查看更多选项,请访问https://groups.google.com/d/optout。
Thanks,Philo Yang
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china+unsubscribe@googlegroups.com。
minux 的意思大约是,弄出这样一个库来,不会带来真正的好处,但可能把一些事情搞砸。
发件人: golang...@googlegroups.com [mailto:golang...@googlegroups.com] 代表 hyper-carrot
发送时间: 2014年12月8日 9:05
收件人: golang...@googlegroups.com
主题: Re: [gocn:12761] Re: go标准库container支持multi goroutine吗?
--
--
官网: http://golang-china.org/
IRC: irc.freenode.net #golang-china
@golangchina
---
您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china...@googlegroups.com。
要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/golang-china/454ae9d6-a512-42cd-9f68-8560686246b2%40googlegroups.com。
要查看更多选项,请访问https://groups.google.com/d/optout。
--
--
官网: http://golang-china.org/
IRC: irc.freenode.net #golang-china
@golangchina
---
您收到此邮件是因为您订阅了Google网上论坛中的“Golang-China”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到golang-china...@googlegroups.com。