Adventures in C# and Windowsland, part 1

Yes, you read well, I meant C# and Windows. No, you understood wrong, I’m not leaving the boat.

Turns out that I am able to get up to 4 points more in one of my networking exams at university if I deliver a small Networking-oriented project. Obviously, I am gonna take this up. Unfortunately, the project *has* to be done with the .NET framework.

So today 2 guys (I wonder how much Microsoft pays for this) came to show us basic C# and ASP.NET usage telling us how beautiful, easy and whatever .NET is compared to anything, while I was rumbling in my head that I could have done the same things they were doing (at least for the C# side) with Qt with the same amount of code (or even less), *really* multiplatform and *really* native looking. Anyway.

I decided to take this as an opportunity to find out what’s outside the KDE, Qt, and Linux land, and see if there is something worth being used out there. So I set up a Windows XP virtual machine in VirtualBox (that, by the way, is an incredible piece of software) and installed:

  • Visual Studio Professional 2008
  • Microsoft Expression Studio

And started out playing some games. Obviously, I will compare the 2 tools with Eclipse and Qt Designer, the tools I use the most.

The installation process was a pain in my ass. Seriously. Installing Visual Studio just for C# and ASP.NET took more than installing Windows itself. I can’t understand how this is possible. Installing Expression Studio took its 10 minutes, that I am trying to accept as a reasonable time, trying to forget that I use pacman and reinstalling the whole KDE takes 1-2 minutes. Anyway.

The thing that sucked the most was installing the MSDN library. Aside from the fact that comparing Qt Docs to MSDN seems an insult, and MSDN really fails in providing a new, but quite experienced programmer an useful, browseable documentation, and that’s 100 points less, IT TOOK 80 F*****G MINUTES TO INSTALL. Now, we all know that 1.5 GB are a decent amount of files, but I wonder what MSDN installer does apart from copying them. Indexing? No, actually trying to search stalls windows. Supposing Windows copy system sucks and it took 20 minutes to copy the file, I still wonder why a strange action I don’t recall the name of took 60 minutes.

Ok, let’s try to forget this and try to get a first opinion.

Visual Studio, on which I heard all kinds of bells & whistles, isn’t very much superior to Eclipse IMHO. I found out some features I am used to, some features I like (like autocompletion of events), but it looks like it focuses that much on autocompletion and similar stuff that sometimes gets in your way (like autoindentation when you don’t ask it). One of the reasons why I like Eclipse out of anything else out there (yet) is that it provides the essential features to speed up your work, nothing more nothing less. Visual Studio still remains a nice IDE, but I wonder what happens when you use classes outside the MSDN Library.

Expression Blend is another matter. It is probably the best tool I’ve ever seen in ages. Its interface reminds of the Adobe Flash one, and the nice news is that you can do anything you could do with Flash: creating animations, custom controls, dynamic styles, etc, without writing a single line of code and with the possibility of exporting to C# AND Silverlight. Blend pretty much rocks, and I invite anyone who cares about similar stuff to try it (there’s a free 30 days trial on microsoft’s site), since it’s a tool I would love to see. I imagine Plasmate being something similar. And Qt Designer being something similar in the future.

Anyway, after seeing all the possibility in the GUI side without writing a single line of code, it comes to the point when you actually have to write some code. After 30 (!) minutes of researching, I found out how to access members created in Blend in C#. One could argue I don’t know how to search, I could argue that for some reason I find what I need with Qt in some seconds, and Blend documentation doesn’t have this. In fact, I guessed. Probably Blend developers thought that everything could be done without coding. Anyway, prepare for the horror.

Storyboard story = (Storyboard)Resources[“FieldsIncomplete”];

What.the.hell.is.that. You are telling me that to access an animation I have to write similar shit? I sincerely hope there is another way, otherwise no matter how good Blend is, but fails. Or better, XAML fails.

Then, layouting plain sucks. Anyone who has ever used Qt Designer and was singing while drawing perfect layouts with a single click would start swearing looking at how weird Windows Forms and WPF handle layouts. I can’t even explain since I still haven’t found out how they work. That’s a huge point less.

That’s all for now. There are some good points, some very good ones, some bad ones, and some awful ones. As of today, the way you can design the GUI (except layouting, that had the opposite effect) and the animations in Blend is the only thing that didn’t make me regret using Qt.

In the next days, I’ll try giving some insights into C#, and start really comparing it to C++/Qt

~ by Dario on 8 April, 2009.

