如果我已经知道大会,我还应该学习C吗?

时间:2022-09-11 09:22:11

Often one of the main reasons given for learning C is that it brings you closer to programming at a low level which gives you insights into how things really work in higher level languages.

通常,学习C的主要原因之一是它使您更接近低级编程,这使您可以深入了解事物在更高级语言中的工作方式。

I've been programming in various Assembly flavors for awhile and you can't get any lower level than what I have been coding in and I have no illusions about what reference types or pointers really are. It should be pointed out that I also am fairly prolific in Java and C#. I don't only know assembly.

我已经在各种程序集风格中编程了一段时间,你不能得到比我编写的任何更低的级别,我对幻想的参考类型或指针没有任何幻想。应该指出的是,我在Java和C#方面也相当多。我不仅知道装配。

Is it still worth the effort cracking open K&R and spending some valuable time learning the intricacies of the C language or would my time best be served learning something else?

是否仍然值得努力破解开放的K&R并花费一些宝贵的时间来学习C语言的复杂性,或者我的时间最好是学习别的东西?

14 个解决方案

#1


Often one of the main reasons given for learning C is that it brings you closer to programming at a low level

通常,学习C的主要原因之一是它使您更接近低级编程

Well, scratch that one off, look at the others and decide for yourself. If you want to:

好吧,抓住那一个,看看其他人并自己决定。如果你想:

  • remain close to low level but gain portability
  • 保持接近低水平,但获得便携性

  • be able to work with the huge codebase that C has already
  • 能够使用C已经拥有的庞大代码库

  • just learn something new
  • 只是学到新东西

then you might want to learn C.

那么你可能想学习C.

#2


Yes, absolutely. Writing a program of any significant size is very cumbersome in straight assembly, so most applications that are written down-to-the-metal (like hardware drivers) will mostly be in C, or at least C gluing together calls to assembly functions.

是的,一点没错。编写任何大尺寸的程序在直接组装中非常麻烦,因此大多数采用金属写入的应用程序(如硬件驱动程序)大多数都是在C中,或者至少C将调用集合函数粘在一起。

Also, because C has such a close relationship with the machine (that is to say, it is low level), learning C after assembly will be a good stepping stone for understanding what a compiler really does to turn high-level code into machine instructions.

另外,因为C与机器有如此密切的关系(也就是说,它是低级别的),所以在组装后学习C将是理解编译器将高级代码转换为机器指令的真正功能的一个很好的垫脚石。 。

#3


You know assembly and you seem to know C#. It's never a bad thing to learn yet another language but I would only recommend learning C if you are going to need it in the near future. I think you would broaden your knowledge more by learning a dynamic language like Ruby or a functional like Common Lisp.

你知道汇编,你似乎知道C#。学习另一种语言绝不是坏事,但如果你在不久的将来需要它,我只会建议学习C.我认为你可以通过学习像Ruby这样的动态语言或像Common Lisp这样的功能来扩展你的知识。

#4


Absolutely! Learning C will improve your assembler programming as well. As you learn C you will start to transfer the structured method to your assembler programming. I noticed that the more I learn of high level languages the better the organization and understandability of my assemble language programming.

绝对!学习C也将改进你的汇编编程。学习C语言后,您将开始将结构化方法转移到汇编程序编程中。我注意到,我越了解高级语言,我的汇编语言编程的组织和可理解性就越好。

