language-design

unique_ptr - major improvement?

In actual C++ standard creating collections satisfying following rules is hard if not impossible: exception safety, cheap internal operations (in actual STL containers: the operations are copies), automatic memory management. To satisfy (1) a collection can't store raw pointers. To satisfy (2) a collection must store raw pointers. To...

Why don't popular programming languages use some other character to delimit strings?

Every programming language I know (Perl, Javascript, PHP, Python, ASP, ActionScript, Commodore Basic) uses single and double quotes to delimit strings. This creates the ongoing situation of having to go to great lengths to treat quotes correctly, since the quote is extremely common in the contents of strings. Why do programming languag...

Why doesn't deferred execution cache iterative values?

Take the code below, adapted from this question: //Borrowed from another question because its a simpler example of what happened to me. IEnumerable<char> query = "Not what you might expect"; foreach(char vowel in "aeiou") { query = query.Where(c => c != vowel); } foreach (char Output in query) { System.Out.WriteLine(Output); } ...

Programming Language Properties that facilitate refactoring?

What are common traits/properties of programming languages that facilitate (simplify) the development of widely automated source code analysis and re-engineering (transformation) tools? I am mostly thinking in terms of programming language features that make it easier to develop static analysis and refactoring tools (i.e. compare Java v...

C#: No implict conversion from Class<Child> to Class<Base>

Following snippet wouldn't compile. With following error: Cannot implicitly convert type 'Container<ChildClass>' to 'Container<BaseClass>' class BaseClass {} class ChildClass : BaseClass {} class Container<T> where T : BaseClass {} class Program { static void Main() { // why doesn't this work? Container<BaseClas...

Is there a C++ styled language without C trappings?

The main reason to use C++ over a managed language these days is to gain the benefits C++ brings to the table. One of the pillars of C++ is "you don't pay for what you don't need". It can be argued though that sometimes you don't want to pay for backward compatibility with C. Many of the odd quirks of C++ can be attributed to this backwa...

Why does the is keyword require a non-null expression?

The MSDN documentation for the is keyword says: expression is not null Why? If MethodThatReturnsNull() is type were called shouldn't that return false since null certainly isn't that type? ...

Java compilers or JVM languages that support goto?

Is there a java compiler flag that allows me to use goto as a valid construct? If not, are there any third-party java compilers that supports goto? If not, are there any other languages that support goto while at the same time can easily call methods written in Java? The reason is I'm making a language that is implemented in Java. Gotos...

How should Chomsky's Hierarchy and Turing Machines influence language design?

I'm currently studying for a discrete mathematics test in which we are learning Chomsky's hierarchy and the type of automatas that recognize each level of the hierarchy. I'm being taught that most computer languages fall within "level 2 and 1" of the hierarchy, but not precisely how. My questions are: What features belong to each lev...

Why is Multiple Inheritance not allowed in Java or C#?

I know that multiple inheritance is not allowed in Java and C#. Many books just say, multiple inheritance is not allowed. But it can be implemented by using interfaces. Nothing is discussed about why it is not allowed. Can anybody tell me precisely why it is not allowed? ...

What is your ideal calling convention for methods?

What is your ideal calling convention for methods? If you could just throw away everything you don't like about your current language(s) and start over, how would you do it? ...

Chained invocation in Java 7?

I was just reading a Java7 preview presentation (pdf) and there was a slide on Chained Invocation. Here is the example used in the slide: // Construction with setters DrinkBuilder margarita = new DrinkBuilder(); margarita.add(“tequila”); margarita.add(“orange liqueur”); margarita.add(“lime juice”); margarita.withRocks(); margarita.withS...

How does a stackless language work?

I've heard of stackless languages. However I don't have any idea how such a language would be implemented. Can someone explain? ...

Why differentiate between methods that return a value and methods that don't?

Why do some languages differentiate between methods that return a value and methods that don't? i.e. in Oracle's PL/SQL, where the primary difference between a function and a procedure is that the function must return a value, and the procedure must not. Likewise for languages that don't, why not? EDIT: I have found a related questi...

What does DIM stand for in Visual Basic and BASIC?

What does DIM stand for in Visual Basic? ...

What does void mean in C, C++, and C#?

Looking to get the fundamentals on where the term VOID comes from and why it would be called void. The intention of the question is to assist someone who has no C experience and is suddenly looking at a C-based codebase. ...

Interface/Superclass for Collections/Containers in c++

I'm coming from the Java world and are building a small c++ program at the moment. I have an object that does some work and then returns the result of the work as a list. Now a day later i changed the behavior of the object to save the results in a set to avoid duplicates in the container. But I can't simply return the set because I us...

What kind of language should I design for a particle engine scriptable engine?

I was wondering which kind of expressiveness fits a language used to generate particle effects.. Supposing to want an engine as flexible as possible what kind of 'features' should it have? (in addition to trivial ones like color, position, velocity, acceleration) ...

Does c# have any statements which don't follow left to right evaluation order?

An idle question on language design, see "Does C# have a right hand if like Perl". For example, in recent C family languages z = foo ( a, b, c ); a is evaluated, then b, then c, so left-to-right. z = a ? b : c; a is evaluated, then either b or c, so left-to-right order. In Python, you write a conditional expression as z = b if ...

If you are a language designer, how would you make ignoring parameters more succint for lambdas?

Based on this, how would you make ignoring parameters more succint? var m = menuStrip.Items.Add("Hello", null, delegate { MessageBox.Show("Como Esta Mundo"); }); I'm thinking along the lines of: var m = menuStrip.Items.Add("Hello", null, ==> MessageBox.Show("Como Esta Mundo") ); var m = menuStrip.Items.Add("Hello", null, ? => Message...