5 ms·
Another amateur linguist + software dev here (loosely involved in NLP-related work and studied linguistics at university). I invite you to try to convince me th
by Cyranix 14y ago
Another amateur linguist + software dev here (loosely involved in NLP-related work and studied linguistics at university). I invite you to try to convince me that there might possibly be a natural-language-esque version of the (in)famous inverse square root function that is more comprehensible than the original.
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.
- einhverfr 14y agoMy point is that one doesn't use a natural language to get the job done, one uses a computer language in the likeness of a natural language to get the job done. The similarity speeds learning process. 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 to function sqrt(float number) returns float ( and we might want to change this to make it more concise float function sqrt(float number) { }
- pdonis 14y agoDECLARE FUNCTION q_rsqrt (float number) THAT RETURNS float AS ( .... ); 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.
- einhverfr 14y agoIt's not that far from PL/SQL and PL/PGSQL CREATE OR REPLACE FUNCTION foo (int bar0) RETURNS int language plpgsql security definer volatile as $$ begin return $1 + 1; end; $$;
- qu4z-2 14y agoWhich is the reason I can't stand SQL
- Turing_Machine 14y agoI was thinking COBOL. Edit: added sample. http://www.csis.ul.ie/cobol/examples/Conditn/IterIf.cbl http://www.csis.ul.ie/cobol/examples/Conditn/IterIf.cbl
- einhverfr 14y agoNow, there is a program that an ordinary person might be able to read to understand what it does.
- dinkumthinkum 14y agoI wouldn't say that is "natural language like." I would just say that is a very loquacious programming language. I contend the C equivalent of that is more readable. You're using the same sort of constructs in typical programming languages but still lacking anything like the kind of fluid reading and understanding one would expect from the promise of English like programming languages.
- einhverfr 14y agoIf that is the promise it will never be met for the very simple reason I mentioned above: natural language is defined by how the speakers individually use the language. Computer languages are defined by specification. That kiss the flexibility you are asking for right there and that's why you can never program in English. It isn't just a question of imprecision. NULL in SQL is more imprecise than most of the things folks might argue about in English.... The problem is as to how you define correct usage and correct behavior. 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.
- Cyranix 14y agoThe method signature is the low-hanging fruit. Try the method body. 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.
- einhverfr 14y agoI don't see anything wrong with the message body. The point is we are talking about similarity, not identity. I have been clear: you can't program in English but there is some benefit to having languages which are easy for English-speakers to learn. > 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.
- dougk16 14y agoI think you're missing the practical use cases of natural language programming, at least those in the next decade or so. "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.
- pdonis 14y agoWhat you want isn't "natural language programming"; what you want is an AI. I think that's more than a decade away.
- dougk16 14y agoWell, we start to split hairs here, although my over the top "Hello computer!" skewed what I was getting at. If NLProgramming gains ground, there will likely be some level of AI behind it, but not necessarily a "true" AI. And it's not what I want...it will put me out of work ;)
- einhverfr 14y agobut you still require a hyperdefined subset of English to make that work, and such a parser cannot take into account dialectal and language drift issues.
- dougk16 14y agoIt could if there were some level of AI behind it.
- einhverfr 14y agoBut at that point you run into another problem, namely that you can interact with computers in natural language but I don't think you can program them, because once you have that level of AI, you can't guarantee that two computers will have the exact same understanding of the command any more than you can expect that two programmers will read a spec in the exact same way. What this means is that the consistency gained in programming languages would be lost. A computer program would no longer generate repeatable results.
- fusiongyro 14y agoThis is the best, most succinct and apt summary of the situation I've ever seen: "I contend that there is no sufficiently high level of abstraction where natural language would be more suitable." 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.
- einhverfr 14y agoSure. But the question is whether it works best to have a high level abstraction which resembles a natural language.