It is very useful to be able to mix C and assembler. Being able to use both in a single project allows you to use the appropriate solution in any given situation within that project. For most tasks C is quicker to code, occasionally the opposite is true, assembly language is quicker. Sometimes the assembly language is better able to express a particular aspect of a solution (assembler's close mapping to the hardware can make programming I/O or device management clearer). For more abstract concepts C can be clearer (C++ can be better again).

能够混合C和汇编程序非常有用。能够在单个项目中使用它们允许您在该项目中的任何给定情况下使用适当的解决方案。对于大多数任务来说,C编码速度更快,有时候情况恰恰相反,汇编语言更快。有时,汇编语言能够更好地表达解决方案的特定方面(汇编程序与硬件的紧密映射可以使编程I / O或设备管理更加清晰)。对于更抽象的概念,C可以更清晰(C ++可以再次更好)。

The same goes for learning C++. I find myself using an object oriented approach to both my C and assembler programming.

学习C ++也是如此。我发现自己使用面向对象的方法来进行C语言和汇编程序编程。

In the end it's horses for courses. Use the appropriate language for the problem at hand.

最后,它是课程的马匹。针对手头的问题使用适当的语言。

#5


I think the most important reason why you should learn any programming language is so that you can put it to some use.

我认为你应该学习任何编程语言的最重要原因是你可以使用它。

If you've learnt Assembly to do something, and you feel you can do something else better in C, then go ahead by all means.

如果你已经学会装配做某事,并且你觉得你可以用C做更好的事情,那么一定要先行。

But if you find that you've got nothing to do in C, then professionally there's no point in learning it.

但如果你发现你在C中无所事事,那么从专业角度来说,学习它是没有意义的。

If however you want to do it as a hobby or a personal endeavor. Then it's your time, do anything you want.

但是,如果您想将其作为业余爱好或个人努力。那是你的时间,做你想做的任何事。

#6


C is portable (if you write it carefully), that is a good reason for me.

C是便携式的(如果你仔细写的话),这对我来说是一个很好的理由。

#7


No one has mentioned....

没人提到......

that C is a route to writing assembler quicker. When I wrote computer games, we wrote everything in C first then re-wrote the parts that took all the time, the old 80-20 rule. 80% of the time is in 20% of the code.

C是更快地编写汇编程序的途径。当我编写电脑游戏时,我们首先在C中编写了所有内容,然后重新编写了所有时间的部分,即旧的80-20规则。 80%的时间是20%的代码。

To do this we compiled the code we wished to re-write and used the dump to assembler file flag. Then we took the C generated assembler file and used that as the basis to write more optimised assembler code. This was far quicker than starting from scratch.

为此,我们编译了我们希望重写的代码并使用dump to assembler file flag。然后我们采用C生成的汇编程序文件,并将其作为编写更优化的汇编程序代码的基础。这比从头开始要快得多。

Today this approach is far harder as the compilers are far better and it is so much harder for humans to improve the compilers code - since processors got so complicated and fast code has become about keeping the caches and pipelines full.

今天这种方法要困难得多,因为编译器要好得多,并且人类更难以改进编译器代码 - 因为处理器变得如此复杂,快速的代码已经变成了保持缓存和管道的完整。

Tony

#8


Learning a new language is always a fun thing to do, especially if it's significantly different, paradigm-wise, from what you already know. So I'd say go for it.

学习一门新语言总是一件有趣的事情,特别是如果它与你已经知道的有很大不同,范式明智。所以我会说去吧。

I found it very interesting that C has still been one of the most sought-after languages on major search engines and book sites.

我发现C非常有趣,C仍然是主要搜索引擎和书籍网站上最受欢迎的语言之一。

#9


Maybe not...but it won't hurt to learn it :) I personally learned x86 assembly before C and my assembly knowledge made it easier for me to grasp C pointers.

也许不是......但是学习它不会有什么害处:)我个人在C之前学习了x86汇编,我的汇编知识让我更容易掌握C指针。

#10


It depends. If you want to work with C++, you surely should also learn C. If you want to code in Python or Perl you don't really need it, as you have an understanding for the internals from Assembler.

这取决于。如果你想使用C ++,你肯定也应该学习C.如果你想用Python或Perl编写代码,你真的不需要它,因为你对Assembler的内部有了解。

One thing: Do you worked in Assembler with pointers and the heap? Understanding pointers and memory-management is very important for every higher language. If you didn't get the idea of pointers and the heap right, you should give C a try.

一件事:你在Assembler中使用指针和堆工作吗?理解指针和内存管理对于每种更高级的语言都非常重要。如果你没有得到指针和堆的想法,你应该尝试C。

#11


I look at it pragmatically - I wouldn't bother unless you feel like you have jobs where performance is more important than programmer productivity. After 12 years of programming, I've never come across a job that should have been written in C, instead of a garbage collected language. But, your situation may vary.

我务实地看待它 - 除非你觉得你的工作表现比程序员的工作效率更重要,否则我不会打扰。经过12年的编程,我从未遇到过应该用C编写的工作,而不是垃圾收集语言。但是,您的情况可能会有所不同

