Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

What feature do you wish that your compiler possessed that it currently doesn't? And why would it make your job easier? Are there any negative impacts to your new feature?

Just keep it a bit realistic and refrain from answers such as "I wish my compiler could read my mind and write the whole program for me!"

share|improve this question

closed as not constructive by Anna Lear Dec 20 '11 at 21:59

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

7  
Obligatory support for do_what_i_want() and do_what_i_want_faster() functions. –  jonescb Jan 14 '11 at 14:12
5  
I certainly would NOT want a "write the whole program for me" feature in a compiler. If that existed I could be replaced by anyone who could type. –  JohnFx Jan 14 '11 at 16:32
1  
@Anna: So when I used to Google, I should actually ask Anna! –  Lukas Eder Jan 14 '11 at 18:08
show 7 more comments

25 Answers

This question es very easy to confuse "What do you wish your compiler could do for you (that it currently doesn't)?" with "What do you wish your programming language could do for you (that it currently doesn't)? (and supported by a compiler)"...

share|improve this answer
add comment

I write embedded systems in C. I wish the compiler would output an annotated assembly listing including the time/clocks required for the entire statement.

The gcc -S flag is nice and all but I sometimes need native instructions and a good guestimate of the time for a statement.

For example:

if( foo[idx]->flag ) {
  # 35 instructions; 0.85usec

  do_something(foo[idx]);
  # 12 instructions; 0.23usec

etc. (Numbers for entertainment purposes only.)

share|improve this answer
3  
Unless your hardware is really primative, that just doesn't work well. Modern machines do so much stuff out-of-order, trying to extract as much instruction level parallelism as possible, that the mental model that time equals the sum of difficulties of asked for actions isn't even remotely close. –  Omega Centauri Jan 14 '11 at 19:18
show 2 more comments

A really nice feature would be scriptable style guideline enforcing. For example, if I had an opening bracket on the same line as the if statement, and there was no space between the closing parenthesis and opening bracket, give a warning (it really gets on my nerves). I don't mind a variety in the styles various programmers use, but at least let your code breath a little :P

share|improve this answer
add comment

I want my compiler to come with a separate documented framework that it uses to do parsing. Then my IDE could understand the code in the same way my compiler (at least the parsing portion of it) understands it. Basically if a feature was added to the language, and the compiler was extended to support this feature, my IDE would automatically understand it (I suppose it depends on the feature).

I guess XCode 4 does something like this with LLVM, so maybe my compiler does support it. It would be nice if more IDEs used it though.

share|improve this answer
show 1 more comment

I wish that it automatically made me a coffee while it compiles if it expects to take more than 5 minutes.

share|improve this answer
show 1 more comment

Extended Static Checking

I wish my compiler could check pre- and post-conditions and other invariants at compile time ... that would help me to better document my code and, of course, to find bugs!

See the following attempts to do this: ESC/Java, Spec# and Whiley

share|improve this answer
show 2 more comments

Hyperlinks(or maybe distinct error codes), along with messages, with each type of error to a forum that tells you how to solve it.

Reason I say this is because i have been facing trouble with svn, it gives one error message which may have several possible causes and I can't figure out which one was the actual cause. (I know svn is not a compiler, btw).

share|improve this answer
show 1 more comment

Hard-coded "treat warnings as errors" :)

share|improve this answer
add comment

Automated Distributed build.

I used to work for a company that had a build system that utilized all idle machines in the build processes. When you came back from lunch your machine would be sluggish for about 10 seconds as it finished off the current compilation.

But it paid off when you were building as it not only used your machine but any machine that was currently idle chipped into to build a bit of your code.

share|improve this answer
show 1 more comment

More static analysis along with special pragmas or comments to inform it of your intentions. Help me prove the code does what I intend!

This would be especially useful with multithreaded programming to prove that locks are always taken before shared memory is used.

share|improve this answer
add comment

I want of the compiler the ability to replace any function in the standard libraries with my own version. I'm looking at you .NET.

I want Interfaces that contain code & data.

share|improve this answer
show 4 more comments

I know this is the linker's doing, but I wish the compiler would tell me if I've got the file it's trying to generate locked by the operating system so it doesn't go through the business of trying to compile something that it can never finish.

share|improve this answer
show 1 more comment

Multi-Threading

