This page lists ways in which programming languages resemble the EnglishLanguage, or other natural spoken languages. One purpose of this exercise is to determine whether such features really do improve readability.
CeeLanguage (and CeePlusPlus):
Ways in which not enough programming languages are like English:
Prepositions
Function calls in most modern languages tend to have nothing but commas separating them. Witness VbScript programs that have to deal with MicrosoftWord documents in terms like this:
WordApp.Documents.Open FileName,1,1,0,"","",1,"","",0There are little-used conventions in this and similar languages that allow you to explicitly name parameters, but they are seldom used because they tend to be so verbose. And in VbScript's case, you can't use built-in constants anyway, so it doesn't help much.
WordApp.Documents.Open FileName, ConfirmConversions = 1, _ ReadOnly=1, AddToRecentFiles=0,"","", Revert=1,"","", Format=0The obvious solution would be to name your arguments after prepositions, but in many languages, prepositions are reserved words. In VB, "for", "to", and "with" are all reserved. RubyLanguage may be a little more flexible, since it claims "reserved words aren't", but I do know you still can't use "for".
SmallTalk gets around this by making prepositions and other argument specifiers a part of the symbol name. ''If I had Squeak installed, I'd check now to see if you could have a method called self:super: legally."
Several languages offer KeywordParameterPassing, which addresses this issue.
Adverbs
Many functions have true/false parameters that specify how the function should be performed. Others have a big bitmapped integer that can be boolean-mathed into all kinds of flags. But don't you wish you could just do something like this:
MsgBox "Can't open this frightfully important file!" Urgently
Being unlike English is not necessarily a bad thing. The English language (like other natural languages) leads to a lot of redundancy and ambiguity. Anyone who has programmed in a language that tries to be a lot like English (CobolLanguage, AppleScript) usually finds the necessary phrasings to be too verbose. (For example, "set the x-coordinate of the top-left-corner of window to 0" rather than "window.topLeft.x := 0".) A terse domain-specific notation has benefits. Think about how algebra and calculus would be if we had to do it in English. -- KrisJohnson
Perhaps, but there are some things English has that are both efficient and familiar. But you're right, and in fact when I created this page, I noted that I couldn't think of any examples offhand for PythonLanguage, which is considered one of the most readable of the current generation of scripting languages. Indeed, this supports that the things which make languages readable are not the things which make it like English, and fights against the CobolFallacy. Just look at the popularity of ForthLanguage, despite how its stack-based syntax and reverse-Polish notation create rather mind-bending word orders to the uninitiated. (X @ 3 > Y @ 5 < OR NOT) -- NickBensema
The syntax of one routine calling a subroutine is not only hierarchical, but dictatorial because the communication between caller and subroutine is dictatorial in nature. The caller commands the subroutine to act and gives it all the required arguments. The caller must be smart enough to know what arguments the subroutine requires, e.g., f(x).
However, in the universe, not all communications are dictatorial, some are dialogs. A caller says, "come on over and have dinner with me and my wife." The callee says, "That sounds good. What time?" The caller responds "7:30ish." That dialog is basically f(x) = come-over(7:30ish).
A language can be designed to use peer to peer communications between caller and called? Moreover, that language can have an infinitely variable syntax, like English. Is that language already classified? Does this language constitute a new paradigm?
You appear to be informally describing a casual mix of ActorsModel, FuzzyLogic, and NaturalLanguageProcessing, which smacks of StrongAi. I'm not aware of any language that supports infinitely variable syntax -- not human languages even variable syntax are infinitely, though perhaps some natural languages close-ify. :-) To be a new paradigm, there would need to be some core distinguishing characteristic upon which the language (or a family of languages) is based, preferrably with a formal theoretic foundation.
Perhaps I characterized this argument passing process inappropriately, I'm not a language pro. Just a programmer who has used a lot of languages over the years.
A metalanguage called TACL has the ability for a routine to get its arguments, character by character, from the caller line. See: http://docs.hp.com/en/NSGSeries.html, "TACL Reference Manual." Pages describing #ARGUMENT 9-21... and pages describing ROUTINE 4-9... describe how a TACL ROUTINE can get its arguments, including a character at a time, from the calling line.
This process of calling and getting arguments seems like a dialog to me, instead of a command call with all the arguments pushed on the subroutine.
Since a ROUTINE can get characters from the call line, it can parse whatever argument syntax for that ROUTINE that its programmer wants (maybe infinite syntax variety is an overstatement). In this particular language, the arguments must always be trailing the routine name on the call line. But, that is not an absolute restriction on all languages.
P.S. I don't understand the math in http://www.lcs.mit.edu/publications/pubs/pdf/MIT-LCS-TR-194.pdf (re: ActorsModel). But, the distributed environment is familiar to me. TACL runs only on Non-Stop(tm) computers, which is a distributed network of fault-tolerant multi-cpu nodes communicating over a network. I programmed on a Tandem (now HP) for many years. My comment about caller-callee dialog is not only applicable to a distributed environment.
For me, the division between writing a subroutine and writing an application server has become blurred. Whichever one you write, the purpose is similar, to make an object that does something for you when called. The difference between the two is not what the object does but how the call is done. What syntax difference is required between calling a subroutine and calling a server? -- EdwinEarlRoss
Sorry, not quite following you here. Various forms of RemoteProcedureCall require no syntax difference between calling a local procedure and a remote procedure. E.g. CORBA, Java RMI, .NET Remoting, WebServices, etc.
Thank you, I wasn't sure and had to ask the Q. You have confirmed what I believed to be true, "no syntax difference between calling a local procedure and a remote procedure." -- EdwinEarlRoss
PPS My comment about caller-callee dialog is not about ActorsModel, FuzzyLogic, NaturalLanguageProcessing, or StrongAi. -- EdwinEarlRoss
See Also: TheRightWayToDoWordyBlocks