RE: Re: AI assistant for NetBeans

2024-02-09 Thread Peter Kirkham
When the AI hype train was just getting rolling last year I thought I 
would try this out to write a basic but non-trivial algorithm. I wanted 
to implement a method to get the nodes and weights for Gauss-Laguerre 
quadrature integration for the Gamma function for any number of nodes, 
rather than just using a hard-coded series of arrays for the numbers. I 
didn't need to do this (the hard-coded array approach works) but I 
thought this was an interesting test because it's not an everyday garden 
topic that the AI will just be able to cut and paste from Stack 
Overflow. On the other hand it does have a known solution so it can be 
shown whether the AI solution is any good or not.


The AI was able to generate a plausible looking solution very quickly 
and confidently. Which was, at first glance, impressive. Wow. It 
compiled first time and ran. Syntactically it was great. And that is 
where the positives end. The code wasn't just wrong in terms of being 
close, but inaccurate. It was just gibberish. The results weren't even 
vaguely in the ballpark. People talk about AI being able to pass 
university exam level questions... what a load of rubbish. This was 
clearly plagarised so badly that the 'student' submitting the answer was 
clueless that their answer was even wrong.


The AI had no idea -- and why would it. It is nothing more than a large 
neural net that has produced a sequence of tokens based on another input 
sequence of tokens. At its heart it is nothing more than a sophisticated 
regression algorithm based on a series of data points which were used to 
train it. What we are doing is the equivalent of deriving a line of best 
fit through a cloud of data points and then asking the algorithm to 
extrapolate based on that regression equation. It works -- of course it 
does, it's just an equation -- but fundamentally it is grossly 
misleading. Any decently educated person knows that extrapolation is 
fraught with error. And that is all AI is (with the techniques used 
today). A sophisticated extrapolation engine. Anyone who says otherwise 
is deluding themselves.


Andreas is, in my view, completely right. If you rely on AI for coding 
you will spend more time correcting the code than you would writing it 
yourself. More than that, the code appears very neat, so the errors are 
not obvious at first. Writing the code yourself will also bring you 
closer to it, and that familiarity will breed insight that AI never had 
to start with and certainly cannot impart to its users. Why would you 
want to give up that side benefit from writing your own code?


AI is, in my view, one of the more dangerous fads to come out recently. 
Not necessarily because of the harm it might do itself, but because it 
drives a false sense of security amongst those that do not understand it 
-- which is to say most of the world, as there are very few people I've 
met who are able to explain to me how it works, even on a basic level. 
Perversely this could lead to a loss of knowledge and intelligence 
amongst the non-machine population.


Maybe I'm wrong and I'm just a modern-day Luddite. I'd be interested to 
know if there are any genuine real-world cases where AI code is useful. 
I was thinking that maybe boilerplate code, like when writing GUI etc. 
but NetBeans Matisse already has that covered just fine. How would AI 
improve this? It wouldn't have a chance improving on many of the 
algorithms I write for solving engineering problems for the simple 
reason that many of those algorithms never existed before I wrote them 
and I'm proud to admit that I had to fall back on real intelligence, and 
not artificial intelligence, to write them :-)


Anyway, an interesting topic!

Peter

On 2024/02/08 16:17:51 Andreas Reichel wrote:
> On Thu, 2024-02-08 at 11:16 -0500, Alonso Del Arte wrote:
> > There isn't, but probably soon there will be. If it's built-in, it
> > better come with an off switch. But if BlueJ adds an AI assistant,
> > then we're really in trouble.
>
> I have tried them all on IntelliJ and I can tell you: they are rubbish!
> OpenAI is great for looking up JAVA or C API efficiently and for this
> case you have a 50% chance to get something useful (although 50% chance
> of getting completely wrong information, like Java Libraries that don't
> exist.)
>
> But in the IDE it is just annoying. You will spend more time correcting
> the suggestions than writing code.
>
> Example: ask for a Java Example of Prophet Time Series Forecast! Or ask
> for a sample of RGBA to ARGB Byte Swapping using SSE or AVX.
> The given information will be TOTALLY wrong and fantasy!
>
> Cheers
> Andreas
>
>
>

-
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: Error highlighting for editor in NetBeans RCP application

2024-01-15 Thread Peter Kirkham

Update.

Turns out that when I previous tried enabling every single module in the 
the 'ide' and 'platform' I hadn't done a clean a build. When tried again 
and did this, the error highlighting worked. After some laborious trial 
and error I found that the module I needed to have enabled was the 
'Project UI' module in 'ide'. I didn't have this enabled in my platform 
application as I was just loading a file. I'll need the Project UI 
eventually, so it's not a drama.