Oh lord do I wish MSBuild utilized all my cores to compile my project in a timely fashion. :(

Long builds + frequent builds = a lot of wasted time. But at least it gives me the time to answer questions like this. :p

share|improve this answer
show 4 more comments

I wish my linker wouldn't use so much memory, I have to force my window manager into swap space to compile large programs.

share|improve this answer
1  
Most people who can't afford decent computers also don't compile and link their own applications. It's great to test on a low-end machine, but development should normally be done on high-end machines. –  David Thornley Jan 18 '11 at 18:43
show 3 more comments

Send an SMS to my phone when compilation finishes.

Be aware of the full build processes so that in can give an ETA of completion.
Do I have time for a coffee or lunch?

share|improve this answer
3  
@Lukas Eder: OK. simple incremental build should be quick (but a full build/test cycle can take a while). Especially when you are merging branches. –  Loki Astari Jan 14 '11 at 19:30
7  
make something && mail -s "Build complete" [phone number]@[carrier gateway] should do the trick. Just look up what the "SMS gateway" is for your cell carrier, and any emails sent to that address will get sent to your phone by SMS. –  Austin Hyde Jan 15 '11 at 5:48
show 3 more comments

Less cryptic error messages when using C++ templates.

share|improve this answer
1  
This<std::is<std::one<std::of<std::my<std::c++<std::pet, std::peeves> > > > > > –  Aphex Jan 14 '11 at 22:45
show 1 more comment

Since I'm using Visual Studio 2008 for C++:

Reliable IntelliSense.

share|improve this answer
3  
"Visual Studio 2008 for C++" ... you poor thing. Unfortunatley IntelliSense for C++ in VS2010 is hardly any good either. –  Andrew Arnold Jan 14 '11 at 20:13
1  
Take a look at Visual AssistX: wholetomato.com –  JBRWilkinson Jan 15 '11 at 11:38
add comment

I would like a "How do I wrap X to get Y" in Java. Starting with e.g. a FileInputStream ending up in a BufferedReader would be very nice to have suggested to replace with

new BufferedReader(new InputStreamReader(new FileInputStream(...)))

Takes a while to figure out on your own while learning.

share|improve this answer
1  
Why not use commons.apache.org/io directly? –  Lukas Eder Jan 14 '11 at 19:17
show 3 more comments

I wish the Java compiler would recognise SQL statements similar as the C# compiler does with Linq! I don't know how Linq works in detail, but I think it must be awesome if used correctly!

Actually, I would like it to be able to accept any DSL definition, such that I can write my own language extensions without the need of creating a new compiler with the javacc (which I have not tried yet).

share|improve this answer
1  
@Jeremy, manually encode to en.wikipedia.org/wiki/Pro%2AC –  user1249 Jan 15 '11 at 9:16
show 5 more comments

It's really a language change that I'm asking for here, but I wish C#'s foreach were compile-time checked (and able to make inferences about what non-generic IEnumerables return). (Better still, of course, would be to ditch non-generic IEnumerable entirely).

share|improve this answer
add comment

Dead code finding

I would love that my compiler find any piece of code/class/functions that is not used, so that I can remove it.

I hate dead code. Deleting unused lines of code is one of my greatest pleasures in programming.

share|improve this answer
3  
It can be done with a bit of ZEN and any version control system. Check out the code history. If the code has never been touched for 5 years and looks creepy and buggy and you don't want to touch it either, why, chances are high it's actually not used. This is similar to dust (=dead code) in a hallway (=execution flow). Dust only assembles at the sides of the hallway, where no one (=thread) is walking. :) –  Lukas Eder Jan 14 '11 at 15:43
3  
This is something I really like of the Go compiler. If you don't use a variable it forces you to remove it. –  OscarRyz Jan 14 '11 at 15:57
7  
@Lukas: We didn't touch the function 'main' since we the project started and it has weird exception-handly hacky code in it. Should I delete it, then? How often code is modified is no indicator of use - you need code coverage for that. –  JBRWilkinson Jan 15 '11 at 11:33
show 4 more comments

Fix obvious coding typos.

Such as:

  1. '.' when I meant '->' and there's no operator overloading, so the compiler knows what I mean.

  2. Incorrect casing - 'Class' when I meant 'class', but it's not obvious in my 8pt font on my 2560x2048 display.

  3. Simpel lettre trasnposition - 'clsas' when I meant 'class'..

Clearly there are tools like ReSharper that can already do this, but they only work as-you-type and only for certain environments.

The compiler has all the information it needs to determine what I meant and could make an educated guess whether I want to go with the suggestion or not.

