为什么你使用表达能力较差的语言,我也应该使用?

发布于 2024-08-24 10:26:16 字数 371 浏览 12 评论 0原文

我是一名 Python 程序员,也了解一些 Ruby 和 PHP。我对 Java 的了解还不够多,无法做任何有意义的事情,而且我当然也不了解 C、C++ 或其他低级语言。我听过所有“谁关心速度,因为硬件便宜,但编码器昂贵”的争论,我不想在这里引发争论。我想了解有关较低级编程语言社区(无论是 C 还是汇编)的两件事:

  1. 您选择仍然使用它的主要原因是什么(工作要求、速度、桌面与 Web 等)< /em>?
  2. 这么晚了我还值得花时间学习 C++(从金钱角度来说)或其他语言吗?或者我会受益吗?

另外,在选择原因时,请考虑动态类型与静态类型的优点/缺点。我主要为网络编程,但没有充分考虑这一点,因为部分原因是网络是我所知道的一切。

I'm a Python programmer who knows a bit of Ruby and PHP as well. I don't really know enough about Java to do anything meaningful, and I certainly don't know C, C++, or other low-level languages. I've heard all the "Who cares about speed because hardware is cheap, but coders are expensive" arguments, and I'm not trying to raise a debate here. I want to understand 2 things about the community of lower level programming languages (whether it's C or even assembly):

  1. What is the main reason you choose to still use it (job requirements, speed, desktop vs web, etc)?
  2. Is it still worth me taking the time to learn C++ (monetarily speaking) or others this late in the game, or will I benefit?

Also, consider the benefits / disadvantages of dynamic vs static typing, when choosing your reasons. I primarily program for the web, but don't take that fully into consideration because it's partly due to the fact that the web is all I know.

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

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

发布评论

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

