用两种语言编写程序? [英] Writing a program in 2 languages?

查看:86
本文介绍了用两种语言编写程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个程序可以用一种以上的编程语言编写吗?我在 The Daily WTF 上读到的东西似乎暗示大公司/组织在构建大型应用程序时会使用几种不同的语言.这是如何运作的?我从与 Django 的合作中了解到,动态网页通常与许多不同的语言(用于控制器的 Python、用于视图的 HTML + Django 的模板语言以及用于模型的 SQL)组合在一起,但是 程序,即编译时会变成 .exe 的东西?

Can a program be written in more than one programming language? The stuff I read on The Daily WTF seems to imply that big companies/organizations employ several different languages when building a large application. How does that work? I know from working with Django that dynamic web pages are often put together with a bunch of different languages (Python for the controllers, HTML + Django's templating language for the view, and SQL for the models), but what about programs, ie stuff that would turn into an .exe when compiled?

推荐答案

使用不同的语言和技术构建大型应用程序是很常见的.混合语言有不同的方式.

It's quite common to build large applications using different langauges and technologies. Mixing languages comes in different ways.

首先,来自不同语言的编译器可以生成可以链接在一起的兼容输出.这可以是来自 C、C++、Pascal 和其他语言的 .obj 文件编译为本机代码.或者可以是 .NET 程序集 - 您可以毫不费力地从任何其他 .NET 系列语言程序集使用以任何 .NET 系列语言编写的程序集.

First, compilers from different languages can produce compatible output that can be linked together. That can be .obj files from C, C++, Pascal and other languages compiling to native code. Or that can be .NET assemblies - you can effortlessly use an assembly written in any .NET family language from any other .NET family language assembly.

然后,有各种互操作性技术.您可以将一些代码包装为 COM 对象并从不同语言的应用程序中使用.或者你可以将不同语言的代码放入不同的程序中,让它们通过一些进程间通信技术(如 RPC)进行通信.在后一种情况下,他们根本不会关心其他进程是如何工作的——他们只发送和接收消息——就像你不关心你的浏览器和你从中读取页面的网络服务器很可能是用不同的语言编写的一样.

Then, there're various interoperability technologies. You could have some code wrapped as a COM object and consumed from an application in a different language. Or you could put code in different langauges into different programs and make them communicate via some interprocess communication technology like RPC. In the latter case they will not care at all how the other process works - they only send and receive messages - much like you don't care that your browser and the web server you read pages from are most likely written in different languages.

这篇关于用两种语言编写程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