|
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' ...
|
|
|
|
|
Sould note that when Programming (talking to) humans is much education between Chemists and physicists. Agree we need a pretty good AI to take over the details of creating a program and avoiding the failures of precision (as in missing commas etc.)but the AI needs to be able to learn how we think. And we write math using integer to real and back quite often and only occasionally blow the wad. Think about translating the gibs free energy - from chemistry - to the conservation of energy as in all else. Confuse those two and the barn goes up in a hot one. One damn smart computer to follow us into our thousands of specialties.
|
|
|
|
|
So I had a lot of practice spotting poorly placed operators. I would much rather spend one day every other year looking for a misplaced semi-colon than spend the time adding verbosity. Plus, in my opinion, the ability to see on screen without scrolling the maximum amount of logic is paramount in writing good systems. The eyes move orders of magnitude faster than scrolling. I have seen some beautifully written, well documented code that was nearly impossible to trouble shoot for all the novel in the code.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: Plus, in my opinion, the ability to see on screen without scrolling the maximum amount of logic is paramount in writing good systems. The eyes move orders of magnitude faster than scrolling. I have seen some beautifully written, well documented code that was nearly impossible to trouble shoot for all the novel in the code.
I have seen all too much code that took most the screen to display a simple concept. E.g.,
if ( a = b )
{
c = d;
}
else
{
if ( p == q )
q = r;
};
This coder use spacing to up his LOC/day count. Comprehension....well...that leaves a lot to be desired.
And I agree about beautifully written code. I saw a 1000 character program written in one line with no white space. Couldn't begin to understand what it was doing.
Ennis Ray Lynch, Jr. wrote: So I had a lot of practice spotting poorly placed operators. I would much rather spend one day every other year looking for a misplaced semi-colon than spend the time adding verbosity.
If there is time, and no pressure, a misplaced semi-colon isn't a problem. But, add pressure, such as commodities trading, and you have 2 minutes to find and fix the bug, well....pass the Maalox please.
|
|
|
|
|
This is a major rant I have about default (e.g. StyleCop) formatting conventions. They waste so much space that you can't actually see what the code does.
|
|
|
|
|
|
Wow, at >8000$ for a smartphone resolution screen? Seriously?
|
|
|
|
|
rjmoses wrote: trace their origins back to the days when terseness was a desirable quality. It still is. A decent C# class uses less characters to convey the same info as written in Object Pascal. Less characters to convey the same info - do you really need a "begin" and an "end" block?
rjmoses wrote: Be clear and obvious in describing the functionality of the module. When is something obvious? If you've ever hunted a swallowed exception in VB6, you'll know that this is not possible. Code should be unambigious, simple and clean. It should not become an exercise to omit documentation.
rjmoses wrote: 2) The language should be portable. It's not the language that decides on what platforms it will be implemented. VB6 will never appear on Linux without starting a major war.
rjmoses wrote: 3) The code should be almost self-documenting. Only if you're not coding, but scripting. That means that we'd limit this "programmer" to an IDE like MS Access. You'd never get InterOp or call the WinAPI. You'd never get a pointer.
rjmoses wrote: 5) The language should incorporate most commonly-used functionality. I've yet to meet the (broadly used) language that doesn't. Type-safety is something valuable - suggesting to remove it would be a step back.
rjmoses wrote: 6) And, finally, it should be easily extensible. A language? Please not; how would your old code react to changes? Can you oversee whether or not your change "breaks" something?
Sorry, but only MS Access has these properties. I don't see it being used in the same way we use programming languages.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I just did my 29th update to Firefox the other day. It took me about 3 hours to get it back to where it was. Windows 7 keeps bugging about "New updates are ready to install". And Adobe Acrobat keeps crashing....
My point is: How can the programming process be improved? Such that we don't have 29 versions of FF? Or weekly updates ready to be installed. Or "Should a crash report be sent..."?
|
|
|
|
|
rjmoses wrote: How can the programming process be improved? First you identify whether you're attacking the right thing; it's not due to the language that Acrobat behaves the way it does.
rjmoses wrote: How can the programming process be improved? Seriously?
- Start educating people. No, don't send them to an expensive 5-day course where they learn to parrot the most used words, but educate them.
- Kick marketing and sales out of the IT-room.
- Drop
agile ad hoc methods.
- Force the boss to use the product on a daily base just as an end-user would use it.
- Care about your product.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote:
rjmoses wrote: 2) The language should be portable.
It's not the language that decides on what platforms it will be
implemented. VB6 will never appear on Linux without starting a major
war.
Every language* is portable, but not every language gets ported everywhere.
* With the possible exception of the various assembly languages, but I suspect that even they could be compiled for a system they weren't intended for, perhaps with some limitations, but I'm no expert on that.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Portable assembler is known as plain C.
|
|
|
|
|
Eddy Vluggen wrote: A decent C# class uses less characters to convey the same info as written in Object Pascal. Less characters to convey the same info - do you really need a "begin" and an "end" block?
If you are looking for terseness, go APL.
On a more moderate scale: What is really the purpose of those parentheses around if conditions, while conditions and for loop specification? Pascal can make due without them. Why do you have to double up the equals sign? Pascal can make due without that. Why do you have to double up all logical operators? The answer: Because the language "designers" didn't have a clue about language design.
Why do you have this ugly try-catch mess? In Chill, any statement may include an exception handler before its closing semicolon; it doesn't have to be pre-announced. The presence of an ON clause implies exception handling; you don't need to pre-announce it.
Why do you have to explicitly declare that "this is the end of the handling of this alternative", when the specification of the next alternative follows immediately? In Pascal you don't.
Why do you have to enclose exception handling in braces? The braces must , unconditionally, be there, but Chill makes due without them. A general rule in Pascal and its derivatives is that {...} is a block, and a simple statement is a block, so wherever a block is called for, a simple statement can be used.
Why to you have to include the body of a switch statement in braces, creating two nesting levels (the second one is each of the alternatives) when there logically is only one?
etc. etc.
Terseness is to remove from the language selected keywords and markers on your private hate list. The keywords/markers on someone else's hate list that is not on yours, you might fiercely defend as a way to improve readability, provide redundance to catch errors etc etc. Very few people really sat down to "tersify" a language specification, removing ALL unneccessary blurb; they use terseness as an argument to defend their own hate list.
|
|
|
|
|
Let's see.. there must be a relevant XKDC... oh, yeah, this'll do: http://xkcd.com/927/[^]
Such language should not be English-centric like most of today's languages; rather each developer should be able to view and edit the code in his own chosen language. (And formatted as the individual likes as well.)
In fact, I think a new language should be XML-based with the IDE applying styling and such as specified by the user.
Of course, I would never use such a language, I'd stick with good old C#.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Algol-67 was defined in terms of abstract syntax elements that could be represented using any suitable set of concrete symbols. I never saw much Algol-67 source code, but most of what I have seen used German keywords.
(Algol-67 never caugth on - it was way ahead of its time. Even today, 47 years later, it would definitely be descibed as a very advanced language. I haven't looked at the specification for a while, but I am sure that some of its useful features are still missing from today's languages.)
Maybe it was Algol-67 that inspired us when we as students made a Norwegian version of Pascal. It really was a simple word replacement program replacing MEDAN with WITH, BYRJ with BEGIN and STOGG with END (those who know Norwegian will see that we chose the dialect-based Norwegian variant), writing it to a temporary file and invoking the standard compiler on that temporary one. It worked perfectly as long as you in you user defined symbols stayed away from both the Norwegian and English reserved words.
|
|
|
|
|
Sounds like you really just want a compiler to be more helpful with errors. Tools like Resharper help with this in Visual Studio!
Hogan
|
|
|
|