Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Background compile error highlighting for C++?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Jul 15 2008 :  5:18:20 PM  Show Profile  Reply with Quote
Hello there,

Sometimes the lack of features in today's C++ editors (compared to Java/C#) makes one wonder if people still write programs in this language...


Right now VAX can already highlight misspelled words. Wouldn't it be lovely to extend it to highlight compile errors the same way? And hovering over highlighted item would show a pop up with error text spit by the compiler.

It would probably require VAX to run the C++ compiler over the current source files in the background and then process its output. I don't know how feasible that one is, but I know it would for sure be worth another hundred bucks for me and boost the user experience immensely.

There's a video of emacs using gcc for background syntax error highlighting:
http://www.youtube.com/watch?v=F5Cc2W6PbL8

Thanks for reading,
Gennadiy

Correctness might be a theoretical concept but incorrectness has practical implications.

Edited by - GennadiyKorol on Feb 22 2009 3:10:52 PM

feline
Whole Tomato Software

United Kingdom
19004 Posts

Posted - Jul 16 2008 :  1:55:44 PM  Show Profile  Reply with Quote
The immediate thought is "when" do you run the compiler over the code? Most of the time the code is invalid since I am editing it. Only occasionally can you compile the code and hope to get anything sensible out of the other end.

Something as simple as a missing bracket or semi-colon can make most of the file invalid.

The next concern is "what compiler" and "how do we compile the code?" Some of our users just use the IDE as an editor, and use a different compiler, sometimes on a different OS.

Also pre-processor definitions, etc, can make a lot of difference to how a file is compiled.

zen is the art of being at one with the two'ness
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Jul 16 2008 :  2:11:19 PM  Show Profile  Reply with Quote
One would for sure like the highlighting to update upon file save. Except that you could make it optional to update some time period after the user stopped editing the code, as Eclipse does this with Java which works pretty well actually.

Thing it doesn't do well though is keeping the error highlighting when I go on typing, I think one would prefer not to see it while editing the source, but update shortly after, when you generally "reevaluate the code visually" by yourself.

Having a missing semi colon or bracket could also be easily detected by the parser (is it not already?) But even then you could tell the compiler to stop when the first error is reached.

Essentially the user is responsible for fixing the compile errors, they are not supposed (but of course are welcome) to be specific. What it helps with is seeing the errors as you go, being able to read the error by hovering the mouse over the red highlight. I did not understand how helpful it was until I had to do projects in Java, using Eclipse.

Same goes for pre-processor, it's user responsibility to interpret the compilation errors, which are not going to become less specific anyway. VAX would rather provide a much more interactive rendering of the errors in the source editor.


I'd say you would only need to compile the current file you are working on (even though modifying one file could invalidate others) and compiling other files *dependent on the modified one* in some lazy fashion to not take away too much user time.

Resolving file dependencies shouldn't be hard using the basic include header scanning, I know gcc can create dependency lists, can't Microsofts compiler?


The most important question is which compiler to use. I'd say couple of the most popular ones. You could gather the statistics about what compiler is used most and prioritize supporting them first, making the most people happy sooner.

I'd use the compiler that is defined in the current project. One would essentially need to be able to parse the output of the compiler (ie, recognizing that something is an error, a warning and extracting the description) and render it in the editor.

I would think the output would be pretty similar in most of the compilers. So I think supporting more compilers would be just a matter of slightly modifying the parsers.

Thanks for your response,
Gennadiy

Correctness might be a theoretical concept but incorrectness has practical implications.

Edited by - GennadiyKorol on Jul 16 2008 2:15:19 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19004 Posts

Posted - Jul 18 2008 :  2:28:31 PM  Show Profile  Reply with Quote
First which compiler to use, I did not make myself clear. I used to develop code for both Windows and UNIX, and sometimes I would edit my UNIX code in the IDE. However VA, and Windows its self, would have no knowledge of and no access to the compiler I was using to compile the code.

This is not the normal situation, but things like this do happen.

I can think of other edge cases as well.

Having said that, IF this can be made to work then the idea is very appealing.

I have put in a feature request to see what our developers make of this idea:

case=18601

zen is the art of being at one with the two'ness
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Jul 18 2008 :  3:25:51 PM  Show Profile  Reply with Quote
In such case it would be natural to not expect VAX to highlight your unix code errors :) Even then, assuming you'd use GCC on Unix, VAX could have an advanced option of specifying the custom compiler (a path to it with flags) allowing you to solve such problems. You wouldn't edit your code too much without being able to compile it anyways, right?

Thanks for putting a feature request, I believe this would be one of the killer features.

I have also worked on compilers before and I think I have a clear sight about how this could be done. Let me know if you need a volunteer or something :)

Thanks again

Correctness might be a theoretical concept but incorrectness has practical implications.

Edited by - GennadiyKorol on Jul 18 2008 3:27:04 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19004 Posts

Posted - Jul 19 2008 :  09:26:25 AM  Show Profile  Reply with Quote
When I was working under UNIX it was SCO UNIX, and the code was compiled with cc or CC, which is a different beast to gcc.

Ignoring the whole question of the compiler, simply compiling the current file while the user is also editing it could be "interesting". We cannot assume that the file will compile instantly, or that it will compile without causing a big CPU spike.

Waiting for the user to stop typing is fine, but if they start typing as soon as we start compiling...

I see various possible complications, but I also see some real promise, if this can be done without causing to many problems

Don't hold your breath, I don't expect us to try and do anything about this idea for a while.

zen is the art of being at one with the two'ness
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Jul 19 2008 :  09:47:53 AM  Show Profile  Reply with Quote
Wouldn't putting the compiler into really low priority thread solve such issues? Ie, once user starts typing the scheduler is going to suspend the compiler thread and let the user type.

Having said that, today most of us are using dual core CPU's so the compiler could run in a separate thread without slowing down the user anyways :)

Also you would need to break the compilation once user started typing if the previous one was not yet finished since the source is outdated.

You could also add incremental feature of reparsing only certain lines (for instance the current one) by modifying only the respective nodes in the Abstract Syntax Tree. This would involve writing your own sort of compiler error-checker though.

Glad to know you are considering this and waiting anxiously for any kind of beta version! :)

Correctness might be a theoretical concept but incorrectness has practical implications.

Edited by - GennadiyKorol on Jul 19 2008 10:05:15 AM
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Jan 29 2009 :  5:21:06 PM  Show Profile  Reply with Quote
This is another feature that seems to work pretty good in NetBeans (even without having it configured with the compiler).

It is highlighting the symbols that generate error with an optional message about the error while hovering over the symbol.

Computers today have more than one core, running a compiler over a single file should not be a big deal, performance wise.

And parsing the basic compiler output seems to be close to trivial. Just the line number and error message inside the editor would already be a huge help.

Correctness might be a theoretical concept but incorrectness has practical implications.
Go to Top of Page

hotzenplotz
Senior Member

Austria
34 Posts

