合并不同语言的程序
我有三个具有不同功能的程序(一个在 C++ + WinAPI 中,另一个在 C# .NET 中,最后一个在 Java 中)。我将选择其中之一并实现另外两个的功能。是否有可能以某种方式合并它们?我需要将它们放在一个 GUI 中,在一个进程下(至少在视觉上)。 IPC不是问题。
谢谢你的任何事
I have three programs (one in C++ + WinAPI, another one in C# .NET and the last one in Java) with different functions. I am about to choose one and implement functions of the other two. Is it possible to somehow merge them? I need to have them in one GUI, under one process (at least visually). IPC isn't a problem.
Thanks for anything
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你能做的最好/最简单的事情就是只用 C# 制作 GUI,在 Windows 客户端中你可以使用 Windows Forms 或 WPF,在基于 Web 的情况下你可以使用 ASP.NET WebForms 或 ASP.NET MVC。
在所有这些情况下,除了 MVC (Razor) 之外,您都拥有在 Visual Studio 中设计和自定义 GUI 的非常好的工具。
您的 C++ 代码可以包装在类库中,或者正如您所说,如果它必须作为应用程序运行,则可以通过某种 IPC 访问,对于 Java 也是如此,但如果您可以 100% 自由地编写和重写您也可以想象的东西将 Java 代码移植到 C++,这可能很容易、很困难或不可能,具体取决于 Java 代码的作用。
最后,如果 C++ 和 Java 应用程序必须保持分离,并且必须在同一台或另一台计算机上在后台运行,并且您仍然希望从 C# GUI 中使用它们的服务或方法,正如您提到的,IPC 可能是一种方式,不确定是什么您可以在 Windows 中使用 Java 和 IPC 进行操作,当然 java 可以公开或使用 XML Web 服务。
I think the best/easiest thing you could do is make the GUI only in C#, in windows clients you could use Windows Forms or WPF, in web based you can use ASP.NET WebForms or ASP.NET MVC.
in all these cases except MVC (Razor) you have really good tools for designing and customizing the GUI within Visual Studio.
Your C++ code can be wrapped in a class library or as you say accessed via some kind of IPC if it has to run as application, same for Java but if you are 100% free to write and re-write things you could also imagine to port the Java code to C++, this could be easy, difficult or impossible depending on what the java code does.
at last resort if both C++ and Java applications must stay separated and must run in background on same or another machine and you still want to consume their services or methods from your C# GUI, as you mentioned, IPC is probably the way, not sure what you can do in Windows with Java and IPC, surely java can expose or consume XML web services.
您会发现的问题是每个进程都有自己的进程模型,您要么需要使进程模型共存,要么需要多个通信进程(尽管用户不需要看到它们)。例如,对于Java,它可以是“王”,或者您可以在另一个进程中设置某种子进程,或者您可以让它在每次调用时设置/取消其进程模型。哪种方法最好部分取决于您将使用“来宾”语言执行的操作的复杂性。
不过,最主要的一件事是,只有一种语言可以控制 UI——一般来说,不同语言的 UI 不会共存,而且我怀疑您是否可以在 C# GUI 中拥有 Java UI 对象,至少不能没有将其视为外部窗口。
The problem you will find is that each has its own process model, and you either need to get the process models to coexist or you'll need several communicating processes (though the user need not see them). With Java, eg, it can be "king", or you can set up a sort of sub-process in another process, or you can have it set up/take down its process model on every call. Which approach is best depends in part on the complexity of the operations you'll be doing in the "guest" language.
The one main thing, though, is that only one language can control the UI -- in general different language UIs don't coexist, and I doubt that you can have eg, a Java UI object in a C# GUI, at least not without treating it as a foreign window.
如果您谈论的是重写程序的最佳语言,那完全取决于主要功能。如果您主要需要它与 Windows 很好地集成,那么 C# 将是显而易见的选择。如果您的主要想法是使其跨平台,那么在 Java 中最有意义。
如果您正在谈论一起运行它们并使用 IPC,那么是的,这也是可能的 - 您可以使用从完全成熟的 IPC 框架到本地主机上套接字上的自定义协议的任何内容。那里不应该有太大的问题,但请记住,根据其他语言的部分有多大,重写它们的时间可能会花费同样多的时间(而且这样也可以减少维护负担)。 )从其他进程控制 GUI 也很复杂,可以通过跨进程传递本机画布 ID 来完成,但是很难正常工作,可能不是特别安全,并且很难弄清楚发生了什么维护的角度。
If you're talking about the best language to rewrite the programs in, that depends entirely on the primary function. If you mainly need it to integrate with Windows nicely, C# would be the obvious choice. If your main idea is to make it cross-platform, it'd make most sense in Java.
If you're talking about running them together and using IPC then yes, that's possible too - you could use anything from a fully blown IPC framework to a custom protocol over sockets on localhost. There shouldn't be too much of an issue there, though remember depending on how big the parts in other languages are, it may cost just as much in terms of time to rewrite them (and there's less of a maintenance burden that way too.) There's also complexities with controlling GUIs from other processes, it can be done ish by passing native canvas IDs around cross process, but it's hard to get working properly, may not be particularly safe and makes it quite difficult to work out what's going on from a maintenance perspective.