在解释语言中使用匈牙利符号前缀是否有意义? [英] Does it make sense to use Hungarian notation prefixes in interpreted languages?

查看:132
本文介绍了在解释语言中使用匈牙利符号前缀是否有意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,为了避免重复的问题,我查看了以下帖子.

First of all, I have taken a look at the following posts to avoid duplicate question.

https://stackoverflow.com/questions/1184717/hungarian-notation
>为什么我不应该使用匈牙利符号"?
是否真的需要变量前缀(匈牙利表示法")了吗?
人们是否真正使用匈牙利命名约定世界?

https://stackoverflow.com/questions/1184717/hungarian-notation
Why shouldn't I use "Hungarian Notation"?
Are variable prefixes ("Hungarian notation") really necessary anymore?
Do people use the Hungarian Naming Conventions in the real world?

现在,所有这些帖子都与C#,C ++,Java(强类型语言)相关.
我确实知道在编译之前知道类型时就不需要前缀.
不过,我的问题是:

Now, all of these posts are related to C#, C++, Java - strongly typed languages.
I do understand that there is no need for the prefixes when the type is known before compilation.
Nevertheless, my question is:

考虑到您在运行时之前看不到对象的类型,是否值得在基于解释器的语言中使用前缀?

如果有人可以将此帖子发布为社区Wiki,请这样做.我对这篇文章中的声誉(或负面声誉)几乎不感兴趣.

If someone can make this post a community wiki, please do. I am hardly interested in the reputation (or negative reputation) from this post.

推荐答案

在Python中人们不赞成匈牙利符号传送类型(系统匈牙利语")的原因很简单.这是误导.变量可能称为iPhones(电话的整数,也许是:-),但是因为它是Python,所以没有什么可以阻止您将整数以外的东西放进去了!也许您会发现出于某种原因需要这样做.然后,所有使用它的代码对试图理解它的人都是极具误导性,除非您当然在全局范围内更改了变量的名称.

The reason Hungarian notation conveying type ("systems Hungarian") is frowned upon in Python is simple. It's misleading. A variable might be called iPhones (the integer number of phones, maybe :-) but because it's Python, there's nothing at all to keep you from putting something other than an integer into it! And maybe you will find you need to do that for some reason. And then all the code that uses it is very misleading to someone trying to understand it, unless of course you globally change the name of the variable.

此符号旨在帮助您跟踪静态类型语言中的变量类型,并且可以说是有用的.但是,考虑到以更好的方式完成这项工作的IDE的可用性,即使对于静态类型的语言,它现在也已过时.

This notation was intended to help you keep track of variable types in statically-typed languages and was arguably useful for a time. But it's obsolete now, even for statically typed languages, given the availability of IDEs that do the job in a much better way.

这篇关于在解释语言中使用匈牙利符号前缀是否有意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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