Author Topic: Codecompletion for D  (Read 21343 times)

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Codecompletion for D
« on: April 10, 2010, 10:42:55 pm »
I tinkered with the idea to implement codecompletion for D.
Since the current completionsupport is only based on the analogy of D to C.
I think there would be 3 possibilities to implement this.

a) Implement it in the same Parser-classes as cpp
b) Implement in the same codecompletion plugin, but with it's own parser-framwork
c) completly independent plugin for D-Parser

re a) I think this would be not a good idea. Specifically when we want implement more languages, this will become a nighmare of if/else blocks
re b) I have seen, that cpp-related code is not only in the parser-subfolder, but also in the main-folder of this plugin. But this would probably be the easiest way to go.
re c) IMHO this would be the cleanest implementation. But for now, I have no clue how this can be loaded or managed in parallel with the cpp-codecompletion plugin.

So what are your thoughts?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Codecompletion for D
« Reply #1 on: April 11, 2010, 04:08:45 pm »
Code
re b) I have seen, that cpp-related code is not only in the parser-subfolder, but also in the main-folder of this plugin. But this would probably be the easiest way to go. 

Sorry, I have never used D language.

But I have some kind of familiar with the current CC plug-in's code. :D

There are two major parts of CC, the first part (we say part A) was collecting tags. we use the parser class and other helper classes(all the code was under parser- subfolder as you said) to analyze all the source code, then we store all the tags(some times, we call Tokens).

The second part( we say Part B) was doing the completion and other UI tips( eg, when the mouse hover on some ids, there is a function tip or when you enter some text, then there is a completion list prompt below your caret), it need to resolve the current code statement syntax.

Currently CC's code is quite mixing. So, if you want to implement a D language, you need to implement a part A for D language, and only modify some code in Part B.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Codecompletion for D
« Reply #2 on: April 11, 2010, 05:50:53 pm »
Ah I see, that makes now more sense to me.

So I make a DParser class with the same interface as Parser, and we can load the correct parser related to the opened file/project?


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Codecompletion for D
« Reply #3 on: April 11, 2010, 06:19:18 pm »
The best thing will be to extract part B and put it in the cb's sdk... but I suppose this will be tough...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: Codecompletion for D
« Reply #4 on: April 12, 2010, 07:44:39 pm »
whoa I have been throwing an eye to D language and there are no IDE for it as I now that supports CC would be of great help since D seems to come after C and the future will change got it? A B C D  :lol:

Also I have read that D is easier to parse!

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Codecompletion for D
« Reply #5 on: April 12, 2010, 09:58:35 pm »
Yeah, D is indeed a very powerful language. And the dmd compiler is really fast.
Today Andrei Alexandrescu posted a measurement about D-compiletime as a comparsion to google's go language.
And the result is amazing :)
The std-library of D (88KLOC) in 1.24 sec.
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=108831

At work I code in C++ and when I try to compile my really small projects, I can go for a coffee, or two ...  :D

But as you mentioned, D lacks on support with really good GUI-tools such as IDE's, ...
But then codeblocks come into play ...

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: Codecompletion for D
« Reply #6 on: April 13, 2010, 01:14:01 am »
Interesting almost like running a php script  :)

Offline Aelxx

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Codecompletion for D
« Reply #7 on: April 13, 2010, 04:35:25 pm »
DMD D compiler generates tags itself with using option -X in JSON format, but as for now it doesn't generate tags for local variables. Maybe it's needed to ask for this feature to the developers of D.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Codecompletion for D
« Reply #8 on: April 13, 2010, 04:43:50 pm »
Ah I see, that makes now more sense to me.

So I make a DParser class with the same interface as Parser, and we can load the correct parser related to the opened file/project?



For the Part A step, I think (suggest) you could try our "parserthread test project", which only do the batch parsing on only one file, and you can test you own D Parser.

See here:ParserTester for codecompletion plugin

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Codecompletion for D
« Reply #9 on: April 13, 2010, 08:35:24 pm »
Oh cool,
I will try it out!

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codecompletion for D
« Reply #10 on: February 10, 2011, 08:45:22 am »
Oh cool,
I will try it out!

Dear Nocide,

I would like to know that you have finished the codecompletion for D or not.

I'm looking for this also, but I'm not so skilled in patching or improving codeblocks source files; so if you can provide the solution will be a great good news for me and other ones who like D Language.


waiting for your kindly feedback.


Sincerely yours,

Daivd.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Codecompletion for D
« Reply #11 on: February 10, 2011, 10:59:39 pm »
... but I'm not so skilled in patching or improving codeblocks source files...
Have you tried? The codebase is not that big and not that hard to work with. You only need to know C++ at decent level.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codecompletion for D
« Reply #12 on: February 11, 2011, 02:25:38 am »
... but I'm not so skilled in patching or improving codeblocks source files...
Have you tried? The codebase is not that big and not that hard to work with. You only need to know C++ at decent level.

Dear oBFusCATed,
I only knows a little bit about C Language, I'm not familiar with C++   :(

I recognized that the D Language is as good as C (or C++) and has more important properties than C (and C++). Personally thinking, it will be one of the most popular and important languages in future after D2 is soon formally released out. (D core developers are working very hard every day.)

Here is a CHM file about D Language for your reference.
https://docs.google.com/leaf?id=0B38se3xzJrbuMjNlMTQ5MzUtYTM1NC00M2UyLWJjODctMDZlM2Y2ZWQwYjlm&hl=en&authkey=CPvh1ZoG

