c代码可重用性 [英] c code reusability

查看:71
本文介绍了c代码可重用性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个疑问......为什么重复使用同一种语言(当然不仅仅是c)和同一编译器下使用

开发的软件是如此困难?

似乎语言本身不足以构建一个非平凡的

系统。这是正确的吗?我是否应该考虑使用其他资产作为包装

系统,组件模型等......来构建复杂的东西?做了这个

资产是否存在没有成本且没有操作系统依赖?是否同意

在开源编程社区中使用它们?


如果答案是:


1.- C语言(或gcc编译器)是不够的。一个开放的,便携的和广泛使用的组件模型对于非平凡的系统是必要的。

2.-在开源世界中没有这样的模型

我的问题是:


我们还在等什么?


谢谢...

I have a doubt... why is so dificult to reuse software developed under
the same language (not only c of course) and under the same compiler?.
It seems the language itself is not enough to build a non trivial
system. Is this right? should I think in use other assets as package
systems, component models etc... to build something complex? did this
assets exist with no cost and no OS dependence? is there an agree on
the use of them in the open source programming comunity?

if the answers are:

1.- C language (or gcc compiler) is not enough. An open, portable and
widely used component model is necesary for non trivial systems
2.- There''s no such a model in the open source world

my question is:

what are we waiting for?

thanks...

推荐答案



mister catering写道:

mister catering wrote:

我有一个疑问......为什么重复使用同一种语言(当然不仅仅是c)和同一编译器下使用开发的软件是如此困难?
I have a doubt... why is so dificult to reuse software developed under
the same language (not only c of course) and under the same compiler?.



好​​问题。这个概念很好,但却充满了陷阱。


很难用如此普遍的方式编写代码,以至于它可以广泛使用

采用和改编。


即使使用包含模板和抽象的编译器,使用固定代码通常也很麻烦。通常代码执行97%的工作,但要获得所需的最后3%需要深入了解

源代码,此时它就是滑坡,\\ ... ...你开始看到

你可以转储代码页面,或插入一个更好的算法,

或使所有字符串可以本地化,以及在你知道它之前,有几乎没有剩下的原始代码。


....或者固定代码可能做出过时的假设,比如记忆是昂贵的,或者它与其他一些你想要拖入的b
/ b的其他包装有关。

理想情况下,我们将使用

一些元语言键入所有Knuth和CACM算法,并且编译器可以生成来自
$ b的代码$ b将元语言转换成我们想要的任何语言。但是我们还没有那么多b $ b。


Good question. The concept is a good one, but fraught with pitfalls.

It''s hard to write code in such a general fashion that it can be widely
adopted and adapted.

Even with compilers that embrace templates and abstraction, it''s often
too cumbersome to use canned code. All too often the code does 97% of
the job, but to get the needed last 3% requires digging into the
source code, at which point it''s a slippery slope,\... you start seeing
places where you can dump pages of code, or insert a better algorithm,
or make all the strings localizable, and before you know it, there''s
almost none of the original code left.

.... or the canned code may make outdated assumptions, like memory is
expensive, or it''s tied to some other package that you really don''t
want to drag in.

Ideally we''d have all of Knuth''s and CACM algorithms typed in using
some meta-language, and have compilers that could generate code from
the meta-language into whatever language we wanted. But we''re not
there yet.


先生餐饮说:
mister catering said:

我有一个疑问......为什么难以重复使用同一种语言(当然不仅仅是c)和同一编译器下的

开发的软件?
I have a doubt... why is so dificult to reuse software developed under
the same language (not only c of course) and under the same compiler?.



不是。只需将想要重复使用的内容推送到自己的库中。

将公共接口(原型,任何需要的类型和宏定义,

等)推入标题。包括标题,链接库,你就完成了。

这比火箭科学更容易。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)

It''s not. Just shove the stuff you want to re-use into its own library.
Shove the public interface (prototypes, any needed type and macro defs,
etc) into a header. Include the header, link the library, and you''re done.
This is even easier than rocket science.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


Richard Heathfield< in **** *@invalid.invalidwrites:
Richard Heathfield <in*****@invalid.invalidwrites:

先生餐饮说:
mister catering said:

>我有疑问..为什么如此难以重复使用相同语言(当然不仅仅是c)和同一编译器下开发的软件?
>I have a doubt... why is so dificult to reuse software developed under
the same language (not only c of course) and under the same compiler?.



不是。只需将想要重复使用的内容推送到自己的库中。

将公共接口(原型,任何需要的类型和宏定义,

等)推入标题。包括标题,链接库,你就完成了。


It''s not. Just shove the stuff you want to re-use into its own library.
Shove the public interface (prototypes, any needed type and macro defs,
etc) into a header. Include the header, link the library, and you''re done.



应用程序代码通常不会如此容易地成为一个好的库,

。根据我的经验。应用程序和库通常有不同的假设。

Application code doesn''t usually make a good library so easily,
in my experience. An application and a library often have
different assumptions.


这比火箭科学更容易。
This is even easier than rocket science.



着名的遗言...

-

Ben Pfaff

电子邮件: bl*@cs.stanford.edu

web: http://benpfaff.org


这篇关于c代码可重用性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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