gsoc Syndicate content

» GSOC: C++2011 Support in KDevelop Part 1

Tue, 06/28/2011 - 14:09

Hey all,

I finally want to write a bit about my work on KDevelop during this year’s GSOC. To make things a bit more interesting for the whole crowd, even for those heretics that don’t use KDevelop, I want to highlight some C++2011 features I got to know in the process. Hence this multipart blog post should be interesting for all KDE hackers, as eventually we will be able to use these shiny new features of what is to be known as C++2011.

For those interested in the full overview of changes in C++2011, take a look at e.g. the C++0x Status Page in GCC 4.6, the wikipedia article on C++0x, or try to get hold of a copy of the C++2011 FDIS spec file. Note that the latter is apparently not freely accessible, see also this stackoverflow discussion. Still, maybe you find someone who can send you a copy…

So, lets get down to business. Following is a not-complete list of C++2011 features I’ve already implemented in KDevelop. If I mess something up in explaining a new feature, or if I forget an important aspect, please add a comment.

Range-Based for

This neat little addition is not so important to most Qt developers. We know and love our foreach macro. C++2011 comes with a similar built-in construct called range-based for. Essentially the syntax goes like this:

  1. QVector<MyType> list;
  2. for(const MyType& item : list) {
  3. // do stuff
  4. }

It’s neat, and very similar in syntax to the oldschool foreach macro. But there is a big difference: Where foreach makes a copy of the container, range-based for does not. This has mainly two implications:

  1. foreach is slow when used with containers that don’t use implicit sharing, most prominently STL containers
  2. range-based for has undefined behavior when you change the list you iterate over inside the loop.

Personally, I think I’ll stick to the foreach macro as it’s known to work well and has no big downsides in most Qt-based applications, as implicit-sharing is widely used throughout Qt.

RValue References / Move Support

This feature is a more advanced topic and mainly interesting for library developers who want to implement move semantics and/or achieve perfect forwarding, resulting in much better performance under certain conditions. Take a look at the Brief Introduction to RValue References, or the associated spec changes. From the syntax POV it’s just a matter of using && for rvalue references compared to the single & for normal lvalue references.

Defaulted and Deleted functions

This addition to the C++ spec is very welcome to me as it makes some code much more readable and also can be used to prevent hard-to-debug bugs or to improve performance. I’m talking about defaulted and deleted functions. E.g. from the wikipedia article:

  1. struct NonCopyable {
  2. NonCopyable & operator=(const NonCopyable&) = delete;
  3. NonCopyable(const NonCopyable&) = delete;
  4. NonCopyable() = default;
  5. };
  6. struct NoInt {
  7. void f(double i);
  8. void f(int) = delete;
  9. };

This shows the syntax of how to use this new feature. The advantages:

  • You can explicitly mark functions as deleted: Before you had to move these functions into private section of a class and not provide an implementation. When (accidentally) trying to use such a function you used to get unintuitive compile or linker errors. Now you get a nice message about usage of an explicitly deleted function.
  • You can prevent unwanted conversions: Using deleted functions is also useful when you want to prevent some function to be called with a different type that can be implicitly converted to your function’s wanted argument type.
  • Performance with defaulted functions: Compilers tend to write highly optimized code where possible. Implicitly defined constructors or assignment operators e.g. are one of these cases. But as soon as you use inheritance you (mostly) cannot use the implicit versions. Thanks to the new defaulted functions you can do that again. Furthermore it’s possible to change the access policy of an implicitly defined function (which are usually public) using the default syntax.
Variadic Templates

I confess that this is one of the more esoteric features of C++2011 for me. I never really did any serious template meta programming, and variadic templates are just as complicated as the other template programming. Yet I do see the advantages if people start to use it.

Anyhow, I implemented the required parser changes into KDevelop, but proper code completion and DUChain integration might need some time and brain effort :)

static_assert

Now back to simpler things, yet definitely welcome and useful ones. One example are static assertions, i.e. compile-time assertions. The document I linked to contains a list of examples which should show how useful this feature is. Note that we Qt-users know and love the Q_ASSERT macro, but it is a runtime check. Boost users have had a BOOST_STATIC_ASSERT macro for some time, now we will finally be able to use it as well.

STL updates

Ah, before I forget it: Since KDevelop parses the STL includes, you should be able to use all new STL features already. If you spot a serious parser error in one of the include files of GCC 4.6 or 4.7, please notify me.

much much more