30 Responses to “Adventures in C# and Windowsland, part 1”

  1. Well I agree that VS sucks about installation and system resources, but you were running stuff in VirtualBox. If you try that without virtualisation, I’m sure you will get better performance.

  2. I quite don’t think so, since on virtualbox windows installs and starts up faster than on the same machine without virtualization (back in the days), so I think it’s really not virtualbox to blame. Also other people who installed VS & MSDN complained about the same problem, that anyway is a general problem of windows installations

  3. oh poor dario, i feel pain for you :p

  4. Since VS 2005 is the only IDE I know well (having been taught mostly VB.NET in college) I wondered what it would look like from a Qt developer’s point of view. I love all the autocompleteness in VS, it took me a while to get used to the differences in Eclipse for the 2 classes I had in Java, and I can’t imagine using an IDE that doesn’t support a lot of autocomplete. I never tried Blend, or anything else from .NET 3.x, as it came out a year before I graduated and the department hadn’t switched yet so I can’t comment on that. The one thing always bugged me about layouts in Visual Studio was the use of a strange measurement unit the twip, which is what I think caused your problems too.

    Oh, and the fact that in VS everything is absolutely positioned so you have to write all sorts of code to reposition items in the maximize event in case the user doesn’t like working with whatever size you made your form… I hope Qt Designer is better at this?

    VS is a pig, 2005 barely ran on my machine with 512 MB of RAM, and of course it eats hard drive space. More than anything I have every seen, including Windows and even MS Office 2007. I never found the documentation very useful either, I turned to my teachers and classmates for help instead.

  5. Thanks for the review. As Linux nerds, we often have a pretty narrow horizon. Looking forward to a follow-up. As a language, C# is supposed to be very good.

  6. “Visual Studio still remains a nice IDE, but I wonder what happens when you use classes outside the MSDN Library.”

    If you’re wondering about code completion, that’s achieved through reflection and works on any assembly you reference.

  7. @marco:😀

    @Angel Blue01: Thank you very much for your comment, I hoped to raise some opinions from people more experienced than me. Yes, Qt Designer’s layouts works even when Maximizing. They actually react to every change in the widget’s size, and that’s probably the best thing we have in Qt in the GUI design part, and the more toolkits I discover, the more I realize it. Btw: I use Eclipse with C++ (and with Java since a month, for university), and Java support has more features Visual Studio have.

    @Hans: Thanks for reading, I plan on more than a follow-up, both for tools and languages

  8. In my previous comment, I meant that Eclipse in Java have more features that you can find in Visual studio that Eclipse/C++ misses.

  9. @Toni: That’s cool, but what about inline documentation? That is one of the features I like the most

  10. I have tried using Visual C++ on windows, natively, not emulated, and I can tell you that the performance actually *is* horrible.
    And don’t get me started on their “Managed” C++.

  11. And yes C# is a nice language, have a look at Generics, Linq, lambdas (some of this is also already in Mono). For your web project you might consider ASP.NET MVC. jQuery comes builtin.

  12. Nice insights, out of curiosity I planned to give it a try too. I wonder whether non-MSDN auto-completion does also work with C++?

  13. @drfav: inline documentation for any classes show up in Intellisense as you type. A shorthand for generating a comment body (for classes, class fields, properties & methods) is typing three consecutive slashes. It works pretty nicely once you get the hang of it.

  14. I’ve installed Visual Studio 2008 on a windows system before and it really *does* take over an hour. As a matter of fact, there’s a point where the installer just hangs for a period of about half an hour without any feedback on what’s going on. I was about to close it thinking it had failed when i t finally just moved forward. And don’t get me started on the time it took to copy the libraries’ documentation

  15. What I find interesting is that you *have* to program in the .net framework – and the fact that two men came and showed you how to do it.

    Sounds like something from a conspiracy movie. Does your univ know that MS is peddling this stuff to its students?

    Anyway good post!!

  16. @Toni: thanks for the hints, I’ll check them out.

    @Javier: At least I’m not the only one🙂

    @Matt: I don’t know. For sure my university has a partnership with Microsoft, in fact I own a license for each product I mentioned, thanks to MSDN Academic Alliance, that lets students of partner universities obtain a download and license code for free. I know that sucks, but I take this as an occasion.

  17. Thanks for the review! Like Angel Blue01 I like to know what there is beyond your horizon. Love to see the next article too!

  18. I would suggest staying far away from WinForms. They are pretty terrible. However, WPF + XAML + C# makes a pretty ok development environment for GUI apps. If you are actually serious about picking up WPF you will probably need to buy a book because Microsoft’s documentation really sucks in helping you learn a technology (this may be because they have a technology book publishing subsidiary). In any case Visual Studio breaks your brain because you don’t actually learn the languages you program in. There is such a thing as too much auto completion. Text Editors FTW.

  19. thank you, now i know i’m not the only one that had that pain when working with that .NET stuff… my experience was quite similar

  20. Personally, I had the same reaction when moving to Windows and .NET (I am also a student, and had previously spent 3 semesters using nothing but Linux and Java). However, I think that you’re taking the wrong approach if you take it negatively from the start. Both environments have their good/bad sides after all.

  21. @Diedrik: For sure🙂

    @Tim: In fact I was attracted to WPF (mostly thanks to Blend, that Microsoft doesn’t push enough, imho), and I’ll probably get a book, thanks for the hint.

    @bert: shit happens, they say😀

    @Jean: well, if you read my post carefully, I’m taking a completely neutral approach, in fact I said that Blend is superior to any tool I’m using right now, and Visual Studio has some more features I like than Eclipse have. I am very open to alternatives, in fact I’m taking this as a chance to learn🙂

  22. I found weird your surprise to the way to access animations in code with C#, it’s just an object in a hastable that is being casted. Now, If you compare it to this Qt lines of code:

    widget1.defaultModel()->appendItem(new QtListDefaultItem(“Simple!”));

    The “defaultViewMode()” function violates all the conventions I know, it is a property? use a getDefaultViewMode(), is a class method? the setDefaultVIewMode should be a better name.

    I just find extrange you feel confortable with this syntax compared with the hashtable syntax.

  23. Ramses: your example comes from a blog post on an experimental new implementation of ListView in Qt, API details probably haven’t been worked out yet, please compare to something that is actually in Qt now to be a bit more objective.

  24. @Ramses: apart from the fact that that one is still not a Qt API, the problem from hash tables is that I need to explicitely cast to retrieve something usable, and casts are bad, especially when you’re retrieving an object by its name. XAML could have been provided a StoryBoard object, that would have been more simple, intuitive and safe.

  25. Comparing C#/WPF with C++/Qt isn’t that fair.
    C# is the “lazy” kind of language like Java.

    Try to compare C++/WPF with C++/Qt or C#/WPF with Java/Jambi.

  26. @SDiZ: Erm, that’s what I’m doing. Anyway, the functionalities in QtCore are the same of the “laziness” of C# and Java

  27. I often comment that Microsoft’s corporate newsletter department is the largest user of the Linotype in the world. If they were actually using their own products for the purpose, they would have to fix them.

    I have gvim installed on my Windows machines so I can get work done, but my debugger is VS2005, so I’m often starting and stopping VS. A pain, but better than dealing with all the pain of VS.

  28. To be fair, I think some (at least) of the layouting and design issues you guys are finding are more a lack of experience with the platform than with the platform itself. For example, in WinForms, take a look at the Dock and Anchor properties for making controls that reflow/resize when the parent container’s size changes. Also, TableLayoutPanel’s saved me mountains of trouble in the past.

    On the other hand, I’ll definitely agree that Qt is just that much better to work with for anything that’s a little more than your standard WIMP application.

  29. You can’t really understand/use WPF without understanding the model-view-viewmodel architecture.

    WPF objects directly bind to viewmodel data.
    Once you get used to it though, its very powerful.

    However, it’s mostly useful in projects where you have a lot of data which has to be presented and manipulated by the user. Or projects where its important to stylize the ui in funky/non-standard ways.

    If you are writing a simple control app or toy project, WPF is way overkill.

  30. WinForms doesn’t seem to have layouts as such. What it does have is anchors (I think they’re called). You can anchor a widget to any combination of north, south, east and west, and so have it expand when that side of the parent container moves.

    It’s always been enough for me with the simple forms I’ve created in VS.

    Intellisense, on the other hand, is the single best feature of a microsoft product I ever remember using (I haven’t used Expression Studio, though). I work with C# at my dat job, and Intellisense makes my life so much easier. OTOH, from what I’ve seen of Dave Nolden’s work on DUChain in KDevelop, it blows Intellisense out of the water.

    And ASP.NET is not the perfect web language by any stretch of the imagination, but it’s a damn sight better than PHP.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: