-1

What is the official name of the principle, in language design, where the language tries to offer one way of accomplishing a particular task (as opposed to have multiple ways of accomplishing the exact same thing)?

  • 3
    The Zen of Python states that "There should be one –and preferably only one– obvious way to do something." But this is neither "official" nor a concise name. In any case this is just a counterreaction to the TIMTOWTDI principle from the Perl community. And Python in particular also has many duplicative or non-obvious features :) – amon Sep 22 '18 at 5:46
  • When you asked that question, you seemed to be under the impression there are so many languages in the world which follow "this principle" (and not just Python), that it must have a name. If you can give us some examples for such languages (5 to 10 would be good start, to justify a common name)? – Doc Brown Sep 22 '18 at 9:07
  • @DocBrown : The only impression I had, when asking this question, is that a wordy concept might have a shorter name. I didn't even know its Python roots until I upvoted Amon's comment. – Lonnie Best Sep 23 '18 at 21:01
  • @LonnieBest: well, my point is, when there are no languages out there which follow this idea, it is probably not "a principle" and definitely not worth to get a name on its own. Every multi-purpose language, including Python, offers multiple ways to achieve a certain task. – Doc Brown Sep 24 '18 at 5:39
  • @DocBrown : Yeah, I got your point. However, I still think the concept is worthy of a shorter official name because it is an extreme of a continuum. Even if python doesn't adhere to that extreme, the language's designers probably consider the concept with each proposed addition to the language. And, from Amon, it seems Perl's TIMTOWTDI is on the opposite end of that continuum. – Lonnie Best Sep 25 '18 at 6:41
5

There is none. Mind that having different ways to yield the same result may be useful. You may want it fast, safe, with little code or just compliant, using a particular infrastructure. Languages that only offer one way are not likely to be popular.

Edit

Assuming the one-way idea is supposed to make it easier for programmers to succeed, there is a more common design principle (that does have a name) which makes it easy to succeed when trying to achieve something. Rather than forcing us to do something a certain way, we are guided to proper usage.

This is sometimes referred to as making people fall into the pit of success, meaning it will be harder to misunderstand a system and use it the wrong way than it is to use it the right way. This can be achieved by allowing only one way, because that would automatically be the right way. But it may also be due to prior art that people are familiar with, closely related to POLA (the principle of least astonishment).

Falling into the pit of success however is more commonly mentioned in relation to code libraries or classes than entire programming languages.

  • Do you have any support for you final sentence? Seems to me that Java, until recently, was more of a "one typical way to do things" language, and it is popular. – user949300 Sep 22 '18 at 16:13
  • @user949300 Perhaps we interpret "one way to accomplish a task" differently. Java is a general purpose OO language that allows plenty of ways to do stuff. If you need some space to store temporary data you can use a file, a memory stream or a list object for instance – Martin Maat Sep 22 '18 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.