These are only some of the new features which I’ve added support for in KDevelop. I’ll try to sit down later today to write part 2, otherwise I’ll do that after I come back from the Fusion festival next week. Anyways, you can stay tuned for features like constexpr, opaque-enum-declarations, class-enums, improved right-shift token handling in nested templates, etc. pp.

» KDevelop: Randa and GSOC 2011

Thu, 06/09/2011 - 15:59

Yawn. Hello everyone!

After two nights of backporting sleep in my RL branch to fix the deficiency I built up during Randa, I feel somewhat normal again. Time to blog, eh?

Randa

Lets begin with Randa. It was not only my first time there, but also my first time ever to be in the Swiss Alps. And furthermore it was the first time for me to be in the Alps without crying out loud about the lack of snow as I didn’t intend to go snowboarding. You can imagine it was a very pleasant experience for me. I definitely want to come back to go on some more serious hiking trips uphill. But I diverge ;-)

Randa as place for a sprint was simply awesome: Secluded hence no real distractions. Great environment to clean your head, get fresh air and stay focused and productive. Good food, nice people, … I could go on here :) The only negative things I noticed where the unstable networking and the dormitories.

KDevelop Sprint

The KDevelop sprint at Randa was very successful and productive. Here is a group picture of those who attended:

Randa 2011 KDevelop Group Picture
KDevelop Hackers at Randa 2011

from left to right: Sven Brauch (Python Support), Laszlo Papp (Gluon), Milian Wolff (…), Niko Sams (PHP, GDB, …), Aleix Pol (CMake, …), Alexander Dymo (UI, Ruby, …)

Aleix already blogged about what he did, so I won’t reiterate that. Instead let me point you to the incomplete log of our discussions on Techbase. Here are my personal highlights of the sprint:

  • We/I will setup a continous/nightly build- and regression-testing machine for KDevplatform/KDevelop and related plugins. Thanks already for the kind offers for hosting. More on this later
  • some more plugins from e.g. Quanta will see a released soon. Due to lack of manpower we cannot wait for a stable Quanta release, but some plugins in there are already stable and usable.
  • we will have some “welcome to kdevelop” page eventually, based on Aleix’s work with the Plasma Dashboard
  • Niko’s “Browser Like Tabs” mode will be merged eventually, try it out now and give us feedback!
  • Alexander merged a partial rewrite of the UI framework in KDevelop, bringing lots of new features and less bugs as well as reducing our codebase!
  • Sven attended his first KDE sprint and continued to work on a kick-ass python language support for KDevelop! Rock on!

I could go on and on here, we really did lots of stuff. It was great meeting you all again, hope to see you soon (at the Desktop Summit?).

GSOC

To finish this already long blog off, here a few notes on my GSOC. As you might have heard, I work on bringing C++2011 (aka C++0x) support to KDevelop. I’ve already pushed some changes to my branch which adapt our parser to support the range-based for loop syntax as well as RValue references and variadic templates. Proper DUChain integration is pending, yet it already makes working with C++2011 features much more bearable! Stay tuned for a more in-depth report.

» The End Is Nigh

Wed, 05/25/2011 - 16:35

No I’m not a nutjob who talks about the rapture (epic fail btw.). Instead, I’m talking about my time as a bachelor student. I’ve just handed in my thesis after weeks of work on it. You might have noticed by my recent absence from KDE hacking. But rest assured. Now I’m back again :)

First of all the GSOC hack time started officially this week. I got a slot again, and am a few days behind schedule yet am confident to fetch up. I’ll be working on bringing C++0x or now C++2011 support to KDevelop. You can read my proposal online.

Secondly next week I’ll be at Randa for the KDevelop sprint (among others). I’m really looking forward to it, so many nice people to meet again — awesome!

So expect more from my side again. I’ll also start to go through the bug reports of the last weeks which I have not yet attended to. Stay tuned and welcome back :)

» Short GSOC 2010 Note

Sun, 08/22/2010 - 17:50

Hey all,

before I go on a short one-week vacation, I wanted to leave you a short note about the outcome of my GSOC, where I tried to revive the Quanta+ brand.

First up, I passed, many thanks to my mentor Andras Mantia. But well, it’s not like I got that for free. In a first estimation I did about 500 commits to Quanta, PHP and KDevplatform in the last three months. So I hope you all agree that I deserve the Google money :)

But lets talk about what I planned to achieve and what I actually achieved:

  • the XML/HTML plugin is working quite well but is still requiring lots of polishing
  • the browser preview plugin is supposedly being worked on by another studen in Brazil, I’m awaiting her first results and will polish it together with her.
  • you still cannot rename tags and automatically rename the close tag as well or similar
  • the multilang branches have imo nice API additions and seem to work reasonably well. At least my test cases of CSS inside HTML worked fine for me

