1 / 7

Comparison of Batak & C++

Comparison of Batak &amp; C++. C++ #include &lt;iostream.h&gt; int main() { cout &lt;&lt; “Hello world<br>”; }. Batak Program Hello; integer main() { writeline(‘Hello world’); }. Hello world. No superficial #include directive Hello is an object of type program, explicitly exposed. C++

matteo
Download Presentation

Comparison of Batak &amp; C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Comparison of Batak & C++

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

  3. 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); } Conversion (type casting)

  4. 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 Remarks about conversion

  5. 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); Operation prototype • 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. 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 Remark

More Related