From Reddit, a nice survey: http://www.reddit.com/r/coding/comments/118ssp/honours_student_at_my_university_is_doing_a/
For my Computer Science Honours research project, I am currently investigating ways of improving the terse, technical error messages given by traditional compilers to make them more useful to novice programmers. As part of this research, I have designed this survey to help determine which types of common novice errors are inadequately reported by a traditional compiler and to gather ideas on how they should be reported to a novice.<
http://www.esurveyspro.com/Survey.aspx?id=23752434-e25f-4a48-86bf-bb2634e1b5ce So this survey is not to improve error messages in general, it's specific for newbies. So the error situations shown in the survey are not typical for C programmers. Below some of the examples converted to D, with their relative error messages. --------------------------------- void main() { int height = 25; int width = 50; int area = height.width; } temp.d(4): Error: undefined identifier 'width' --------------------------------- void main() { int x = 3; int y = 2(x + 1); } temp.d(3): Error: function expected before (), not 2 of type int --------------------------------- int main() { for (int i = 0, i < 10, i++) { // do something } return 0; } temp.d(2): Error: semicolon expected, not '<' temp.d(2): Error: expression expected, not '<' temp.d(2): Error: found '10' when expecting ';' following for condition temp.d(2): Error: expression expected, not ',' temp.d(2): Error: found 'i' when expecting ')' temp.d(2): Error: expression expected, not ')' temp.d(2): Error: found '{' when expecting ';' following statement temp.d(5): Error: Declaration expected, not 'return' temp.d(6): Error: unrecognized declaration --------------------------------- void main() { int value = 0; while (value < 10) do { // do something value++; } } temp.d(8): Error: found '}' when expecting 'while' temp.d(8): Error: found 'EOF' when expecting '(' temp.d(8): Error: expression expected, not 'EOF' temp.d(8): Error: found 'EOF' when expecting ')' temp.d(8): Deprecation: do-while statement without terminating ; is deprecated temp.d(8): Error: found 'EOF' when expecting '}' following compound statement --------------------------------- void main() { double value = 1; switch (value) { case 1: // do something break; } } temp.d(4): Error: 'value' is not of integral type, it is a double temp.d(5): Error: case must be a string or an integral constant, not 1 temp.d(4): Deprecation: non-final switch statement without a default is deprecated --------------------------------- void main() { int i = 0; if (i => 0) { // do something } } temp.d(4): Error: expression __lambda2 of type void does not have a boolean value --------------------------------- void toDouble(int integer) { return cast(double)integer; } int main() { double x = toDouble(1); return 0; } temp.d(2): Error: cast has no effect in expression (cast(double)integer) temp.d(2): Error: cannot return non-void from void function temp.d(5): Error: expression toDouble(1) is void and has no value --------------------------------- int f(int x) { return x * x - x + 1; } int main() { int x = 5; x = f; return 0; } temp.d(6): Error: not a property f --------------------------------- import std.math; int main() { double x, y; x = 0.5; sin(x) = y; return 0; } temp.d(5): Error: sin(cast(real)x) is not an lvalue --------------------------------- void main() { int arr[10]; for (int i = 0; i < 10; i++) { arr(i) = 0; } } temp.d(5): Error: function expected before (), not arr of type int[10u] --------------------------------- import std.stdio; int main() { int i = 1; printf("%f\n", i); return 0; } 0.000000 (DMD gives no warning here) ================================= Let me add few basic mistakes specific for D, and the error messages they generate: void main() { foreach (i, 0 .. 10) {} } temp.d(2): Error: basic type expected, not 0 temp.d(2): Error: no identifier for declarator int temp.d(2): Error: found '0' when expecting ';' temp.d(2): Error: expression expected, not '..' temp.d(2): Error: found '10' when expecting ')' temp.d(2): Error: found ')' instead of statement temp.d(3): Error: unrecognized declaration --------------------------------- void main() { int[10] data; foreach (i, x, data) {} } temp.d(3): Error: no identifier for declarator data temp.d(3): Error: found ')' when expecting ';' temp.d(4): Error: found '}' when expecting ')' temp.d(4): Error: found 'EOF' instead of statement temp.d(4): Error: found 'EOF' when expecting '}' following compound statement --------------------------------- void main() { int[10] data; foreach (i; x; data) {} } temp.d(3): Error: found ';' when expecting ')' temp.d(3): Error: found ')' when expecting ';' following statement --------------------------------- void main() { int[10] data; foreach (i; x, data) {} } temp.d(3): Error: undefined identifier x --------------------------------- struct Foo { int x; } void main() { Foo[10] data; foreach (f; data) f.x++; } [No error messages nor warnings] --------------------------------- Some of those D error messages are sub-optimal for new programmers. Bye, bearophile