Anyhow, on one hand I’m personally satisfied with what I achieved code wise, esp. looking at the diffs and knowing how many iterations some of the multilang structures required. On the other hand I had hoped to achieve much more. A first alpha release of Quanta is really not visible to me in the near future.

But, and here I make a promise I do intend to keep: I won’t desert Quanta. Quite the contrary. KDevelop will probably keep my main focus, but I do intend to improve Quanta, esp. merge the multilang branches into KDevplatform for example. My intended time plan contains a note to merge multilang after the movingrange branches into KDevplatform 1.2. Lets see how that works out.

The XML plugin I will definetly continue to polish and make it work as good as possible. Even now it is helpful for more than just web developers: I personally already rely on it when working on Kate language files for example. So there is a personal desire to have it working as good as possible, even though I don’t do much/any web development these days.

Bla bla bla, enough rambling and dumping my thoughts. Lets close this up by saying: Have a nice week, cya soon, hopefully well rested and ready to kick some more code lines :)

Bye

» Quanta GSOC midterm evaluation

Thu, 07/08/2010 - 22:24

Hey there!

Midterm evaluations for GSOC are coming up and Andris Mantia, my mentor I finally met at Akademy, asked be to blog about what we already have in Quanta. Because there is a lot and most of you are not aware of that. And to be honest it’s actually too much to put into a single blog post, so I hope to do more of a series of blog posts showing off some features.

Quanta 4 is not Quanta 3

Anyhow, I fear that a disclaimer is in place, for all of you who are desperately looking forward a KDE4 version of Quanta. The thing is, I cannot, nor do I want to, port Quanta from KDE3 times as-is to KDE4. Instead I build on top of the KDevplatform that is also used for KDevelop and KTechlab. By sharing the basic code it gets much easier to maintain Quanta in the future. This decision brings two things with it:

  1. We get an awesome library to built new stuff on top, making things like the new PHP which is already much more advanced than anything from KDE3, actually plugin possible.
  2. We don’t have all features from Quanta 3 or if we have, they might look and work differently. This also means that you won’t be able to take your Quanta 3 workflow without changes over to Quanta 4.

Some examples for the last part, that also sheds some light on our (== KDevelop team) preferred way of designing the IDE:

First and foremost, dialogs are evil. There, I said it. I doubt I’m the only one here and there are actually many other KDE applications following this mantra. Afaik Aurelien from Gwenview is trying to make it the first app in KDE without any modal dialogs. Go for it dude! What does that mean for Quanta? You might remember that Quanta 3 had lots and lots of dialogs. You could change attributes of HTML tags via dialogs, you could insert code via dialogs. In Quanta 4 this wont be the case, at least I won’t write these dialogs. Instead I concentrate on kickass code completion, which should make these dialogs obsolete.

  • offer context sensitive code completion, e.g. only tags that are valid at the given cursor position or attributes that fit into the given tag under the cursor
  • directly insert tags with all required attributes
  • make it possible to trigger a file-selection dialog in e.g. src="..." or similar attributes from within code completion (there’d be a ‘select file…’ code completion item)

In my opinion every dialog that created or changed code can be replaced by code completion. And if you use it, it’s much faster to write and change code. You don’t have to grasp a new magic modal dialog and find the attribute you want to change. Instead you simple select it, CTRL + Space for code completion and insert the stuff you want.

existing Quanta 4 features

So much for the design ideas in Quanta4, now lets talk about what we already have now in Quanta4. For the uninitiated, you can find the source code at http://gitorious.org/kdevelop/quanta. You will need KDevplatform, KDevelop-PG-Qt and QJSON to get all plugins built.

Also another note is in place here: Even though I have the GSOC and spent lots of time on Quanta, the features I describe below wouldn’t exist if not for the help and work of others. Most notably Niko Sams (PHP, CSS, Execute Browser, Execute Script, XDebug, Crossfire, …), Ruan Strydom (XML/SGML, PHP formatter) and all the other guys happily hacking away at KDevplatform and it’s core plugins and libraries.

PHP

For those that never heard about the work Niko and me put into the PHP language support plugin for KDevelop, you have quite a lot of catching up to do :) I’m too lazy to reiterate everything, if you are interested, read my blog posts: http://milianw.de/tag/php

But frankly, you should instead just try it out. We released PHP together with KDevelop 4.0 and most distros should package it. I still actively work on it and e.g. just brought in some PHP 5.3 features (namespaces) the other day.

