为什么使用谷歌V8
我不明白。我是一名 C/C++ 程序员,V8 对我来说可能有什么用处?那里的示例和教程很少,而且它们都缺乏实质内容 - 我不想使用另一个库来添加几个数字或在控制台窗口中打印一些内容。 我的问题是:这项技术是否有真正的用途?如果有,那么情况会怎样? 另外,我可以用这种方式做 GUI 的任何部分吗?
感谢帮助。
I don't get it. I'm a C/C++ programmer, what's the possible use of V8 for me? There are few examples and tutorials out there, and they all lack substance - I don't want to use another library to just add a couple of numbers or print something in a console window.
My question is: is there a real use for this technology, and if yes, then would be the scenario?
Also, can I do any part of GUI this way?
Help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
“V8 是 Google 的开源 JavaScript 引擎”
所以重点是用 JavaScript 编写代码的能力,并且运行得相当快(对于解释型动态语言)。 Google Chrome 使用 C++ 编写,将其用于内部脚本编写 - 不仅用于常规网页脚本编写,还用于扩展代码。让我们将其视为“实际用途”。
因此,如果您的应用程序需要脚本,V8 可能适合您(JS 不是一种完美的语言,但仍然相当不错)。至于GUI,您需要先将GUI组件与JS绑定,没有内置的UI组件(如TCL中的Tk)。
"V8 is Google's open source JavaScript engine"
So the whole point is ability to write code in JavaScript, and run it quite fast (for an interpreted dynamic language). Google Chrome, which is written in C++, uses it for internal scripting — not only for regular web page scripting, but also for extension code. Let's consider this as a 'real use'.
So, if your app needs scripting, V8 may be good for you (JS is not a perfect language, but stil quite decent). As for GUI, you'll need to bind your GUI components with JS first, there's no built-in UI components (as Tk in TCL).
v8 的一个真正用途是node.js。我希望这已经足够好了
One real use of v8 is node.js. I hope that is good enough
Google V8 是一个 JavaScript 引擎。
我真的不认为这就是您正在寻找的东西。
Google V8 is a JavaScript engine.
I don't really think it is what you are looking for.
V8 是一个 JavaScript 引擎。它最常见的用途是允许您的软件的用户使用比您的软件编写语言更简单的语言(在您的例子中是 C++)来编写脚本。
这与 Matlab、AutoCad、Microsoft Office 等的方法相同。
如果您编写任何类型的商业应用程序,您可以公开一些 API 并允许其他开发人员为您的应用程序创建插件,而无需他们了解 C/C++。
V8 is a JavaScript engine. The most common use for it is to allow users of your software to write scripts in simpler language than that your software was written with (C++ in your case).
It´s the same approach of Matlab, AutoCad, Microsoft Office, and etc.
If you write any kind of commercial application, you can expose some APIs and allow other developer to create addons for your applications without require them to know C/C++.
实际使用怎么样:您可以使用 javascript 作为调试或测试工具 - 将 javascript 控制台添加到您的应用程序并将 GUI 应用程序的命令绑定到 javascript 函数,您将能够使用 javascript 脚本测试您的 UI 应用程序。这样,您将减少所需的手动测试量 - 手动测试只需验证用户操作是否执行了正确的命令。
您可以使用 javascript 实现 GUI,就像在 Python 和其他脚本语言中使用 Qt 一样(请参阅 PyQt、QtRuby、PerlQt 等)。有关如何为 V8 创建绑定,您可能需要查看此内容
How about this for real use: You can use javascript as a debugging or testing tool - add a javascript console to your app and bind the commands of your GUI application to javascript functions, and you'll be able to test your UI application using javascript scripts. This way you'll reduce the amount of manual testing needed - manual testing would only have to verify that a correct command was excutes as a result of user action.
You can do GUI in javascript the same way that Qt is being used in Python and other scripting languages (see PyQt, and QtRuby, PerlQt, etc.). For how to create bindings for V8 you may want to check out this