Questions involving the design and structure of programming languages.

learn more… | top users | synonyms

88
votes
14answers
8k views

Why do most programming languages only support returning a single value from a function?

Is there a reason why functions in most(?) programming languages are designed to support any number of input parameters but only one return value? In most languages, it is possible to "work around" ...
77
votes
20answers
12k views

Are null references really a bad thing?

I've heard it said that the inclusion of null references in programming languages is the "billion dollar mistake". But why? Sure, they can cause NullReferenceExceptions, but so what? Any element of ...
62
votes
8answers
14k views

How were some language communities (eg, Ruby and Python) able to prevent fragmentation while others (eg, Lisp or ML) were not?

The term "Lisp" (or "Lisp-like") is an umbrella for lots of different languages, such as Common Lisp, Scheme, and Arc. There is similar fragmentation in other language communities, like in ML. ...
61
votes
14answers
12k views

Why is 0 false?

This question may sound dumb, but why does 0 evaluates to false and any other [integer] value to true is most of programming languages? String comparison Since the question seems a little bit too ...
54
votes
11answers
5k views

I've been told that Exceptions should only be used in exceptional cases. How do I know if my case is exceptional?

My specific case here is that the user can pass in a string into the application, the application parses it and assigns it to structured objects. Sometimes the user may type in something invalid. ...
52
votes
12answers
5k views

Did the developers of Java consciously abandon RAII?

As a long-time C# programmer, I have recently come to learn more about the advantages of Resource Acquisition Is Initialization (RAII). In particular, I have discovered that the C# idiom: using (var ...
49
votes
9answers
36k views

Why use partial classes?

In my understanding, the partial keyword does nothing but allow a class to be split between several source files. Is there any reason to do this other than for code organization? I've seen it used for ...
44
votes
5answers
5k views

Why do old programming languages continue to be revised?

This question is not, "Why do people still use old programming languages?" I understand that quite well. In fact the two programming languages I know best are C and Scheme, both of which date back to ...
43
votes
9answers
4k views

Why don't languages include implication as a logical operator?