To list just a few things we have:

  • state of the art code completion
  • inline syntax checking and error reports
  • context browsing
  • inline documentation and PHP.net integration

If you thought Quanta 3 was good for PHP development, try this, really :)

Ah and before I forget that: Niko also wrote a plugin that integrates XDebug: http://nikosams.blogspot.com/2010/02/kdevelop-xdebug-php-debugger.html

CSS

Here I think I can simply link to Nikos blog posts explaining and showing off his CSS language support plugin:

http://nikosams.blogspot.com/2010/01/kdevelopquanta4-css-language-support.html
http://nikosams.blogspot.com/2010/02/css-language-support-update.html

As you can see once again: When using and implementing the tools in KDevelop properly for a language you get insanely good code completion and context sensitive help plus some browsing utilities. Very handy indeed, and once again (imo) better than what we had in Quanta 3.

Once we have proper multi language support in a single file, expect more goodness from my side, I only added more inline previewing, e.g. for colors.

XML

This is by far the largest surprise for me. Ruan Strydom, a South African, announced at one day - out of the blue - that he is working on a XML language support plugin for KDevelop. And he did a quite good job at it. I’ve been helping out there the last weeks and fixed bugs and added a few features, but it’s still mostly his work. It is already quite useful, as it parses the XSD or DTD that is used in your document and based on that offers you context sensitive code completion and context browsing. It also works somewhat for SGML, e.g. HTML and is quite handy.

There is still quite a few things to do here, e.g. report errors about invalid attributes, tags, etc. pp (currently only real XML syntax parse errors are reported).

Snippets and External Scripts

In Quanta 3, custom toolbars and the actions in them where apparently quite popular. In KDevelop and hence Quanta as well, this is currently handled differently, yet the features should be the same, if maybe with a different workflow. See e.g. http://milianw.de/blog/snippets-in-kdevelop-kate on how snippets work, and http://milianw.de/blog/kdevelop-externalscript-plugin for external scripts.

These should (hopefully, if not please report) give you all the features you had with user actions in Quanta 3. Putting these actions into toolbars is not there and I frankly don’t see the huge need for it that would make up for the huge time I’d had to spent on it to get that working again.

The future and call for feedback

So as you can see, Quanta is not dead, but got very much revived. I hope to get our beloved webdevelopment IDE up and running next year at latest, if possible with a few first test releases this year. Anyhow, back to GSOC:

It’s currently midterm and I already achieved a lot, in the next weeks I will definitely spent my time in getting proper multi language support in a single file up and running. That would then finally make it possible to have proper context browsing and code completion in e.g. a template that includes CSS, PHP and HTML. Also the inline HTML preview from Quanta 3 is needed to be ported / reimplemented. But I might be missing things, which makes me conclude this overlong blog post with a call to old Quanta 3 users:

What features are you missing above from Quanta 3?

Please write one comment per feature and then do “+1” kind of comments to get a basic vote here. That way I can see on what features I have to concentrate on to get Quanta 4 up and running.

Bye

» KDevelop PHP Advancements: Namespaces and Error Recovery

Thu, 06/24/2010 - 02:08

Hi there,

just a quicky before I head off to bed and go on a short vacation the next few days:

PHP support in KDevelop now has support for the first PHP 5.3 feature, namely namespaces. I’m still convinced that the syntax sucks pretty bad in PHP’s implementation of namespaces but well, my hands are tight and I had to support it. Anyhow, with PHP master you shouldn’t get syntax errors anymore when using namespaces, but instead proper code completion, syntax highlighting and context information… Well, full blown DUChain integration :)

Furthermore I just introduced the first few error recoveries in PHP that should make the situation a bit better when you work on a broken file. Up until now any parse error resulted in a file with no advanced PHP features at all until you fixed that parse error. Now it should at least skip parse errors in code segments between braces (classes, functions, conditionals, namespaces, …). It can be much improved of course, and I’ll do just that next week.

Bye!

» KDevelop - ExternalScript plugin

Wed, 06/16/2010 - 14:06

Heyho, me again :)

Seems like I have quite the urge to write blog posts recently… Anyhow:

The last two days I reimplemented / ported two features from Quanta 3 times to KDevelop (if you still didn’t get it: everything is a plugin, hece it will be reused in Quanta 4). What I’m talking about is most importantly the revival of a “execute external script” plugin. It’s currently still in a feature branch, but will hopefully be merged into master soon. But what can you do with it? Well, think about the following usecases and see how they can be solved with this plugin:

