什么高级语言最像c?

发布于 2024-09-07 02:34:25 字数 114 浏览 2 评论 0原文

我一直在学习 C:它是一门美丽的、经过深思熟虑的语言。然而,它的级别太低,以至于编写任何类型的大型项目都会变得乏味。

哪种高级语言具有最类似于 C 的语法,但没有 C++ 等语言中的所有混乱。有吗?

I've been learning C: it's a beautiful, well-thought-out language. However, it is so low-level that writing any sort of major project becomes tedious.

What higher-level language has the most C-like syntax—but without all the clutter that you find in something like C++. Does one exist?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

月亮邮递员 2024-09-14 02:34:26

D 编程语言试图成为 C++ 应该成为的样子(根本不是抨击 C++,它是我的主要语言),我在网站上引用了一句话:“D 是一种系统编程语言。它的重点是将功能与功能结合起来。” C 和 C++ 的高性能以及 Ruby 和 Python 等现代语言的程序员生产力特别关注质量保证、文档、管理、可移植性和可靠性的需求。”与 A 相比,D 的问题是相对较新。许多语言,但幸运的是它仍然可以使用 C 库,这允许它访问大量预先存在的代码库。当然值得一看。

Java 是另一种选择,但它明显比 C 慢。语法上它非常相似,并且为编写代码提供了一个很好的面向对象的环境。大多数人还认为它是比 C 和 C++ 更安全的语言。在企业中得到广泛应用。

Python 虽然在语法上与 C 不同,但它是一种非常流行的高级面向对象编程语言,并且可以导入 C 模块,这在以后可能非常有用。

The D programming language is an attempt to be what C++ should have been (not bashing on C++ at all it is my primary language) and I quote from the website, "D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of quality assurance, documentation, management, portability and reliability. " The issue with D is it is relatively new compared to a lot of languages but luckily it can still use C libraries which allows it to access a large pre-existing code base. Certainly worth checking out.

Java is another option however it is notably slower than C. Syntactically it is very similar and offers a nice object orientated environment for writing code. It is also considered by most to be a safer language than C and C++. It is widely used in enterprise.

Python while syntactically not like C is a high level Object Orientated Programming Language that is very popular and can import C modules which may be very useful down the track.

感性不性感 2024-09-14 02:34:26

这是一个太宽泛的问题,最好制作社区维基。

然而,在我看来,C 的主要特点是它的紧凑性。整个语言可以用 K&R 这样的小书来描述。人们可以毫不费力地记住所有语法细节(因为语法细节太少了),并且它不会试图保护用户免受自身侵害。

像 C++ 这样的语言更加巴洛克式。记住所有规则和例外是相当困难的。我对 Perl 和 Ruby 也有同样的感觉。有很多事情需要记住,也有很多事情需要注意。

我对 Python 也有同样的紧凑感(尽管可能不如 C)。几乎没有“特殊语法”,所有库和模块都以类似的方式操作。

这(可能像对此问题的大多数其他评论一样)是个人评价,绝不是最终决定。

This is too broad a question and is best made Community wiki.

However, in my mind, the main distinguishing feature of C is it's compactness. The whole language can be described in a small book like K&R. One can remember all the syntactic details without much effort (since there are so few of them) and it doesn't try to protect it's users from themselves.

Languages like C++ are much more baroque. It's quite hard to remember all the rules and exceptions. I feel the same way about Perl and Ruby. There are lots of things to remember and lots of things to watch out for.

I feel the same sense of compactness with Python (although perhaps not as much as C). There's very little "special syntax" and all libraries and modules are operated upon in a similar fashion.

This (probably like most other comments on this question) is a personal evaluation and is by no means a final word.

↙温凉少女 2024-09-14 02:34:26

可能是 Java 和 C#...我认为 Java 多一些。

