迁移代码库时,下一代低级语言中哪种是最佳选择?

huangapple go评论92阅读模式
英文:

What next generation low level language is the best bet when migrating a code base?

问题

假设你有一家公司正在运行大量的C/C++代码,并且你希望开始计划迁移到新技术,以免像15年前的COBOL公司那样。

目前,C/C++运行得非常好,并且市场上有很多开发人员可以使用。

但是你想现在开始考虑这个问题,因为考虑到庞大的代码库和数据敏感性,你觉得在不过载预算和开发团队的情况下,可能需要5-10年才能迈向下一步。

你听说过D,它开始变得相当成熟,以及Go,它有望变得非常流行。

你会选择哪个,并且为什么?

英文:

Let's say you have a company running a lot of C/C++, and you want to start planning migration to new technologies so you don't end up like COBOL companies 15 years ago.

For now, C/C++ runs more than fine and there is plenty dev on the market for it.

But you want to start thinking about it now, because given the huge running code base and the data sensitivity, you feel it can take 5-10 years to move to the next step without overloading the budget and the dev teams.

You have heard about D, starting to be quite mature, and Go, promising to be quite popular.

What would be your choice and why?

答案1

得分: 40

D和Go可能会变得像Python和Ruby一样受欢迎。它们各自填补了一个市场空缺,尽管D本来应该成为C++的全面替代品,但它可能永远无法获得足够的用户群体来取代C++。更不用说它们两者都不够稳定/成熟,而且不知道在未来10-20年内是否会有对这些语言的支持,以适应当时的硬件和操作系统。考虑到C/C++几乎是编译语言的代表,并且在绝大多数操作系统和本地代码应用程序中使用,它在可预见的未来很不可能消失。

英文:

D and Go will probably just become as popular as Python and Ruby are today. They each fill a niche, and even though D was supposed to be a full-fledged replacement of C++, it probably will never acquire enough mass to push C++ away. Not to mention that they both aren't stable/mature enough, and it's unknown whether you'll have support for these languages in 10-20 years for the then-current hardware and operating systems. Considering that C/C++ is pretty much the compiled language and is used in the great majority of operating systems and native-code applications, it's very unlikely that it'll go away in the foreseeable future.

答案2

得分: 37

C和C++是一对几乎无敌的组合,当涉及到本地/非托管/“低级”语言时。

并不是因为它们是最好的语言,相反,只是因为它们存在,能够完成工作,并且足够好。毫无疑问,例如D在大多数方面都比C++更好。但它在最重要的方面失败了:与所有现有的C++代码的兼容性。如果没有这个要求,大部分代码今天都会用托管语言编写。如今有这么多代码库使用C++的唯一原因是因为他们去年使用了它,而且切换到其他语言会太麻烦。但是,如果他们切换,他们通常不会切换到D。他们会切换到C#、Java或Python。

对于D和其他“新兴”语言来说,竞争相同领域的问题在于,虽然它们更好,但它们并没有足够突破性的特点来激励人们真正切换到它们。

因此,C和C++将继续存在。C不太可能进一步发展。它就是它的样子,它需要填补的一个领域是“简单性,即使对于编译器编写者来说也是如此”。即使他们再也不修订标准,其他语言也不太可能在这个领域击败它。

C++的发展变化更加剧烈,C++0x即将到来,他们已经有了一个巨大的功能列表,计划在此之后实现。C++在任何方面都不是一个死胡同。

这两种语言将继续存在。也许在50年后,其他语言会取代它们,但这不会在本十年内发生。

英文:

C and C++ are a pretty much unbeatable combo when it comes to native/unmanaged/"lowlevel" languages.

Not because they're the best languages, far from it, but because they're there, they do the job, and they're good enough. There's little doubt that D, for example, is better than C++ in most respects. But it fails in the most important one: Compatibility with all the existing C++ code. Without that requirement, most of that code would be written in a managed language today anyway. The only reason so many codebases use C++ today is because they used it last year, and it'd be too much of a pain to switch to something else. But if and when they switch, they typically don't switch to D. They switch to C# or Java or Python.

