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.
> Do you accept that programming has its basis in mathematics and logic?
This is one of the foundations of programming, particularly pronounced in technical fields. As you get to solving higher level problems however, other things come into play.
For example, suppose we are building a robot to automate some physical process (let's say, making coffee). We are going to have low-level programming which takes care of ensuring that we can tell the robot what exactly we want to do. If resources are tight we may do all of this low-level, but if we can spend more on resources we might want to have a higher-level (scripting, if you will) environment for brewing coffee.
On the higher level, our calculations are not going to be how many j of heat to add to the water. They will be what temperature to bring the water to. We may specify how finely the grounds are to be ground, etc. These instructions will resemble a cookbook recipe more than they will resemble a mathematical diagram, and this is the difference between high-level and low-level languages.
> If so, how is making computer languages resemble human languages a more direct way to improve comprehension than learning some math?
but the similarity is not just in vocabulary. In English we might write "three plus two equals five" where "plus" is essentially a conjunction, three and two are subjects, equals is a verb, and five is the predicate/object. This works because English has a subject-verb-object verb. Similarly a equals b plus c tells us that we can find out the value of a by adding b and c. In English there is a difference between a = b + c and b + c = a. There may not be a logical difference but there is a semantic difference that does not exist in pure math.
So let's imagine math written in another language, Irish Gaelic, translated word-for-word into English and ignoring conjucated prepositions. Irish Gaelic has a verb-subject-object word order, so we might write equals a adding and c. Maybe a nice way to represent this symbolically would be (= a (+ b c)). There wouldn't be a computer language like that, would there be?
The problem though that lisp encounters is that it is disorienting, and it is disorienting because the structure bears no resemblance to English.
If English-Likeness is a problem, surely that applies to word order and other syntactic similarities just as much as it applies to lexical similarities.
https://en.wikipedia.org/wiki/Polish_notation -- is that what you're looking for?
Sorry, no time to continue the debate. You're welcome to keep believing, and human-languages interactions sure would be neat at any level, but I'm coming from too pragmatic an angle to believe this will happen before a complete mapping of the human brain or the singularity.
Ummm straw man there.
My point was just that computer languages which leverage people's existing understanding of natural languages do better than those which don't. I said way up at the beginning of my post that the constraints were totally different and that natural languages are quite a bit further from computer languages than we like to think.
I thought we were talking about likeness, not substitutability.
Let me see if I got that right. You see the need to transform:
float Q_rsqrt( float number )
into: DECLARE FUNCTION q_rsqrt (float number) THAT RETURNS float AS
but you see no need to do anything to: 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;
I intentionally didn't refer to your later, more "concise" attempt, because the topic of discussion is the "English -Likeness" and, unlike "DECLARE FUNCTION q_rsqrt (float number) THAT RETURNS float AS", your "float function sqrt(float number)" doesn't add English likeness to the syntax.Now, your assertion was that "what English-likeness does is it speeds up learning". Since we're all just flinging around theories unsupported by research and data, I'd like to posit that the main motivation behind attempts to do away with programming languages and replace them with natural languages is the misconception that you can learn to program without learning to think like a programmer. It doesn't really have much to do with syntax itself, it has to do with inherent complexity of programming.
To take your example, Lisp uses an unusual syntax which makes it disorienting at first. This "disorientation" is something people will deal with in a matter of days, whereas their struggle to plumb the depths of macros and functional programming will take much, much longer.
All in all, I believe that small degrees[1] of "English-Likeness" might help English speakers learn the syntax of the language a bit faster, but that benefit would prove insignificant when compared to the rest of the effort necessary to learn to program.
[1]: Small enough to avoid "polluting" the language with the problems @raganwald writes about.
I don't believe this is einhverfr's intent in the least, but the promotion of English is often an ethnocentric activity. Why not a dialect of Chinese (so many native speakers, high information density per character)? Why not a dialect of Spanish (multi-continental reach of native speakers, high incidence of cognates to Romance languages, highly predictable orthography and phonetics)? Why not any language spoken in the Middle East or India or former Soviet states?
If human accessibility were truly the issue, why should we focus our efforts on English speakers -- the people already the most aided by existing language-like tokens! -- instead of promoting efforts to "translate" programming keywords and constructs to other languages? I'll grant that one does not necessarily preclude the other, but I would argue that the former is chasing after diminishing returns at this point in time, whereas the latter represents a significant opportunity to increase ease of access to programming globally.
This doesn't mean I am a fan of such languages from a natural language perspective, btw... I am just saying if I was choosing a language to build a computer language based on, I would not choose a language where imperative tenses of verbs might vary depending on number of addressees, for example....
As I think of it, it might be very interesting to look at computer language design based on other natural languages and see what other problems or opportunities come up. For example, I wonder about slot-based polysynthetic languages (like Algonquin). A computer language based on that would have to be fundamentally different from what we have now.
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.
CREATE OR REPLACE FUNCTION foo (int bar0) RETURNS int language plpgsql security definer volatile as $$
begin
return $1 + 1;
end;
$$;Edit: added sample.
The only promise that English-like languages can ever fulfil is that they will be easier to learn for English-speakers than languages which are not.
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.
What this means is that the consistency gained in programming languages would be lost. A computer program would no longer generate repeatable results.
I think both of our points are somewhat moot though, as I don't see NLP code as something that you would necessarily put up on github. I see it as playing a similar role to DSLs or metaprogramming nowadays, and similarly, it wouldn't always be a good solution.
Simple use case: I recently finished an HTML5 puzzle minigame. The layout is pretty simple and has to adjust to window resizes, but the layout can't be done with straight HTML/CSS. So, my resize function is 120 lines of dense javascript, despite being able to describe in a simple paragraph what I would want. Indeed, a simple paragraph is what was given to me in the first place to describe the layout.