选择脚本语言而不是 C# 的原因是什么? [英] What are reasons to choose a scripting language over C#?

查看:26
本文介绍了选择脚本语言而不是 C# 的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

选择非 DSL 脚本语言而不是静态编译语言的原因是什么?作为 C#?

What are reasons to choose a non DSL scripting language over statically compiled language such as C#?

-编辑-到目前为止很好的答案.我觉得我应该进一步解释.我很确定人们使用 Python 而不是 C# 的原因不仅仅是为了品味和 C# 而不是在其他情况下使用 Python.

-edit- Good answers so far. I feel I should explain further. I am pretty sure people use Python over C# for more reasons than just taste and C# over Python for other situations.

推荐答案

只使用静态类型语言的程序员可能会接受这是一种必要的做事方式.一旦您体验过鸭子类型,您就会意识到多态真的可以这么简单 - 无需所有额外的代码行来指定类型.

Programmers who have only used a statically typed language may just accept that that's a necessary way of doing things. Once you experience duck typing, you realize that polymorphism can really be just that simple - without all the extra lines of code to specify types.

程序运行不需要所有类型声明的东西——这是解放体验——它只是为了让编译器可以检查某些类型的错误.

All that type declaration stuff is not required for the program to work - and this is liberating to experience - it is merely so the compiler can check for certain types of errors.

如果您不使用动态语言进行测试,您可能会遇到编译器会在静态类型语言中捕获的运行时错误 - 但事实证明,这对于静态类型语言来说并不是一个胜利正如您所想的那样,因为无论如何您都应该使用两种类型的语言进行测试.您需要在静态类型语言中进行测试以捕获类型检查无法捕获的其他逻辑错误 - 在许多情况下,这些类型的测试无论如何都会排除与类型相关的错误 - 所以您不需要足够的额外使用动态语言进行测试以抵消您不必执行的类型声明编码.

If you don't do testing in a dynamic language, you can get hit by run-time errors that the compiler would catch in a statically typed language - but it turns out this is not as much of a win for statically typed languages as you might think, because you should be doing testing in both types of languages anyway. You need to test in statically typed languages to catch the other logical errors that the type checking won't catch - and in many cases, those types of tests passing would rule out the type related errors anyway - so you don't need enough extra testing in dynamic languages to offset the type declaration coding you don't have to do.

结果不仅仅是提高了生产力,而是专注于你想做的事情的乐趣,问题的症结所在,而不是陷入困境,告诉编译器一堆东西,这样它就可以保护你免受错误的影响无论如何,您将(至少应该)进行测试.

The result is not just increased productivity, but the pleasure of just focusing on what you want to do, the crux of the problem, rather than getting bogged down in telling the compiler a bunch of stuff so it can protect you from errors you're going to (should, at least) test against anyway.

性能是一种权衡,因为动态语言在运行时不能承担那么多 - 但很多时候性能不是问题.如果是,您可以用较低级别的语言重写性能关键模块.像 Python 这样的语言让这一切变得简单.

Performance is the tradeoff, since a dynamic language can't assume so much at run time - but a lot of times performance is not the issue. And when it is, you can rewrite the performance critical modules in a lower level language. Languages like Python make this easy.

具有类型推断功能的语言是值得考虑的中间地带.

Languages with type inference capabilities are a middle ground worth considering.

这篇关于选择脚本语言而不是 C# 的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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