Anders Hejlsberg谈契约和协同工作能力

声明式编程与函数式思维:.NET开发者元能力升级指南 声明式编程是一种以‘做什么’(What)而非‘怎么做’(How)为核心的软件构造范式,其本质是通过抽象语法和领域特定语言(DSL)降低人类意图与机器执行之间的认知鸿沟。它依托函数式思维——如不可变性、纯函数、高阶操作——在C# LINQ、F# Actor模型及自定义内部DSL中落地;技术价值在于提升代码可读性、并发安全性与跨平台适配能力,广泛应用于高并发风控、实时流处理与医疗规则引擎等场景。本文结合Anders Hejlsberg经典趋势判断与.NET十二年工程实践,系统拆解如何将声明式理念转化为可测量、可 阅读详情

Contracts and Interoperability                                 契约和协同工作能力

A Conversation with Anders Hejlsberg, Part V              Anders Hejlsberg访谈之五

by Bill Venners with Bruce Eckel                                   采访者:Bill Venners、Bruce Eckel

November 3, 2003                                                        时间:2003-11-3

 

Summary

Anders Hejlsberg, the lead C# architect, talks with Bruce Eckel and Bill Venners about DLL hell and interface contracts, strong names, and the importance of interoperability.

提要:

Anders Hejlsberg是C#的首席设计师,在Bruce Eckel和Bill Venners对他的本次采访中,他谈到了“DLL地狱”和契约理论、强名称以及协同工作能力。

 

 

DLL Hell and the Theory of Contracts

“DLL地狱”和契约理论

 

Bill Venners: To what extent is "DLL Hell" a failure of interface contracts to work adequately in practice? If everyone fully understands and adheres to the contract of the functions of a particular DLL, shouldn't updating that DLL in theory not break any code?

在多大程度上讲,“DLL地狱”是接口契约在实际中充分工作时的一个失败?假如每个人都完全理解并且遵循特定DLL的功能契约,那么在理论上,是否不应该升级DLL,以避免对某些代码的破坏?

 

Anders Hejlsberg: Hell has many tortures. One aspect of DLL hell is that you don't adhere to your promised semantic contract. You do something different than what you did before, and therefore you break code. That's actually probably not the biggest issue that we face. The true problem with DLL hell is that we don't allow you to have multiple different versions of a particular DLL present on the machine. Once you upgrade the DLL you upgrade everybody, and that's a mighty big hammer.

“DLL地狱”让我们倍受折磨。一方面,你不会遵循你先前承诺的语义契约,你要做些和以前不同的事情,这样你就破坏了代码。可能这还不是我们面对的最大问题。“DLL地狱”的真正麻烦是我们不允许你在同一台计算机上放置一个DLL的多个不同版本。一旦你更新了这个DLL,你就必须给所有用户升级,这是非常巨大的工作量。

 

Bill Venners: But if the contract is followed, shouldn't the most recent version work for all users of that DLL?

那么,为了遵循契约,最新版本就不应该为该DLL的所有用户工作了?

 

Anders Hejlsberg: In theory, yes. But any change is potentially a breaking change. Even a bug fix could break code if someone has relied on the bug. By the strictest definition you realize that you can do nothing once you've shipped.

理论上来说,是这样的。但任何一个修改都可能具有潜在的破坏性。甚至一个bug修正也能破坏代码,如果用户对此bug已有依赖性。通过最严格的定义,你会认识到,一旦已经发布了(DLL),就不再能对它做任何修改。

 

Versioning is all about relaxing the rules in the right way and introducing leeway. The absolute answer, the only way guaranteed to not break anything, is to change nothing. It is therefore important to support side-by-side execution of multiple versions of the same functionality, on the same box or even in the same process. Side-by-side execution is one option we support in .NET that we didn't support in the older DLL model.