If all you knew was Java, then I would say yeah, it would be great.

如果你所知道的只是Java,那么我会说是的,它会很棒。

#12


I think it depends - do you (or might you in the future) have to deal with a codebase that includes C? There's an awful lot of it out there, so I'm actually surprised that you haven't already had a need to do something with C (at least reading it) given the assembly, C# and Java experience you cite.

我认为这取决于 - 你(或将来可能)你必须处理包含C的代码库吗?那里有很多东西,所以我很惊讶你还没有必要用C做一些事情(至少阅读它),因为你引用了汇编,C#和Java经验。

Also, given that you know the above set of languages and the concepts that go along with them, I'd guess that learning C would be a cakewalk for you.

另外,鉴于您已经了解了上述语言集以及随之而来的概念,我猜想学习C对您来说是一个很好的例子。

#13


YES it is c is like the core of all programming languages almost every language is build based on it and sense you know c# it wont take you much to learn c if you have done a lot of assembly stuff then I guess you may someday if not already work with it I don't think there is a programming job that wants you to know only assembly, C is needed even most low level software like Operating systems use C and Windows uses C++ also so in my opinion you should not even think about it C its like a fundamental knowledge even most of the web developers know C

是的,它就像是所有编程语言的核心,几乎每种语言都是基于它构建的,感觉你知道c#如果你做了大量的装配,你不会花太多时间学习c然后我猜你有一天可能会已经使用它我不认为有一个编程工作要求你只知道汇编,即使是大多数低级软件也需要C,操作系统使用C和Windows也使用C ++,所以在我看来你甚至不应该考虑即使大多数Web开发人员都知道C,它就像一个基本知识

#14


Amazing that in a world of new scripting languages every day there are still people that manage to only know assembler.

令人惊讶的是,在一个新的脚本语言世界中,每天仍然有人只能知道汇编程序。

I myself, after writing perl or javascript for longer periods always find lower level languages like C or C++ kind of lacking, for instance, where in perl I write foreach(@array), in C/C++ I have to fiddle with for loops and indexes and/or iterators.

我自己,在写了更长时间的perl或javascript之后总是找到C或C ++这类缺乏的低级语言,例如,我在perl中编写foreach(@array),在C / C ++中我必须摆弄for循环和索引和/或迭代器。

So, yes, I can only imagine how much you will get from the abstractions C will provide for you.

所以,是的,我只能想象你将从C将为你提供的抽象中获得多少。

Additionally, widening your perspective is always a Good Thing.

此外,拓宽视野总是一件好事。

#1


Often one of the main reasons given for learning C is that it brings you closer to programming at a low level

通常,学习C的主要原因之一是它使您更接近低级编程

Well, scratch that one off, look at the others and decide for yourself. If you want to:

好吧,抓住那一个,看看其他人并自己决定。如果你想:

  • remain close to low level but gain portability
  • 保持接近低水平,但获得便携性

  • be able to work with the huge codebase that C has already
  • 能够使用C已经拥有的庞大代码库

  • just learn something new
  • 只是学到新东西

then you might want to learn C.

那么你可能想学习C.

#2


Yes, absolutely. Writing a program of any significant size is very cumbersome in straight assembly, so most applications that are written down-to-the-metal (like hardware drivers) will mostly be in C, or at least C gluing together calls to assembly functions.

是的,一点没错。编写任何大尺寸的程序在直接组装中非常麻烦,因此大多数采用金属写入的应用程序(如硬件驱动程序)大多数都是在C中,或者至少C将调用集合函数粘在一起。

Also, because C has such a close relationship with the machine (that is to say, it is low level), learning C after assembly will be a good stepping stone for understanding what a compiler really does to turn high-level code into machine instructions.

另外,因为C与机器有如此密切的关系(也就是说,它是低级别的),所以在组装后学习C将是理解编译器将高级代码转换为机器指令的真正功能的一个很好的垫脚石。 。

#3


You know assembly and you seem to know C#. It's never a bad thing to learn yet another language but I would only recommend learning C if you are going to need it in the near future. I think you would broaden your knowledge more by learning a dynamic language like Ruby or a functional like Common Lisp.

