Windows Mobile开发:选择.Net compact与Native(c ++)代码

时间:2023-02-03 12:28:05

I work on an experienced and diverse development team and we are preparing to approach our first mobile development which will be for Windows Mobile 6 (platform changes are not an option).

我在一个经验丰富,多元化的开发团队工作,我们正准备接近我们的第一个移动开发,这将是针对Windows Mobile 6(平台更改不是一个选项)。

We have skills and experience in both Visual C++ and .Net technologies for Windows desktop and server development.

我们拥有用于Windows桌面和服务器开发的Visual C ++和.Net技术的技能和经验。

The mobile development will include some image processing, and read/write access to a bluetooth device. Unfortunately I can't really give any more details than that.

移动开发将包括一些图像处理和对蓝牙设备的读/写访问。不幸的是,我无法提供更多细节。

We are trying to choose between writing the mobile client using managed code or native code. We would use C# or C++ respectively.

我们尝试在使用托管代码或本机代码编写移动客户端之间进行选择。我们将分别使用C#或C ++。

My questions are:

我的问题是:

  • How big is the expected performance differential between these languages? I have heard that native code is significantly faster on mobile devices, but I would love to hear from someone with experience.

    这些语言之间的预期性能差异有多大?我听说本机代码在移动设备上明显更快,但我很乐意听取有经验的人的意见。

  • Are there any major advantages to either language in terms of working with the Windows Mobile services for accessing bluetooth devices?

    在使用Windows Mobile服务访问蓝牙设备方面,这两种语言都有什么主要优势吗?

  • Is there an impact on battery life between managed or native code?

    托管代码或本机代码之间的电池寿命是否会受到影响?

  • Are there any other major should-knows for us to consider?

    还有其他专业应该知道我们考虑吗?

I appreciate your feedback.

感谢您的反馈意见。

3 个解决方案

#1


A very similar question was asked and answered just a few days ago. You can find useful information there.

几天前就提出并回答了一个非常相似的问题。你可以在那里找到有用的信息。

Short answers to your questions:

您的问题的简短答案:

  • Native code is faster, but for many applications the speed difference won't be noticeable. Don't use native code just for the speed, unless this is a key factor for your application. Managed applications can also run fast - it may take them longer to launch.
  • 本机代码更快,但对于许多应用程序而言,速度差异不会明显。不要仅仅为速度使用本机代码,除非这是您的应用程序的关键因素。托管应用程序也可以快速运行 - 启动可能需要更长时间。

  • There is a good Bluetooth library for .NET applications. I am not aware of a similar library for C++ applications.
  • 有一个很好的.NET应用程序蓝牙库。我不知道类似的C ++应用程序库。

  • It is up to your design to achieve good battery life. Choice of platform doesn't matter.
  • 您的设计可以实现良好的电池寿命。选择平台并不重要。

#2


Another consideration is the issue of memory usage and module size. We have run into significant problems in mobile development simply trying to get the OS to load all our DLLs into memory. Unlike regular windows development, there is a very strict limit of 32Mb into which all modules must be loaded. We've had to perform a lot of very dirty tricks to get all our stuff loaded successfully. We have found that even if a user turns on the cell phone or uses a bluetooth device, the drivers for those devices would cause our application to fail because they would use up the space for our modules.

另一个考虑因素是内存使用和模块大小问题。我们在移动开发中遇到了一些重大问题,只是试图让操作系统将所有DLL加载到内存中。与常规Windows开发不同,对于必须加载所有模块的32Mb存在非常严格的限制。我们必须执行许多非常肮脏的技巧才能成功加载所有东西。我们发现,即使用户打开手机或使用蓝牙设备,这些设备的驱动程序也会导致我们的应用程序失败,因为它们会占用我们模块的空间。

With all that in mind, we have been unable to add in support for .Net into our application, because of the extra module weight that this would have introduced into our application. You may need to take this into allowance, if your application has a lot of dependancies.

考虑到所有这些,我们无法在我们的应用程序中添加对.Net的支持,因为这会在我们的应用程序中引入额外的模块权重。如果您的应用程序有很多依赖性,您可能需要考虑这一点。

#3