采用正确的方法,并作些折衷,那么通过对版本的控制,将可以放松这一限制。如果要绝对答案,那么保证不产生破坏性的唯一办法就是什么也不要改动。因此,对同样功能的多个版本的并行执行——在同样一个“匣子”,甚至过程里——的支持就非常重要。并行执行是我们在.NET中支持的一种功能,以前的DLL模式中是不提供的。

 

 

Strong Names in .NET

.NET中的强名称

 

Bill Venners: I assume you use strong names to identify the library version that you want. How do strong names work?

我猜测你是使用强名称来标识需要的链接库的版本。那么强名称是如何工作的呢?

 

Anders Hejlsberg: Strong names have a logical and physical part. The logical part is composed of the namespace and class names. Actually, from the Common Language Runtime's [CLR's] perspective, namespaces don't really exist. We can pretend that namespaces exist in the programming language, but from the CLR's perspective, a class name may have dots in it. That's the logical name of the class. The physical name includes the name of the assembly that the code lives in, the version number, the locale, and the cryptographic key associated with the name.

强名称分为逻辑和物理两个部分。逻辑部分由命名空间和类名组成。实际上,从公共语言运行库(CLR)角度而言,命名空间并非真实存在。我们假定命名空间在编程语言中存在,但从CLR角度观察,一个类名可能会包含一些点号。这就是类的逻辑名称。物理名称包括代码所在程序集的名称、版本号、区域信息以及此名称的密钥。

 

You can refer to a particular type in a particular assembly with a particular version or with a particular strong key. You can literally have a guarantee that you will either get precisely the implementation you were compiled against or nothing. Or, you can relax parts of the strong name. You can say, "I'll take any version later than some version."

你可以通过指定版本号或指定密钥来引用指定程序集中的指定类型。你可以(通过强名称)逐字地确保精确实现对某些东西是否编译。当然,你也可以弱化强名称的某些部分(的限制)。你能这样讲:“我可以使用比某个版本更低的任何版本”。

 

Enforcing Semantic Contracts

强化语义契约

 

Bruce Eckel: Have you come up with any interesting thoughts about ways to enforce semantic contracts?

对于如何强化语义契约,你有什么让大家感兴趣的看法?

 

Anders Hejlsberg: I think the most promising ideas are existing and new developments in pre- and post-conditions, assertions, invariants, and so forth. Microsoft research has several ongoing projects that we continually evaluate . We have looked at some pretty concrete proposals. In the end we realized that—as is the case for almost any truly important feature—you can't just do contract enforcement from purely a programming language perspective. You have to push it into the infrastructure, the CLR, the Common Language Specification, and therefore all the other programming languages. What good is putting invariants on an interface, if it is optional for the implementer of the interface to include the code of the invariant? So it's really more at a type system level than at a programming language level, but that doesn't necessarily mean that we're not going to address it. We are not doing that in the next release, but it could become a first class feature in C# down the line.

我认为大有希望的一些想法已经存在了,如前置条件(pre-conditions)、后置条件(post-conditions)、断言(assertions)和不变式(invariants)等思想的进步。我们陆续评估了微软研究院正在开展的一些项目,同时研究过一些相当具体的建议,最后认识到——对于任何一个真正重要的特性而言都是如此——你不能仅仅从编程语言的角度进行契约强化。你必须将它放入基础架构、公共语言运行库和公共语言规范(Common Language Specification),然后才轮到所有别的编程语言。如果实现接口时是否包含带有不变式的代码是可选的,那么将不变式置于接口上有什么好处呢?它是居于类型系统层次而不是编程语言层次的,但这并不意味着我们不将考虑它(译者注:指编程语言层次)。在下一个版本中我们还不会这样做,但是顺着这条路走下去,它终会成为C#中的基础性特性的。

 

Interoperability

协同工作能力

Bill Venners: You have said that where Java is striving for platform independence, .NET is striving for interoperability. What do you mean by interoperability?

你说过,Java为平台无关性努力,.NET为协同工作能力努力。什么是协同工作能力?

 