Posted - Jan 30 2009 :  5:06:06 PM  Show Profile  Reply with Quote
I _do_ think that compiling would be a big performance hit for most of the projects we have in my company. Think boost pp/bind/function/mpl, and loads and loads of our own templates-magick. And think what would happen if you saved your "common.h" file (that get's included by every single .cpp file): you'd pretty much have to re-compile every single file in the project. We have projects where that can take like 5 to 10 minutes.

It wouldn't be a problem of course, since I'd expect an option to deactivate "on-save-compiling". But of course it wouldn't do me any good either, since I'd *have to* deactivate it.

What would be great though, and probably MUCH less effort to implement, would be the highlighting-part without the "background" part. Means: just scan the output of normal build processes, and highlight the errors.

BTW @ GennadiyKoro: compiling really really slow's my system down. Not so much because the CPU is hogged (I have MPCL installed), but because of the disk!

@ feline: Just because NetBeans was mentioned... didn't you always want to make "Bean Assist X"? :D

Use the source, Luke!
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Jan 30 2009 :  6:14:09 PM  Show Profile  Reply with Quote
You don't need to recompile all of the project, just the current file and those dependent on it, using some kind of lazy evaluation.

That is, you do not have to wait until all the dependent files are recompiled. That's how eclipse works. If you break one of your files, others will slowly get red marks on them. This process runs in a low priority thread so it does not take from the responsiveness of the editor.

But I haven't requested to recompile every file in the project, just the one you work with, which is usually the one you break the most.

I don't think disk should be much of an issue, since frequently accessed files should get cached by the operating system. The problem will be even less prominent when using the precompiled headers.

Also, many errors could be caught by VAX's parser itself, without even invoking the compiler. I believe that's what NetBeans is doing. Checking for missing semicolon, undefined symbol, wrong function arguments etc can be already implemented.

Correctness might be a theoretical concept but incorrectness has practical implications.

Edited by - GennadiyKorol on Jan 30 2009 7:45:36 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19004 Posts

Posted - Feb 02 2009 :  1:07:57 PM  Show Profile  Reply with Quote
quote:
Originally posted by hotzenplotz

We have projects where that can take like 5 to 10 minutes.


At my last job a full recompile was over 2 hours! It was a rather large solution

Simply having VA parse the file in the background and highlight "problems", this is currently done, and how the:

VA Options -> Advanced -> Underlines -> Underline mistyped symbols using

feature works.

As soon as you want to get beyond this, at least with C++, template classes, macros, and related code is quickly going to cause a world of pain. As many of our users know, VA can have problems with some types of code like this.

I wonder how good NetBeans parser is with complex C++ macros.

Only re-compiling the current file is a fair statement, but what happens when this is a header file? They are often included in multiple files.

Lets take a simple case, a header file called "test_va.h" included in just 2 cpp files. foo.cpp has:

#ifdef UNIX
#include "test_va.h"
#endif

and bar.cpp has:

#ifndef UNIX
#include "test_va.h"
#endif

instant problem, since VA does not know the state of this pre-processor declaration.

A second real world question. What happens when you are engaged in a 2 hour edit? I have never used an IDE with background compiling, so I don't know what happens then, but I have often set off on writing code, and not reached a point where I can expect any of it to compile for a good couple of hours.

During this time having most of the screen highlighted as "invalid" is no use to me, since I know it is invalid.

My manual solution was to manually compile just the single current file when I was done, to see what the compiler made of it, CTRL-F7 for me in VS2005.

zen is the art of being at one with the two'ness
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Feb 06 2009 :  07:24:32 AM  Show Profile  Reply with Quote
Recompiling a header file can be done by creating a dummy cpp file with the content:

#include "header.h"

Then you can run a compiler over it and parse the errors to display them in the editor.


The #ifdef problem is not really a problem since you do not really need to know if the header is included or ifdeffed out. In worst case, you will redundantly recompile that C++ file in the background idle thread upon the header file modification.

But how often that can happen? How often do you edit Unix include files while compiling on Windows? I would say almost never.

But then again, you can limit the highlighting to the *current* file only and focus on the errors made in this file leaving the ctrl-shift-B to check for "whole project" compilation problems.



About the second issue, writing 2 hour code:

Usually the code is "invalid" in terms of functionality, not "compilability", especially for such a long time.

I do not think many people keep the code uncompilable for such a long time, because:

The usual compile errors are using undefined functions, the wrong function parameters, variables, etc.
But that is okay, since usually you create an interface to the class using stubs before implementing it.

And if you break the interface, the compiler should very well remind you of that. The interfaces are part of OOP design and should very well be done before the actual implementation of the interfaces starts.


So from my understanding I would say most people would prefer compiler error highlighting in their editor even while implementing the classes.


And of course, users can easily enable/disable the compiler error highlighting to fit his preferences.

Correctness might be a theoretical concept but incorrectness has practical implications.

Edited by - GennadiyKorol on Feb 06 2009 07:26:05 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19004 Posts

Posted - Feb 06 2009 :  09:28:10 AM  Show Profile  Reply with Quote
I am not against this idea, I rather like the idea, but some of your points do not automatically apply.

Editing UNIX code under windows, how about 8 hours a day for several weeks or months at a time? I have done that at my old job. VIM is very good, but it has no proper intellisense. We have various users who work on cross platform projects, so simply saying "you only edit Windows code under Windows" is not a valid assumption.


2 hour edit where nothing compiles, again speaking from experience, this often happens for me. Constructing some new classes, adding a pile of interlinked methods... certainly this does not always happen, but it does happen.


I do like the idea and I see the appeal, but I also see some of the potential problems.

zen is the art of being at one with the two'ness
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Feb 06 2009 :  09:50:01 AM  Show Profile  Reply with Quote
I think you are using extreme use cases to argue against optimizing the workflow of the common case.

As I have said again, in those two cases you have described you can just go:

VAX --> Disable Compiler Error Highlighting.

Done, problem solved. You can work 10 hours on the broken code from UNIX under Windows with out any problem.

But then in 90% of other use cases the value of this VAX plug-in will be dramatically increased given this feature is implemented.

Correctness might be a theoretical concept but incorrectness has practical implications.

Edited by - GennadiyKorol on Feb 06 2009 09:50:25 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19004 Posts

Posted - Feb 09 2009 :  10:51:49 AM  Show Profile  Reply with Quote
Firstly please note that I have already put in a feature request for this, to see what our developers make of it. I am not saying "no", I am trying to think through edge cases.

Speaking as technical support, "it works 90% of the time" is a nightmare, since that means 10% of our customers are going to be complaining it does not work.

If we can think through the edge cases and note potential work arounds in advance then this is useful.

Working in support has taught me that our users are doing all sorts of strange things. Cross platform development is not that uncommon.

zen is the art of being at one with the two'ness
Go to Top of Page

alextooter
Ketchup Master

55 Posts

Posted - Feb 12 2009 :  09:12:05 AM  Show Profile  Reply with Quote
Hi, I have read a blog post by M$ guys, he said they have put this idea in VS2010,

http://blogs.msdn.com/vcblog/archive/2009/01/27/dev10-is-just-the-beginning.aspx

Currently, M$'s compiler is not good enough to run on background and point out which error you have made,maybe it's not VAX's responsibility to do such job.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19004 Posts

Posted - Feb 12 2009 :  10:31:45 AM  Show Profile  Reply with Quote
Thank you for the link, it is a very interesting read. I especially like the comments about just how HARD it is to parse C++ code. Nice to see someone else say this

zen is the art of being at one with the two'ness
Go to Top of Page

M2tM
Junior Member

12 Posts

Posted - Feb 12 2009 :  7:03:20 PM  Show Profile  Reply with Quote
If it were easy nobody would purchase Visual Assist X and there would be more than one quality plugin of this nature. ;)

Huge props to you guys.
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Feb 22 2009 :  2:59:30 PM  Show Profile  Reply with Quote
I never doubted that it's hard to parse C++ code, especially with templates which theoretically make it Halting-problem hard... :)


It's just that you already have a lot of parsing working very well and adding those features would dramatically improve the programming experience.
Once you have tried it with Java and Eclipse you are just left there wondering why nobody have made progress in that direction with C++ IDE's.


I recall seeing emacs (I think) that was running GCC in the background and provided the error highlighting. I'll see if I can find that video.

EDIT: Here it is:
http://www.youtube.com/watch?v=F5Cc2W6PbL8


Correctness might be a theoretical concept but incorrectness has practical implications.

Edited by - GennadiyKorol on Feb 22 2009 3:10:23 PM
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000