Farseerfc的小窝 - zhihu//farseerfc.me/zhs/2016-08-08T16:15:00+09:00为什么 Linus Torvalds 不愿意将 Linux 变成 GPLv3 授权?2016-08-08T16:15:00+09:002016-08-08T16:15:00+09:00farseerfctag:farseerfc.me,2016-08-08:/zhs/why-linus-torvalds-undermine-gplv3.html<p>从 <a class="reference external" href="https://www.zhihu.com/question/48884264/answer/113454129">知乎</a> 转载</p>
<p>和上篇文章一样,这篇也是来自一个知乎上我回答的问题。</p>
<p>原问题:为什么 Linus Torvalds 不愿意将 Linux 变成 GPLv3 授权?</p>
<div class="panel panel-default">
<div class="panel-heading">
DebConf 14: Q&A with Linus Torvalds</div>
<div class="panel-body">
<div class="well" style="padding: 0">
<div class="tab-content" id="youtubeku">
<div class="tab-pane fade active in" id="youtube_1Mg5_gxNXTo">
<div align="left" class="youtube embed-responsive embed-responsive-16by9"> <iframe allow="fullscreen" class="embed-responsive-item" frameborder="0" src="https://www.youtube.com/embed/1Mg5_gxNXTo"></iframe> </div>
</div>
<div class="tab-pane fade" id="youku_XMTY3NjIzNDU0NA">
<div align="left" class="youku embed-responsive embed-responsive-16by9"> <iframe allow="fullscreen" class="embed-responsive-item" frameborder="0" height="498" src="https://player.youku.com/embed/XMTY3NjIzNDU0NA" width="510"></iframe> </div>
</div>
</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#youtube_1Mg5_gxNXTo">Youtube</a></li>
<li><a data-toggle="tab" href="#youku_XMTY3NjIzNDU0NA">Youku</a></li>
</ul>
</div>
</div>
</div>
<p>我的回答:</p>
<blockquote>
<p>这里有段 Linus Torvalds 在 DebConf 14 上的 Q&A:
<a class="reference external" href="https://youtu.be/1Mg5_gxNXTo?t=47m20s">https://youtu.be/1Mg5_gxNXTo?t=47m20s</a></p>
<p>其中关于 GPLv3 和协议的那一段在47:20开始到57:00左右。
里面 Linus 对自己的观点澄清得很清楚了。
看u2b或者听英语有困难的请留评论,我抽空可以试着翻译一下。</p>
</blockquote>
<div class="section" id="id2">
<h2>然后接下来就是我承诺的翻译了 …</h2></div><p>从 <a class="reference external" href="https://www.zhihu.com/question/48884264/answer/113454129">知乎</a> 转载</p>
<p>和上篇文章一样,这篇也是来自一个知乎上我回答的问题。</p>
<p>原问题:为什么 Linus Torvalds 不愿意将 Linux 变成 GPLv3 授权?</p>
<div class="panel panel-default">
<div class="panel-heading">
DebConf 14: Q&A with Linus Torvalds</div>
<div class="panel-body">
<div class="well" style="padding: 0">
<div class="tab-content" id="youtubeku">
<div class="tab-pane fade active in" id="youtube_1Mg5_gxNXTo">
<div align="left" class="youtube embed-responsive embed-responsive-16by9"> <iframe allow="fullscreen" class="embed-responsive-item" frameborder="0" src="https://www.youtube.com/embed/1Mg5_gxNXTo"></iframe> </div>
</div>
<div class="tab-pane fade" id="youku_XMTY3NjIzNDU0NA">
<div align="left" class="youku embed-responsive embed-responsive-16by9"> <iframe allow="fullscreen" class="embed-responsive-item" frameborder="0" height="498" src="https://player.youku.com/embed/XMTY3NjIzNDU0NA" width="510"></iframe> </div>
</div>
</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#youtube_1Mg5_gxNXTo">Youtube</a></li>
<li><a data-toggle="tab" href="#youku_XMTY3NjIzNDU0NA">Youku</a></li>
</ul>
</div>
</div>
</div>
<p>我的回答:</p>
<blockquote>
<p>这里有段 Linus Torvalds 在 DebConf 14 上的 Q&A:
<a class="reference external" href="https://youtu.be/1Mg5_gxNXTo?t=47m20s">https://youtu.be/1Mg5_gxNXTo?t=47m20s</a></p>
<p>其中关于 GPLv3 和协议的那一段在47:20开始到57:00左右。
里面 Linus 对自己的观点澄清得很清楚了。
看u2b或者听英语有困难的请留评论,我抽空可以试着翻译一下。</p>
</blockquote>
<div class="section" id="id2">
<h2>然后接下来就是我承诺的翻译了</h2>
<a aria-controls="ebbd22ff" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#ebbd22ff" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="ebbd22ff">
<blockquote>
Q: Do you agree that you undermine GPLv3? and ...</blockquote>
</div>
<p>问:你是否同意说你贬低了 GPLv3 ? 以及……</p>
<a aria-controls="505c14ba" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#505c14ba" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="505c14ba">
<blockquote>
L: Yes</blockquote>
</div>
<p>L: 是的</p>
<a aria-controls="97e91d0f" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#97e91d0f" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="97e91d0f">
<blockquote>
Q: How can we get you to stop?</blockquote>
</div>
<p>问:我们如何才能让你别这么做?</p>
<a aria-controls="77f7155c" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#77f7155c" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="77f7155c">
<blockquote>
L: What?</blockquote>
</div>
<p>L: 什么?</p>
<a aria-controls="d3591d99" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#d3591d99" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="d3591d99">
<blockquote>
Q: ...How can we get you to stop?</blockquote>
</div>
<p>问:……我们如何才能让你别这么做?</p>
<a aria-controls="7b4e5b8a" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#7b4e5b8a" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="7b4e5b8a">
<blockquote>
L: Oh I hate GPLv3. I undermined it on purpose.
I actually thought the GPLv3 extensions were horrible.
I understand why people would want to do them but I think it should have
been a completely new license.</blockquote>
</div>
<p>L: 哦我讨厌 GPLv3 ,我是在故意贬低它。实际上我觉得 GPLv3 的扩展非常可怕。
我能理解为什么人们想要做这个,但是我觉得它本应是一个全新的协议。</p>
<a aria-controls="20696190" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#20696190" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="20696190">
<blockquote>
Emm my argument for liking version 2, and I still think version 2 is a
great license, was that, "I give you source code, you give me your
changes back, we are even." Right? That's my take on GPL version 2, right,
it's that simple.</blockquote>
</div>
<p>嗯我喜欢版本 2 的那些理由,并且我仍然觉得版本 2 是一个非常棒的协议,
理由是:「我给你源代码,你给我你对它的修改,我们就扯平了」
对吧?这是我用 GPL 版本 2 的理由,就是这么简单。</p>
<a aria-controls="7565a2bc" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#7565a2bc" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="7565a2bc">
<blockquote>
And version 3 extended that in ways that I personally am really
uncomfortable with, namely "I give you source code, that means that if
you use that source code, you can't use it on your device unless you
follow my rules." And to me that's, that's a violation of everything
version 2 stood for. And I understand why the FSF did it because I know
what the FSF wants. But to me it's not the same license at all.</blockquote>
</div>
<p>然后版本 3 的扩展在某些方面让我个人觉得非常不舒服,也就是说「我给你源代码,
这意味着你必须服从我的一些规则,否则你不能把它用在你的设备上。」
对我来说,这是违反了版本 2 协议所追求的所有目的。然而我理解为什么 FSF 要这么做,
因为我知道 FSF 想要达成什么,但是对我来说这完全是不同的协议了。</p>
<a aria-controls="f0b4e1fb" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#f0b4e1fb" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="f0b4e1fb">
<blockquote>
So I was very upset and made it very clear, and this was months before
version 3 was actually published. There was a discussion about this
long before... There was an earlier version of version 3, years before
actually, where I said "No, this is not gonna fly."
And during that earlier discussion I had already added to the kernel that,
"Hey, I don't have the version 2 or later". And there was no...
And I was really happy then when version 3 came out, that I have done that
something like 5 years before, because there was ever never any question
about what the license for the kernel was.</blockquote>
</div>
<p>所以我当时非常不安,并且表明了自己的观点,并且这是在版本 3 发布的数月之前。
在那很久之前曾经有过一场讨论……在版本 3 之前有一个早期的版本,
事实上几年之前,那时我就说过:「不,这不可能工作」。
并且在那个早期的讨论阶段我已经在内核里写好了「嘿,我可没有写过版本 2
或者更高版本」。所以之后也没有过(争议)……随后版本 3 出来的时候我非常开心,
因为我早在大概 5 年前做了预防,之后也就再也没有过关于内核的协议究竟是哪个
版本的讨论。</p>
<a aria-controls="32e9bcca" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#32e9bcca" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="32e9bcca">
<blockquote>
But I actually thought that version 3 is ... Uh, no ... I actually think
version 3 is a <strong>FINE</strong> license, right. I'm a firm believer in,
"If you write your code, it is your choice to pick a license."
And version 3 is a fine license. Version 3 was not a good ...
"Here we give you version 2, and then we tried to sneak in these new rules,
and tried to force everybody to upgrade." That was the part I disliked.
And the FSF did some really sneaky stuff, downright immoral in my opinion.</blockquote>
</div>
<p>不过事实上我觉得版本 3 是……呃不……我事实上觉得版本 3 是个 <strong>不错</strong> 的协议,
对吧。我坚定地相信「如果是你写的代码,那么你有权利决定它应该用什么协议」。
并且版本 3 是个不错的选择。版本 3 不好的地方在……「我们给你了版本 2
,然后我们试图偷偷混入这些新的规则,并且想逼着所有人都跟着升级」这是我不喜欢版本
3 的地方。并且 FSF 在其中做了很多见不得人的事情,我觉得做得很不道德。</p>
<a aria-controls="318f390b" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#318f390b" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="318f390b">
<blockquote>
Q: So you are talking about <a class="reference external" href="https://en.wikipedia.org/wiki/Tivoization">Tivoization</a>?</blockquote>
</div>
<p>问:所以你在说 <a class="reference external" href="https://en.wikipedia.org/wiki/Tivoization">Tivoization</a> 的事情么?</p>
<div class="panel panel-default">
<div class="panel-heading">
译注: 关于 <a class="reference external" href="https://en.wikipedia.org/wiki/Tivoization">Tivoization</a></div>
<div class="panel-body">
Tivoization 是 FSF 发明的一个词,表示 TiVo 的做法。 TiVo
是一个生产类似电视机顶盒之类的设备的厂商,他们在他们的设备中用到了 Linux
内核和很多别的开源组件,并且他们根据 GPLv2 协议开放了他们使用的组件的源代码。
然而他们在他们出售的设备中增加了数字签名,验证正在执行的系统和软件是他们自己
编制的软件,从而限制了用户修改运行软件的自由。这种做法在 FSF 看来是钻了 GPLv2
的法律上的空子,所以 FSF 提出了 GPLv3 封堵这种做法。</div>
</div>
<a aria-controls="db80a74e" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#db80a74e" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="db80a74e">
<blockquote>
L: Ehmm, yeah the Tivoization is always my main, eh dislike of version 3.
And, the FSF was being very dishonest thing. "Hey, we actually allow you
to invalidate the Tivoization clause" and they tried to, they literally
lied to people, and say "Hey, so that means that you can use GPLv3 without
the Tivoization part", right. This is ... How many people heard this
particular statement from the FSF? (Please raise your hands)</blockquote>
</div>
<p>L: 没错,Tivoization 的事情一直是我反对版本 3 的主要根据。并且,FSF
在这件事上表现得极不诚实。「嘿,其实我们允许你无效化 Tivoization 条款」,这样他们试图,
应该说他们是在明白着欺骗别人,并且说「嘿,这意味着你可以使用除去 Tivoization 部分的 GPLv3」。
这很……在场的诸位中有谁从 FSF 那儿听过这个说法?(请举手)</p>
<a aria-controls="d4a2f0a6" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#d4a2f0a6" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="d4a2f0a6">
<blockquote>
Ok, maybe they only tried to convince me with that one.
But they did try. And it was like, "I'm not stupid", right. Yes, you can
... The GPLv3 allows you to say "Ok, Tivoization is not an issue for us".
But it allows somebody else to take the project, and say "Hey, I ... The
GPLv3 without Tivoization is compatible with the full GPLv3, so I will now
make my own fork of this, and I will start doing drivers that use the full
version of version 3" And where am I stuck then? I am stuck saying "Hey I
give you the source code, and now I can't take it back your changes".
That's completely against the whole point of the license in the first
place.</blockquote>
</div>
<p>好吧,或许他们只试过对我用这套说辞,但是他们真的试过。我的反应是「我可不傻」,对吧。是的,
的确你可以…… GPLv3 允许你说「好, Tivoization 的事情对我们来说不是问题」,
但是它同时又允许别人接过这个项目,并且说「嘿,我觉得……去掉了 Tivoization 的 GPLv3
是兼容完整的 GPLv3 的,所以我可以 fork 这个项目,然后我将在自己的 fork 上用完整的
GPLv3 写驱动。」然后我就囧了。我的困境在于说「嘿,我给了你我的源代码,现在我却不能拿回你对它
的修改了」。这是彻底违背了我用这个协议最初的目的了。</p>
<a aria-controls="2f77aec5" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#2f77aec5" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="2f77aec5">
<blockquote>
So the FSF was, I mean the kind of stuff that was going on behind the
scenes, ah, made me once and for all to decide to never had any thing to
do with the FSF again. So if you wanted to give money to an organization
that does good? Give it to the EFF. The FSF is full of crazy bittered
people. That's just mine opinion. Uh, actually I have ... Ah ...
I overstated that a bit, right. The FSF has a lot of nice people in it,
but some of them are bit too extreme.</blockquote>
</div>
<p>所以 FSF 是,我是说那时他们暗地里做的那些事情,让我当下决定永远不再和 FSF 有任何瓜葛。
所以如果你想捐钱给一个行善的组织,那就捐给 EFF 吧。FSF 充满了疯狂难处的人。这只是我的观点。
呃其实我……嗯……我说得有点过分了。FSF 里有很多不错的人,不过其中有些人有点过激。</p>
<a aria-controls="51874275" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#51874275" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="51874275">
<blockquote>
Q: Well I wish the EFF care more about software freedom. But, uh,
can you ... Do you think that Tivoization benefits me as a user somehow?</blockquote>
</div>
<p>问: 嗯我也希望 EFF 能更多的关注于软件的自由方面。但是你能……你觉得 Tivoization
这种行为也能在某种方式上让我作为用户获益么?</p>
<a aria-controls="489be787" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#489be787" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="489be787">
<blockquote>
L: No, no I don't. I mean that ... But that was never my argument. That
was not why I selected the GPLv2. This is my whole point. It's not that
I think Tivoization is necessarily something that you should strive for.
But it is something that in my world view, it's your decision.
If you make hardware that locks down the software, that's your decision
as a hardware maker. That has no impact on my decision as a software maker
to give you the software. Do you see where I am coming from? I don't like
the locked down hardware, but at the same time that was never the social
contract I intended with Linux.</blockquote>
</div>
<p>L: 不,我不觉得。我的意思是……这从来都不是我的论据,这不是我选择了 GPLv2 的理由。
并不是说我觉得 Tivoization 是某种值得你去争取的权利,而是说在我的世界观中,这是你的决定。
如果你生产硬件去锁住了其中的软件,这是你作为一个硬件提供者的决定。
这完全不影响我作为一个软件提供者给你软件的决定。你能看出我的立场在哪儿了么?
我不喜欢上锁的硬件,但是同时这也从来不是我想要给 Linux 加上的的社会契约。</p>
<a aria-controls="d4934e2e" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#d4934e2e" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="d4934e2e">
<blockquote>
To me, umm, I mean, people may or may not
realize GPLv2 wasn't even the first license for Linux.
To me the important part was always "I give you software, you can do
whatever you want with it. If you making improvements, you have to give
them back." That was the first version of the license. It also had a
completely broken clause which was completely insane and I was stupid.
Hey it happened. My origin license says that you can't make money
change hands. And that was a mistake. That was clearly just wrong and bad
because it really didn't have anything to do with what I wanted. But I
was young, I was poor, I didn't realize that the whole money thing wasn't
the important part. And I have saw the errors in my ways, I saw the GPLv2
and said "Hey, that's the perfect license". And I saw the GPLv3 and I said
"No, that's overreaching a lot, that's not what I wanted". And so I made
Linux GPLv2 only, right.</blockquote>
</div>
<p>对我来说,呃我想说,大家可能知道或者不知道, GPLv2 并不是 Linux 的最初的协议。
对我来说重要的部分一直是「我给你软件,你可以用它做任何你想要做的事情。如果你做了任何改进,
你需要把它交还给我。」这是协议最初的样子。最早的协议还有一条完全错误的条款,写得完全不合理,
那时我很傻。嘿我也傻过。我最初的协议说你不能用它赚钱。这是失策,这明显是不对的不好的,
因为它和我真正想要做的事情没有任何关系。但是那时我很傻很天真,
我没意识到钱的事情在其中完全不重要。然后我发现了其中的问题,我看到了 GPLv2 然后说「嘿,
这是个完美的协议」。然后我看到了 GPLv3 我说「不,这做得过分了,这不是我想要的」
所以我让 Linux 成为了仅限 GPLv2 ,对吧。</p>
<a aria-controls="9e4f3a4f" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#9e4f3a4f" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="9e4f3a4f">
<blockquote>
Q: So do you think getting the patches back is as useful even if you can't
modify the device that it is used on?</blockquote>
</div>
<p>问: 所以你是否认为,即使你不能修改跑着这个软件的设备,拿回对软件的修改也还是同样重要的?</p>
<a aria-controls="1eafb32a" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#1eafb32a" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="1eafb32a">
<blockquote>
L: Yeah, absolutely. And I mean TiVo itself is actually an example of this.
Their patches were kind of crafty but I mean they were basically running
on a, originally a fairly standard MIPS thing. And their patches were
working around bugs in the chipsets they used. And they were valid patches.
The fact that they then felt that their hardware had to be locked down
someway. I didn't like it. But as I have mentioned, I felt that that was
their decision.</blockquote>
</div>
<p>L: 是的,当然。我想说 TiVo 它自己实际上就是一个例子。他们的修改有点复杂,但是我想说他们基本
是,一开始基本是运行在一套相当标准的 MIPS 设备上。然后他们的修改是想绕开他们用到的芯片上的
一些问题,并且这些是合格的修改。之后的事情是他们觉得他们需要锁住他们的硬件,我不喜欢这个。
但是就像我已经说的,我觉得这是他们的决定。</p>
<a aria-controls="93f9460e" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#93f9460e" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="93f9460e">
<blockquote>
And they had real reasons for that. That's something people sometimes
missed. There are sometimes reasons to do what TiVo did. Sometimes it's
imposed on you by, wireless carriers. Sometimes it's imposed on you by
Disney. Uh sometimes it's imposed on you by laws. The GPLv3 actually
accepts the last one when it comes to things like medical equipment
I think. But the point is that the whole Tivoization thing is, sometimes
it's, there is a reason for it. And if you make ... I mean I am not a
hardware designer. I think FPGA and stuff like that is really cool.
But I always ... I mean I really don't want to impose my world view on
anybody else. You don't have to use Linux. If you do use Linux, the only
thing I asked for is source code back. And there is all these other
verbiages in the GPLv2 about exact details, those aren't important.
And that was always my standpoint.</blockquote>
</div>
<p>并且他们有真正的理由去这么做。这是有时人们忽视的地方。有时是真的有理由去做 TiVo
他们做的事情。有时强加给你这种限制的是,无线运营商。有时强加给你的是迪士尼。
有时强加给你限制的甚至是法律。 GPLv3 在医疗设备之类的场合其实允许最后一种情况,我记得。
我的观点是,整个 Tivoization 的事情有时是有理由去这么做的。如果你生产……
我是说我不是硬件设计者,我觉得 FPGA 之类的东西很酷,但是我……我的意思是我真的不想把我对世界的
看法强加给别人。你不是非得要用 Linux ,如果你想要用 Linux
,那么我唯一要求你做的事情是把源代码(变更)还给我。然后在 GPLv2
中还有很多繁文缛节规定了详细的细节,这些都不重要。这是我一直以来的观点。</p>
<a aria-controls="1bed26a3" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#1bed26a3" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="1bed26a3">
<blockquote>
Q: Ok, well I will stop my non-point of making noise now.</blockquote>
</div>
<p>问: 好吧那我就不浪费时间了。</p>
<div class="panel panel-default">
<div class="panel-heading">
译注: 关于 <a class="reference external" href="https://zh.wikipedia.org/wiki/ISC%E8%A8%B1%E5%8F%AF%E8%AD%89">ISC 协议</a></div>
<div class="panel-body">
ISC 协议是一个开源软件协议,和两句的 BSD 协议功能相同。OpenBSD 项目选择尽量用 ISC
协议公开他们新写的代码。</div>
</div>
<a aria-controls="a8a95a78" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#a8a95a78" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="a8a95a78">
<blockquote>
L: I mean don't get me ... I mean I like other licenses too. I have used
like the four, emmm... Which BSD license is the acceptable one?
One of the BSD license is actually really nice. And it's actually the...
What?</blockquote>
</div>
<p>L: 我的意思是别误解……我也喜欢别的协议。我用过……到底是哪个 BSD 协议是可以接受的?
有一个 BSD 协议实际上非常不错。它实际上是……什么?</p>
<a aria-controls="4624145d" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#4624145d" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="4624145d">
<blockquote>
A: ISC</blockquote>
</div>
<p>观众: ISC</p>
<a aria-controls="b1cbe308" aria-expanded="false" class="translate-collapse-btn" data-toggle="collapse" href="#b1cbe308" role="button">
<span class="badge badge-pill badge-light"><i class="fa fa-language"></i> </span></a><div class="collapse" id="b1cbe308">
<blockquote>
L: ISC? And I actually encourage people who don't care about the giving
code back but care about the "Hey, I did something cool, please use it".
I encourage people to use the BSD license for that. And I mean the BSD
license is wonderful for that. It so happens that I thought that for my
project the giving back is equally important so I, for me BSD is bad.
But the point is <strong>for me</strong>. The GPLv3 maybe the perfect license for what
you guys want to do. And that's fine. And then it's the license you should
use. It's just that when somebody else wrote the code you don't get that
choice.</blockquote>
</div>
<p>L: ISC?并且事实上我在鼓励那些不在意拿回修改但是在意「嘿,我做了一个很酷的东西,请用它」。
我鼓励这些人去用 BSD 协议做这些事情。我想说 BSD 协议在这种场合是完美的。
只是碰巧我觉得对于我的项目,拿回修改也同样重要,所以对我而言 BSD 不好。但是重点是
<strong>对我而言</strong> 。 GPLv3 可能对你们想要做的事情而言是完美的协议,这很好,并且这时你就应该去用
GPLv3 。只是当代码是别人写的时候,你没有这个选择权。</p>
</div>
C语言中“.”与“->”有什么区别?2016-08-08T00:02:00+09:002016-08-08T00:02:00+09:00farseerfctag:farseerfc.me,2016-08-08:/zhs/dot-and-arrow-in-c.html<p>从 <a class="reference external" href="https://www.zhihu.com/question/49164544/answer/114584541">知乎</a> 转载</p>
<p>转载几篇知乎上我自己的回答,因为不喜欢知乎的排版,所以在博客里重新排版一遍。</p>
<div class="section" id="id2">
<h2>原问题:C语言中“.”与“->”有什么区别?</h2>
<p>除了表达形式有些不同,功能可以说完全一样阿。那为何又要构造两个功能一样的运算符? 效率有差异?可是现在编译器优化都那么强了,如果真是这样岂不是有些多此一举</p>
<hr class="docutils"/>
<p>刚刚翻了下书,说早期的C实现无法用结构直接当作参数在函数间传递,只能用指向结构的指针在函数间进行传递!我想这应该也是最直观的原因吧。</p>
</div>
<div class="section" id="id3">
<h2>我的回答</h2>
<p>首先 <code class="code">
a->b</code>
的含义是 <code class="code">
(*a).b</code>
,所以他们是不同的,不过的确 <code class="code">
-></code>
可以用 <code class="code">
*</code>
和 <code class="code">
.</code>
实现,不需要单独一个运算符。
嗯,我这是说现代的标准化的 C 语义上来说, <code class="code">
-></code>
可以用 <code class="code">
*</code>
和 <code class="code">
.</code>
的组合实现。</p>
<p>早期的 C 有一段时间的语义和现代的 C 的语义不太一样。</p>
<p>稍微有点汇编的基础的同学可能知道,在机器码和汇编的角度来看,不存在变量,不存在 struct …</p></div><p>从 <a class="reference external" href="https://www.zhihu.com/question/49164544/answer/114584541">知乎</a> 转载</p>
<p>转载几篇知乎上我自己的回答,因为不喜欢知乎的排版,所以在博客里重新排版一遍。</p>
<div class="section" id="id2">
<h2>原问题:C语言中“.”与“->”有什么区别?</h2>
<p>除了表达形式有些不同,功能可以说完全一样阿。那为何又要构造两个功能一样的运算符? 效率有差异?可是现在编译器优化都那么强了,如果真是这样岂不是有些多此一举</p>
<hr class="docutils"/>
<p>刚刚翻了下书,说早期的C实现无法用结构直接当作参数在函数间传递,只能用指向结构的指针在函数间进行传递!我想这应该也是最直观的原因吧。</p>
</div>
<div class="section" id="id3">
<h2>我的回答</h2>
<p>首先 <code class="code">
a->b</code>
的含义是 <code class="code">
(*a).b</code>
,所以他们是不同的,不过的确 <code class="code">
-></code>
可以用 <code class="code">
*</code>
和 <code class="code">
.</code>
实现,不需要单独一个运算符。
嗯,我这是说现代的标准化的 C 语义上来说, <code class="code">
-></code>
可以用 <code class="code">
*</code>
和 <code class="code">
.</code>
的组合实现。</p>
<p>早期的 C 有一段时间的语义和现代的 C 的语义不太一样。</p>
<p>稍微有点汇编的基础的同学可能知道,在机器码和汇编的角度来看,不存在变量,不存在 struct 这种东西,只存在寄存器和一个叫做内存的大数组。</p>
<p>所以变量,是 C 对内存地址的一个抽象,它代表了一个位置。举个例子,C 里面我们写:</p>
<div class="highlight"><pre><span class="code-line"><span></span><span class="n">a</span> <span class="o">=</span> <span class="n">b</span></span>
</pre></div>
<p>其实在汇编的角度来看更像是</p>
<div class="highlight"><pre><span class="code-line"><span></span><span class="o">*</span><span class="n">A</span> <span class="o">=</span> <span class="o">*</span><span class="n">B</span></span>
</pre></div>
<p>其中 A 和 B 各是两个内存地址,是指针。</p>
<p>好,以上是基本背景。</p>
<p>基于这个背景我们讨论一下 struct 是什么,以及 struct 的成员是什么。
假设我们有</p>
<div class="highlight"><pre><span class="code-line"><span></span><span class="k">struct</span> <span class="n">Point</span> <span class="p">{</span></span>
<span class="code-line"> <span class="kt">int</span> <span class="n">x</span><span class="p">;</span></span>
<span class="code-line"> <span class="kt">int</span> <span class="n">y</span><span class="p">;</span></span>
<span class="code-line"><span class="p">};</span></span>
<span class="code-line"><span class="k">struct</span> <span class="n">Point</span> <span class="n">p</span><span class="p">;</span></span>
<span class="code-line"><span class="k">struct</span> <span class="n">Point</span> <span class="o">*</span><span class="n">pp</span> <span class="o">=</span> <span class="o">&</span><span class="n">p</span><span class="p">;</span></span>
</pre></div>
<p>从现代语义上讲 <code class="code">
p</code>
就是一个结构体对象, <code class="code">
x</code>
和 <code class="code">
y</code>
各是其成员,嗯。</p>
<p>从汇编的语义上讲, <code class="code">
p</code>
是一个不完整的地址,或者说,半个地址,再或者说,一个指向的东西是虚构出来的地址。而 <code class="code">
x</code>
和 <code class="code">
y</code>
各是在 Point 结构中的地址偏移量。也就是说,必须有 <code class="code">
p</code>
和 <code class="code">
x</code>
或者 <code class="code">
p</code>
和 <code class="code">
y</code>
同时出现,才形成一个完整的地址,单独的一个 <code class="code">
p</code>
没有意义。</p>
<p>早期的 C 就是在这样的模型上建立的。所以对早期的 C 而言, <code class="code">
*pp</code>
没有意义,你取得了一个 struct ,而这个 struct 不能塞在任何一个寄存器里,编译器和 CPU 都无法表达这个东西。</p>
<p>这时候只有 <code class="code">
p.x</code>
和 <code class="code">
p.y</code>
有意义,它们有真实的地址。</p>
<p>早期的 C 就是这样一个看起来怪异的语义,而它更贴近机器的表达。
所以对早期的 C 而言,以下的代码是对的:</p>
<div class="highlight"><pre><span class="code-line"><span></span><span class="n">p</span><span class="p">.</span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span></span>
<span class="code-line"><span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">;</span></span>
<span class="code-line"><span class="n">a</span> <span class="o">=</span> <span class="o">&</span><span class="p">(</span><span class="n">p</span><span class="p">.</span><span class="n">x</span><span class="p">);</span></span>
</pre></div>
<p>而以下代码是错的:</p>
<div class="highlight"><pre><span class="code-line"><span></span><span class="p">(</span><span class="o">*</span><span class="n">pp</span><span class="p">).</span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span></span>
</pre></div>
<p>因为作为这个赋值的目标地址表达式的一部分, <code class="code">
*pp</code>
,这个中间结果没法直译到机器码。</p>
<p>所以对早期的 C 而言,对 pp 解引用的操作,必须和取成员的偏移的操作,这两者紧密结合起来变成一个单独的操作,其结果才有意义。</p>
<p>所以早期的 C 就发明了 -> ,表示这两个操作紧密结合的操作。于是才能写:</p>
<div class="highlight"><pre><span class="code-line"><span></span><span class="n">pp</span><span class="o">-></span><span class="n">x</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span></span>
</pre></div>
<p>嗯,这就是它存在的历史原因。
而这个历史原因现在已经不重要了,现代的符合标准的 C 编译器都知道 <code class="code">
(*pp).x</code>
和 <code class="code">
pp->x</code>
是等价的了。</p>
<p>说句题外话, C++ 里面还发明了 <code class="code">
.*</code>
和 <code class="code">
->*</code>
这两个运算符(注意 <code class="code">
->*</code>
不是单独的 <code class="code">
-></code>
和 <code class="code">
*</code>
并排放的意思),关于为什么要发明这两个运算符,而不能直接说 <code class="code">
a ->* b</code>
的意思就是 <code class="code">
a ->(*b)</code>
,这个就作为课堂作业吧。</p>
</div>