Anders Hejlsberg: Interoperability means several things. First, it means interoperability between various programming languages in .NET. Our design goal was that the .NET CLR would be language neutral, that it would support multiple programming languages. Java, by contrast, was one programming language and execution machinery for that one programming language. The CLR supports many features that have surfaced in only a few programming languages, for example, pointers. Unsafe code in C# and managed C++ have pointers, but Visual Basic and JScript don't. Yet all the infrastructure for pointers is in place in the CLR. Language interoperability is about the realization that as much as we try we're not going to convince everybody that you just program in one programming language. And honestly the way that the industry moves forward and innovation happens is by new programming languages being created. And we're not going to try to stop that. We're going to encourage it.

协同工作能力有几个方面的意思。首先,它指.NET框架下不同语言的协同工作能力。我们的设计目标是:.NET CLR成为语言的核心,让它支持多种编程语言。而相反地,Java只是一种编程语言,而且它提供的执行机制也只支持一种编程语言。CLR支持很多只有少数几种编程语言具有的特性,如指针。C#的不安全代码和托管C++有指针,但VB和JScript没有。然而,指针的所有基础性支持都放置在CLR中了。我们将努力实现多种语言的协同工作能力,而不是要人相信你仅仅使用一种语言编程。老实说,工业进步和革新出现都是伴随新兴编程语言的发明到来的。我们不但不会阻止,反而会推进这一进程。

 

Another aspect of interoperability is interoperability with existing systems. Back when we were in the Java business, one of the things that we tried to improve upon in our Java VM was interoperability with existing code, because we just think that kind of interoperability is so key. And we still think that. In the CLR, therefore, we have focused very heavily on interoperability with DLLs,COM, OLE automation—all of these technologies that any piece of code was written in before .NET.

其次,它是指已有系统间的协同工作能力。回头看Java模式,其目标之一就是努力提升Java虚拟机的能力,就是为了和已有代码协同工作,这恰恰是因为我们看到这种协同能力至关重要。顺此思路,在CLR中,我们就非常关心与DLLs、COM以及OLE的协同——使用这些技术的所有代码都是在.NET出现以前完成的。

 

It goes back to what I said earlier [In Part IV] that the key today is leverage. We've got to find ways for our programmers to leverage existing systems and code. Achieving that goal means having great interoperability, because how else can you leverage? That puts us in a complete opposition to Java's "100% Pure" viewpoint of the world. And I think we're doing the right thing with it. I really do.

我曾经说过(在第四次访谈):目前,关键的是“杠杆”。我们要为程序员找到方法去“撬动”已有的系统和代码。实现该目标就意味着要有良好的协同工作能力,难道你有别的什么办法么?不过这也将我们推到了Java宣称的“100%纯度”观点的对立面,但我认为我们这样做是正确的,肯定是。

 

If you contrast what it feels like to call a DLL from C# versus to do it from Java, you'll very quickly see what I mean. It is very complicated to use JNI, and I think it is a pity that they haven't done anything better there, because so much more could be done. It doesn't make sense that the minute you have to interoperate with any other system in the world you enter this netherworld that is quite possibly more complicated than straight C or C++ programming. You have to run all these tools that spit out some header files. You have to remember to call this and that. If you want to dereference an object, you better remember to lock it down else it could, in one out of a thousand cases of running your program, move when the GC somehow happens to sweep right then. Then you can never reproduce it again. If it's OK for a system to do garbage collection and type safety and all, why shouldn't it help you interoperate? It just seems like such a reasonable thing to do.

如果你对比在C#和Java中对dll的调用方式就会很快明白我的意思。JNI使用起来非常复杂,我对他们没能做得更好些感到遗憾,实际上在这方面大有可为。此刻你就好像进入了地狱一样,它比用C或者C++直接编程要复杂得多,这毫无意义。你必须运行很多工具去挑出一些头文件,必须记住调用这个、调用那个。如果想解除对一个对象的引用,你最好首先锁定它,否则,此时垃圾收集器可能碰巧清除掉它——你的程序运行时,此种可能性为千分之一。如果这样的话,你就无法让它再生了。如果系统能够管理好垃圾收集、类型安全等等工作,岂不是对协同工作大有帮助么?这恰恰是一件非常值得去做的事情。

 

