The C/C++/Java family of languages and Borland Delphi have much in common, to the extent that Delphi and Borland C++ emit compatible object files.

Things that C programmers will find different in Delphi
  • Use begin and end instead of { and } to delimit blocks of code.
  • The language is not case-sensitive at all, but some string comparison functions are. Default string comparison (e.g. if strA = strB then ... ) is case sensitive.
  • When to use a semicolon in Pascal. The semantics of semicolons are slightly different. In Pascal, a semicolon is a statement seperator, not a statement terminator as it is in c. That is, in a block, the semicolon after the last statement is optional in Pascal. The C syntax is actually more intuitive.
  • Assignment is spelled := not =, pronounced "colon-equals", "assign" or "gets the value". Equality test is spelled = not ==.
  • In function parameters, it is better style to use var parameters instead of pointers to things. These are identical under the hood, but var params read better.
  • If a function doesn't return a value, it is declared with the keyword procedure. If it does, it is declared with the keyword function. This is a harmless if eccentric quirk of Pascal.
  • #define is not used for everyday simple tasks like defining numeric or string constants. Use const instead. There is a preprocessor, but thankfully it is not your first recourse.
  • There are no ++, -- += *= etc. operators
  • Assignments do not return values, You can't do a = b = c;
  • Integers are not Booleans. Booleans are not integers. True is not = 1, though Ord(true) is.
  • You can make sets of enums. Use these instead of bit-flags.
  • There is a built-in string type. A delphi string is not an object, but it works simply and easily.
  • You must declare all of your variables at the start of a procedure.
  • The interface section of your unit corresponds to a .h file, the implementation section corresponds to the associated .c file
  • You will find working with untyped pointers, type coercion and bitwise operations doable, but more verbose and less gracefull than in C. The point is that you shouln't be doing a lot of this.
  • Delphi is a proprietary language, with only one closed-source implementation, and the future direction is determined by a single vendor.

Things that C++ programmers will find different in Delphi, in addition to the above:

  • For the most part, you will use single inheritance
  • The property keyword explicitly links your related gettor and settor methods, which can then be private. This may be part of Borland C++ builder, but C++ is a standard and that standard unfortunately does not include properties.
  • There is run-time-type information, but only for published properties.
  • There are no templates. You may miss these.
  • There are no operator overloads. I for one don't miss them.
  • There are no implicitly-called user-defined cast operators. I for one don't miss them.
  • All objects are on the heap, you must free them manually.
  • The only namespaces are units.
  • A class cannot span multiple source files.
  • There are no make files. But then you won't need them.
  • Compilation, even a complete build is is really, really fast.
Things that Java programmers will find different in Delphi, in addition to some of the above
  • There is no garbage collection. Except for strings. And interfaces. And components with owners.
  • There is a richer non-Object-Oriented type system that allows you to define your own types including enumerations.
  • You can have global variables and functions - i.e. not attached to any object. Use them sparingly and well.

Log in or register to write something here or to contact authors.