In addition to the great - and long - answer in the other question mentioned by kgiannakakis I have to add a few thoughts and points.

除了在kgiannakakis提到的另一个问题中的伟大和长期答案之外,我还要添加一些想法和观点。

At my workplace we've been writing applications for Windows CE 5.0 using C++ and ATL/WTL. This ends up being nice to work with and very light compared to both MFC and .Net.

在我的工作场所,我们一直在使用C ++和ATL / WTL编写Windows CE 5.0应用程序。与MFC和.Net相比,这最终可以很好地工作并且非常轻便。

The other point to take into consideration (as explained by a senior developer here) is that the .Net compact framework needs to recompile the byte code into machine code each time the application is switched to. This could potentially take a long amount of time and processor power so be careful.

要考虑的另一点(正如高级开发人员所解释的那样)是.Net紧凑框架需要在每次切换应用程序时将字节代码重新编译为机器代码。这可能需要很长的时间和处理器能力,所以要小心。

#1


A very similar question was asked and answered just a few days ago. You can find useful information there.

几天前就提出并回答了一个非常相似的问题。你可以在那里找到有用的信息。

Short answers to your questions:

您的问题的简短答案:

  • Native code is faster, but for many applications the speed difference won't be noticeable. Don't use native code just for the speed, unless this is a key factor for your application. Managed applications can also run fast - it may take them longer to launch.
  • 本机代码更快,但对于许多应用程序而言,速度差异不会明显。不要仅仅为速度使用本机代码,除非这是您的应用程序的关键因素。托管应用程序也可以快速运行 - 启动可能需要更长时间。

  • There is a good Bluetooth library for .NET applications. I am not aware of a similar library for C++ applications.
  • 有一个很好的.NET应用程序蓝牙库。我不知道类似的C ++应用程序库。

  • It is up to your design to achieve good battery life. Choice of platform doesn't matter.
  • 您的设计可以实现良好的电池寿命。选择平台并不重要。

#2


Another consideration is the issue of memory usage and module size. We have run into significant problems in mobile development simply trying to get the OS to load all our DLLs into memory. Unlike regular windows development, there is a very strict limit of 32Mb into which all modules must be loaded. We've had to perform a lot of very dirty tricks to get all our stuff loaded successfully. We have found that even if a user turns on the cell phone or uses a bluetooth device, the drivers for those devices would cause our application to fail because they would use up the space for our modules.

另一个考虑因素是内存使用和模块大小问题。我们在移动开发中遇到了一些重大问题,只是试图让操作系统将所有DLL加载到内存中。与常规Windows开发不同,对于必须加载所有模块的32Mb存在非常严格的限制。我们必须执行许多非常肮脏的技巧才能成功加载所有东西。我们发现,即使用户打开手机或使用蓝牙设备,这些设备的驱动程序也会导致我们的应用程序失败,因为它们会占用我们模块的空间。

With all that in mind, we have been unable to add in support for .Net into our application, because of the extra module weight that this would have introduced into our application. You may need to take this into allowance, if your application has a lot of dependancies.

考虑到所有这些,我们无法在我们的应用程序中添加对.Net的支持,因为这会在我们的应用程序中引入额外的模块权重。如果您的应用程序有很多依赖性,您可能需要考虑这一点。

#3


In addition to the great - and long - answer in the other question mentioned by kgiannakakis I have to add a few thoughts and points.

除了在kgiannakakis提到的另一个问题中的伟大和长期答案之外,我还要添加一些想法和观点。

At my workplace we've been writing applications for Windows CE 5.0 using C++ and ATL/WTL. This ends up being nice to work with and very light compared to both MFC and .Net.

在我的工作场所,我们一直在使用C ++和ATL / WTL编写Windows CE 5.0应用程序。与MFC和.Net相比,这最终可以很好地工作并且非常轻便。

The other point to take into consideration (as explained by a senior developer here) is that the .Net compact framework needs to recompile the byte code into machine code each time the application is switched to. This could potentially take a long amount of time and processor power so be careful.

要考虑的另一点(正如高级开发人员所解释的那样)是.Net紧凑框架需要在每次切换应用程序时将字节代码重新编译为机器代码。这可能需要很长的时间和处理器能力,所以要小心。