Bill Venners: From my perspective looking in from the outside of both Microsoft and Sun, I've noticed a cultural or philosophical difference between the two companies that I think influences the design differences between Java and .NET. At Microsoft, I get the sense that the prevailing view is that software is written to program the hardware—the box, the device, and so on. I think that's a totally reasonable perspective given how Microsoft makes its money. By contrast, even though "The network is the computer" was a Sun marketing slogan, I find that attitude really does exist in Sun culture to a great extent. The network offers the services, not the box. And Java is really like an object-oriented layer sitting on top of the network stack, aimed at abstracting away the heterogeneity connected to the network.

以我一个局外人的角度来审视Microsoft和Sun,我发现是两个公司在文化和哲学范畴的差异导致了Java和.NET在设计上的差异。我感觉,Microsoft的主流观点是:软件编写好后是用来控制硬件的,如一些匣子、设备等等。我认为这对于Microsoft为什么能大赚其钱是个完全合理的解释。而尽管“网络就是计算机”过去只是Sun的市场口号,但这种意识的确在其企业文化中有相当程度的积淀。网络提供服务,而不是“匣子”。Java的确像是一个居于网络栈顶的面向对象阶层,致力于剥离和网络相关的异质成分。

 

Anders Hejlsberg: What's interesting is that any Java solution you care to point at in the real world has platform-specific stuff in it. I know of nothing that is pure Java only, that doesn't somehow rely on some other component. Any of the web stuff relies on Apache or some web server, some database, and some form of interoperability with those systems. It's just ridiculous to think that the whole world is pure Java. The whole world is about putting systems together and making them work. And that's why the whole world is so excited about things like web services, because they're a wonderful way to interoperate. And we just think interoperability comes in many forms and we should just push as hard as we can and make it better and easier for systems to interoperate.

有趣的是,你在现实世界中挑出任何一个Java解决方案来分析,都会发现它包含与平台相关的东西。我还没有发现任何东西是纯Java的,一点儿都不依赖别的组件。Web程序依赖于Apache或者别的Web服务器,以及数据库,要和别的系统建立某些形式的协同工作关系。以为整个世界都是纯Java的,这非常荒谬。世界是把各种系统放到一起,然后让它们一起工作。这就是全世界都为Web Services这类东西感到激动的原因——它们是实现协同工作的美妙方法。我们认为协同工作能力将出现在很多领域,我们将竭力推动它的发展,让各种系统更好、更早地协同工作。

 

Bill Venners: Actually, the scenario you just described is exactly what I have on the Artima.com server. I have Tomcat running JSPs, and Tomcat does talk to Apache.

事实的确如此,你所描绘的就是我的Artima.com服务器工作时的情景。我用Tomcat来运行JSPs,让Tomcat和Apache对话。

 

Anders Hejlsberg: And you probably have a database.

可能你还有一个数据库。

 

Bill Venners: Yes, the Java application also talks to a database. There is platform-specific stuff in the sense that the Java API implementations use JNI, but the code of my application is all Java. And in my case even the connectors from Tomcat to Apache and the database are pure Java, because they use sockets to interoperate, not JNI.

是的,Java应用程序也和数据库通讯。在Java API通过使用JNI来实现这点上讲,是平台相关的,但我的应用程序代码都全是Java的。在我的这个解决方案中,甚至Tomcat与Apache、数据库的连接器都是纯Java编写的,因为它们使用套接字而不是JNI来协同工作。

 

Bruce Eckel: One of the things that I like about Python is that it says if you want to be platform independent you can, if you want to talk to the platform, you can.

