|
Even HTML defies this requirement
|
|
|
|
|
Keith Barrow wrote: I'm pretty sure I read somewhere that natural language processing on a machine is impossible because it would break one of the Goedel incompleteness theorems.
Tell that to the GrandNagUs.
The report of my death was an exaggeration - Mark Twain
Simply Elegant Designs JimmyRopes Designs
I'm on-line therefore I am.
JimmyRopes
|
|
|
|
|
So... what you want is a common business oriented language?
COBOL it is!
|
|
|
|
|
It looked like a description of a BASIC to me
|
|
|
|
|
My thoughts exactly, except portability part.
I work in VB.NET, have weak typing, good descriptive code etc...
And recently I had a discussion with a colleague who prefers C# who espouses "real" programming, symbols instead of words for start/end of function etc...until we got to code review and I got to see:
while () {
...
...
if ()
{
...
...
break;
} // end if
...
} // end while
I didn't call him on it, really
I intend to live forever. Or die trying.
|
|
|
|
|
I admit I do this nowadays in Delphi (three cycle, a case and a try..except down) - and remember Excel VBA, as it wrote If after End for me, while the Delphi IDE is unable to do it for me
So long, VB haters...
|
|
|
|
|
The brace matching of Visual Assist is good enough that I usually don't need to do this. However, I often comment the else node in larger if constructs to keep track of the conditions needed to get there. Something like this:
if (a > 0)
{
if (b > 0)
{
...
}
else {
...
}
}
else {
...
}
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
How about Cobol+?
Cobol, PL/1, etc., have a lot of nice features.
I like the tasking (multi-threading), resource management/control and arithmetic formula capabilities of PL/1.
I like the sentence-like structuring of COBOL.
What would a "new" language look like that incorporated this stuff?
|
|
|
|
|
After two decades of cobol I am ready to chuck it out the window
|
|
|
|
|
After three decades of COBOL and more languages than I have fingers and toes, COBOL still is the language that comes the closest to the ideal that rjmoses described.
|
|
|
|
|
|
COBOL was the first thing that came to my mind. After working through all of the fancy toy languages from Lisp to C#, it still remains the most readable and "natural" in my experience.
|
|
|
|
|
Oh, yeah!
I forgot to add: "Communications is two or more individuals sharing AND understanding an idea."
The "and understanding" part often gets overlooked in programming.
|
|
|
|
|
What you tell a computer to do must be precise. Computers are machines, they have no intelligence or subjectivity, and in the end everything we tell them to do comes down to bit twiddling in particular memory or disk locations. There are whole levels of existing code (OSs and byte code executors, then compilers) between you and that, but in the end that's what it comes down to, and in order to translate your code into those low level instructions for the computer, your code must be entirely unambiguous.
Natural language is ambiguous, subjective and often imprecise and confusing. That's why mathematicians use a formal way of writing (equations and carefully phrased theorems/axioms/etc), rather than a normal talking language.
And do you really want to be working in a code base where one person has typed
if(a == 5) { DoSomeStuff(); }
... and someone else
if a is 5 then dosomestuff end
?
|
|
|
|
|
BobJanova wrote: if(a == 5) { DoSomeStuff(); }
Take away one '=' in the if statement, put it in a seldom used error recovery routine and you have the bug I spent six months chasing. The mental skills required to spot the difference between '=' and '==' is difficult overcome when you are under pressure.
I also chased a bug where a statement was inserted between the closing parenthesis and the opening brace, thus changing the entire program flow. (if (a == b) dosomethingnew; { dosomething };
What I want is to be able to look at a piece of code and accurately comprehend the meaning, intention and function of what the original programmer was trying to convey.
"if a is 5..." can be a lot clearer than "if (a=5)..." in many cases.
And, I'm not suggesting allowing mixed language constructs that do the same thing, although that is not out of the picture.
And, as you stated so well, the machine requires precision. I agree!
The question I'm raising is: How can we design a programming language that is easier, more accurate, less error prone, easier to modify, etc.?
|
|
|
|
|
Yes, well a bare equal-sign should be an error; assignment should be with := , a la Pascal and others.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
rjmoses wrote: Take away one '=' in the if statement, put it in a seldom used error recovery routine and you have the bug I spent six months chasing. The mental skills required to spot the difference between '=' and '==' is difficult overcome when you are under pressure.
A good IDE like Visual Studio will catch that one, and many other errors, when debugging. With ReShaper installed it will catch it when typing.
|
|
|
|
|
In C / C++ the IDE cannot catch it, because it as an absolut correct statement !
Ever seen the simple strcpy() function:
void strcpy( char *source, char *destination )
{
while (*destination++ = *source++ )
;
}
|
|
|
|
|
Fire up any text editor, compile the code below as pure C and you have what you asked for ...
#define IF if (
#define THEN ){
#define ELIF } else if (
#define ELSE } else {
#define ENDIF }
#define IS ==
#define EQUALS ==
|
|
|
|
|
Thanks!
Here's a set of C macros I found real useful that's along the same lines. I tripped them across 20 years ago when I had a programmer working for me that couldn't keep his braces balanced.
I known I will take heat about these macros from certain types of people on this thread, but, remember, this is a problem some of us have been wrestling with since Day 1.
So, for the purists in the group, be thankful for all your experience, but remember back to your early days and, if your were writing bug-free programs back then, you're welcome to comment.
/* (e) is any valid C expression */
/* Uppercase is necessary because of the cursive processing of statements like "else" by the C pre-processor */
/* IF-THEN-ELSE-ELSEIF */
#define IF(e) { if (e)
#define THEN {
#define ELSE_IF(e) } else if (e) {
#define ELSE } else {
#define END_IF ;}}
#define DO_N_TIMES(e) { int __Iii; for (__Iii = 0; __Iii < (e); __Iii++) {
#define END_DO ;}}
#define DO_UNTIL(e) { for (; !(e); ) {
#define END_UNTIL ;}} // END_DO will work also
#define DO_WHILE(e) { while (e) {
#define END_WHILE ;}} // END_DO will work also
#define FOR(e) { for (e) {
#define END_FOR ;}}
#define CASE(e) { switch (e) {
#define CASE_OF(e) case e: {
#define DEFCASE default: {
#define DEFAULT default: {
#define END_COF } break;
#define END_CASE }}
#define BEGIN {
#define END }
#define AND &&
#define OR ||
#define NOT !
#define EQ ==
#define NE !=
#define LT <
#define GT >
#define LE <=
#define GE >=
#define BAND &
#define BOR |
#define BXOR ^
#define BNOT ~
#define LSHF <<
#define RSHF >>
#define INC ++
#define DEC --
#define MOD %
#define ADDR(e) &(e)
#define PTR(e) *(e)
#define BOOLEAN unsigned char
#define BYTE unsigned char
#define REAL double
#define INTEGER int
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
|
|
|
|
|
rjmoses wrote: "if a is 5..." can be a lot clearer than "if (a=5)..." in many cases.
Honestly, no. Does "is" mean "has same value as"? Is it a value comparison or a reference comparison? Or does it mean "is an instance of..." or "belongs to the same type/class/struct definition"?
Or does it mean, which is what I would expect if we spoke plain English, "a and 5 are simply two names for one single enity"? (After all, if A is 5 it means that A and 5 are the same object, like saying that Obama is the President of the USA and the President of the USA is Obama).
|
|
|
|
|
The question I'd ask is why aren't you running lint (or an equivalent) on your codebase? Would find and flag both of these...
|
|
|
|
|
Well, the weak typing you suggest probably isn't less error-prone. Consider this for example.
S = 12; .
.
.
S += 34; .
.
.
print S;
Now someone else comes and hijacks the variable in between.
S = 12; .
.
.
String tmp = S; S = "Test";
...
S = tmp; .
.
.
S += 34; .
.
.
print S;
How long will it take you to find this?
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
I think the crux of the problem is that we need Service Pack 1 on the Human OS, but this runs the risk of breaking 'being human'. The alternative is the embedded artificial intelligence into all machines so they know to do what we 'meant', not what we 'said'.
|
|
|
|
|
... sorry, being human, meant to say 'is to embed artificial intelligence' ...
|
|
|
|