Maybe this question is not going to mean a lot if C and C++ are put into context, but I kept wondering why later languages such as Java and specially C# haven't been made simpler in regards of their syntax?

That's why I was wondering if there's some important reason for this, because for me it looks like these languages - C# being my pick - would be slightly (or even a lot) more productive if:

1.Drop semicolons.

2.Case sensitivity was dropped - it's very annoying and I see not benefit in using it in modern languages.

3.Logical operators where just and and or instead of && and || (faster typing? - at least I find letters faster to be typed).

4.If there was a way you didn't have to type classes' names every time you call a method within it(i.e allowing one to type only WriteLine instead of Console.WriteLine)

And there could be many others - it's interesting to notice I have myself figured out more efficient ways (more efficient = less typing) to declare methods and variables without changing functionality, thus the reason why I keep wondering why things weren't made differently (not just about programming).

So, in the end, is there any technical or historical reason why languages are kept so similar and more productive syntax aren't adopted (which seems to be the case for C like languages).

  • 6
    How is the syntax going to be less complex if you add more options? I.e. optional semicolons will pretty much by definition make the syntax more complex, see ECMAScript or Scala for examples. Scala is a particularly good example, because (unlike ECMAScript) it wasn't designed in a hurry, and it had the benefit of being able to learn from ECMAScript, and yet, Semicolon Inference in Scala can still lead to hard-to-track-down bugs and surprising non-sensical behavior, and (most importantly relating to your question) significantly complicates the syntax. Aug 5 '16 at 23:54
  • 3
    #3 is a wash: if you exchange one token for a different token, the syntactic complexity stays exactly the same. #4, I simply don't understand. Aug 5 '16 at 23:55
  • 3
    Ruby is probably not a good example. Its syntax is so insanely complex that the only parsers that have ever been able to properly parse it are either created by extracting the parser from the original implementation into a C library (e.g. the melbourne parser used by Rubinius) or hand-translating the parser from C into another language (e.g. JRuby's parser is more or less hand-translated from YARV's). Or, to put it another way: in the 24 years of Ruby history, nobody has managed to write a parser for it other than the original parser (which is at the same time also the specification). Aug 6 '16 at 0:04
  • 4
    @EzequielBarbosa: "These points I didn't make explicit, but they could imply my question isn't the same." Then maybe you should. Because your question comes off as an opinion-based, "Why don't these languages do the things I think are easier to write?" With no real facts to back up its assertions. Aug 6 '16 at 0:23
  • 2
    What makes you think languages that subscribe to your 4 proposals are automatically more productive? Aug 6 '16 at 1:10

Why do I see this phenomenon? Or: why do the few languages I am learning share the C-like syntax?

Let's decompose this question into several parts.

  • Why did the original designer(*) of the language adopt a C-like syntax?
  • For each element of syntax design (such as those mentioned by the asker), are there legitimate reasons or arguments favoring such use?
  • Why do such languages become popular? Does C-like syntax lend to the popularity of a programming language?
  • Why aren't there languages with syntax crossovers from two or more languages, i.e. between a C-like syntax and another non-C-like syntax?

Why did the original designer(*) of the language adopt a C-like syntax?

A lot of programming languages have just one original designer in the beginning; some have a few; very few programming languages were designed by a committee from the beginning.

You can find interviews of these language designers on the internet. Often they will explain why the decision was made.

For each element of syntax design (such as those mentioned by the asker), are there legitimate reasons or arguments favoring such use?

The semicolon question has been asked before. If anyone has something to add, please go over the existing answers, and add a new one if your contribution is new.

The case sensitivity question has been answered by Microsoft.

For logical operators, in the early days it was widely believed that a language should provide both non-short-circuit (evaluate both) and short-circuit evaluations for and and or.

Example (Pascal):

  • Both operands evaluated: and, or
  • Short-circuit evaluated: and_then, or_else

The opinion on short-circuit evaluation has shifted in the last few decades.

The Console.WriteLine question is a result of being an object-oriented programming language. In short, in order to make a function call, it is necessary to specify whether the function is a member of the class (if it is a static method) or a member of an instance (if it is an instance method).

Aside from Console, there are several text outputs that are commonly used in C# programming:

  • System.Diagnostics.Debug
  • System.Diagnostics.Trace

If you look at the Visual Studio project configuration page, you can find that Debug and Trace can be independently enabled or disabled in debug builds.

From a language design point of view, one can argue whether WriteLine should belong to a text output, or to a string. Consider these alternatives:

  • "Hello world\n".WriteTo(Console.Out);
  • Console.WriteLine("Hello world");

The first alternative can be implemented by defining a C# extension method that has a TextWriter as its second argument; the first argument is the string.

Why do such languages become popular? Does C-like syntax lend to the popularity of a programming language?

I will let others answer this part.