我喜欢Python的原因之一就是它告诉我:如果你希望平台无关,你能办到;如果你想和平台对话,你能办到。

 

Anders Hejlsberg: Yes, exactly. It should be your choice.

完全正确,你的选择应该是这样。




编程语言如何影响开发者生产力与设计思维 编程语言不仅是语法工具,更是塑造开发者认知模式、设计决策和工程效率的核心载体。其抽象层级、语法噪音、类型系统与工具链协同能力,共同决定了代码的可读性、可维护性与错误发现时机。例如,C#的async/await降低异步心智负担,F#的模式匹配强化状态建模严谨性,Rust的所有权机制在编译期拦截内存隐患——这些并非炫技,而是对‘人机协作效率’的底层优化。在微服务、实时处理、数据科学等多元场景中,语言选型实为问题域测绘:用最贴合语义表达与运行约束的工具,减少无谓摩擦。老赵点滴的实践启示正在于此:回归语言本质,方能 阅读详情

相关推荐

.NET技术博客的深度写作范式与静态基建实践

技术博客本质上是知识结晶的静态载体,其核心价值在于可信、可验证、可复现。从.NET生态出发,理解编译器原理与运行时机制是构建深度技术内容的基础;而将C#语言本质、Roslyn编译器、JIT优化等底层原理转化为可调试、可测量、可交互的文档形态,则体现了工程化写作的技术价值。这种范式超越了API教程与碎片化笔记,服务于中高级开发者对‘为什么这样设计’的系统性追问,广泛应用于性能调优、源码阅读、跨平台迁移等真实工程场景。老赵点滴正是这一理念的长期实践样本。

diedangxiang4092的博客 513

Delphi的高光时刻!C#之父Anders Hejlsberg的祝福:持续更新、持续发展的Delphi家族- Delphi 2009及其后的新功能

当Anders Hejlsberg宣布Delphi于1995年2月14日在旧金山推出时,有一则轶事表明微软的一些员工也出席了。安德斯起立鼓掌。因此,他于次年被邀请担任微软的杰出工程师和技术研究员。然后,他设计了J ++,C#和Typescript,并获得了2001年Dobb博士的卓越编程奖。 2005年,安德斯向Delphi团队发送了以下电子邮件,以庆祝德尔福10岁生日。 大家好, 想象一...

Delphi开发局QQ群:32422310 971

C#编程从入门到精通:环境搭建、核心语法与面向对象实战指南

面向对象编程(OOP)是现代软件开发的核心范式,它通过封装、继承和多态三大特性,将数据与操作数据的方法组织成类与对象,从而提升代码的可维护性、可复用性和可扩展性。其原理在于模拟现实世界,将复杂系统分解为相互协作的实体。这一技术价值在于能够构建出结构清晰、易于管理和协作的大型复杂应用程序,广泛应用于桌面软件、Web后端、游戏开发和企业级系统构建。在工业控制与物联网(IoT)等具体场景中,例如开发上位机软件与海康威视等硬件设备交互时,扎实的OOP基础尤为关键。本文以C#语言为例,系统讲解从开发环境搭建、基础语法

weixin_33849215的博客 384

C#首席设计师Anders Hejlsberg专访

7月,O’Reilly 编辑John Osborn参加了微软职业开发者会议。在此,他对著名的工程师、微软.Net框架设计师、C#程序语言首席设计师Anders Hejlsberg进行了采访。Anders Hejlsberg因设计PC上最早的语言之一—Turbo Pascal而出名。他把Turbo Pascal授权给Borland公司,后又率队开发了Delphi—一个极为成功的可视化的客户/服务应用

Ajou's Blog 1345

PPT| 公司网络安全意识培训 P73