I want to compile and run a simple helloworld.cpp-like file without setting up a build environment nor do I want to setup a project for it.
Use an external script: quick compile. It just runs this command: g++ -o %b %f && ./%f
In this code %f gets replaced with the path to the currently active file and%b is it’s basename (i.e. without extension).
I want to sort / uniq / … the selection in the current document.
Here you can either use Kate Scripts, which gives you the same features. But to show you the capabilities of the external script plugin, this is a good example:
Setup an external script, that gets the current selection (or the whole file if nothing is selected) piped into it’s STDIN and let the selection (or, again, the whole file if nothing was selected) in the active document get replaced by the STDOUT of the external script. I’ve added an example doing just that.
I want to google for the selection in the active document.
I got this example from the External Tools plugin for Kate, and made it possible to do that with the new plugin in KDevelop. Simply use the following script: xdg-open "http://google.com/search?q=%s"
Note: %s gets replaced by the shell-escaped version of the selected text in the document.
I want to run an external syntax checker on my file / folder / …
Simply use an external script for it :) With the various %... placeholders it should be easy enough to do.

Here are a few screenshots showing the tool in action:

QuickCompile RunExternal Script SetupExternalScript - sort

Second feature that I pushed in, which you can also see in action for the external scripts, is the possibility to assign shortcuts to snippets and external scripts. Eventually I’ll also try to bring back the “user toolbars” from Quanta 3 times, but I hope to do that properly inside KDELibs for reuse by other applications.

Another thing: In Quanta 3 times it was easier to create external scripts that showed some UI and asked for more user input. This is not possible since Kommander (which was used back then) is not available nowadays. If someone polishes the afaik halfway working port, I’m willing to implement it again. Anyhow I think nowadays one should use Qt Designer and Ruby or Python bindings to create UIs. Sure, a bit harder but much more powerful.

But well, now it’s your turn to write cool external scripts :) And to give me feedback: What kind of scripts would you write? What %... placeholders do you need?

PS: Even though I booked flights and accommodation ages ago, I haven’t yet announced it in proper KDE-style yet:

I'm going to Akademy 2010

» KDevelop Webdev plugins merged into Quanta GIT

Sun, 06/13/2010 - 17:18

Quick note:

I’ve just merged all webdevelopment related plugins except PHP & PHP-Docs into Quanta git. You can get them all in one place now by cloning Quanta: http://gitorious.org/kdevelop/quanta

Since I also moved all halfworking plugins to UNPORTED (they don’t get installed), you should be fine by just installing all of Quanta to get the plugins. If you only want one of them, going into it’s subfolder and building it standalone should hopefully still work though.

In other notes: Thanks to Ruan Styrdom for starting work on a PHP formatter plugin for KDevelop. It uses phpStylist and it’s already somewhat working. Awesome :)

/me is off to more GSOC hacking, bye

» First Days of Quanta+ GSOC 2010

Fri, 06/04/2010 - 22:16

Ok, finally I take the time to blog again.

The last two weeks have been a busy time for me and I couldn’t find as much time for GSOC as I would have wanted. I had to finish up some things at KDAB where I spent the last three months doing an internship (maybe I should write another blog about that eventually…). Afterwards I took five days of vacation, visiting a friend in Lisboa, Portugal - a very good decision to clear my head :) Esp. considering that I directly dropped back into my old job at the IT administration here at my university, where I had to quickly finish another project that I delayed until the last days possible ;-)

But… Even before GSOC officially started I already committed a few small things. But yesterday and today I finally started for good. Thanks to the discussion with Andris (my mentor) I actually think to know what I have to do ;-) Porting Quanta+ is not an easy task, even though there is already a Quanta binary that links against KDE4 and “works”. There are tons of files and hundres of lines of code commented out that are left to be ported. And I have to wager: What can I port in the few weeks left for GSOC and what should I drop for now? What is superseded, or should be eventually superseded, by a proper KDevplatform integrated plugin?

But well, I think I know what to do for the next few days:

  • make Quanta specific code specific to Quanta (yeah, cool eh :P)
    currently QuantaCore is a plugin and hence also shows up in KDevelop showing Quanta specific stuff there, not nice
  • spruce up Ruan Strydom’s XML plugin for KDevplatform and purge the DTEP stuff in Quanta while merging as much as possible
  • make the ‘insert tag’ etc. pp. related actions, toolbars from Quanta3 work again
  • polish Niko Sams upload, css, xdebug, execute script, execute browser plugins

If I manage most of these, I’m confident to say that I reached an important step towards a once again useful Quanta. Lets see how it works out.