250

For languages that use first-class functions, its quite common that the syntax of referring to a function is: a = object.functionName while the act of calling that function is: b = object.functionName() a in the above example would be reference to the above function (and you could call it by doing a()), while b would contain the return value of the ...


240

The real answer is XML has an L in the name because a guy named Raymond Lorie was among the designers of the first "markup language" at IBM in the 1970'ies. The developers had to find a name for the language so they chose GML because it was the initials of the three developers (Goldfarb, Mosher and Lorie). They then created the backronym Generalized Markup ...


180

Because it is a language. A markup language, not a programming language. Notice that natural human languages like English and Spanish don't "do" anything either. In fact, technically C++ and Java and the like don't "do" anything until they're fed into a compiler and the output gets executed. Doing stuff and being a language are largely orthogonal to each ...


121

I'm sure designers of languages like Java or C# knew issues related to existence of null references Of course. Also implementing an option type isn't really much more complex than null references. I beg to differ! The design considerations that went into nullable value types in C# 2 were complex, controversial and difficult. They took the design teams ...


102

Let Σ be a non-empty, finite set of symbols, called an alphabet. Then Σ* is the countable infinite set of finite words that can be formed by concatenating zero or more symbols from Σ. Any well-defined subset L ⊆ Σ* is a language. Let's apply this to XML. Its alphabet is the Unicode character set U, which is non-empty and ...


102

Consider the following. var [Example Number] = 5; [Example Number] = [Example Number] + 5; print([Example Number]); int[] [Examples Array] = new int[25]; [Examples Array][[Example Number]] = [Example Number] Compare it with the more traditional example: var ExampleNumber = 5; ExampleNumber = ExampleNumber + 5; print(ExampleNumber); int[] ...


101

0 is false because they’re both zero elements in common semirings. Even though they are distinct data types, it makes intuitive sense to convert between them because they belong to isomorphic algebraic structures. 0 is the identity for addition and zero for multiplication. This is true for integers and rationals, but not IEEE-754 floating-point numbers: 0.0 ...


97

Disclaimer: Since I don't know any language designers personally, any answer I give you will be speculative. From Tony Hoare himself: I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal ...


94

It was done because it's the correct thing to do. The fact is that allowing all methods to be overridden is wrong; it leads to the fragile base class problem, where you have no way of telling if a change to the base class will break subclasses. Therefore you must either blacklist the methods that shouldn't be overridden or whitelist the ones that are allowed ...


88

Exceptions were invented to help make error handling easier with less code clutter. You should use them in cases when they make error handling easier with less code clutter. This "exceptions only for exceptional circumstances" business stems from a time when exception handling was deemed an unacceptable performance hit. That's no longer the case in the ...


88

Since you asked why C# did it this way, it's best to ask the C# creators. Anders Hejlsberg, the lead architect for C#, answered why they chose not to go with virtual by default (as in Java) in an interview, pertinent snippets are below. Keep in mind that Java has virtual by default with the final keyword to mark a method as non-virtual. Still two concepts ...


88

“nth-generation language” is a buzzword. It is a marketing term. There is no universally accepted definition of what exactly defines the “nth generation” for n > 2. Some people categorize “scripting” languages such as Perl or Python as 4GLs because they are much more high-level than C, while others think the defining characteristics of 4GLs is that they're ...


85

There are 3 reasons for this: The cost of checking for overflows (for every single arithmetic operation) at run-time is excessive. The complexity of proving that an overflow check can be omitted at compile-time is excessive. In some cases (e.g. CRC calculations, big number libraries, etc) "wrap on overflow" is more convenient for programmers.


77

Ruby and Python both have benevolent dictators at their helm. They are languages deeply rooted in pragmatic concerns. Those are probably the most significant factors inhibiting fragmentation. Lisp and ML, on the other hand, are more like "design by committee" languages, conceived in academia, for theoretical purposes. Lisp was originally designed by ...


74