近年来,随着互联网的不断发展,网络安全问题也日益凸显,各种网络安全事件层出不穷,对个人和企业的信息安全带来了巨大的威胁。针对这一现状,国家加强了对信息安全的保护,相继颁布了多项法律法规,其中最重要的就是网络安全法。本文将从网络安全法和其他相关法律入手,对信息安全的保护措施进行深入分析。 本人在四大咨询机构从事咨询工作多年,二十年一线数字化规划咨询经验,提供制造业数智化转型规划服务,顶层规划/企业架构/数据治理/数据安全解决方案资料干货. 该PPT共73页,原文获取及来源公众号:【智能制造数字化咨询】

waldensss的博客 1422

使用PackStack工具自动化部署OpenStack

搭建 OpenStack 环境,每个组件的安装和配置都需要熟悉其特定的依赖关系、参数设置等,对于初学者来说容易出错。PackStack 工具通过集成一系列脚本和配置文件,便于快速搭建OpenStack练习环境。CPU:支持 Intel VT - x 或 AMD - V 硬件虚拟化技术,并且要在 BIOS 里开启此功能。内存:16GB以上存储:200GB以上可用空间(2)VMware WorkStation16.0以上版本(3)远程连接工具(如Xshell、MobaXterm)

2301_80440447的博客 4094

Anders Hejlsberg访谈:委托、组件以及表面上的简单性

本访谈系列的翻译已经征得原作者的同意,转载请保留原作者和译者的链接。Copyright © 1996-2005 Artima Software, Inc. All rights reservedDelegates, Components, and SimplexityA Conversation with Anders Hejlsberg, Part IIIby Bill Venners

5835

手机相机基础技术解析:从硬件到算法的全面指南

手机相机的成像过程可简化为的链路,其核心硬件包括 镜头、CMOS传感器、ISP(图像信号处理器) 以及配套的软件算法。

weixin_44239603的博客 2450

TypeScript 深度教程:从起源到未来的完整指南

​​:社区维护的类型声明库​​自动生成​​:使用dts-gen快速生成声明文件TypeScript 通过持续演进(@ref)和前瞻性布局(@ref),正在重塑现代编程范式。其核心价值在于 ​​用类型系统为代码构建安全网​​,同时 ​​保持与 JavaScript 生态的无缝兼容​​。随着 AI 和编译技术的突破,TypeScript 将继续引领前端工程化的发展方向。

Rysxt_的博客 948

KT148A语音芯片SOP外挂功放芯片8002D的说明_V1

KT148A语音芯片内置8欧姆0.5W的功放,所以一般的应用场景,播放一些提示音音量是足够的。但是有的需求还需要驱动更大的扬声器,实现更大的播放音量,这里我们给出解决方案。KT148A+HAA8002D的组合

qyvhome的博客 2152

【Spring Cloud Alibaba】Linux安装RocketMQ以及RocketMQ Dashboard可视化工具

在当今分布式架构的开发中,消息队列成为了一种常见的解决方案。RocketMQ是阿里巴巴开源的分布式消息中间件,具有高吞吐量、高可用性和强大的扩展性,因此在构建大规模、高可靠性的应用系统时备受推崇。而在使用RocketMQ时,为了更好地了解消息的流动和监控,RocketMQ Dashboard成为了一个不可或缺的可视化工具。本篇博客将带大家一步步在Linux系统中安装RocketMQ,并介绍如何配置和使用RocketMQ Dashboard。

编码人生 3385

TypeScript 快速入门:从 JavaScript 到类型安全的第一步

核心痛点:JavaScript 的灵活是双刃剑。当项目从 1000 行增长到 10000 行、团队从 1 人扩展到 10 人,动态类型变成最大负债:函数参数类型成谜、对象属性重构全凭运气、第三方库升级后全线崩溃。TypeScript 是社区对"大规模 JavaScript 可持续工程化"交出的事实标准答案。适配人群:具备 JavaScript ES6+ 基础,首次接触 TypeScript 的前端工程师、全栈开发者、Node.js 后端开发者。

我的博客 371

基于MATLAB的拉盖尔-高斯光束叠加相位模拟