Peter

On 14/01/2024 10:45 pm, Peter Kirkham wrote:


Hello there,

I've not had to reach out to the NetBeans community for a while, 
although I've been using NetBeans and the RCP for many years.


Most of the work I've done has involved embedding different 
Swing-based JPanels in TopComponents and just leveraging the 
platform's windowing system etc. Recently I started to develop an 
editor for a custom language, which is the first time I've done this. 
I've been following the tutorials, and learning a lot about lexing and 
parsing etc. Along the way I've run into a few speed bumps, but I've 
been able to resolve everything by reading the copious documentation 
on the platform or, on occasion, delving into the source on GitHub to 
see how a particular issue was been resolved in the IDE itself.


There is one issue I cannot seem to find an answer for.

*The BACKGROUND*

This relates to error highlighting. As per the error highlighting 
tutorial 
(https://netbeans.apache.org/tutorial/main/tutorials/nbm-javacc-parser/#_implementing_a_new_feature_error_parsing) 
I've create an error highlighting task that extends ParserResultTask 
and implemented a factory that extends TaskFactory:


public class EclSyntaxErrorHighlightingTask extends 
ParserResultTask {

     @Override
     public void run(EclParserResult result, SchedulerEvent event) {
     LOG.log(Level.INFO, "Running EclSyntaxErrorHighlightingTask: {0}", new 
Object[]{event.toString()});
     try {
[ omitted ...]
     } catch (BadLocationException | 
org.netbeans.modules.parsing.spi.ParseException ex) {
     Exceptions.printStackTrace(ex);
     }
     }

     @Override
     public int getPriority() {
     return 100;
     }

     @Override
     public Class getSchedulerClass() {
     return Scheduler.EDITOR_SENSITIVE_TASK_SCHEDULER;
     }

     @Override
     public void cancel() {
     }
}

and

@MimeRegistration(mimeType = "text/x-eclipse", service = TaskFactory.class)
public class EclSyntaxErrorHighlightingTaskFactory extends TaskFactory {

     @Override
     public Collection create(Snapshot snapshot) {
     EclSyntaxErrorHighlightingTask task = new 
EclSyntaxErrorHighlightingTask();
     LOG.log(Level.INFO, "Created EclSyntaxErrorHighlightingTask from {0}", 
new Object[]{snapshot.toString()});
     return Collections.singleton(task);
     }
}

Note I've added a couple of logging events so I can see when the 
factory is called and creates the highlighting task, and also see when 
the task is run. For the eagle-eyed, yes the language is called the 
eclipse language, but it is nothing to do with that other IDE. It's a 
reservoir simulation language in the oil and gas industry that dates 
back to the 1980s...


*The ISSUE*

When I run the custom language model as a module within the IDE 
(right-click the module and Run), everything works a charm. Opening a 
file generates the following in the log:


INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTaskFactory]: 
Created EclSyntaxErrorHighlightingTask from Snapshot 1894046798: 
ECLIPSE_Test_Deck.ecl
INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTaskFactory]: 
Created EclSyntaxErrorHighlightingTask from Snapshot 1894046798: 
ECLIPSE_Test_Deck.ecl
INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTask]: 
Running EclSyntaxErrorHighlightingTask: SchedulerEvent 
1007833880(source: CurrentDocumentScheduler)
INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTask]: 
Running EclSyntaxErrorHighlightingTask: SchedulerEvent 
210858918(source: CurrentDocumentScheduler)


So the task is being created and added to the Scheduler, and is being run.

Now, rather than running as a standalone module, what I really want to 
do is to put the module into my platform suite. Adding the module into 
the platform suite and then running the application works for 
everything except the error highlighting. So far I've done syntax 
highlighting, code completion, code reformatting, code folding, match 
occurrences. It's all working. But the error highlighting stubbornly 
does nothing. Not even having the decency to throw an exception...


When opening my custom language file, the log now shows:

22:09:48 [EclSyntaxErrorHighlightingTaskFactory|INFO]: Created 
EclSyntaxErrorHighlightingTask from Snapshot 1437838154: 
ECLIPSE_Test_Deck.ecl


So it appears that the highlighting task gets created, but it just 
isn't being run

Error highlighting for editor in NetBeans RCP application

2024-01-14 Thread Peter Kirkham

Hello there,

I've not had to reach out to the NetBeans community for a while, 
although I've been using NetBeans and the RCP for many years.


