开发者

How to measure the "understandability" of a language?

开发者 https://www.devze.com 2023-01-18 01:17 出处:网络
I have often read that some programming languages are clear than others and I asked myself several times if there is an objective way to measure the clarity of a language in order to design, given an

I have often read that some programming languages are clear than others and I asked myself several times if there is an objective way to measure the clarity of a language in order to design, given an abstract syntax, a concrete syntax as clear a开发者_开发知识库nd human friendly as possible. Perhaps exist some kind of designs patterns for that purpose?

In short: How can be achieved the maximum clarity of a syntax? Know any way to quantify the "clarity" or "expressiveness" of a language?

Makes sense to try to measure these aspects?

Thanks.


I have heard this phrase too many times carelessly thrown at different languages, and different people will choose different languages based on different criteria.

In Beautiful Code, Yukihiro Matsumoto (Ruby's designer) makes an argument about how much simpler it is to write a Hello World program in Ruby than in Java. Although I don't think this example is meant to scale, the author's point is that the amount of cruft you have to add on to your code reflects the deficulty in understanding a program written in a that language. That is, the less distraction you get, the more "readable" the program is.

Now, in my experience, good programmers write clear code in all languages they program in, though even more clearly in languages they are more familiar with. The author's talent as well as the breadth of his experience in that lenguage end up dwarfing the language itself's clarity or expressiveness.

Another point to consider is the amount of available libraries and the quality of the APIs. If you have to write less "support code" to get the job done, then it's likely the resulting program is clearer because it appears more straight to the point.


There have been some studies in what is called "natural programming" which may be of interest to you:

http://www.cs.cmu.edu/~NatProg/index.html

They attempt to design languages to meet human expectations instead of trying to conform people to what's simplest for a computer. And they're basing it on experiments. For instance studying how many people bring back a pear from a box of fruit when you instruct them to "bring back something is not an apple or a pear". (I haven't kept up with their results, but it sounded like a promising project.)

Still, "clarity" and "expressiveness" are nebulous things to gauge. There are of course studies which do quantitative measure of languages against one another, like the Computer Language Benchmarks Game. Some people have taken data from solutions offered in that game and graphed trends like "code size vs. performance":

http://blog.gmarceau.qc.ca/2009/05/speed-size-and-dependability-of.html

You might be able to make some shaky metrics-based propositions about a general-purpose-language based on trends in code size it takes to perform a given task efficiently. But then you're pinning down fairly subjective notions of what "clarity" and "expressiveness" are. (I'm biased to believe shorter programs that do the same work faster are often clearer, but there are many counterexamples.)

So I'd say that in the absence of a defined target audience with which you can do usability studies with test subjects, you won't do much better than these kinds of metrics for making generalizations about languages.

(Note: I like Rebol and I think it has the power to be incredibly clear and expressive...but only if you use it a certain way which involves developing DSL dialects as you go, which is not the way a lot of people think when they program. Yet!)


I don't think there is. Clarity is subjective, and design patterns are not a good measure for clarity of a language (indeed, design pattern are usually born to circumvent the limitation of a language).

Some people likes a language with rich and concise semantic (e.g. perl) and doesn't really mind the use of symbols, while other prefers a syntax that resembles natural language, such that you appear to speak to the computer (e.g. Hypercard) and doesn't really mind the verbosity or the ambiguousness.


A question like this usually results in a pedantic answer.

Languages are like tools.

They are built to suit certain purposes. Logic programming language solve certain problems in a more elegant way than an object oriented program would. Similarly, many main stream solution are easily done by a typical object oriented or procedural language.

Temperament and other factors of the tool user, in this case a programmer also matters. Some folks have achieved nifty solutions in Perl but it has always looked like black magic to me. I prefer Python's structural simplicity. For some, it's use of white space has been abominable.

It would be at best a very subjective evaluation, if there can be an evaluation of a language clarity and expressivity.

How ever, a clear indication is wealth of code production in that language. Some language like brainfuck has not been adopted while Python, Ruby etc have gained popularity. Although, these and many factor can be an indicator only. Some language, despite good constructs may not find much takers.

Network effect also affect the language adoption.


I find LOLCODE to be the most understandable language of them all:

HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
    UP VAR!!1
    VISIBLE VAR
    IZ VAR BIGGER THAN 10? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE


Measuring the understandability of a language is not as important as measuring the understandability of a programmer.


You can also look at the book "Concepts of Programming Languages" by Latest Edition, BY R. W. Sebesta. There is chapter in this book (chapter 1 or 2 I don't remember exactly) discuss criteria to evaluate a programming language.

0

精彩评论

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

关注公众号