Windows C API比C#/ .NET困难得多 [英] how much harder is Windows C API than C#/.NET

查看:89
本文介绍了Windows C API比C#/ .NET困难得多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于编写Windows桌面应用程序,使用Windows C API比使用C#/ .NET要困难得多,假设编码是在

中完成的编辑?哪些具体方面更难?我正在寻找那些尝试过两者的程序员的回复。


***********开始背景/战争故事


我正在移植一个名为Vitalnet的C / Curses数据分析应用程序,

大约70,000行源代码和200,000行头文件,<来自C / Curses版本的
,在windows下运行。我使用了带有

2.0 .NET框架的C#。

http://www.ehdp.com/vp-win/picture01.htm 显示了Vitalnet Windows界面看起来的一些图片

喜欢。我把代码写入vi编辑器,

这是我更喜欢的,并且是制作程序所必需的,因此它可以生成多个自定义可执行文件的
。我还没有尝试过C Windows API

。我喜欢在C和C#中编程很多,并且没有发现C#

很难使用,但我担心一些.NET的缺点我已经观察到了b
。下面的测试是在Windows 2000,Pentium III,Seagate

7200.7硬盘,256 MB RAM上。


我在C#/ .NET中发现的问题我考虑使用C API:


** 1)开始慢。我电脑上的启动时间(秒):


Vitalnet .NET第一次(不使用ngen)= 11

Vitalnet .NET第二次(不使用ngen) )= 5

Vitalnet .NET第一次(使用ngen)= 9

Vitalnet .NET第二次(使用ngen)= 4

Microsoft Word = 2

Vitalnet Curses = 1


** 2)使用大量内存。在我的电脑上使用的RAM(MB):


Vitalnet .NET = 20(每次调用)

Microsoft Word = 3

Internet Explorer = 1

Vitalnet Curses = 1


** 3)在阅读和解析数百万条记录时运行速度较慢。 C / $
版本在代码的关键部分使用指针。我还没有真正尝试在.NET应用程序中优化该部分,但它会更难。

我的PC上两个不同的大分析的时间(秒): br />

Vitalnet .NET = 15 + 27 = 42

Vitalnet Curses = 14 + 16 = 30


** 4)似乎更难安装。因为.NET框架可能需要安装

。安装到笔记本电脑(使用合法软件),得到了各种来自微软的消息,我认为可能会让用户感到困惑。在另一个

手上,我知道如果你运行

Windows Update,框架会自动安装。


** 5)从逆向工程看似不太安全。我知道通常很容易从头开始而不是窃取别人的代码,但是你永远都不会知道
。我混淆了函数和变量名。


** 6)更难维护(在这种特殊情况下)。该应用程序具有超过1000个现有业务逻辑C函数的
,以及用C编写的许多数据
结构。这对于支持基于Web的
$ b是必要的$ b版本的Vitalnet,所以我不想完全切换到C#(或

java)。使用CPP宏,我将C业务逻辑函数

合并到C#/ .NET中。我认为这是可以阅读的,但肯定是不同的

和非标准。也许更好地使用C.


我有这样的想法,编程C API是一个很大的痛苦。

但我从来没有尝试过,所以不知道。有些事情很容易在/ b
C#/ .NET中,我不知道使用C API是否容易。例如,使用C API在选项卡式页面中嵌入

浏览器。或者,设置具有许多事件的复杂树

视图。或者,做flowlayout。我不感兴趣

托管代码和垃圾收集的好处:我想我可以处理

指针和malloc /免费罚款,除非我失踪关于C

API的一些事情。此外,代码简洁本身对我没什么好处。我更担心用户界面编程的难度,以及

必须手工做很多容易出错的低级细节。


我知道微软希望开发人员将.NET用于新的应用程序。我不知道有多少广泛使用的商业桌面应用程序用于C#/ .NET已经开发了b $ / b
。我也正在考虑使用AJAX使web版本更具互动性。我对MFC / C ++不感兴趣(已经使用了

C,不喜欢C ++,MFC听起来更复杂)。我对

Basic不感兴趣。我喜欢Java,但它缺少一些我需要与

结构和传递参数相关的功能。如果我决定切换,我已经知道用什么书和其他

资源来学习C API。


******** ***结束背景/战争故事


所以,那些尝试过两者的程序员,使用Windows C API比C#使用更难的b / b
/.NET用于编写桌面应用程序,

假设程序员正在编写编辑器?或任何其他

评论。


Daniel Goldman

解决方案

< blockquote>嗨!


所以,那些尝试过两者的程序员,使用Windows C API比C#使用更难的b / b
/.NET用于编写桌面应用程序,

假设程序员正在编写编辑器?或任何其他

评论。



W32桌面应用程序开发的黄金分割是

Borland Delphi 2006.如果你用我们的库补充它,

适用于您的应用类型,您可以非常快速地获得快速结果:

