Presentation is loading. Please wait.

Presentation is loading. Please wait.

Comparison of Batak & C++. Hello world C++ #include int main() { cout << “Hello world\n”; } Batak Program Hello; integer main() { writeline(‘Hello world’);

Similar presentations


Presentation on theme: "Comparison of Batak & C++. Hello world C++ #include int main() { cout << “Hello world\n”; } Batak Program Hello; integer main() { writeline(‘Hello world’);"— Presentation transcript:

1 Comparison of Batak & C++

2 Hello world C++ #include int main() { cout << “Hello world\n”; } Batak Program Hello; integer main() { writeline(‘Hello world’); } No superficial #include directive Hello is an object of type program, explicitly exposed.

3 Conversion (type casting) C++ int main() { char s1[5] = “32767”; char s2[5] = “65536”; int i = atoi(s1); long l = atol(s2); s1 = itoa(i) s2 = ltoa(l); l = 32767L; float f = (float) i; i = (int) f; } Batak int main() { char[5] s1 := ‘32767’, s2 := ‘65536’; integer i := integer(s1); long l := long(s2); s1 := char[5](i) s2 := char[5](l); l := 32767; float f := float(i); i := int(f); }

4 Remarks about conversion C++ uses badly named operations (atoi, atol, ltoa, itoa) Programmers have to memorize those names C++ uses different syntax to achieve that (e.g., (int) and atoi) Batak uses properly- named operations (the same name with the target type) Programmers don’t have to memorize additional names Same syntax, conversion is just like calling other operations

5 Operation prototype C++ void move_to (int old_x1, int old_y1, int new_x1, int new_y1); Batak void move_to (integer old_x1, old_y1, new_x1, new_y1); In C++, programmers have to repeat the name of type in the operation prototype In Batak, they don’t have to C++ void move_to (int x1, int y1, int x2, int y2, char s1[], char s2[]); Batak void move_to (integer x1, y1, x2, y2; char[] s1, s2);

6 Operation prototype and object declaration C++ void move_to (int x1, int y1, int& x2, int& y2, char s1[], char s2[]) { int a, b; a = x1; b = y1; x2++; y2++; char s3[], s4[]; strcpy(s3, s1); strcpy(s4, s2); } Batak void move_to (integer x1, y1; integer& x2, y2; char[] s1, s2) { integer a, b; a := x1; b := y1; x2++; y2++; char[] s3, s4; s3 := s1; s4 := s2; }

7 Remark C++ Programmers have to repeat the description of parameter passing for every object, even they are of the same type The syntax of objects list in the operation heading is unnecessarily different from the ones in the operation body Programmers have to memorize name of operation to assign string value; assigning string value is unlike assigning other value. Batak Programmers don’t have to repeat the description of parameter passing, if the objects are of the same type The syntax of object list in the operation heading is only necessarily different (e.g., passed-by address) Programmers don’t have to memorize name of operation to assign string value; assigning string value is just like assigning any other value


Download ppt "Comparison of Batak & C++. Hello world C++ #include int main() { cout << “Hello world\n”; } Batak Program Hello; integer main() { writeline(‘Hello world’);"

Similar presentations


Ads by Google