It might be a strange question, but why there is no implication as a logical operator in many languages (Java, C, C++, Python Haskell - although as last one have user defined operators its trivial to ...
43
votes
9answers
14k views

Why is String immutable in Java?

I couldn't understand the reason of it. I always use String class like other developers, but when I modify the value of it, I need to create new instance of String. What might be the reason of ...
42
votes
7answers
3k views

Why is the finalize method included in Java?

According to this post, we should never rely on the finalize method to be called. So why did Java include it in the programming language at all? It seems like a terrible decision to include in any ...
40
votes
6answers
7k views

Why was C# made with “new” and “virtual+override” keywords unlike Java?

In Java there are no virtual, new, override keywords for method definition. So the working of a method is easy to understand. Cause if DerivedClass extends BaseClass and has a method with same name ...
40
votes
12answers
9k views

Should I use a parser generator or should I roll my own custom lexer and parser code?

What specific advantages and disadvantages of each way to working on a programming language grammar? Why/When should I roll my own? Why/When should I use a generator?
38
votes
15answers
3k views

How would you design a programming language? [closed]

If you were to design a programming language, how would you do it? What features would you put in? What would you leave out? Statically or dynamically typed? Strongly or weakly typed? Compiled or ...
38
votes
15answers
10k views

How have languages influenced CPU design? [closed]

We are often told that the hardware doesn't care what language a program is written in as it only sees the compiled binary code, however this is not the whole truth. For example, consider the humble ...
37
votes
22answers
3k views

Has whitespace in identifiers ever been idiomatic? [closed]

C# style suggests using CamelCase in identifiers to delimit words. Lisp tradition suggests using-dashes-instead. Has there ever existed a programming language where using spaces in identifiers was ...
37
votes
12answers
3k views

Why does the assignment operator assign to the left-hand side?

I began teaching a friend programming just recently (we're using Python), and when we began discussing variable creation and the assignment operator, she asked why the value on the right is assigned ...
37
votes
2answers
2k views

Why do bitwise operators have lower priority than comparisons?

Could someone explain the rationale, why in a bunch of most popular languages (see note below) comparison operators (==, !=, <, >, <=, >=) have higher priority than bitwise operators (&, |, ...
35
votes
26answers
2k views

What do you wish language designers paid attention to? [closed]

The purpose of this question is not to assemble a laundry list of programming language features that you can't live without, or wish was in your main language of choice. The purpose of this question ...
35
votes
12answers
4k views

Why do most programming languages have special keyword or syntax for declaring functions? [closed]

Most programming languages (both dynamically and statically typed languages) have special keyword and/or syntax that looks much different than declaring variables for declaring functions. I see ...
33
votes
3answers
1k views

Does Java development typically involve more subclassing than C#/.NET?

I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly ...
32
votes
2answers
6k views

Why is 'void' not allowed as a generic type in C#

What were the design decisions that argued in favour of void not being constructable and not being allowed as a generic type? After all it is just a special empty struct and would have avoided the ...
31
votes
10answers
7k views

If null is bad, why do modern languages implement it? [closed]

I'm sure designers of languages like Java or C# knew issues related to existence of null references (see Are null references really a bad thing?). Also implementing an option type isn't really much ...
28
votes
4answers
3k views

Why doesn't C# have local scope in case blocks?

I was writing this code: private static Expression<Func<Binding, bool>> ToExpression(BindingCriterion criterion) { switch (criterion.ChangeAction) { case ...
27
votes
7answers
2k views

Disadvantages of scoped-based memory management

I really like scope-based memory management (SBMM), or RAII, as it is more commonly (confusingly?) referred to by the C++ community. As far as I know, except for C++ (and C), there's no other ...
27
votes
4answers
1k views

How do programming languages define functions?

How do programming languages define and save functions/methods? I am creating an interpreted programming language in Ruby, and I am trying to figure out how to implement function declaration. My ...
26
votes
15answers
2k views

Is there a language out there in which parameters are placed inside method name?

in JavaScript: function getTopCustomersOfTheYear(howManyCustomers, whichYear) { // Some code here. } getTopCustomersOfTheYear(50, 2010); in C#: public List<Customer> ...
26
votes
8answers
1k views

Why is there such limited support for Design by Contract in most modern programming languages?

I recently discovered Design by Contract (DbC) and I find it an extremely interesting way to write code. Among other things, it would seem to offer: Better documentation. Since the contract is the ...
25
votes
7answers
3k views

Why are so many languages passed by value?

Even languages where you have explicit pointer manipulation like C it's always passed by value (you can pass them by reference but that's not the default behavior). What is the benefit of this, why ...
25
votes
3answers
8k views

How fast can Go go?

Go is one of the few languages that are supposed to run 'close to the metal', i. e. it's compiled, statically typed and executes code natively, without a VM. This should give it a speed advantage over ...
25
votes
6answers
2k views

Why do programming languages allow shadowing/hiding of variables and functions?

Many of the most popular programming languges (such as C++, Java, Python etc.) have the concept of hiding / shadowing of variables or functions. When I've encountered hiding or shadowing they have ...
25
votes
9answers
1k views

Why most “well-known” imperative/OO languages allow unchecked access to types that can represent a 'nothing' value?

I have been reading about the (un)convenience of having null instead of (for example) Maybe. After reading this article, I am convinced that it would be much better to use Maybe (or something ...
24
votes
4answers
2k views

Why do C# and Java use reference equality as the default for '=='?

I've been pondering for a while why Java and C# (and I'm sure other languages) default to reference equality for ==. In the programming I do (which certainly is only a small subset of programming ...
21
votes
4answers
8k views

Why do iterators in Python raise an exception?

Here's the syntax for iterators in Java (somewhat similar syntax in C#): Iterator it = sequence.iterator(); while (it.hasNext()) { System.out.println(it.next()); } Which makes sense. Here's ...
21
votes
9answers
3k views

Are there any programming languages that follow a minimalist development approach?

I find it that when languages are considered the same as commercial software, there is always a constant need to add new features to justify new releases. Can there be or are there languages where ...
19
votes
3answers
980 views

Why is the rec keyword needed in F#?

In F# it is necessary to use the rec keyword. In Haskell there is no need to explicitly tell if a given function is recursive or not. Given the role of recursion in functional programming, the F# ...
18
votes
16answers
2k views

Why aren't databases integrated as a language feature?

Are there any programming languages that have a built-in database as a first-class language feature rather than connecting to an external SQL (or other) database? What would be the drawbacks and ...
18
votes
13answers
1k views

Should data structures be integrated into the language (as in Python) or be provided in the standard library (as in Java)?

In Python, and most likely many other programming languages, common data structures can be found as an integrated part of the core language with their own dedicated syntax. If we put LISP's integrated ...
17
votes
10answers
8k views

What do Java developers think of Scala? [closed]

I've noted that IDE support is nowhere near as good, but the language itself supports functional programming idioms much more cleanly.
16
votes
16answers
6k views

What can be done to programming languages to avoid floating point pitfalls?

The misunderstanding of floating point arithmetic and its short-comings is a major cause of surprise and confusion in programming (consider the number of questions on Stack Overflow pertaining to ...
16
votes
5answers
2k views

Why is studying an lisp interpreter in lisp so important?

I have seen many CS curriculums and learning suggestions for new programmers that call for the aspiring programmer to study a lisp interpreter that is specifically written in lisp. All these sites ...
16
votes
3answers
1k views

Java and .NET: Why different sorting algorithms are used by default?

Just wondering why Java and .NET Framework uses different sorting algorithm by default. In Java Array.Sort() uses Merge Sort algorithm by default and as Wikipedia.com says: In Java, the ...
15
votes
8answers
2k views

Why is C++ still “hybrid”

On a related question, it has been clarified why C++ is not compatible with C in many aspects. However C++ is still a "hybrid"* language. And unfortunately, many programmers still consider C++ as a "C ...
15
votes
5answers
14k views

Why is Python slower than Java but faster than PHP [closed]

I have many times seen various benchmarks that show how a bunch of languages perform on a given task. Always these benchmarks reveal that Python is slower then Java and faster than PHP. And I wonder ...
15
votes
1answer
362 views

Does Groovy follow Tennent's Correspondence Principle?

Here's an interesting discussion of Tennent's Correspondence Principle, and a brief description from Neal Gafter: The principle dictates that an expression or statement, when wrapped in a closure ...
15
votes
2answers
2k views

In hindsight, is basing XAML on XML a mistake or a good approach?

XAML is essentially a subset of XML. One of the main benefits of basing XAML on XML is said to be that it can be parsed with existing tools. And it can, to a large degree, although the (syntactically ...
14
votes
8answers
4k views

Why is x=x++ undefined?

It's undefined because the it modifies x twice between sequence points. The standard says it's undefined, therefore it's undefined. That much I know. But why? My understanding is that forbidding ...
14
votes
9answers
3k views

Career advice: PhD in theory of programming languages [closed]

I'm very interested in the theories of programming languages and going to apply a PhD in this topic, but I want to know more about the career after the graduate education. besides being a professor, ...
14
votes
3answers
3k views

Why null pointer instead of class cast?

In Java: int count = (Integer) null; throws a java.lang.NullPointerException. Why doesn't this throw a Class Cast Exception for ease in programmer understanding? Why was this exception chosen ...
13
votes
18answers
3k views

What do you think was a poor design choice in Java? [closed]

Java has been one of the most (the most?) popular programming languages till this day, but this also brought controversy as well. A lot of people now like to bash Java simply because "it's slow", or ...