文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>The depressing state of dynamic languages

The depressing state of dynamic languages

时间:2009-04-06  来源:cobrawgl

I love to code in Python and JavaScript and I have coded in them for some years now. The unfortunate thing is that their current state is depressing for writing bigger applications. This is unfortunately true for most dynamic languages such as PHP, Ruby or Perl.

One must understand that dynamic scripting languages were made for one thing: writing small applications (small scripts, small websites). Performance and maintainability isn't a big issue for small scripts / small applications - hence, most of the scripting languages perform REALLY bad and maintainability is really hard.

Anyhow, the core problem of dynamic languages is brain dead compilers - - actually, most of them don't have a compiler at all, they let everything be evaluated and checked at runtime. Currently a lot of work is being done in improving performance, but one thing that's forgotten is doing any forms for sanity checks that can help a programmer. Imagine if a Python compiler could check simple things like function signatures at compile time or even just making sure that you don't spell a functions name wrongly (i.e. check that a function is actually defined in the current environment).

An example: In Python (or any other "dynamic" languages) you can write following unsound code (at least this is unsound if you haven't done any "magic" to the environment):

def blah(): calling_a_magic_function() import not_found_module not_found_dict['not_found'] = "NOT FOUND!" 

The above program will run without any problems - there aren't any sanity checks and you can't tell the compiler to "turn on sanity checking". If you do small scripts then this isn't an issue, but if you are doing a big application with lots of modules and lots of code, then changes are very hard to do since the compiler does not give any form for help.

I have built simple custom tools on top of pyflakes to check for simple things such as calling a function that isn't defined or imported. But I wish that Python could do these checks for me, so if I used a module that wasn't defined it would throw an error before running the actual code. Check out my post Static checking Python code for more info.

Anyhow, having coded in Java I think the real strengths of Java is the JVM and an amazing compiler that can spot tons of errors at compile time (such as calling a method with invalid parameters). Of course, such checking is much harder to do in Python (or other "dynamic" languages) - - that said, it's not impossible and the worst thing the compiler can do is to ignore static checking and let the runtime system handle everything.

Anyhow, my hope is that not only performance improves for dynamic languages, but also static checking for stupid errors.

相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载