More and more people foucing and learning it.
So, if CodeBlocks fully support it will be a very good strategetic decision.
(even C++0x really released out, I don't think C++0x will be more better than D.)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Codecompletion for D
« Reply #13 on: February 11, 2011, 02:32:45 am »
I have open that CHM, and look at the first page containing a minimal d language sample code, it seems D language is much like c/c++, but has some special keyword or grammar.

So, If you are familiar with D, you can quickly familiar with C/c++.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
« Last Edit: February 12, 2011, 01:35:43 am by wangdong1226 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Codecompletion for D
« Reply #15 on: February 11, 2011, 08:52:41 am »
Not knowing c++ will not allow you to contribute :(

I recognized that the D Language is as good as C (or C++) and has more important properties than C (and C++). Personally thinking, it will be one of the most popular and important languages in future after D2 is soon formally released out. (D core developers are working very hard every day.)
No, it won't, it will always be a moving target and the libraries will be a moving target, so no one will use it seriously.  :lol: 8)
The future is in haskell, scala and f# (ocaml this one is really used for something). So go check them.
D is the same shuffle of the imperative features of C++ and Java + something more...

BTW1: I was passionate about D, too, I've even tried it and now I'm not passionate :)
BTW2: I don't want to start language war type of discussion :)
BTW3: For full support in C::B you need a core developer passionate about D and there isn't one around here, so there is very little chance this to happen.  :(
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codecompletion for D
« Reply #16 on: February 28, 2011, 07:57:13 am »
...
No, it won't, it will always be a moving target and the libraries will be a moving target, so no one will use it seriously.  :lol: 8)
The future is in haskell, scala and f# (ocaml this one is really used for something). So go check them.
D is the same shuffle of the imperative features of C++ and Java + something more...

BTW1: I was passionate about D, too, I've even tried it and now I'm not passionate :)
BTW2: I don't want to start language war type of discussion :)
BTW3: For full support in C::B you need a core developer passionate about D and there isn't one around here, so there is very little chance this to happen.  :(

I'm learning D Language, and after finishing it, I'll go back to learn C++; this stage will cost about 10+ years.   :lol:
And after finishing C++, I'll try to delivery patches to some core developers of CB to modify the codecompletion or other parts of CB to improve the support of D Language.  This will cost about 1~2 years.  :)
If someone pay a little bit mercy on me, will greatly reduce the time schedule.  :P

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Codecompletion for D
« Reply #17 on: February 28, 2011, 09:59:38 am »
I'm learning D Language, and after finishing it, I'll go back to learn C++; this stage will cost about 10+ years.   :lol:
And after finishing C++, I'll try to delivery patches to some core developers of CB to modify the codecompletion or other parts of CB to improve the support of D Language.  This will cost about 1~2 years.  :)
If someone pay a little bit mercy on me, will greatly reduce the time schedule.  :P
so, we will see your patch ten years later. :wink: Anyway, I can help you if you would like to help C::B. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: Codecompletion for D
« Reply #18 on: February 28, 2011, 06:34:23 pm »
D seems to be a pretty nice language/idea the problem is that it lacks the multitude of libraries available for C++. While you can use c standard libraries in my opinion it isn't enough (creating wrappers and porting is a huge work). On the other hand learning so many languages can drive you crazy  :P In my case I had work with visual basic, java (lightly, hated all VM/JIT stuff), ecma script (java script, action script), pascal, C#(almost java) and my favorites php and c/c++ The other day I was thinking of moving to C# (faster development) since the mono framework has implemented something that makes your application almost native, but I will always return to C++ Besides everyone on this forums knows at least a little english, if it wasn't the case we would have some serious communication problems. So c/c++ can be compared to english xD (everyone knows at least a little bit)

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Codecompletion for D
« Reply #19 on: March 01, 2011, 03:11:38 am »
D seems to be a pretty nice language/idea the problem is that it lacks the multitude of libraries available for C++. While you can use c standard libraries in my opinion it isn't enough (creating wrappers and porting is a huge work). On the other hand learning so many languages can drive you crazy  :P In my case I had work with visual basic, java (lightly, hated all VM/JIT stuff), ecma script (java script, action script), pascal, C#(almost java) and my favorites php and c/c++ The other day I was thinking of moving to C# (faster development) since the mono framework has implemented something that makes your application almost native, but I will always return to C++ Besides everyone on this forums knows at least a little english, if it wasn't the case we would have some serious communication problems. So c/c++ can be compared to english xD (everyone knows at least a little bit)


Yes, you are right. D really lacks of the multitude libraries. Until now, for the released D2, the library there is only Phobos.

D2 (ver 2.052)has formally supported 64bit on Linux (64bit will formally support for other platforms later on: Win, OS X, FreBSD, etc), and its under construction: Shared libraries for Linux.

So, a moment later, we will see that we can use Linux libraries in D, and it will no long with the title that 'lack of libraries'.

BTW, as I know, GTK+ 3.0 has formally released, and it introduced a "GObject Introspection" which can widely enlarge the programming languages' bundling using (of course includes D Language).

"GObject Introspection" implements calling GObject easily and fluently. It means that every Language just need to build a 'GObject Introspection' bundle, then the Language can easily and fluently call every API of GTK+ 3.0 through this bundle;
It is excited! you know, GTK+ is a very very good GUI level library which was written in C Language. ^_^

Your advice is very kindly also. For I'm not so wise, learn too many languages really will confusing me. ha ha   :D
I only will learn C Language and D Language,  and also will try to learn C++ Language (for understanding CodeBlocks's source code and can submit patches to CodeBlocks's core developers).
« Last Edit: March 01, 2011, 03:19:32 am by wangdong1226 »

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: Codecompletion for D
« Reply #20 on: March 01, 2011, 08:03:42 pm »
This seems a full featured D IDE http://www.dsource.org/projects/poseidon I haven't tried it but it seems to have code completion, so if you haven't yet, try it