www.dewresearch.com


Delphi具有C#的生产力和C的速度。还有一些你不能在C#或C ++中做的事情(用于科学和工程):

http:// www .dewresearch.com / Delphi2006Demo.html


(但只有在你有快速上网的情况下点击链接)。


最好的问候!

Atmapuri




Atmapuri写道:


嗨!


那么,你们两个都试过的程序员,多少硬化是否使用Windows C API而不是C#/ .NET来编写桌面应用程序,

假设程序员正在编写编辑器?或任何其他

评论。



W32桌面应用程序开发的黄金分割是

Borland Delphi 2006.如果你用我们的库补充它,

适用于您的应用类型,您可以非常快速地获得快速结果:

www.dewresearch.com


Delphi具有C#的生产力和C的速度。还有一些你不能在C#或C ++中做的事情(用于科学和工程):

http:// www .dewresearch.com / Delphi2006Demo.html


(但只有在你有快速上网的情况下点击链接)。


最好的问候!

Atmapuri



我以为我排除了Delphi编程语言,因为

我需要合并大量现有的C代码和标题

文件(我原帖中的原因#6),但我我再看看。如果

看起来有可能,我会另外发帖。


回到原来的问题:我有兴趣获得反馈基于经验,基于

,使用Windows C API比编写桌面应用程序要多得多,而且假设程序员是

编入编辑器。


Daniel


2006年9月3日消息

< 11 ********************** @ 74g2000cwt.googlegroups。 comdan写道:


>回到我原来的问题:我有兴趣获得反馈,基于经验,对它来说有多难使用Windows C API而不是使用C#/ .NET来编写桌面应用程序,假设程序员正在编写编辑器。



我一直使用IDE而不是编辑器。为了便于编程,我会将C#和

VB6放在一起,确实很快将一个应用程序放在一起。我喜欢C和API,但是需要更长时间(根据我的经验)

将应用程序放在一起。如果您计划进行严肃的编程,那么无论如何都需要

来使用C#中的API,C#中缺少大量的编程,它是

在我看来,这是它最大的弱点。现在有很多帮助,因为在社区中积累了经验。 MS确实需要接受

需要,并发布一个合适的API库。另外还缺少#include

语句 - 如果你用一些文件来编写,你需要使用几个文件

每次使用它们时都会手动将每个文件链接到你的项目中 -

绝对痛苦!


使用API​​的AC应用程序启动速度更快,可以编译工作

stand -单独。 Delphi在编译独立应用程序方面仍处于领先地位,而且启动速度很快,我仍然很想回到它。还有更多免费的Delphi实用程序,它总是有一个很好的社交精神。一个很好的例子是Mike Lischke的虚拟树视图和

MustangPeak的VirtualShellTools - 在C#

中没有任何东西可以不付费。我不确定这会很快改变。


-

Jeff Gaines


For writing a Windows desktop application, how much harder is it to use
the Windows C API than C#/.NET, assuming the coding is done in an
editor? What specific aspects were more difficult? I''m looking for
responses from programmers who have tried both.

*********** Begin background / war story

I''m porting a C/Curses data analysis application called Vitalnet, with
about 70,000 lines of source code and 200,000 lines of headers files,
from a C/Curses version, to run under windows. I have used C# with the
2.0 .NET framework.

http://www.ehdp.com/vp-win/picture01.htm shows some pictures of what
the Vitalnet Windows interface looks like. I write code into vi editor,
which I prefer and is necessary to make the program so it can generate
multiple customized executables. I have not tried the C Windows API
yet. I like programming in both C and C# a lot, and did not find C#
difficult to use, but am concerned with some of .NET downsides I have
observed. The tests below are on Windows 2000, Pentium III, Seagate
7200.7 hard disk, 256 MB RAM.

Problems I found with C#/.NET that make me consider using C API:

** 1) Starts slow. Startup times (secs) on my PC:

Vitalnet .NET first time (not using ngen) = 11
Vitalnet .NET second time (not using ngen) = 5
Vitalnet .NET first time (using ngen) = 9
Vitalnet .NET second time (using ngen) = 4
Microsoft Word = 2
Vitalnet Curses = 1

** 2) Uses lots of memory. RAM used (MB) on my PC:

Vitalnet .NET = 20 (with each invocation)
Microsoft Word = 3
Internet Explorer = 1
Vitalnet Curses = 1

** 3) Runs slower when reading and parsing millions of records. The C
version uses pointers in a critical section of code. I have not really
tried optimizing that section in the .NET app, but it would be harder.
Time (secs) for two different big analyses on my PC:

Vitalnet .NET = 15 + 27 = 42
Vitalnet Curses = 14 + 16 = 30

** 4) Seems harder to install. Because .NET framework might need to be
installed. Installing to a laptop (with legal software), got various
messages from Microsoft that I think might confuse users. On the other
hand, I know the framework is automatically installed if you run
Windows Update.