FORTRAN compilers ignored spaces so: result = value * factor r e s u l t = val ue * fac tor result=value*factor were identical as far as the compiler was concerned. Some SQL dialects allow embedded spaces in column names but they need to be surrounded by backquotes or some other delimiter before they can be used.


74

Because the math works. FALSE OR TRUE is TRUE, because 0 | 1 is 1. ... insert many other examples here. Traditionally, C programs have conditions like if (someFunctionReturningANumber()) rather than if (someFunctionReturningANumber() != 0) because the concept of zero being equivalent to false is well-understood.


72

When should an exception be thrown? When it comes to code, I think that following explanation is very helpful: An exception is when a member fails to complete the task it is supposed to perform as indicated by its name. (Jeffry Richter, CLR via C#) Why is it helpful? It suggests that it depends on the context when something should be handled as an ...


72

Languages have copied that from C, and for C, Dennis Ritchie explains that initially, in B (and perhaps early C), there was only one form & which depending on the context did a bitwise and or a logical one. Later, each function got its operator: & for the bitwise one and && for for logical one. Then he continues Their tardy introduction ...


69

The fundamental problem with "void" is that it does not mean the same thing as any other return type. "void" means "if this method returns then it returns no value at all." Not null; null is a value. It returns no value whatsoever. This really messes up the type system. A type system is essentially a system for making logical deductions about what ...


66

The problem here isn't that HashSet lacks a Get method, it's that your code makes no sense from the perspective of the HashSet type. That Get method is effectively, "get me this value , please", to which the .NET framework folk would sensibly reply, "eh? You already have that value <confused face />". If you want to store items and then retrieve ...


65

Suppose we're designing a new language and we want Sqrt to be an instance method. So we look at the double class and begin designing. It obviously has no inputs (other than the instance) and returns a double. We write and test the code. Perfection. But taking the square root of an integer is valid, too, and we don't want to force everyone to convert to ...


64

All of the languages you mentioned support type inference, which means the type is an optional part of the declaration in those languages because they're smart enough to fill it in themselves when you provide an initialization expression that has an easily-determined type. That matters because putting the optional parts of an expression farther to the right ...


64

Who says it's a bad tradeoff?! I run all of my production apps with overflow checking enabled. This is a C# compiler option. I actually benchmarked this and I was not able to determine the difference. The cost of accessing the database to generate (non-toy) HTML overshadows the overflow checking costs. I do appreciate the fact that I know that no ...


62

Indeed, Scala allows this, though there is a convention that is followed: if the method has side-effects, parentheses should be used anyway. As a compiler writer, I would find the guaranteed presence of parentheses quite convenient; I would always know that is a method call, and I wouldn't have to build in a bifurcation for the odd case. As a programmer ...


61

It could be useful to have sometimes, no doubt. Several points argue against such an operator: The characters - and > are valuable, both in isolation and combined. Many languages already use them to mean other things. (And many can't use unicode character sets for their syntax.) Implication is very counter-intuitive, even to logic-minded people such as ...


60

Yes, the designers of C# (and, I'm sure, Java) specifically decided against deterministic finalization. I asked Anders Hejlsberg about this multiple times circa 1999-2002. First, the idea of different semantics for an object based on whether its stack- or heap-based is certainly counter to the unifying design goal of both languages, which was to relieve ...


59

It's because it's important for humans to recognize that functions are not just "another named entity". Sometimes it makes sense to manipulate them as such, but they are still able to be recognized at a glance. It doesn't really matter what the computer thinks about the syntax, as an incomprehensible blob of characters is fine for a machine to interpret, ...


59

Is it a bad design for a programming language to allow spaces in identifiers? Short answer: Maybe. Slightly longer answer: Design is the process of identifying and weighting conflicting solutions to complex problems, and making good compromises that meet the needs of stakeholders. There is no "bad design" or "good design" except in the context of the ...


Only top voted, non community-wiki answers of a minimum length are eligible