首先,我们需要设置模拟所需的参数,如光腰半径、传播距离、光束的角动量等。其中,(U)表示光束的电场复振幅,(r)和(\phi)分别是极坐标系下的径向和角向坐标,(z)是传播距离,(A)是归一化系数,(w_p)是光束的光腰半径,(L_p^q)是拉盖尔多项式,(k)是波数,(l)是光束的角动量。通过修改模拟参数,如光腰半径、传播距离、角动量等,您可以进一步探索和理解拉盖尔-高斯光束的叠加相位效应。拉盖尔-高斯光束是一种特殊的光束模式,具有广泛的应用领域,包括光学信息处理、激光加工和量子光学等。

m0_47037246的博客 945

Delphi字符串1-based索引原理与安全实践

字符串索引是编程中最基础也最易出错的概念之一,其本质是内存访问的安全契约与人类直觉的工程平衡。Object Pascal采用1-based索引并非历史妥协,而是通过编译期范围检查、数学表达对齐和VCL生态统一,构建出区别于C/Python的强类型安全范式。这种设计使字符串操作天然具备边界防护能力,显著降低越界崩溃风险,在工业控制、医疗设备等高可靠性场景中价值突出。结合热词‘[]’和‘字符串’,本文深入解析UnicodeString字符访问、AnsiString字节访问及动态数组混合索引的三重语义,并覆盖M3

weixin_30634661的博客 463

STM32智能小车控制舵机转向

文章目录前言一、舵机简单介绍及接线方式二、cubeMX配置三、代码解析总结 前言 本文将带大家学习如何驱动舵机转向 一、舵机简单介绍及接线方式 信号线(黄线)红线(电源线)棕色(地线) 舵机的控制一般需要一个20ms左右的时基脉冲,该脉冲的高电平部分一般为0.5ms-2.5ms范围内的角度控制脉冲部分,总间隔为2ms。以180度角度伺服为例,那么对应的控制关系是这样的: 0.5ms--------------0度; 1.0ms------------45度; 1.5ms------------90度; 2

m0_49476241的博客 8614

亲测解决This application failed to start because no Qt platform plugin could be initialized.

这个问题是由于环境变量改变或者Qt的路径改变导致,解决办法是在环境变量里面重新添加Qt路径。

狂小虎/Anthony Dave的博客 KuangXiaoHu's Blogs 2929

微软技术日报 11-09:.NET 8 与 9 明日同时停止支持,注册表编辑器出了 WinUI 3 版

今天这四条消息的共同点是收口。.NET 8 和 9 的支持期到点,注册表编辑器的新界面只放在仓库里给人看,GitHub 把一类危险触发器按住默认,微软在安全报告里把防线从地址黑名单挪到行为。收口并不等于关门。.NET 10 还在支持期里,被按住的触发器可以用策略按文件放回来,实验室里的样例随时可能变成产品。区别在于这些动作要有人签字,不再是默认开着。如果今天只做一件事,去看一眼构建机上的 .NET 版本。明天之后,8 和 9 的漏洞补丁不会再来了。

海盗Sharp的博客 390

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

AI驱动数据处理的安全边界:行业现状、风险权衡与本地化实践路径

本文基于第三方数据,分析AI用于数据处理的安全议题。大模型应用加速普及,但伴随数据出境、影子AI、幻觉与成本失控等风险。行业共识指向“脚本复用”路径:将分析逻辑本地化固化,实现数据可控、结果可复现、成本可降。产品如数以轻舟提供本地处理、多模型接入与一次付费永久使用方案。建议企业从数据落点、可控性、可复现性与合规性四维度评估选型,推动AI在安全边界内释放价值。

数据矿工-数据化运营博客 329

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

上一篇: Bertrand Meyer谈契约式设计
下一篇: 深入解析ATL(第二版ATL8.0)(2.1-2.2节)
mengtech
博客等级 码龄19年 44粉丝 3472原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值