Favorite Language/Editor Features
(Originally posted on the TopCoder forums)

What are your favorite language or editor features, or what would you love to be able to use?

Some of my favorites are closures, dynamic typing, mix-ins, and functions as first order objects. Originally these were just neat features, but I've found myself using them as the best way to express my ideas in code, even in a contest situation. Actually, C#'s anonymous delegates are the reason I use it in contests, despite generics being quite a bit weaker than templates (superficially they seemed as powerful, but as a scientist the first thing I would want to do is code numerical routines in a generic fashion, and guess what -- you can't even ensure that a certain class can use regular operators. This really bugs me.)

I'll also admit to being swayed by Paul Graham's Essays, and I'd love to try out some of the interesting macro hacks that he speaks of, but so far I haven't had many opportunities to do so.

There are a few dream features I'd love to use, even though I'm not sure if they'd be altogether useful. I've just never seen them before, and I figure that language/editor design is something fun enough that I'd like to throw them out there to see what people have to say.

There's a pattern running through most of these requests, namely that programming languages seemed to have evolved and entrenched themselves at a time when terminal capabilities enforced a text-only approach to programming. Now we have real-time 3D games producing life-like imagery, but for some reason, programming has only incorporated such features into a layer on top of the languages (like the facilities in ReSharper, which has made my programming much more enjoyable). I want to know how much farther you can push things.

1. Support for different fonts and symbols, native to the code, and extremely accessible to the editor.

This might just be my background in math, but I'd love to declare my variables using Greek letters, declare a function using a big beautiful, curly, math blackboard font F, write case statements using a curly brace { and conditionals on the right side, access array fields with subscript notation -- or tensors using super/subscript notation, and have all of that shown to me graphically.

Again, I'm not sure if it's just my background, but when I see people sketching out a program on a blackboard, or on scratch paper, or formatting it for publication, it doesn't look like code, but much more like formulas. They don't use massive variable names -- they declare these once, like in documentation, and then proceed to think using this extremely compressed language, with one letter identifiers and mathematical notation. I don't know why languages haven't done this yet. (Edit: actually this might be a good jumping off point. Scoped aliases, which would work like c-macros, not references, but they'd be scoped)

2. Support for mathematical notation like summation (the Sigma symbol), or products, or set operations, and so forth, in the code. I also think a facility to distinguish between enumerable, comparable, and hashable objects and data structures might be a win, but it seems quite heavy-weight.

3. Easy and straightforward access to random numbers and characters within a range, in the code. It's no secret that random numbers are useful for a wide range of problems. They're so useful that it seems silly that every time I want one, just any old random number, that I must declare a randomization object, then type Rand.Next(0,100) or whatever. Why can't I write ~(0,100) or something?

4. A graphical representation of state machines. Over and over again, state machines seem to drastically simplify a large number of otherwise difficult problems. We can work these out on paper, but then we can't ship them with the code. Or we can use some external program to draw things for us, and then ship the doc with the code, hoping that people will read it, and not let it get out of sync. Why not have simple facilities for writing or detecting state machines, and then graphical representations of them? With facilities like Yield, Iterators, and object wide booleans, we're halfway there.

5. Interactive compilation. I don't just mean like a regular interpreter, I mean something more like when in Mathematica or Maple, you type in a command, hit the enter button, and it produces something that the program compiles down to. "What's the derivative of some long expression?" Write it, take the derivative, and it tells me. I want to be able to ask, "What code is produced when I pass this closure to this function?" Write it, hit enter, and it should be able to say.

Do you guys have any other dream features? Anything so good that it would compel you to try a new language? Why?