评论(7

匿名。 2024-08-31 10:26:16

这里是无耻的 Fortran 程序员。速度速度速度。哦,与我一起工作的所有科学家都相当流利地使用 Fortran。但后来我在大型集群和超级计算机上从事计算电磁学工作,如果网络应用程序跳起来咬我的鼻子,我就无法识别它。

我不认为 Fortran 是低级的或表达能力较差的,我认为它是用于线性代数和更一般的数字运算的 DSL。那我为什么要上钩并回答这个问题呢?

动态类型与静态类型?请保持静态,一切都在编译时绑定,以便编译器可以进行优化。

Unashamed Fortran programmer here. Speed speed speed. Oh, and all the scientists I work with are reasonably fluent in Fortran. But then I work in computational electromagnetics on large clusters and supercomputers and wouldn't recognise a web application if it leapt up and bit me on the nose.

I wouldn't regard Fortran as low-level or less-expressive, I think it's a DSL for linear-algebra and more general number-crunching. So why did I take the bait and respond to this question ?

Dynamic vs static typing ? Static please, everything tied down at compile time so the compiler can work its socks off optimising.

浅浅淡淡 2024-08-31 10:26:16

对于 Web 程序员来说,C/C++ 几乎不会给你带来任何优势。它的表现力不如 Perl、Ruby、Python 等,并且需要更多代码并需要关注内存管理的细节。不幸的是,选择一种语言的“特性”往往要其次才是选择它的平台。 C++ 不像 C# 那样干净和优雅,这大部分来自于它对 C 的兼容性。遗憾的是,尽管对于某些事情有更好的语言,但大多数都没有编译,并且大多数没有得到广泛支持。

如果您计划开发一个商业产品,客户将下载或接收 CD,那么 C/C++ 可以为您提供知识产权保护(难以逆向工程)、较小的运行时占用空间以及针对旧平台的能力就像Windows XP一样。

学习C/C++还为时不晚。只要所有高级语言存在,C/C++ 就会存在,因为这些语言是用 C/C++ 实现的。并不是说有一天我们都会转向 Python,而 C/C++ 就会退役。高级非编译语言不能自我提升,因此如果没有 C++,它们就无法存在。

如果您要实现更高级别的东西,例如语言、API、工具包、驱动程序、IDE 等,那么它是可以使用的工具。但是,如果您想要以最快的方式来实现,则 C++ 不是可以使用的工具。开发内部 GUI 应用程序或 Web 应用程序。

只需学习适合该工作的工具即可。如果工作发生变化,或者您希望换工作,那么您可能需要推动自己学习 C++,以了解计算机科学世界的另一面,即 CPU 与您当前编写 Web 应用程序之间的一面。

For a web programmer, C/C++ will offer you virtually no advantage. It is less expressive than Perl, Ruby, Python, etc. and requires more code and attention to detail of memory management. Unfortunately, choosing a language for its "features" is often second to choosing for its platform. C++ isn't as clean and elegant as C#, most of that comes from its C compatibility. Sadly, even though there are better languages for certain things, most aren't compiled and most aren't widely supported.

If you plan to develop a commercial product that the customer will download or receive on CD, then C/C++ offers you protection of your Intellectual Property (hard to reverse engineer), and a small runtime footprint, as well as ability to target older platforms like Windows XP.

It is not too late in the game to learn C/C++. C/C++ will be around as long as all the higher level languages are around, because those languages are implemented in C/C++. It is not as if we will all move to Python one day and C/C++ will be retired. High level, non-compiled languages are not self-hoisting, so they cannot exist without C++.

It is the tool to use if you are going to implement higher level things like languages, APIs, toolkits, drivers, IDEs, etc. But C++ is not the tool to use if you want the fastest way to develop an internal GUI app or a Web app.

Just learn the tool for the job. If the job changes, or you wish to change the job, then you may want to push yourself to learn C++ to see the other side of the Computer Science world, the side between the CPU and what you currently write your web apps in.

乞讨 2024-08-31 10:26:16
  1. 我认为这里的三大原因将是性能、遗留系统支持和嵌入式开发。

  2. 如此主观,它使任何答案几乎毫无用处。

  1. I'd think the big three reasons here are going to be Performance, Legacy System Support, and Embedded Development.

  2. So mega subjective it renders any answer next to useless.

旧情勿念 2024-08-31 10:26:16

对于数值计算,我直接编写 C++ 比直接使用 Python 更快。当然,我可以将我的 C++ 库连接到更高级的语言(我确实这么做了),但由于我的大部分工作都是在低级数字方面完成的,所以我不会获得太多收益。

还要考虑到许多库,尤其是科学计算中的库,都采用 FORTRANCC++ 语言,并从 C++ 链接到它们。 code> 比自己创建包装器和接口要快得多(特别是如果您只是想要完成它)。

能否从学习低级语言中获得任何收益很大程度上取决于您的问题领域。

For the numerical calculations I do writing straight C++ is just faster than using e.g. straight Python. Sure, I can interface my C++ libraries to higher-level languages (and I do), but since most of my work is done on the low-level numerical side, I wouldn't gain too much.

Also consider that a lot of libraries especially in scientific computation are in FORTRAN, C or C++ and linking against them from C++ is much faster (especially if you just want to get done with it) that creating wrappers and interfaces all yourself.

If you would gain anything from learning a low-level language depends a lot on your problem domain.

南烟 2024-08-31 10:26:16

使用较低级语言有几个很好的理由。

首先,有很多应用程序的性能非常重要。我工作的主要应用程序本身就足够慢(它做了很多事情),并且在 Python 中无法使用。

其次,有些应用程序需要的独立可执行文件并不是那么大。

第三,C 和 C++ 中存在大量遗留代码,并且不会很快消失。

第四,操作系统通常用C或C++或类似语言编写,并在其中公开API。如果您需要与操作系统保持密切联系,无论出于何种原因,您最好使用操作系统语言。

动态类型显然更适合让应用程序快速启动和运行,而我的 Lisp 背景让我相信静态类型通常只是过早的优化。然而,很多人认为静态类型对于在大型项目中强制执行正确性要好得多,并且 C 和 C++ 非常适合大型项目。

关于你的第二个问题,我不知道你将来想做什么,所以我不知道你是否值得学习C++。对于专业发展,我强烈建议学习多种语言,包括 C 或类似语言。 SO 还有其他关于学习什么语言的问题。

There are several good reasons for lower-level languages.

First, there's a lot of applications where performance does matter. The main application I work on is slow enough as it is (it does a whole lot of things), and would be unusable in Python.

Second, there are applications that require standalone executables that aren't all that big.

Third, there's a tremendous amount of legacy code in C and C++, and it isn't going away any time soon.

Fourth, operating systems are normally written in C or C++ or similar languages, and expose APIs in them. If you need to get chummy with the OS, for whatever reason, you're better off using the OS language.

Dynamic typing is very clearly better for getting an application up and running fast, and my Lisp background pushed me to believe that static typing is normally just premature optimization. However, lots of people believe that static typing is much better for enforcing correctness in large projects, and C and C++ are well suited for large projects.

For your second question, I have no idea what you want to do in the future, so I don't know if it would be worthwhile for you to learn C++. For professional development, I'd strongly suggest learning a variety of languages, including C or a similar language. There are other questions on SO about what languages to learn.

安静被遗忘 2024-08-31 10:26:16

为什么 Python、Ruby 和 PHP 不自己编写?

任务关键型应用程序需要尽可能最佳的性能和算法,并且不需要元编程之类的东西。
C++ 有一些很棒的想法和库,然后我在这些现代语言中发现了它们,有时更好,有时更差(比较 C++ 中模板和 Java 中泛型的功能)。
低级语言将使您更多地了解计算机、操作系统或网络的较低级抽象。

静态限制了你的编程,通常会让你写出类型,但它也让你更好地以某种方式表达你的意图,这种方式可以由编译器自动证明,并且你可以获得工具的支持。 Dynamic 为您提供了自由的双手,您可以做更多、也许更容易的事情,但是您必须更好地进行测试。

Why aren't Python, Ruby and PHP written in itself?

Mission critical applications need best possible performance and algorithms and doesn't need things like metaprogramming.
C++ has some great ideas and libraries, which I then found in those modern languages, sometimes better sometimes worse (compare power of templates in C++ and generics in Java).
Low level languages will make you learn something more about lower level abstractions of the computer, operating systems or networks.

Static restricts you in programming and often makes you write out the types, however it also let's you better express your intent in a way, which is automatically provable by compiler and you can get support for tools. Dynamic gives you free hands, you can do more and maybe easier, however you have to test better.

静谧幽蓝 2024-08-31 10:26:16

我可能在这里误解了您的意思,但听起来您的印象是 C++ 是适合每种项目的语言。事实并非如此。您不会使用利勃海尔卡车进行越野公路旅行。现有的每种流行语言都是如此,因为它在某些情况下效果很好。曾经有一段时间,C++ 被用来编写 Web 应用程序,但由于生产和性能之间的权衡,它很快就被 Perl 脚本所取代。因此,针对你的第一个问题,人们仍然使用它主要是因为在某些情况下它是完成工作的最佳工具。

至于要不要学,我说你有时间、有意愿就学吧。即使 C++ 从来都不是您所从事的任何项目的正确工具,但对 C++ 中必需的概念的充分理解将使您成为每种语言的更好的开发人员。

I may be misunderstanding you here but it sounds like you're under the impression that C++ is the appropriate language for every kind of project. It isn't. You wouldn't use a Liebherr truck for a cross country road trip. Every popular language in existence got that way because it works well for some situations. There was a time when C++ was used to write web applications which quickly gave way to Perl scripts because the trade-off between production and performance. So in response to your first question, mainly people still use it because in certain situations it's the best tool for the job.

As far as whether or not you should learn it, I say if you have the time and the desire go for it. Even if C++ is never the correct tool for any of the projects you take on a decent understanding of concepts that are necessary in C++ will make you a better developer in every language.

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