你知道汇编,你似乎知道C#。学习另一种语言绝不是坏事,但如果你在不久的将来需要它,我只会建议学习C.我认为你可以通过学习像Ruby这样的动态语言或像Common Lisp这样的功能来扩展你的知识。

#4


Absolutely! Learning C will improve your assembler programming as well. As you learn C you will start to transfer the structured method to your assembler programming. I noticed that the more I learn of high level languages the better the organization and understandability of my assemble language programming.

绝对!学习C也将改进你的汇编编程。学习C语言后,您将开始将结构化方法转移到汇编程序编程中。我注意到,我越了解高级语言,我的汇编语言编程的组织和可理解性就越好。

It is very useful to be able to mix C and assembler. Being able to use both in a single project allows you to use the appropriate solution in any given situation within that project. For most tasks C is quicker to code, occasionally the opposite is true, assembly language is quicker. Sometimes the assembly language is better able to express a particular aspect of a solution (assembler's close mapping to the hardware can make programming I/O or device management clearer). For more abstract concepts C can be clearer (C++ can be better again).

能够混合C和汇编程序非常有用。能够在单个项目中使用它们允许您在该项目中的任何给定情况下使用适当的解决方案。对于大多数任务来说,C编码速度更快,有时候情况恰恰相反,汇编语言更快。有时,汇编语言能够更好地表达解决方案的特定方面(汇编程序与硬件的紧密映射可以使编程I / O或设备管理更加清晰)。对于更抽象的概念,C可以更清晰(C ++可以再次更好)。

The same goes for learning C++. I find myself using an object oriented approach to both my C and assembler programming.

学习C ++也是如此。我发现自己使用面向对象的方法来进行C语言和汇编程序编程。

In the end it's horses for courses. Use the appropriate language for the problem at hand.

最后,它是课程的马匹。针对手头的问题使用适当的语言。

#5


I think the most important reason why you should learn any programming language is so that you can put it to some use.

我认为你应该学习任何编程语言的最重要原因是你可以使用它。

If you've learnt Assembly to do something, and you feel you can do something else better in C, then go ahead by all means.

如果你已经学会装配做某事,并且你觉得你可以用C做更好的事情,那么一定要先行。

But if you find that you've got nothing to do in C, then professionally there's no point in learning it.

但如果你发现你在C中无所事事,那么从专业角度来说,学习它是没有意义的。

If however you want to do it as a hobby or a personal endeavor. Then it's your time, do anything you want.

但是,如果您想将其作为业余爱好或个人努力。那是你的时间,做你想做的任何事。

#6


C is portable (if you write it carefully), that is a good reason for me.

C是便携式的(如果你仔细写的话),这对我来说是一个很好的理由。

#7


No one has mentioned....

没人提到......

that C is a route to writing assembler quicker. When I wrote computer games, we wrote everything in C first then re-wrote the parts that took all the time, the old 80-20 rule. 80% of the time is in 20% of the code.

C是更快地编写汇编程序的途径。当我编写电脑游戏时,我们首先在C中编写了所有内容,然后重新编写了所有时间的部分,即旧的80-20规则。 80%的时间是20%的代码。

To do this we compiled the code we wished to re-write and used the dump to assembler file flag. Then we took the C generated assembler file and used that as the basis to write more optimised assembler code. This was far quicker than starting from scratch.

为此,我们编译了我们希望重写的代码并使用dump to assembler file flag。然后我们采用C生成的汇编程序文件,并将其作为编写更优化的汇编程序代码的基础。这比从头开始要快得多。

Today this approach is far harder as the compilers are far better and it is so much harder for humans to improve the compilers code - since processors got so complicated and fast code has become about keeping the caches and pipelines full.

今天这种方法要困难得多,因为编译器要好得多,并且人类更难以改进编译器代码 - 因为处理器变得如此复杂,快速的代码已经变成了保持缓存和管道的完整。

Tony

#8


Learning a new language is always a fun thing to do, especially if it's significantly different, paradigm-wise, from what you already know. So I'd say go for it.

学习一门新语言总是一件有趣的事情,特别是如果它与你已经知道的有很大不同,范式明智。所以我会说去吧。

I found it very interesting that C has still been one of the most sought-after languages on major search engines and book sites.

我发现C非常有趣,C仍然是主要搜索引擎和书籍网站上最受欢迎的语言之一。

#9


Maybe not...but it won't hurt to learn it :) I personally learned x86 assembly before C and my assembly knowledge made it easier for me to grasp C pointers.

也许不是......但是学习它不会有什么害处:)我个人在C之前学习了x86汇编,我的汇编知识让我更容易掌握C指针。

