language-design

Function overloading by return type?

Why don't more mainstream statically typed languages support function/method overloading by return type? I can't think of any that do. It seems no less useful or reasonable than supporting overload by parameter type. How come it's so much less popular? ...

What are practical guidelines for evaluating a language's "Turing Completeness"?

I've read "what-is-turing-complete" and the wikipedia page, but I'm less interested in a formal proof than in the practical implications of being Turing Complete. What I'm actually trying to decide is if the toy language I've just designed could be used as a general-purpose language. I know I can prove it is if I can write a Turing mac...

What are you looking forward to in Java 7?

Java SE 7 is the next major release for Java SE. The details are sketchy, same goes for timelines, although Alex Miller has a nice round-up, and generally a good place to start. Also, here is a summary of Java 7 update by Mark Reinhold, cheif engineer for Java SE. So, what major features scheduled for release are you looking forward t...

Adding a language to the AVM2

Hey there I'm interested in making a language to run on the AVM2 and I'm looking for advice on where to start. I do realize that this is by no means a trivial task, but I would like to give it a try and at the very least learn more about implementing a language along the way. I have messed around with ANTLR and have been reading up on ...

Partial evaluation for parsing

I'm working on a macro system for Python (as discussed here) and one of the things I've been considering are units of measure. Although units of measure could be implemented without macros or via static macros (e.g. defining all your units ahead of time), I'm toying around with the idea of allowing syntax to be extended dynamically at r...

C++0x implementation guesstimates?

The C++0x standard is on its way to being complete. Until now, I've dabbled in C++, but avoided learning it thoroughly because it seems like it's missing a lot of modern features that I've been spoiled by in other languages. However, I'd be very interested in C++0x, which addresses a lot of my complaints. Any guesstimates, after the s...

Do we need a Java++?

It seems to me that, in some ways, Java is where C was a while back. Both are fairly minimalist languages for their time, with relatively clean, simple cores to build on. (I'm referring to the core language here, not the libraries.) Both are/were extremely popular. Both are/were lingua francas, with tons of legacy code. Both are/wer...

Using multiple languages in one project

From discussions I've had about language design, it seems like a lot of people make the argument that there is not and will never be "one true language". The alternative, according to these people, is to be familiar with several languages and to pick the right tool for the job. This makes perfect sense at the level of a whole project o...

Why is short-circuiting not the default behavior in VB?

VB has operators AndAlso and OrElse, that perform short-circuiting logical conjunction. Why is this not the default behavior of And and Or expressions since short-circuiting is useful in every case. Strangely, this is contrary to most languages where && and || perform short-circuiting. ...

Uses for Dynamic Languages

My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing...

Why doesn't Java allow generic subclasses of Throwable?

According to the Java Language Sepecification, 3rd edition: It is a compile-time error if a generic class is a direct or indirect subclass of Throwable. I wish to understand why this decision has been made. What's wrong with generic exceptions? (As far as I know, generics are simply compile-time syntactic sugar, and they will be t...

Elegant ways to return multiple values from a function

It seems like in most mainstream programming languages, returning multiple values from a function is an extremely awkward thing. The typical solutions are to make either a struct or a plain old data class and return that, or to pass at least some of the parameters by reference or pointer instead of returning them. Using references/poin...

What would your own programming language look like?

What would your own (I assume perfect) programming language look like? Give a small example and explain your novel ideas! I'm really interested in the syntax. ...

Namespace Specification In Absence of Ambuguity

Why do some languages, like C++ and Python, require the namespace of an object be specified even when no ambiguity exists? I understand that there are backdoors to this, like using namespace x in C++, or from x import * in Python. However, I can't understand the rationale behind not wanting the language to just "do the right thing" whe...

What is the rationale for the behavior of the 'this' keyword in JavaScript?

I am asking this from a language design point of view. So I am trying to find out What is the rationale for the behavior of this? To what degree the behavior of this was a mistake, or could be improved upon? To clarify why I'm uneasy about this, consider this example: var a = {}; a.f = function(){ return this; } var f = a.f; // f(...

Why is Syntactic Sugar sometimes considered a bad thing?

Syntactic sugar, IMHO, generally makes programs much more readable and easier to understand than coding from a very minimalistic set of primitives. I don't really see a downside to good, well thought out syntactic sugar. Why do some people basically think that syntactic sugar is at best superfluous and at worst something to be avoided?...

What is the purpose of null?

I am in a compilers class and we are tasked with creating our own language, from scratch. Currently our dilemma is whether to include a 'null' type or not. What purpose does null provide? Some of our team is arguing that it is not strictly necessary, while others are pro-null just for the extra flexibility it can provide. Do you have an...

if question

hi , i have little problem with if { string nom; string ou; nom = "1"; if (nom == "1") { nom +=1; ou = nom; } Console.Write(ou); } but i cant print ou value i dont know why ...

Why do compilations take so long?

I am designing a programming language and one of the problems i was thinking was why do programming languages take long to compile. Assumed c++ takes a long time because it needs to parse and compile a header everytime it compiles a file. But i -heard- precompiled headers take as long? i suspect c++ is not the only language that has this...

Immutable Collections Actionscript 3

I've been trying lately to implement some clean coding practices in AS3. One of these has been to not give away references to Arrays from a containing object. The point being that I control addition and removal from one Class and all other users of the Array receive read only version. At the moment that read only version is a ArrayItera...