3

When talking about features of programming languages, such as in Programming Language Comparison and D Language Feature Comparison Table, I was wondering what aspect of languages the concept "features" belong to or are discussed under?

Thanks and regards!

Community
  • 1
  • 1
Tim
  • 1
  • 141
  • 372
  • 590

3 Answers3

2

This is just a gut feeling, I'm not a language theory guy or anything. I'd say adding a feature to a programming language means both

  1. adding semantics for certain circumstances or construction (e.g. "Is-expressions return a boolean according whether the type of a template argument matches some type according to the following fifty rules: ...")
  2. defining a syntax that belongs to it (e.g. adding IsExpr : "is" "(" someKindOfExpression ")" in the grammar)
  • Thanks! But when talking about language features independent of specific languages, e.g., when comparing what features several languages might or might not have in common, does language syntax still play a role? – Tim Mar 29 '11 at 14:20
  • @Tim: When discussing this, many focus on the semantics because the syntax is considered less important for the programmer (incrementing `x` by 1 is the same thing regardless of whether it's `++x`, `x := x + 1` or `inc(x)`). But there have been more than enough syntax flamewars as well, so... ;) –  Mar 29 '11 at 14:23
1

It depends entirely on what you mean by a "feature," and how it's implemented. Some features, like Java's generics, are nothing but syntactic sugar - so that's a "syntax feature." The bytecode generated is unaffected by using Java's generics due to type erasure. This allows for backwards compatibility with pre-generic (e.g. Java 1.5) bytecode.

Other language features go much deeper than the syntactic level, like C#'s generics, which are implemented using reification to provide "first-class" generic objects.

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
  • Generics are *not* a "syntax feature". They come with a whole load of semantic rules, and not lightweight ones at that. Even if they only exist at compiletime. –  Mar 29 '11 at 14:10
  • So you're saying that Java generics are a combination of syntax and semantics? – Matt Ball Mar 29 '11 at 14:15
  • Of course. `class Foo { public T x; }` differs from `class Foo { ... }`, and both differ from `class Foo { int x; }`. And the difference in syntax is the smallest. –  Mar 29 '11 at 14:19
1

I don't think that there is a clean separation for the concept of programming language "features", as many features like garbage collection (Java) or pattern matching (Haskell) are being provided by the runtime environment. So, generally I would say that the programming language - the grammar - per se provides no features. It just determines the rules of the language (Syntax). As the behaviour is being determined by how the code (produced by the grammar by obeying its rules) is being interpreted, programming language features are a sematic aspect.

das_weezul
  • 6,082
  • 2
  • 28
  • 33
  • But these features are defined as part of the pogramming language, regardless of how they are implemented (e.g. at compiletime vs. runtime). And many features come with some syntax that wouldn't be in the language without that features - `case x of () -> ()` is only syntactically valid Haskell because there's pattern matching. –  Mar 29 '11 at 14:21
  • @delnan Good example but still "case x of () -> ()" is just a possible "sentence" generated by the Haskell-grammar. You and I understand its meaning by evaluating the semantics mentally. To be a useful feature of a programming language the syntax must be evaluated/interpreted. but I'm just nitpicking here ;) – das_weezul Mar 29 '11 at 14:39