#10


It depends. If you want to work with C++, you surely should also learn C. If you want to code in Python or Perl you don't really need it, as you have an understanding for the internals from Assembler.

这取决于。如果你想使用C ++,你肯定也应该学习C.如果你想用Python或Perl编写代码,你真的不需要它,因为你对Assembler的内部有了解。

One thing: Do you worked in Assembler with pointers and the heap? Understanding pointers and memory-management is very important for every higher language. If you didn't get the idea of pointers and the heap right, you should give C a try.

一件事:你在Assembler中使用指针和堆工作吗?理解指针和内存管理对于每种更高级的语言都非常重要。如果你没有得到指针和堆的想法,你应该尝试C。

#11


I look at it pragmatically - I wouldn't bother unless you feel like you have jobs where performance is more important than programmer productivity. After 12 years of programming, I've never come across a job that should have been written in C, instead of a garbage collected language. But, your situation may vary.

我务实地看待它 - 除非你觉得你的工作表现比程序员的工作效率更重要,否则我不会打扰。经过12年的编程,我从未遇到过应该用C编写的工作,而不是垃圾收集语言。但是,您的情况可能会有所不同

If all you knew was Java, then I would say yeah, it would be great.

如果你所知道的只是Java,那么我会说是的,它会很棒。

#12


I think it depends - do you (or might you in the future) have to deal with a codebase that includes C? There's an awful lot of it out there, so I'm actually surprised that you haven't already had a need to do something with C (at least reading it) given the assembly, C# and Java experience you cite.

我认为这取决于 - 你(或将来可能)你必须处理包含C的代码库吗?那里有很多东西,所以我很惊讶你还没有必要用C做一些事情(至少阅读它),因为你引用了汇编,C#和Java经验。

Also, given that you know the above set of languages and the concepts that go along with them, I'd guess that learning C would be a cakewalk for you.

另外,鉴于您已经了解了上述语言集以及随之而来的概念,我猜想学习C对您来说是一个很好的例子。

#13


YES it is c is like the core of all programming languages almost every language is build based on it and sense you know c# it wont take you much to learn c if you have done a lot of assembly stuff then I guess you may someday if not already work with it I don't think there is a programming job that wants you to know only assembly, C is needed even most low level software like Operating systems use C and Windows uses C++ also so in my opinion you should not even think about it C its like a fundamental knowledge even most of the web developers know C

是的,它就像是所有编程语言的核心,几乎每种语言都是基于它构建的,感觉你知道c#如果你做了大量的装配,你不会花太多时间学习c然后我猜你有一天可能会已经使用它我不认为有一个编程工作要求你只知道汇编,即使是大多数低级软件也需要C,操作系统使用C和Windows也使用C ++,所以在我看来你甚至不应该考虑即使大多数Web开发人员都知道C,它就像一个基本知识

#14


Amazing that in a world of new scripting languages every day there are still people that manage to only know assembler.

令人惊讶的是,在一个新的脚本语言世界中,每天仍然有人只能知道汇编程序。

I myself, after writing perl or javascript for longer periods always find lower level languages like C or C++ kind of lacking, for instance, where in perl I write foreach(@array), in C/C++ I have to fiddle with for loops and indexes and/or iterators.

我自己,在写了更长时间的perl或javascript之后总是找到C或C ++这类缺乏的低级语言,例如,我在perl中编写foreach(@array),在C / C ++中我必须摆弄for循环和索引和/或迭代器。

So, yes, I can only imagine how much you will get from the abstractions C will provide for you.

所以,是的,我只能想象你将从C将为你提供的抽象中获得多少。

Additionally, widening your perspective is always a Good Thing.

此外,拓宽视野总是一件好事。