language-design

Are preprocessors obsolete in modern languages?

Hello, I'm making a simple compiler for a simple pet language I'm creating and coming from a C background(though I'm writing it in Ruby) I wondered if a preprocessor is necessary. What do you think? Is a "dumb" preprocessor still necessary in modern languages? Would C#'s conditional compilation capabilities be considered a "preprocessor...

Does Python copy value or reference upon object instantiation?

Hi folks, A simple question, perhaps, but I can't quite phrase my Google query to find the answer here. I've had the habit of making copies of objects when I pass them into object constructors, like so: ... def __init__(self, name): self._name = name[:] ... However, when I ran the following test code, it appears to not be necessa...

Why does C# allow abstract class with no abstract members?

The C# spec, section 10.1.1.1, states: An abstract class is permitted (but not required) to contain abstract members. This allows me to create classes like this: public abstract class A { public void Main() { // it's full of logic! } } Or even better: public abstract class A { public virtual void Ma...

Is there a programming language that performs currying when named parameters are omitted?

Many functional programming languages have support for curried parameters. To support currying functions the parameters to the function are essentially a tuple where the last parameter can be omitted making a new function requiring a smaller tuple. I'm thinking of designing a language that always uses records (aka named parameters) for ...

Language features helpful for writing quines (self-printing programs)?

OK, for those who have never encountered the term, a quine is a "self-replicating" computer program. To be more specific, one which - upon execution - produces a copy of its own source code as its only output. The quines can, of course, be developed in many programming languages (but not all); but some languages are obviously more suite...

What are the highest level languages that can be compiled?

What are the highest level languages that can be compiled to executables? When I say compiled to an executable I am not referring to bytecode, but native assembly code like in the C, C++ sense. EDIT: One issue that I'm having is that clients have ssh access to my server in a limit access acount. They need to run some of my scripts but I...

Why must C/C++ string literal declarations be single-line?

Is there any particular reason that multi-line string literals such as the following are not permitted in C++? string script = " Some Formatted String Literal "; I know that multi-line string literals may be created by putting a backslash before each newline. I am writing a programming language (similar to C) and would like ...

James Gosling's explanation of why Java's byte is signed

I was initially surprised that Java decides to specify that byte is signed, with a range from -128..127 (inclusive). I'm under the impression that most 8-bit number representations are unsigned, with a range of 0..255 instead (e.g. IPv4 in dot-decimal notation). So has James Gosling ever been asked to explain why he decided that byte is...

How to implement C++0x raw string literal?

How to define a working set of lexer and parser (exempli gratia: flex and bison) to support the C++0x styled raw string literals? As you may already know, new string literals in C++0x can be expressed in a very flexible way. R"<delim>...<delim>"; - in this code the <delim> can be pretty much everything and also no escape characters...

Why is only one implicit conversion allowed to resolve the parameters to a function in C++?

This works: #include<cstdio> class A{ public: A(int a):var(a){} int var; }; int f(A obj) { return obj.var; } int main() { std::cout<<f(23); // output: 23 return 0; } while this doesn't: #include<cstdio> class A{ public: A(int a, int b):var1(a), var2(b){} int var1, var2; }; int f(A obj) { return (...

Software for creating "Language Diagrams" structures

Hello, In json.org website you can see several diagrams (which I don't know that correct term to describe) that shows the whole valid syntax of the language. For example http://json.org/object.gif How do these diagrams called? What software do you use to create them? Thank you, Maxim. ...

What is the purpose of case sensitivity in languages?

Possible Duplicates: Is there any advantage of being a case-sensitive programming language? Why are many languages case sensitive? Something I have always wondered, is why are languages designed to be case sensitive? My pea brain can't fathom any possible reason why it is helpful. But I'm sure there is one out there. And ...

Identifying frequent formulas in a codebase

My company maintains a domain-specific language that syntactically resembles the Excel formula language. We're considering adding new builtins to the language. One way to do this is to identify verbose commands that are repeatedly used in our codebase. For example, if we see people always write the same 100-character command to trim whit...

Would making 'this' a reference rather than a pointer be better in retrospect?

Possible Duplicate: Why this is a pointer and not a reference? Is there any reason for this in C++ to be a pointer rather than a reference other than historical language decision? It feels a tad strange given that e.g. copy constructor or assignment operators both accept reference to "that", not a pointer. [I honestly couldn...

Why is F#'s type inference so fickle?

The F# compiler appears to perform type inference in a (fairly) strict top-to-bottom, left-to-right fashion. This means you must do things like put all definitions before their use, order of file compilation is significant, and you tend to need to rearrange stuff (via |> or what have you) to avoid having explicit type annotations. How h...

Why did non-von Neumann languages never became mainstream?

Why did non-von Neumann languages never became mainstream? ...

Operator overloading

From language design point of view , What type of practice is supporting operator overloading? What are the pros & cons (if any) ? ...

Why do most programming languages only have binary equality comparison operators?

In natural languages, we would say "some color is a primary color if the color is red, blue, or yellow." In every programming language I've seen, that translates into something like: isPrimaryColor = someColor == "Red" or someColor == "Blue" or someColor == "Yellow" Why isn't there a syntax that more closely matches the English sente...

Which Forth to start porting from?

I'm looking to develop a new Forth system, aimed at making game development easier on one or possibly several retro console platforms. I'm something of a Forth beginner, and need your help deciding which Forth codebase to start porting from. I'm basically looking for the merits / disadvantages of particular Forths vs each other. I've re...

What is typestate?

What does TypeState refer to in respect to language design? I saw it mentioned in some discussions regarding a new language by mozilla called Rust. ...