问题不在于语言,而在于库。尝试一下 Qt (http://qt.nokia.com/)。它是针对 C++ 的,我知道您说的是 C,但我只是指出一点,您会发现自己编写的代码与使用 Java 或 C# 编写的应用程序一样少(甚至可能更少!)。另外,它们是本机且跨平台的。

关于图书馆的一切。

Probably Java and C#... Java a little more so I think.

And it's not the language - it's all about the libraries. Try out Qt (http://qt.nokia.com/). It's for C++ and I know you said C but I'm just making a point that you'll find yourself writing just as little (and perhaps even less!) code than you'd write for applications in Java or C#. Plus they're native and cross-platform.

All about the libraries.

新一帅帅 2024-09-14 02:34:26

我一直在学习 C:它是一门美丽的、经过深思熟虑的语言。然而,它的级别太低,以至于编写任何类型的大型项目都会变得乏味。

有人会说,第二句话证明了第一句话的断言是错误的。

另一点是,这几乎是无法回答的。什么是“高级”语言?你的“亲密”标准是什么?语法、计算模型、性能?您想用这种假设的语言构建什么类型的应用程序?

如果您只想将自己局限于“看起来像”C 的语言,为什么呢?作为一个已经记不清自己使用过多少种编程语言的人,我可以告诉你,编程语言语法的差异通常并不重要。只要时间允许,您几乎可以习惯任何语法。

I've been learning C: it's a beautiful, well-thought-out language. However, it is so low-level that writing any sort of major project becomes tedious.

Some people would say that the second sentence proves that the assertion of the first sentence is false.

Another point is that this is pretty much unanswerable. What is a "high level" language? what are your criteria for "closeness"? Syntax, computational model, performance? And what kind of applications are you wanting to build with this hypothetical language?

And if you just want to confine yourself to languages that "look like" C, why? As someone who has lost count of the number of programming languages he has used, I can tell you that differences in programming language syntax are generally pretty unimportant. You can get used to pretty much any syntax, given time.

旧梦荧光笔 2024-09-14 02:34:26

这个基本指令比较可以让您很好地了解哪些语言彼此相似。

我想说,除了 $variables 之外,PHP 最像 C,如果你能区分 php 语言和 php 平台的话。 Java 在某些方面进行了尝试,但过于强烈的面向对象性,无法与 C 类似。

This comparison of basic instructions gives you a good idea of what languages are similar to each other.

I would say PHP is most like C except for the $variables, if you can distinguish php the language from php the platform. Java tries in some ways, but is too strongly object oriented to be similar to C.

星軌x 2024-09-14 02:34:26

Javascript 具有相当类似 C 的语法,并且它是一种非常流行的语言。 Javascript 有很多怪癖,但它与 C 有一个强大的相似之处——它很简单。完整的 Javascript 规范非常短,而且该语言非常强大且高级。不过,如果能把它的一些丑陋的东西清理干净那就太好了。

Javascript has a reasonably C-like syntax, and it's a very popular language. Javascript has a lot of quirks, but it has one powerful similarity to C - it's simple. The complete Javascript specification is very short, and the language is very powerful and high-level. It would be great to clean it up from some of its ugly cruft, though.

奶茶白久 2024-09-14 02:34:26

我只想指出,Pascal 在语义上(尽管在语法上不太相似)与 C 非常相似,因此有诸如 Object Pascal、Modula 2、Ada 和 Oberon 之类的选项,您将在其中重用大多数非你已经知道的琐碎的部分,琐碎的部分是拼写。

不过,就就业前景而言,坚持使用 C# 或 Java 可能会更好。

编辑

我还要补充一点,关于杂乱问题,重要的是要弄清楚哪些杂乱是重要的。 C 的语言定义中的“混乱”较少,这是事实,但相关的混乱出现在源代码中。考虑以下内容......

//  C
struct mystruct *myvar;
myvar = (struct mystruct *) malloc (sizeof (struct mystruct));
myvar->a = 1;
myvar->b = 2;
myvar->c = 3;
call_something (myvar);
free (myvar);

//  C++
auto_ptr<mystruct> myvar (new myclass (1, 2, 3));
call_something (myvar);

重点是语言定义中的“混乱”是有原因的。通过在编写库时进行一些前期工作,可以避免大量工作(和混乱)。即使您正在编写一个库,您也可以从其他库编写者所做的前期工作中受益。

I'll just point out that Pascal is semantically (though not so much syntactically) very similar to C, so there are options like Object Pascal, Modula 2, Ada and Oberon out there where you will be re-using most of the non-trivial part of what you already know, the trivial part being the spelling.

You're probably better off sticking with C# or Java in terms of job prospects, though.

EDIT

I'll also add that on the clutter issue, it is important to sort out which clutter is important. C has less "clutter" in it's language definition, true, but the relevant clutter is in source code. Consider the following...

//  C
struct mystruct *myvar;
myvar = (struct mystruct *) malloc (sizeof (struct mystruct));
myvar->a = 1;
myvar->b = 2;
myvar->c = 3;
call_something (myvar);
free (myvar);

//  C++
auto_ptr<mystruct> myvar (new myclass (1, 2, 3));
call_something (myvar);

The point is that the "clutter" in the language definition is there for a reason. With a little up-front work when writing libraries, a lot of work (and clutter) is avoided down the line. And even when you're writing a library, you benefit from the up-front work done by other library writers.

亢潮 2024-09-14 02:34:26

ActionScript 3 怎么样?它很像Java。

How about ActionScript 3? It's a lot like Java.

嘿看小鸭子会跑 2024-09-14 02:34:26

我会投票 C#。我不知道你所说的“混乱”是什么意思,但从可用性的角度来看,C# 很好,因为它避免了 C++ 的一些繁琐的事情,比如必须两次“声明”每个类的方法(在头文件,然后在类的实现中本质上复制相同的内容)。放弃头文件在其他方面也很好,比如消除大型项目中的依赖冲突或避免循环引用。在 C# 中,编译器会处理所有这些事情(尽管您仍然需要设置对其他文件或程序集的引用)。

我从事 C# 工作已有 10 年了,但我仍然怀念指针,不管你信不信,在我看来,指针实际上使调试变得更容易!

I'd vote C#. I don't know what you mean by "clutter," but from a usability standpoint, C# is nice because it avoids some of the tedious things of C++, like having to essentially "declare" each of your class's methods twice (prototyping it in the header file, then essentially duplicating the same thing in your class's implementation). Ditching header files was nice in other ways too, like doing away with dependency conflicts in big projects or avoiding circular references. In C#, the compiler takes care of all that (although you still have to set references to other files or assemblies).

I've been doing C# for 10 years and I still miss pointers, which believe it or not, in my opinion, actually made debugging easier!

甜中书 2024-09-14 02:34:26

如果您要经常编程,那么了解彼此明显不同的语言是很有好处的。了解高级脚本语言(如 python 或 ruby​​)特别有用。如果你能像 C 程序员一样思考,那么你应该可以很好地学习这两者中的任何一个。
许多大型项目利用Python或Ruby等高级语言的快速原型设计,同时也利用C/C++等低开销(快速)编译语言。

If you're going to be programming often, it's good to know languages that are explicitly not like each other. It's especially useful to know high level scripting languages like python or ruby. If you can think like a programmer in C you should be fine learning either of these two.
Many big projects take advantage of the rapid prototyping of higher level languages like python or ruby, but also take advantage of low overhead (fast) compiled languages like C/C++.

迟月 2024-09-14 02:34:26

如果您认为 C++ 很混乱,那么您只是不知道如何编写有效的 C++,因为没有人强迫您使用任何可用的高级工具。您可以完全用 C 加上您最喜欢的 C++ 功能(如 AWESOME 标准库)编写 C++ 程序。这就是整洁的定义。 Java/C# 是一种混乱的语言,您必须将每个函数都放在一个类中。那是混乱。

If you think that C++ is cluttered, then you just don't know how to write effective C++, because nobody forces you to use any of the advanced tools available. You could write a C++ program entirely in C plus your favourite C++ feature (like the AWESOME standard library). That's the definition of uncluttered. A cluttered language would be Java/C#, where you HAVE to put every function in a class. That's clutter.

卸妝后依然美 2024-09-14 02:34:25

哪种高级语言具有最类似于 C 的语法,但又不像 C++ 那样混乱?

我要回答一个稍微不同的问题:

什么语言像 C 一样,设计精良、构思精美,像 C 一样适合系统编程,允许人们进行比 C 更高级别的编程,并且相对整洁?

我认为这个问题没有一个正确的答案,但这里有三个值得候选的答案(按字母顺序排列):

  • < a href="http://go-lang.org/" rel="noreferrer">开始。 Go 在设计精良和构思精美方面得分非常高:Rob Pike 是一位大师级设计师,并且已经练习这种特殊工艺 25 年了。其明确的目标是保持整洁并使系统编程“再次变得有趣”。 Go 仍然是一门新语言,Rob 从 Squeak、Newsqueak、Alef 和 Limbo 那里学到了很多东西。因为 Rob 明白,伟大的设计就是没有不必要的部分,所以 Go 干净整洁。它比 C 更高级别的主要功能是类型安全垃圾收集和出色的并发模型

  • Java。 Java 拥有精心设计的核心(请参阅 Jim Waldo 的书 Java:优秀部分) 但不幸的是,任何成熟、成功的语言都会积累混乱。 Java 最适合高级编程的特性是接口垃圾收集异常

这里的共同点是使用垃圾收集来减轻程序员的内存管理负担。这是生产力的重大提升。

这些语言都有很多值得推荐的地方。我自己喜欢小而简单的语言,而且我非常欣赏 Rob Pike 的作品,所以如果我必须为自己选择一种语言,我会选择 Go,尽管它是新的且未经证实的。

What higher-level language has the most C-like syntax—but without all the clutter that you find in something like C++?

I'm going to answer a slightly different question:

What is a language that is like C in that it is well designed and beautifully thought out, is like C in that it is good for systems programming, allows people to program at a higher level than C, and is relatively uncluttered?

I don't think this question has a single right answer, but here are three worthy candidates (in alphabetical order):

  • D. The D language is designed essentially as a better, cleaner C++. Like C++, D is explicitly designed to incorporate a lot of features, but one hopes in a cleaner, more harmonious way than C++. A major difference that enables programmers to work at a higher level is that memory is managed automatically by the language and safety is guaranteed by the compiler (and run-time system) through garbage collection.

  • Go. Go scores very high on being well designed and beautifully thought out: Rob Pike is a master designer and has been practicing this particular craft for 25 years. Its explicit goal is to be uncluttered and to make systems programming "fun again". Go is still a new language, and Rob has learned much from Squeak, Newsqueak, Alef, and Limbo. Because Rob understands that a great design is one with no unnecessary parts, Go is clean and uncluttered. Its primary features that are higher-level than C are type safety, garbage collection, and an excellent concurrency model.

  • Java. Java has a well-designed core (see Jim Waldo's book Java: The Good Parts) but unfortunately suffers from the clutter that any mature, successful language accumulates. The features of Java that make it most suitable for higher-level programming are interfaces, garbage collection, and exceptions.

The common thread here is using garbage collection to relieve the programmer of the burden of memory management. This is a major boost to productivity.

Each of these languages has much to recommend it. My own taste is for languages that are small and simple, and I admire Rob Pike's body of work very highly, so if I had to pick one for myself, it would be Go, despite the fact that it is new and unproven.

寒冷纷飞旳雪 2024-09-14 02:34:25

在 C++ 中,您可以编写 C 代码并使其成功编译为 C++(大多数情况下)。因此,尽管我认为你的术语“混乱”既是贬义的又是含糊的,但你唯一会遇到的混乱是你自己选择写的东西。您可以将 C++ 用作更大的工具包,而无需使用所有工具(如果您愿意,也可以使用杂乱的工具)。

因此,无论您是否喜欢,答案都是 C++。大多数其他类似 C 的语言都添加了 OO 功能,这可能是您认为的混乱,但您不会无缘无故地得到一些东西,并且您需要有语法来支持附加功能。此类语言包括:

  • Java
  • C#
  • Objective-C
  • D

其中 Objective-C 可能是最像 C 的,因为它是 C 的超集,而 C++ 则不完全是。它也是 OSX 和 iPhone/iPod Touch 开发的首选语言,这可能很有吸引力。

Java 无处不在,但最好的描述可能是表面上类似于 C。 C# 的跨平台支持有限,但它是 Windows GUI 开发阻力最小的途径,具有出色的免费开发工具。 C# 还具有比 C++ 更简单但更严格的 OO 实现,因此可能会满足您的要求,但它与 C/C++ 的相似之处可能会产生误导;它与 Java 的工作方式有根本的不同。 D 在某种程度上是一个利基市场,由单一作者开发(尽管是曾经著名的 Zortech/Symantec C++ 编译器的作者)。

考虑到“低级”和“繁琐”,当着手一个“重大项目”时,你很少会从头开始,只有标准库和操作系统API可用,你会使用第三方和内部开发的库来快速开发更高级别的功能。也就是说,OO 方法通常更适合这种“代码重用”方法,当然 C++ 的标准库和第三方库更广泛(尤其是因为它可以使用 C 库以及 C++ 库)。事实上,我建议除了对 OO 的支持之外,使 C++ 更高级别的唯一因素是它通过类作为第一类对象的可扩展性。尽管如此,它仍然适合作为系统级语言。

In C++ you can write C code and have it compile successfully as C++ (mostly). Therefore, although I suggest that your term "clutter" is both derogatory and ambiguous, the only clutter you will have is what you choose to write yourself. You can use C++ as a bigger tool-bag without using all the tools (or clutter if you prefer).

The answer therefore is C++ whether you like it or not. Most other C-like languages add OO features, which is perhaps what you regard as clutter, but you do not get something for nothing and you need to have syntax to support the additional features. Such languages include:

  • Java
  • C#
  • Objective-C
  • D

Of these Objective-C is probably the most C-Like since it is a superset of C in the way that C++ is not quite. It is also the preferred language for OSX and iPhone/iPod Touch development, which may be attractive.

Java is ubiquitous but probably best described as superficially C-like. C# has limited cross-platform support but is the path of least resistance for Windows GUI development with excellent free development tools. C# also has a simpler but more restrictive OO implementation than C++ so may meet your requirements, but its resemblance to C/C++ can be misleading; it is fundamentally different in how it works in a similar manner to Java. D is somewhat of a niche, being developed by a single author (albeit the author of the once renowned Zortech/Symantec C++ compiler).

Regarding it being "low level" and "tedious", when embarking on a "major project", you would seldom start from scratch with only the standard library and OS API available, you would make use of third-party and in-house developed libraries to quickly develop higher level functionality. That said, an OO approach is generally much more amenable to this 'code-reuse' approach, and of course C++'s standard library and third-party libraries are more extensive (not least because it can use C libraries as well as C++ libraries). In fact I would suggest that apart form support for OO, the only thing that makes C++ higher-level is its extensibility via classes as first-class objects. It remains suitable as a systems-level language nonetheless.

煮酒 2024-09-14 02:34:25

Google 的 Go 语言 具有类似的语法(尽管我认为足够不同)和语义,尽管具有垃圾收集、多态性、等等,内置于语言中。

Google's Go language has a similar syntax (though different enough I suppose) and semantics, though with garbage collection, polymorphism, etc., built into the language.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文