It is suffice to say that C-like syntax is not the only factor that determines popularity. Plenty of popular languages, e.g. Python, Ruby etc., do not have C-like syntax.

It is also suffice to say that the business world does not discriminate programming languages on the basis of syntax. Plenty of large corporations use Python, for example.

Why aren't there languages with syntax crossovers from two or more languages, i.e. between a C-like syntax and another non-C-like syntax?

or, alternatively,

Why aren't there languages with configurable syntax normalizations, such that two programmers working on the same source file can choose two different syntax normalizations, and perform on-the-fly syntax conversions whenever the source file is handed over?

I will let others answer this part.

  • You captured it. I wish I could have been able to structure like you have structure your answer. Especially the first two topics you raise while answering. One other interesting point is about the possibility to output text to the console by means of a method belonging to the string class. That really makes sense as well. That's what I was looking for. Aug 6 '16 at 20:15

To answer your direct question: Why didn't C# adopt these four syntactic changes?

As for #4 - they did. In C# 6.0 with using static you can indeed write WriteLine which saves you some typing. So you get your wish granted!

But for the other 3 points - these we not adopted because C# descends from languages with a different style of syntax, and there would be no clear benefit to changing this syntax. Despite what you claim, there is no evidence your suggested syntax is more productive in general.

You can compare with BASIC (and the various derivatives like Visual Basic and VB.Net) which has the features you request:

  • No semicolons, line breaks are used instead
  • Not case sensitive
  • The logical operators are called and and or
  • A print statement.

Python also almost conforms, except it is case sensitive. BASIC was designed for beginners. Python also emerged from an attempt to create a teaching language for beginners, and usability studies were actually used to determine the simplest syntax.

Java and C# has a different style of syntax because they are derived from C++ and C, so it all comes down to C (which in turn was based on B and BCPL). Neither of these languages were intended for beginners or for teaching. They were systems programming languages intended for hard-core developers.

C++ built on C syntax because it started out as an extension of C. Java built on C++ syntax because it started out as an extension of C++. C# copied Java syntax, because they wanted to lure Java and C++ programmers.

That said, there is no proof that BASIC or Python syntax is more productive as you seem to take for granted. They are designed to be easier to learn but this is not the same as more productive in general use by a competent developer. (Note: there is no proof of the opposite either. It is notoriously hard to measure developer productivity and compare it across languages.)

For example or is clearly easier to understand than || for non-programmers which know basic logic. But if you already know the language by heart, I have a hard time believing one should be significantly more productive than the other. The reason C has the shortcut operators && and || is for symmetry with the bitwise operators & and |. VB.Net has both, and calls them Or and OrElse - certainly not simpler or easier to type!

There are many factors which make a language more or less productive and syntax is just a single superficial factor. For example the C-style languages are all statically typed while BASIC/Python are dynamically typed, which is a much deeper difference.

One thing you mention, case insensitivity, definitely does not improve productivity for competent developers. Case sensitivity may be confusing for beginners, but any competent developer would always be consistent in casing for the sake of readability. Never mind the difficulties of case folding when using Unicode characters from various scripts and languages.

  • 1
    Java did very definitely not start out as an extension to C++. In fact, pretty much the only influence C++ had on Java was in what not to do. Java was predominantly based on Objective-C (which is basically C + Smalltalk, and since Java removes almost everything inherited from C except static types, Java is really Objective-C - C + types, which reduces to Smalltalk + types). C++ heavily relies on punctuation characters, e.g. : for inheritance, Java seems much more in the Algol/Pascal/Modula/Oberon tradition with its use of verbose keywords (extends, implements). Aug 6 '16 at 8:43
  • @JörgWMittag: I read somewhere that Java started out as an attempt to simplify C++ called C++-- which turned into Oak which turned into Java. But honestly I cant remember where, so I can't provide a reference. But it is clear that Java inherits a lot of syntax from the C/C++ family, and the surface syntax is much closer to C++ syntax than pascal syntax.
    – JacquesB
    Aug 6 '16 at 8:59
  • @JörgWMittag: To be clear I'm talking about surface syntax. Semantically Java was probably more influenced by Objective C and Smalltalk.
    – JacquesB
    Aug 6 '16 at 9:20
  • 2
    @JörgWMittag: OK, found a reference: tech-insider.org/java/research/1995/07.html Gosling began by extending the C++ compiler. Eventually, however, he realized that even with lots of extras, C++ would not suffice. Thus, Oak was conceived in mid-1991.
    – JacquesB
    Aug 6 '16 at 15:39
  • 1
    All of that makes it highly unlikely that Java is based on C++. Patrick Naughton himself wrote as much in a newsgroup posting: Java Was Strongly Influenced by Objective-C … and not C++ …. I find it interesting that James Gosling actually started out by extending a C++ compiler, I had never heard about that before. Aug 7 '16 at 1:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.