language-design

What compromises Scala made to run on JVM?

Scala is a wonderful language, but I wonder how could be improved if it had it's own runtime? I.e. what design choices were made because of JVM choice? ...

Use of (non) qualified names

If I want to use the name baz defined in package foo|bar|quz, I've several choices: provide fbq as a short name for foo|bar|quz and use fbq|baz use foo|bar|quz|baz import baz from foo|bar|quz|baz and then use baz (or an alias given in the import process) import all public symbols from foo|bar|quz|baz and then use baz For the langua...

Why is there a sizeof... operator in C++0x?

I saw that @GMan implemented a version of sizeof... for variadic templates which (as far as I can tell) is equivalent to the built in sizeof.... Doesn't this go against the second design principle: prefer libraries to language extensions? ...

Interpreted languages: The higher-level the faster?

I have designed around 5 experimental languages and interpreters for them so far, for education, as a hobby and for fun. One thing I noticed: The assembly-like language featuring only subroutines and conditional jumps as structures was much slower than the high-level language featuring if, while and so on. I developed them both simultan...

Why did the C# designers attach three different meanings to the 'using' keyword?

The using keyword has three disparate meanings: type/namespace aliasing namespace import syntactic sugar for ensuring Dispose is called The documentation calls the first two definitions directives (which I'm guessing means they are preprocessing in nature), while the last is a statement. Regardless of the fact that they are distingu...

What are the lengths/limits C preprocessor as a language creation tool? Where can I learn more about these?

In his FAQ @ http://www2.research.att.com/~bs/bs_faq.html#bootstrapping, Bjarne Stroustrup says: To build [Cfront, the first C++ compiler], I first used C to write a "C with Classes"-to-C preprocessor. "C with Classes" was a C dialect that became the immediate ancestor to C++... I then wrote the first version of Cfront i...

C#, weird optimization

Hi, I'm trying to read my compiled C# code. this is my code: using(OleDbCommand insertCommand = new OleDbCommand("...", connection)) { // do super stuff } But! We all know that a using gets translated to this: { OleDbCommand insertCommand = new OleDbCommand("...", connection) try { //do super stuff } ...

What are the benefits of prototypal inheritance over classical?

So I finally stopped dragging my feet all these years and decided to learn JavaScript "properly". One of the most head-scratching elements of the languages design is it's implementation of inheritance. Having experience in Ruby, I was really happy to see closures and dynamic typing; but for the life of me can't figure out what benefits...

Where are the readonly/const in .NET?

In C++ you'll see void func(const T& t) everywhere. However, i havent seen anything similar in .NET. Why? I have notice a nice amount of parameters using struct. But i see no functions with readonly/const. In fact now that i tried it i couldnt use those keywords to make a function that promises to not modify a list being passed in. Is t...

What syntax sugar or language features makes a language hard/tough to parse?

I did some searching and didn't find a question that "directly" answered this question. Anyway the basic gist of this question is I am wondering what "language feature" or "syntax" that makes a language be a major pain to build a parser, syntax highlighting, etc? This might be subjective but I was thinking of like for example the diffe...

Why doesn't Java warn about a == "something"?

This might sound stupid, but why doesn't the Java compiler warn about the expression in the following if statement: String a = "something"; if(a == "something"){ System.out.println("a is equal to something"); }else{ System.out.println("a is not equal to something"); } I realize why the expression is untrue, but AFAIK, a can never ...

Why do some languages not use semicolons and braces?

It is interesting that some languages do not use semicolons and braces, even though their predecessors had them. Personally, it makes me nervous to write code in Python because of this. Semicolons are also missing from Google's GO language, although the lexer uses a rule to insert semicolons automatically as it scans. Why do some lan...

Several C# Language Questions

1) What is int? Is it any different from the struct System.Int32? I understand that the former is a C# alias (typedef or #define equivalant) for the CLR type System.Int32. Is this understanding correct? 2) When we say: IComparable x = 10; Is that like saying: IComparable x = new System.Int32(); But we can't new a struct, right? o...

Where are the new ideas in programming languages?

I've recently been looking into the topic of programming languages and from what I've seen, few to none serious languages try making really "new" things that were not seen before their creation. Why do all more or less successful programming languages since 1980 or so just combine aspects of their predecessors? I just can't believe t...

Why optional parameters must appear at the end of the declaration

In all programming languages supporting optional parameters that I have seen there is a imitation that the optional parameters must appear at the end of the declaration. No required parameters may be included after an optional item. What is the reason for that ? I guess it can be compiler/interpreter requirement. ...

What was the reason to choose the current syntax `import foo.bar.{Baz => _}` to exclude something from import?

I wonder if there is a good reason for this optical mismatch between e. g. pattern matching, which uses a simple case foo => to denote that no action should be taken. Wouldn't it be reasonable to have something like import foo.bar.{Baz => } instead of import foo.bar.{Baz => _} considering that _ is used as an "import everythin...

Suggestions on syntax to express mathematical formula concisely

Hello. I am developing functional domain specific embedded language within C++ to translate formulas into working code as concisely and accurately as possible. I posted a prototype in the comments, it is about two hundred lines long. Right now my language looks something like this (well, actually is going to look like): // implies tw...

Running time assumptions in Ruby

Ruby looks a very cool language. I've started learning it for the past two three days. One thing that appeals me in Ruby is its simplicity. Very clean code is possible. However, the internal implementations of Ruby is not exposed to the outside world. I learnt that Ruby is written in various languages depending on the flavors. The one ...

Immutability after dependency injection, initialization

I'd like to be able to specify that an object's member variables are immutable once the object has been "initialized", which to me means after it has been injected with any dependencies, and has performed any other initialization operations that it can only perform after DI. Are there languages that satisfy my interest - that formalize ...

How can a language be interpreted by itself (like Rubinius)?

I've been programming in Ruby for a while now with just the standard MRI implementation of Ruby, but I've always been curious about the other implementations I hear so much about. I was reading about Rubinius the other day, a Ruby interpreter written in Ruby. I tried looking it up in various places, but I was having a hard time figurin...