views:

70

answers:

2

what is the main differences between syntax language and s-expressions language ? does using s-expressions affects compiling time (in the parsing process) or does it bring any advantage to the language ?

+1  A: 

In a language such as Lisp or Scheme, using S-expressions to represent the program text probably will reduce the amount of work for the parser. A Lisp compiler will spend less time parsing Lisp source code than a C++ compiler would spend parsing C++ code (C++ has a reputation for being one of the most complex languages to parse).

However, with some exceptions (perhaps C++?), parsing is not the part of the compiler that will take the most time. Java, Python, C#, Delphi all have quite simple grammars.

Greg Hewgill
+1  A: 

Representing source code in a language as S-expressions does make parsing it easy, but that's not the point. The various dialects of Lisp have mechanisms for programs to operate on the structure of other programs, and that requires programs to have a transparent, canonical representation. That representation is S-expressions. They are what Lisp provide things like macros, code running over the program at compiler time, which are practically impossible in languages that don't encode programs as data structures in the language.

Novelocrat