share|improve this answer
6  
+1 as long as it 1) reports all such modifications and 2) lets you turn it off! –  Michael K Jan 14 '11 at 14:39
11  
Is this something the IDE should do rather than the compiler? You want the source to be right surely rather than the compiler forgiving. –  Jon Hopkins Jan 14 '11 at 15:20
2  
@JBRWilkinson: when a word is mispelled, Clang (C/C++/Objective-C) suggests a correction (based on levenshtein distance to names lexically in scope) and parse the rest of the code with this "correction" instead of spewing an error on each line the mispelled word appears :) –  Matthieu M. Jan 14 '11 at 15:36
show 4 more comments

Compiler scripting.

I mean :

  • setup a scripting language engine in the compiler (different or not from the compiled language)
  • after having parsed and interpreted the compilation unit, when the type graphs or something are available, before applying optimization and conversion to final form, call a compilation-unit-specific script (if provided by the programmer)
  • the type information and call graph (informations about the compiled code) are provided to the script and the script can manipulate types and branches as values.
  • once the script have finished running, retrieve the potentially modified code informations and continue the compilation process.

In fact C++ template meta-programming is almost that, compile-time language to manipulate types (and potentially branching). But it's not really like having a specific scripting language to do that and allowing to use that scripting language to any language the compiler can work with. And it lacks a type-type system (see Concepts). And it's syntactically hardcore.

I think that would be awesome. However I'm not a compiler implementor so maybe I don't see some "obvious" problem with this idea.

share|improve this answer
2  
What you're asking for sounds a lot like the Common Lisp macro system. –  Larry Coleman Jan 14 '11 at 14:38
1  
@Klaim: The CL macro system depends partly on the nearly syntax-free nature of Lisp to make it easy to use. (You're essentially writing in the syntax trees I studied in compiler class.) It would be harder to make it language-agnostic. –  David Thornley Jan 14 '11 at 16:15
1  
The point would be to have languages whose only purpose would be to work on types and execution graphs. That would complete the control of the programmer. I feel C++ template meta-programming like if it was some convoluted way to script the classic layer of programming. I think it would be good to have a specific tool to adress meta programming without having the noise of metaprog inside the programming language itself. –  Klaim Jan 15 '11 at 0:00
show 5 more comments

I have the pleasure of working on a system with a compiler not as complete as those you find with C/C++/C# or in fact, as complete as almost all other compilers.

What it does not do, is any form of optimisation.

Although I derive a pleasure of sort in working out new ways to optimise code and have even wrote a pre-processor to handle some common cases, I dearly wish it would just to it for me.


Primary reason being, we have large batch processes that run every night, as well as even larger day long jobs at every end of month. My hand done optimisations generally result in anywhere between 10-200% improvements. Factor that in to process that take more then 1 day to run and you have meaningful improvements. With a code base > 1M LoC spread over 3000+ programs; it's a task I cannot do in an effective manner.

Give me a supported compiler that does it however and we can simply recompile everything!

And life would be good.

share|improve this answer
1  
What language/compiler is it? –  Jon Jan 14 '11 at 21:35
show 2 more comments

I would love to see better error reporting in compilers. A lot of compilers are very vague about compiling errors, or report the wrong error (i.e. the actual error might cause the compiler to fail at a different line).

To further this, it would be great if compilers could make suggestions to you code... e.g. there was an error on line ##, did you mean ***

share|improve this answer
4  
Or even better, include code review as well as warnings and errors 'Snide Compiler Remark: Why in the world did you do it like that???' ;) –  Dan McGrath Jan 14 '11 at 13:59
6  
I believe most of them to be vague on this is because it is very difficult to give accurate error reports. For instance, if you miss a { on a if line somewhere in the middle, and you're choosing to place brackets on a new line, how would the compiler know that it was exactly there that you missed the bracket? It's just very difficult to guess unless you understand what the code's suppose to do. And if the compiler can understand that then why doesn't it just do the whole job of writing it in the first place. ^^ –  gablin Jan 14 '11 at 14:00
6  
For C and C++, clang does extremely good error reporting (that's one of its goals, and they've really put a lot of effort into it). This includes suggestions for how to fix simple errors. –  John Bartholomew Jan 14 '11 at 14:06
7  
Good error reporting is very important; we actually try to avoid "prescriptive" error reporting because if the prescription is wrong 1% of the time, that is potentially thousands of people getting bad advice. See blogs.msdn.com/b/ericlippert/archive/2006/07/07/659259.aspx for more thoughts on the matter. –  Eric Lippert Jan 14 '11 at 15:23
5  
@Stephen, "It looks like you are writing a program..." –  user1249 Jan 15 '11 at 9:13
show 4 more comments

Not the answer you're looking for? Browse other questions tagged or ask your own question.