** 5) Seems less secure from reverse engineering. I know it''s usually
easier to just start from scratch rather than steal someone''s code, but
you never know. I obfuscate function and variable names.

** 6) More difficult to maintain (in this particular case). The app has
over 1000 existing business logic C functions, plus many data
structures written in C. This is necessary to support the web-based
versions of Vitalnet, so I don''t want to totally switch to C# (or
java). Using CPP macros, I incorporated the C business logic functions
into C#/.NET. I think it''s OK to read, but it certainly is different
and non-standard. Maybe better to just use C.

I had the notion that programming the C API is a big pain in the neck.
But I''ve never tried it, so don''t know. Some things that are easy in
C#/.NET, I have no idea if will be easy using C API. For example, embed
a browser within a tabbed page using the C API. Or, set up complex tree
views with many events. Or, do flowlayout. I''m not that interested in
the managed code and garbage collection benefits: I think I can handle
pointers and malloc/free fine, unless I''m missing something about the C
API. Also, code brevity by itself is of little benefit to me. I''m more
concerned about difficulty of programming the user interface, and
having to do a lot of error-prone low level details by hand.

I know Microsoft wants developers to use .NET for new apps. I don''t
know how many widely used commercial desktop apps for C#/.NET have been
developed. I''m also looking into making the web version more
interactive, using AJAX. I''m not interested in MFC/C++ (already using
C, don''t like C++, and MFC sounds more complex). I''m not interested in
Basic. I like Java, but it lacks some capabilities I need related to
structures and passing arguments. I already know what books and other
resources to use to learn the C API, if I decide to switch.

*********** End background / war story

So, you programmers who have tried both, how much harder is it to use
the Windows C API than C#/.NET for writing a desktop application,
assuming the programmer is coding into an editor? Or any other
comments.

Daniel Goldman

解决方案

Hi!

So, you programmers who have tried both, how much harder is it to use
the Windows C API than C#/.NET for writing a desktop application,
assuming the programmer is coding into an editor? Or any other
comments.

The Golden Section for W32 Desktop App development is
Borland Delphi 2006. If you complement it with our library,
for your type of application you can achieve fast results very fast:

www.dewresearch.com

Delphi has the productivity of C# and speed of C. And some
things you cant do in C# or C++ (for science and engineering):

http://www.dewresearch.com/Delphi2006Demo.html

(but click on the link only if you have a fast internet).

Best Regards!
Atmapuri



Atmapuri wrote:

Hi!

So, you programmers who have tried both, how much harder is it to use
the Windows C API than C#/.NET for writing a desktop application,
assuming the programmer is coding into an editor? Or any other
comments.


The Golden Section for W32 Desktop App development is
Borland Delphi 2006. If you complement it with our library,
for your type of application you can achieve fast results very fast:

www.dewresearch.com

Delphi has the productivity of C# and speed of C. And some
things you cant do in C# or C++ (for science and engineering):

http://www.dewresearch.com/Delphi2006Demo.html

(but click on the link only if you have a fast internet).

Best Regards!
Atmapuri

I thought I had ruled out the Delphi programming language, because of
my need to incorporate large amounts of existing C code and header
files (reason #6 in my original post), but I''ll take another look. If
it looks like a possibility, I''ll make a separate post.

Back to my original question: I''m interested in getting feedback, based
on experience, how much harder is it to use the Windows C API than
C#/.NET for writing a desktop application, assuming the programmer is
coding into an editor.

Daniel


On 03/09/2006 in message
<11**********************@74g2000cwt.googlegroups. comdan wrote:

>Back to my original question: I''m interested in getting feedback, based
on experience, how much harder is it to use the Windows C API than
C#/.NET for writing a desktop application, assuming the programmer is
coding into an editor.

I''ve always used the IDE rather than an editor. I would put C# alongside
VB6 for ease of programming, it is very quick indeed to put an app
together. I like C and the API but it takes longer (in my experience) to
put an app together. If you plan to do ''serious'' programming you will need
to use the API in C# anyway, great chunks of it are missing from C#, it''s
its biggest weakness in my view. There is a lot of help now though as
experience has built up in the community. MS really need to accept the
need for this and issue a proper API library. Also missing is the #include
statement - if you write, say, a control using several files you need to
manually link each one to your project each time you use them - an
absolute pain!

A C app using the API will start a lot quicker and can be compiled to work
stand-alone. Delphi is still ahead in terms of compiling a stand-alone app
and speed of starting, I still get tempted to go back to it. There are
also far more free utilities for Delphi, it has always had a great
community spirit. A good example is Mike Lischke''s Virtual TreeView and
VirtualShellTools at MustangPeak - there''s nothing like either in C#
without paying for them. I''m not sure that will change any time soon.

--
Jeff Gaines


这篇关于Windows C API比C#/ .NET困难得多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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