The problem for D and other "upcoming" languages competing for the same niches, is that while they're better, they're not groundbreaking enough to motivate people to actually switch to them.

So C and C++ are here to stay. C is unlikely to evolve much further. It is as it is, and one of the niches it has to fill is "simplicity, even for compiler writers". No other language is likely to beat it in that niche, even if they never revise the standard again.

C++ is evolving much more dramatically, with C++0x getting nearer, and they've already got a huge list of features they want to do afterwards. C++ isn't a dead end in any way.

Both languages are here to stay. Perhaps in 50 years other languages will have replaced them, but it won't happen this decade.

答案3

得分: 24

我目前经常使用D语言。我不建议那些写生产代码的人使用它,因为它还处于非常前沿的阶段。我能使用它是因为我大部分的代码都是生物信息学的研究原型。然而,这门语言正在开始稳定下来。Andrei Alexandrescu将在明年三月发布一本名为《D编程语言》的书,目前正在努力稳定第二版语言的规范,以配合这本书的发布。

虽然D语言不是C语言的正式超集,但我认为它是一种习惯性的超集,除了没有预处理器之外。换句话说,任何用C语言编写的代码(忽略预处理器)都可以在不重新设计的情况下轻松地转换为D语言,因为D语言中有指针和内联汇编等C语言的概念,并且使用方式与C语言相同。D语言还支持直接链接到C代码,并且D标准库包含了整个C标准库。

