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

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

问题描述

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

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

-编辑- 到目前为止,很好的答案.我觉得我应该进一步解释.我敢肯定,人们在C#上使用Python的原因更多,而不仅仅是在其他情况下通过品味和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天全站免登陆