开发者

scripting or programming language? [duplicate]

开发者 https://www.devze.com 2023-04-09 04:27 出处:网络
This question already has answe开发者_开发知识库rs here: Closed 11 years ago. Possible Duplicate:
This question already has answe开发者_开发知识库rs here: Closed 11 years ago.

Possible Duplicate:

When is a language considered a scripting language?

what is the difference between programming and scripting languages? I have worked on C/C++ for a while and now I started looking at Python, I was told it is a good scripting language this post.

But as I'm learning, I'm finding that everything that can be done with C till now can be done with Python! so what is the actual true difference between scripting and programming languages?


I actually believe the question is a bit misleading. Of course a scripting language is also a programming language. But there are differences:

Between Compiled and Interpreted Languages.

Traditionally a language like c is compiled into machine code that can be understood directly by a cpu. A "script language" on the other hand usually is not being compiled into machine code before execution but interpreted using an interpreter. The advantage of an interpreted language usually is that it has a faster development cycle because no compilation is necessary and it is easier to move from one platform to another. E.g. python scripts can be executed on windows, linux, mac without changes. The advantage of a compiled language on the other hand is that it executes usually much faster.

I used "usually" and "traditionally" very often because there are now technologies that make it much harder to draw the line. E.g. it is possible to compile python code directly into native code and there are also interpreters for c code. Also "Just In Time" compiler and virtual machines make it harder to draw here black and white.

More: http://en.wikipedia.org/wiki/Interpreted_language

Duck-Typed and Strong-Typed Languages

Usually script languages are duck-typed which means that a variable can be assigned any type and there is no or only optional checking of types. In compiled languages on the other side like C and C++ every variable is typed and it can and will only hold values of that type. The advantage of a duck-typed language is usually that it requires less physical typing and less code (e.g. type names can be left of function declarations etc...) and it is easier to write reusable functions. The advantage of a strong-typed language usually is that it "helps" the programmer finding bugs before running the application. E.g. the compiler would complain about type errors without the need to run the concrete line where the error is happening. Especially in big projects with many contributors this can become an amazing advantage.

More: http://en.wikipedia.org/wiki/Duck_typing

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号