此外,尽管D语言缺乏库,因为它仍然是一门非常前沿的语言,但由于其元编程能力,它对于库的编写者来说是一个梦想。如果它开始流行起来,它可能会有一些非常令人印象深刻的库。想要预览一下的话,可以看看D2标准库(Phobos)中的std.range或std.algorithm。另外,我在D语言中实现了一个类似OpenMP的并行模型(并行foreach、并行map、并行reduce、futures),作为一个纯库,没有任何特殊的编译器支持。(参见http://cis.jhu.edu/~dsimcha/parallelFuture.html)

考虑到你主要关注长期发展,我建议给D语言六个月的时间来稳定下来(考虑到Andrei的书和目前稳定语言的努力,第二版应该会稳定下来),然后认真考虑一下它。

编辑:现在核心语言规范相对稳定,重点已转向工具链和库的开发,我推荐D语言用于小型生产项目,除非你处于一个非常风险厌恶的环境中。然而,那些绝对需要良好的工具链和库支持的大型项目仍然需要等待。

英文:

I currently use D regularly. I wouldn't recommend it yet for people writing production code because it's too bleeding edge. I get away with it because most of my code is research prototypes in bioinformatics. However, the language is starting to stabilize. Andrei Alexandrescu is releasing a book titled "The D Programming Language" next March, and right now there is a push to stabilize the spec for version 2 of the language in time for the book.

While D is not a formal superset of C, it is what I'd call an idiomatic superset except for the lack of a preprocessor. In other words, any code written in C proper (ignoring the preprocessor), can be trivially translated to D without a redesign, because C concepts like pointers and inline ASM are there and work the same in D as in C. D also supports direct linking to C code and the D standard library includes the entire C standard library.

Also, despite D's lack of libraries because it is still a bleeding edge language, it's a library writer's dream because of its metaprogramming capabilities. If it takes off, it will probably have some pretty impressive libs. For a preview of this, see std.range or std.algorithm in the D2 standard library (Phobos). As another example, I implemented an OpenMP-like parallelism model (parallel foreach, parallel map, parallel reduce, futures) as a pure library in D, without any special compiler support. (See http://cis.jhu.edu/~dsimcha/parallelFuture.html)

Given that you're mostly interested in the long term, I'd say give D 6 months to stabilize (given Andrei's book and the current push to stabilize the language, version 2 should be stable by then) and then take a hard look at it.

Edit: Now that the core language spec is relatively stable and the focus has turned to toolchain and library development, I would recommend D for small production projects unless you are in a very risk-averse environment. Larger projects that absolutely must have good toolchain and library support should still wait, though.

答案4

得分: 15

如果你相信精益生产原则,你应该努力“尽量晚做决策”。这个时刻应该是最后一个负责的时刻,意味着在这个时刻不做决策将消除一个重要的选择。

我认为这个原则可以应用到你的情况上。不要现在就决定使用一种语言(你甚至不知道它是否会在10年后存在),你应该保持选择的开放性。也许重构一些代码,使其更加通用或建立在更多的抽象之上,这样当确实需要迁移时,过程会更容易一些。

英文:

If you believe in the lean manufacturing principles, you should strive to "decide as late as possible". The moment should be the last responsible moment, meaning the moment at which failing to make a decision eliminates an important alternative.

I think this principle can be applied to your situation. Instead of committing now to a language (that you don't even know will be around in 10 years), you should keep your options open. Maybe refactor some of your code so it is a bit more generic or is built on more abstractions, so that when it is indeed required to migrate, the process will be easier.

答案5

得分: 14

坚持使用C和C++。我认为它不会像COBOL那样被淘汰,它的运行效果与其他任何语言一样好,而且你不会有任何问题找到会编写C和C++代码的人。

英文:

Stick with C and C++. I don't see it going the way of COBOL, it runs as well as anything, and you'll have no problem finding people to code in C and C++.

答案6

得分: 14

C++ -- 它相对年轻且更新... 它有很多编译器供应商,并且一直在改进。

C -- 它将长期存在,填补汇编语言和高级语言之间的差距。它也是非常简单和易于实现的语言,因此它将保持作为各种“奇怪”架构(如嵌入式或全新的架构)的第一语言。

D 很有前途,但规范和库仍然非常新且不稳定。

Go 几周前诞生... 不要在重要的大型项目中使用版本为0的任何东西。而且它比 C++D 有很多限制。

英文:

C++ -- it is relatively young and updated... It has a big number of compiler vendors and got
improved all the time.

C -- it would live for a long time filling the gap between assembler and higher level languages. It is also very simple and easy to implement language, so it would remain the
first language for various "strange" architectures like embedded or extremely new ones.

D is promising but still very new and unstable specifications and libraries.

Go was born few weeks ago... Never use anything of version 0 for big important projects. Also it is significantly more limited the C++ or D.

答案7

得分: 10

2019更新: C++将在未来10年内继续存在...(如果不是这样,当这个答案不再相关时,我会更正它....)

公司今天使用COBOL的原因是因为他们已经有数百万行的COBOL代码编写。如果他们可以抛弃它,他们会立即这样做,另一方面,公司使用C/C++作为他们的需求的一部分,并且使用这种语言进行新项目,因为他们不能/不想使用Java/C#或其他基于框架的语言 - 所以COBOL在这里不是类比。

英文:

2019 update: C++ will stay around for the next 10 years... (if not, I will correct this answer, when it will not be relevant any more....)

the reason companies works with COBOL today is b/c they already have millions of COBOL code written. if the could throw it - they will do it at once, on the other hand - companies work with C/C++ as part of their needs and new projects using this language b/c they can't / don't want to use java/c# any other framework based language - so COBOL is not the analogy here.

答案8

得分: 7

像dsimcha所说,D语言目前存在风险。然而,这门语言有着巨大的潜力,它是低级别的,我在使用D语言时体验到了与C++相比大幅提高的生产力。也许这就是人们对动态语言的感受。

Go语言在博客上宣传得太多了,对我来说有点像个笑话。调度接口方法并不简单,而且实际上比调度常规的单继承方法要慢。

如果你有一个庞大的代码库,决策当然更加困难,我建议只在新项目中进行切换,而不是现有项目。

英文:

Like dsimcha said the D way is currently risky. Yet the language has a huge potential, it is low-level and i've experienced drastically better productivity with D (instead of C++). Perhaps what people feel with dynamic languages.

Go is so much blog-marketed it seems like a joke to me.
Dispatching an interface method is not trivial, and actually slower than dispatching a regular single-inheritance method.

If you'd have a huge codebase the decision is of course more difficult, I would advise only to switch for new projects, not for existing ones.

答案9

得分: 6

我不会专注于一种语言,而是更关注围绕它的库。C++与boost库的结合是一个很好的选择。开发C++的人往往对计算机有更好的理解,我自己最初使用Java,它通过隐藏很多基础知识使我的生活变得更轻松,这是好的,但是只有当我学会了C/C++(指针等)之后,我才真正开始理解编程。

我承认C++可能很难(例如内存管理),所以我认为有一个“附加”语言,在性能不是必要的情况下,可读性(==可维护性)很高:我推荐使用Python。

英文:

I wouldn't concentrate on a language but more on the libraries surrounding it. C++ in combination with the boost libraries are an excellent choice. People who develop in C++ tend to have a better understanding of computing, I myself started of with Java which made my life easier by hiding a lot of fundamental stuff, which is good, however I only really started to understand programming once I learned C/C++ (pointers etc).

I do recognise that C++ can be hard (e.g. memory management) so I think it's good to have a 'add on' language where performance is not essential and readability (==maintainability) scores high: I recommend Python for this.

答案10

得分: 3

有无数台运行C++软件的机器,我没有看到它们一次性全部关闭。如果C++会像COBOL一样走向衰落,那么应用程序迁移市场将会很大。届时将会开发专门的工具,将C++应用程序翻译成当时流行的语言(Z++ ???)。

所以我想最好的建议是等到真正面临这个问题时再解决。

英文:

There are countless machines running C++ software, I don't see them shutting down all at once. If C++ will go in the way of COBOL there will be a huge market for application migration. There will be specialized tools developed to translate C++ applications to the popular language of the time (Z++ ???).

So I guess the best advice is to cross that bridge when you come to it.

答案11

得分: 2

如果你想激发对C++/多核开发的兴趣,请查看Intel® Cilk++软件开发工具包。我认为C或C++也不会很快消失。

英文:

Check out Intel® Cilk++ Software Development Kit if you want to spark your interest in C++/Multi-Core development. I don't see C or C++ going away anytime soon either.

答案12

得分: 1

将C*与Cobol进行比较是值得怀疑的

将C*与Cobol进行比较可能会得出错误的结论。C语言在当时是完美的,是一个巨大的进步,而且至今仍然能够完成工作。

在我最慈善的一天里,我会用“不错的尝试”来总结Cobol。

C和C++将会长期存在,因为它们非常适合作为实现语言。这个情况不会真正改变。

此外,需要考虑的主要负面问题是C/C++缺乏内存安全性。随着代码的成熟,这个问题会越来越少。这意味着没有真正的理由去替换旧代码。

我预计软件系统将从C语言向外扩展。看看今天的层次结构:

  • 使用Rails等框架编写的应用程序
  • 使用Ruby、PHP、Python、C#等编写的应用程序后端
  • Ruby、PHP、Python或C#的运行时实现(使用C*编写)
  • 操作系统内核(使用C89编写)

我认为旧的层次结构不会消失,我认为使用C和C++编写的遗留高层次将会在无限期内以这种方式得到支持,最终被用Ruby、Python、C#或未来的开发替代。

英文:

Comparing C* to Cobol is questionable

Comparing C* to Cobol may lead to the wrong conclusion. C was perfect for its day, a huge leap forward on its introduction, and it still gets the job done today.

I would sum up Cobol on my most charitable day with "nice try".

C and C++ will survive for a long time because they fit the bill well as implementation languages. This won't ever really change.

Also, consider that the main negative issue with C/C++ is the lack of memory safety. This tends to be less and less of a problem as codes mature. This means there will not be a serious reason to replace the old codes.

I expect that software systems will grow outwards from C. Look at the hierarchy today:

  • application written in a framework such as Rails
  • application back-end written in Ruby, PHP, Python, C#, whatever
  • Ruby, PHP, Python, or C# run-time implementation (written in C*)
  • OS kernel (written in C89)

I don't think the old layers will vanish, and I think legacy higher layers written in C and C++ will simply be supported that way for an indefinite period of time, eventually being phased out for their replacements written in Ruby, Python, C#, or a future development.

答案13

得分: 0

我们不知道Go语言是否会被接受。仅仅因为它是由Google开发的可能还不够。

D语言呢?虽然有些好的评价,但也不会有很大的发展。几乎没有用户基础。D语言在TIOBE指数上排名第20,并且正在迅速下降。

你可能会说,一个语言的流行程度与它是否适合公司的工作关系不大。但它与能否找到有资质的人来编程有很大关系。

Java目前排名第一,我会很惊讶如果它在未来20年内不再流行。虽然它不被认为是一种系统编程语言,但它的性能足够好,几乎没有C++中不能完成的任务。现在没有人愿意让人工程序员来完成垃圾回收器可以完美且更有效地完成的工作。对我来说,Java相比C++在编程效率方面是一个重要的进步。

我对Ruby印象深刻。它是一种优雅、表达力强的语言:你可以用很少的代码完成很多工作,而且代码大部分都很易读。Ruby的一个主要原则是保持一致性,不给开发者带来意外。这是一个非常好的想法,可以提高生产力。在大规模使用Rails的时候,我对Ruby保持了一定的距离,因为它的参考实现速度非常慢。然而,Sun的JRuby团队已经在JVM上使其运行速度飞快,所以现在它绝对值得考虑。Ruby提供了闭包和一些函数式编程的能力(下面会解释为什么这很重要),虽然它并不被认为是一种函数式编程语言。TIOBE指数:10且上升。

未来需要考虑的一点是,CPU制造商已经受到物理性能限制的限制。不再像过去每年圣诞节都有30%更快的CPU可用。所以现在要获得更高的性能,就需要更多的核心。软件开发需要尽可能多的帮助来支持多核并发编程。C++在这方面基本上让你自己解决,而Java的解决方案在现代标准下是可怕的。

鉴于此,有一种趋势是朝向函数式编程(消除了与并发相关的许多麻烦)以及具有更好并发支持的语言。Erlang就是为此而编写的,也是为了能够在运行中交换代码(Ericsson想要令人难以置信的运行时间)。Scala与Java类似,但对函数式编程和并发支持更强。Clojure也是如此,但它是一种Lisp语言,目前甚至还没有进入前50名(但未来可能会有)。

Scala是由学术界开发的,而且表现出来:它对数据类型非常复杂和严谨;它试图成为编程语言的瑞士军刀。我相信很多中等智商的程序员会对Scala感到困惑。Ruby不太注重函数式编程,也没有太多关于并发的处理,但它是实用的,而且很容易上手。此外,由于它在JVM上运行,可以轻松地与Java库进行交互。所以:

我会押注于Ruby,而Scala有一定的机会。但还有很多其他选择!

英文:

We have no idea if Go will find acceptance. Just being by Google is probably not going to be enough.

D? Well, some nice things are being said about it but it won't be taking off either. No user base to speak of. D is #20 in popularity on the <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html">TIOBE Index</a>, and dropping fast.

You may say that a language's popularity has little to do with how well it's suited for your company's work. But it has a lot to do with how easy it will be to find people qualified to program in it.

Java is on top and I would be surprised if it went far away in the next 20 years. It's not considered a systems programming language but performs well enough that there are few tasks you'd do in C++ that you couldn't in Java. Certainly these days nobody is willing to task human programmers with the job done (flawlessly and often more effectively) by the garbage collector. I for one considered Java a significant step up from C++ in terms of programming effectivity.

I'm quite impressed by Ruby. It's an elegant, expressive language: You can accomplish a lot with not too much code, yet that code is still mostly legible. One of Ruby's main principles is to be consistent and not hold surprises for the developer. This is an extremely good idea, IMO, and boosts productivity. At the time of the big Rails hype (which may still be ongoing), I made a wide berth around Ruby because its reference implementation is abysmally slow. However, the JRuby folks at Sun have made it blazingly fast on a JVM, so now it's definitely worth some consideration. Ruby provides closures and a good handful of functional programming capabilities (see below for why this important), though it's not really considered a FP language. TIOBE index: 10 and rising.

Something to consider for the future is the fact that CPU makers have run up against a performance limit imposed by physics. No longer is there a 30% faster CPU available every Christmas, as it was in the past. So now to get more performance you need more cores. Software development will need all the help it can get in supporting multi-core concurrent programming. C++ leaves you mostly alone with this, and Java's solutions are horrible by modern standards.

In view of this, there's a certain trend toward functional programming (which eliminates much of the hassle associated with concurrency) as well as languages with better concurrency support. Erlang was written specifically for this and for the ability to swap code in a running program (Ericsson wanted incredible uptimes). Scala is similar to Java but with much stronger support for functional programming and concurrency. Clojure, ditto, but it's a Lisp and it's not even in the top 50 (yet!!).

Scala was developed academics, and shows it: It's sophisticated and downright pedantic about data types; it tries to be the Swiss Army Knife of programming languages. I believe a lot of medium-smart programmers will have trouble getting a grip on Scala. Ruby is less FP and doesn't do so much about concurrency, but it's pragmatic, and fun and easy to get stuff done in. Also, running on the JVM, there is an enormous amount of code readily available in Java libraries, which Ruby can interface with. So:

My bet would be on Ruby, with an outside chance on Scala. But there are plenty of alternatives!

答案14

得分: -7

Java。对于大多数低级别的事情,现在的Java已经足够好了。为什么要选择像D或Go这样的C/C++的部分解决方案,当你可以选择像Java一样安全且易于开发的东西呢?如果你正在寻找实时解决方案,D和Go绝对不是,更不用说它们可能比Java支持得还要少了。


Java现在已经是一种系统编程语言。我不明白你怎么能认为带有不安全构造(如指针)的任何东西都是“下一代”的。这些不安全的构造之所以存在,只是因为它是构建图灵完备语言的实用方法。他们并不关心将内存表示为离散对象,只是想构建一个“能用”的东西。Java已经有了硬实时和软实时的应用程序,各种硬件字节码处理器,以及超过20亿台运行Java的移动设备。最多你只需要添加一些与设备互操作的构造,这不会是太多的代码;即使在C/C++中,你仍然需要添加这些构造...

你在编写什么程序?1KB RAM的8位微控制器吗?在这种情况下,使用除了该平台的汇编语言之外的任何东西都是没有意义的...

英文:

Java. For most low level things Java is fine these days. Why go with a partial solution to C/C++ such as D or Go when you can have something as safe and easy to develop with as Java? If you are looking for a real time solution, D and Go are definitely not it, not to mention they are probably even less supported than Java.


Java is now a system programming language. I don't see how you can consider anything with unsafe constructs such as pointers "next gen". The only reason those insecure constructs ever existed is because it was the pragmatic approach to building a turing complete language. There was no concern of representing the memory in discrete objects, because they just wanted to build something that worked. There are already hard and soft realtime applications in Java, a variety of hardware bytecode processors, and over 2 billion mobile devices running Java. At most all you would have to do is add some constructs for interoperability with devices, which wouldn't be that much code; even in C/C++ you'd still have to add these constructs...

What are you programming? 8-bit microcontrollers with 1KB ram? In that case, it would be pointless to use anything other than the assembler for that platform...

huangapple
  • 本文由 发表于 2009年11月29日 22:02:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/1815613.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定