Most of the work I've done has involved embedding different Swing-based 
JPanels in TopComponents and just leveraging the platform's windowing 
system etc. Recently I started to develop an editor for a custom 
language, which is the first time I've done this. I've been following 
the tutorials, and learning a lot about lexing and parsing etc. Along 
the way I've run into a few speed bumps, but I've been able to resolve 
everything by reading the copious documentation on the platform or, on 
occasion, delving into the source on GitHub to see how a particular 
issue was been resolved in the IDE itself.


There is one issue I cannot seem to find an answer for.

*The BACKGROUND*

This relates to error highlighting. As per the error highlighting 
tutorial 
(https://netbeans.apache.org/tutorial/main/tutorials/nbm-javacc-parser/#_implementing_a_new_feature_error_parsing) 
I've create an error highlighting task that extends ParserResultTask and 
implemented a factory that extends TaskFactory:


public class EclSyntaxErrorHighlightingTask extends 
ParserResultTask {

    @Override
    public void run(EclParserResult result, SchedulerEvent event) {
    LOG.log(Level.INFO, "Running EclSyntaxErrorHighlightingTask: {0}", new 
Object[]{event.toString()});
    try {

[ omitted ...]

    } catch (BadLocationException | 
org.netbeans.modules.parsing.spi.ParseException ex) {
    Exceptions.printStackTrace(ex);
    }
    }

    @Override
    public int getPriority() {
    return 100;
    }

    @Override
    public Class getSchedulerClass() {
    return Scheduler.EDITOR_SENSITIVE_TASK_SCHEDULER;
    }

    @Override
    public void cancel() {
    }
}

and

@MimeRegistration(mimeType = "text/x-eclipse", service = TaskFactory.class)
public class EclSyntaxErrorHighlightingTaskFactory extends TaskFactory {

    @Override
    public Collection create(Snapshot snapshot) {
    EclSyntaxErrorHighlightingTask task = new 
EclSyntaxErrorHighlightingTask();
    LOG.log(Level.INFO, "Created EclSyntaxErrorHighlightingTask from {0}", 
new Object[]{snapshot.toString()});
    return Collections.singleton(task);
    }
}

Note I've added a couple of logging events so I can see when the factory 
is called and creates the highlighting task, and also see when the task 
is run. For the eagle-eyed, yes the language is called the eclipse 
language, but it is nothing to do with that other IDE. It's a reservoir 
simulation language in the oil and gas industry that dates back to the 
1980s...


*The ISSUE*

When I run the custom language model as a module within the IDE 
(right-click the module and Run), everything works a charm. Opening a 
file generates the following in the log:


INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTaskFactory]: 
Created EclSyntaxErrorHighlightingTask from Snapshot 1894046798: 
ECLIPSE_Test_Deck.ecl
INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTaskFactory]: 
Created EclSyntaxErrorHighlightingTask from Snapshot 1894046798: 
ECLIPSE_Test_Deck.ecl
INFO [au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTask]: 
Running EclSyntaxErrorHighlightingTask: SchedulerEvent 
1007833880(source: CurrentDocumentScheduler)
INFO [au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTask]: 
Running EclSyntaxErrorHighlightingTask: SchedulerEvent 210858918(source: 
CurrentDocumentScheduler)


So the task is being created and added to the Scheduler, and is being run.

Now, rather than running as a standalone module, what I really want to 
do is to put the module into my platform suite. Adding the module into 
the platform suite and then running the application works for everything 
except the error highlighting. So far I've done syntax highlighting, 
code completion, code reformatting, code folding, match occurrences. 
It's all working. But the error highlighting stubbornly does nothing. 
Not even having the decency to throw an exception...


When opening my custom language file, the log now shows:

22:09:48 [EclSyntaxErrorHighlightingTaskFactory|INFO]: Created 
EclSyntaxErrorHighlightingTask from Snapshot 1437838154: 
ECLIPSE_Test_Deck.ecl


So it appears that the highlighting task gets created, but it just isn't 
being run. Ever.


*Attempts to RESOLVE*

In my custom language module I've added all the dependencies needed, 
plus a few more for the platform (I have in mind to submit a pull 
request for the documentation file which addresses some of the gaps I 
came across). I doubt it's a problem with the code I've written -- it 
works as a plugin in the IDE. So my thinking is that there must be some 
module that needs to be included in the suite which the ParserResultTask 
needs for it to be run. However, a brute force solution of just enabling 
every single module in the the 'ide' and 'platform' in my