70 points · by joshuacc · 13y ago · 74 comments
> put amulet on drawer
> put amulet in drawer
> put amulet behind drawer
> place amulet on drawer
> give amulet to drawer
> push amulet to drawer
> show amulet to drawerA good DSL has no need to "look like English".
(I guess what I'm really saying is that you're right, but you're saying something else, raganwald is right too.)
Another example is Siri. If the end result is not of most importance and an educated guess is acceptable when Siri for scripts could be a way to easily program the device.
Have a look at quicksort in J: quicksort=: (($:@(<#[), (=#[), $:@(>#[)) ({~ ?@#)) ^: (1<#)
Cute, isn't it?
I was playing with J for some time - a few weekends maybe - I managed to get to the level of conscious incompetency, which is a lot for such a foreign language and then stopped, I just had enough. J is certainly very powerful, consistent and logical language and I believe that after some years I would be able to read and comprehend J's code almost as fast as any other language from the get go. I'm just not convinced it's worth it.
Put another way: I certainly hope that future programming languages will not look more like J. And you can, of course, grab a J system and use it today if you want.
qsort ← {1≥⍴⍵:⍵⋄ e← ⍵[?⍴⍵]⋄ (∇(⍵<e)/⍵), ((⍵=e)/⍵), ∇(⍵>e)/⍵}
Unlike J, all the brackets/parens/etc are balanced, and the functions and operators have single-character names.
Having played with both APL and J, I find APL to be easier to read. J was really just an experiment, adding rank matching and forks and hooks to APL, as well as using ASCII only for syntax. It doesn't take long to remember the keys for entering the non-ASCII characters into APL, and it looks more readable than J.
I think a future programming language should have precedences for its operators, though.
In this case, I'm essentially a really slow compiler turning English language into machine language. Who can say to what extent machines will be able to perform this function in the future?
i'd love to hear success stories about this. what makes a dsl intended for domain experts work? i suspect it's got little to do with the dsl and a lot to do with politics and motivation of the parties involved. and unicorn blood, of course.
[edit: limiting functionality (related to raganwald's reply below) reminded me of this exchange - http://news.ycombinator.com/item?id=5111265 - which was perhaps a wiser approach than i thought at the time. lbrandy says: "as simple as possible for analysts to use". and that seems to have been a success story.]
For example, what should happen if the network drops out in the middle of a save? Should it save a copy locally? Where? No, not the temp directory; that will be erased if the computer is rebooted. And so on.
Also, there is a system for logical rules called Attempto Controlled English which I think has some proven use cases for business rules.
Since no one else has mentioned it yet, Lojban [1] seems like the perfect candidate for this.
http://www.ainewsletter.com/newsletters/aix_0503.htm#loglan http://www.tlg.uci.edu/~opoudjis/Play/lojban.html
It was beautiful.
http://www.csse.monash.edu.au/~damian/papers/HTML/Perligata....
maximum inquementum tum biguttam egresso scribe.
Natural languages and computer languages are very different both in how they are used and in the constraints that exist on them. It is very obvious that you can't write programs in written English for that reason, and the only reason why we have this confusion is not what we expect from programming languages but what we expect from natural languages.
As every introductory linguistics textbook will remind you, natural languages are defined by usage patterns. Computer languages however are defined by parser behavior. They must be rigorously specified, while such specification kills natural languages.
Many people, particularly public school English teachers, would like to see English specified to this level of clean, precise, prescriptive rules, but this doesn't really work in practice. Different dialects occur and these dialects often have very different features (note the habitual tenses in African American Vernacular English, for example, which also occurs in some dialects from England). Usage defines the language, just like it can define good/bad coding practices in one school of thought or another, but usage does not define C. If I decide there is a clearer way to handle pointers, what I come up with isn't C any more. However habitual tenses ("I be workin' Tuesdays") as much as they may be seen as "bad English" by some prescriptivists, are just natural, organic developments within the language.
There are also dialects of English that are less imprecise. For example consider legalese which is often considered to be a hyper-defined dialect of English (also a very formulaic one). The advantage is that legalese can fall back to other English terms for additional meaning and one can be reasonably sure what a contract means even if you are not a lawyer.
So what does this mean about English-Likeness? Certainly we wouldn't expect the laws of the nation and contracts to be written in a purely symbolic language even though these need a level of definition well beyond what ordinary everyday English can provide. In fact if we did so, this would interfere with the function of legal instruments. Legalese may be a hyper-defined dialect but at the end of the day, it is still just as much English as African American Vernacular English is. English likeness is more a blessing than a curse in the field of law, even though it is quite clearly both.
Because English-Likeness is both a blessing and a curse there, it is worth asking the same here. Can an ordinary individual read a program written in Perl or Python and understand it? No, but that same ordinary individual probably cannot read the Supreme Court's opinion in Pedilla v. Hanft, or Hamdi v. Rumsfeld either and really understand what the court is arguing about.
But what English-likeness does is it speeds up learning. There is a difference between how quickly you can pick up Spanish as an English speaker and how quickly you can pick up Bahasa Indonesia or Algonquin. Spanish in both structure and vocabulary is much closer to English than either one is to Indonesian or Algonquin, so I think the same applies, and languages which follow very different structures (lisp reminds me of Irish Gaelic due to the latter's VSO word order) tend not to gain much traction.
Additionally English is probably the best language in the world to be like for a programming language. We have a relatively simple lexical structure and a fairly inflexible word order and much of this is due to the fact that Middle English arose as a sort of creole (with all the grammatical simplification that goes with that) between Anglo-Saxon and Old Norman French. Other creoles might be good choices too, but this is a good choice and we might as well stick with it.
[1] Note, we would never say "Me will have to" and yet within the parenthetical, the normal rules of pronoun cases get shifted a bit. See Bailey, Charles, "How English Grammars have Miscued" in Polome, Edgar (ed) "Language Change and Typological Variation," JIES monograph 30.
float Q_rsqrt( float number ) {
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y;
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) );
return y;
}
You have written many words and have buried your counterpoint in the process. Put aside the superficial points (e.g. reasons to choose a dialect of English over a dialect of another language) and address the main issue: if programming is the act of translating human concepts into precisely defined math and logic, how can we reasonably rely on such a fundamentally imprecise tool as natural language to get the job done? I contend that there is no sufficiently high level of abstraction where natural language would be more suitable.As for an example, you just gave one. But if we wanted to make it more natural-language-like it would be a slightly different syntax:
DECLARE FUNCTION q_rsqrt (float number) THAT RETURNS float AS (
....
);
Now if you think of the natural language phenomenon of ellipsis, this gets shortened essentially tofunction sqrt(float number) returns float (
and we might want to change this to make it more concise
float function sqrt(float number) { }
ADD: Do you accept that programming has its basis in mathematics and logic? If so, how is making computer languages resemble human languages a more direct way to improve comprehension than learning some math? Walking up a mountain path is difficult, but not nearly so difficult as moving the mountain until it lies beneath one's feet.
And no programmer will want to write in such a language because it's so verbose.
I don't mind making programming languages look more like natural languages; I would offer Python as an example of a language that takes advantage of this where it makes sense.
But I draw the line at having to type boilerplate; if it's absolutely necessary, at least keep it to an absolute minimum.
I'm reminded of Paul Graham's remark about Prolog being more high level but not more terse, and that this had something to do with its present-day situation. Natural language is high level because it is terse and humans can supply a great deal of omitted information on their own. Teaching the computer how to supply that information is an incredibly error-prone burden. Teaching people how to use precise English seems to be worse than teaching people how to use a precise language that isn't English.
But the question is whether it works best to have a high level abstraction which resembles a natural language.
"Hello Computer! I need an inverse square root function. It should take a float as a parameter and..." - Not practical
"Hello Computer! I need this image to pan across the screen. It should take one second. When it gets there, I want it to stop and become clickable. When you click it..." - Very practical
The practical solution here could even be iterative...
"No computer, no! The image should ease into position, not just go straight there!"
The point is you wouldn't rely on it for precise logic, just "good enough" behavior. You can definitely argue that this isn't programming though.
I mean this in the nicest possible way but this is like saying a whole lot and nothing at the same time. I think if I heard this as a verbal response to the original article, I would think the speaker just wants to hear himself speak.
You haven't really stated counter point by which to justify any kind of disagreement. It's seems to be like a promissory note of "well if the language conformed to some subset dialect like legalese that could be great." I think there are very big problems for English-like programming languages that this sort of skirts over and dismisses. Just because you think people that think a phrase like "Me ain't got no dollas" is horrible grammar are just fuddy duddy "prescriptivists" doesn't really solve the problem of English-like programming languages.
I don't think it would be great if regular English did so. Natural languages can't do so. If you do that you kill the language. My point is simply that we expect English to be like that and it's good that it isn't, but we can still leverage people's understanding of the language to help people learn programming faster, and moreover when languages do not do this they have more trouble gaining traction.