Home > Other projects, Rant > Small project in C#

Small project in C#

Disclaimer: Sometimes I feel like writing about programming. And then I do. If it is not your cup of tea, don’t read this.

In case anyone is interested, I have uploaded the source files of my second “project” I wrote in C# as an exercise. There is no documentation for it and I have no idea what files make up a C# project, so I just packed everything in a ZIP file. To compile you will probably have to change a few paths, but apart from that nothing is necessary. Just download this SQLite port for C#, add the System.Data.SQLite DLL from it to the project and it should compile. I used Visual Studio 2010 express and it needs at least .NET 3.5 or maybe 4.0(?). Don’t expect anything serious, this is something I wrote in 2 days.

How to use (once it compiled):

  1. Download JMDict_e.gz and unpack the file as JMDict_e.xml to the “debug” or “release” folders created automatically for the project. (In other words, the data must be in the executable’s folder.)
  2. The data file is called JMDict_e without an extension, remember to add .xml!
  3. Run the program. This will create a database SQLite can use. (It will throw an exception when it’s done, don’t worry about it.)
  4. Close the program and run it again. You can browse the dictionary.

I have used many C# features that are not present in C++ and it’s possible that an experienced C# programmer would never do it like how I did. Still I’m proud of it as I have used some “advanced” programming features (i.e. reflection) after only spending a few days with the language. For example to describe table columns to my little SQLite wrapper, you just have to create a class containing some fields… Yes, it is nothing serious. Sorry for bringing it up… I have only uploaded it because I didn’t just want to delete the code after spending the whole weekend writing it.

My conclusion: (In the now traditional list format)

  1. I could learn this language to some extent if I spent a little more time on it.
  2. MS documentation sucks. It tells you how to use A to achieve B without explaining what A or B is. Good luck finding out information about those.
  3. MS documentation sucks.
  4. C# has a few intriguing features I have no idea how to use, but I suspect some great secrets are waiting to be discovered.
  5. I still don’t get it why anyone in their right mind would use interfaces apart from the compulsory built in types. Abstract classes always give greater freedom with additional features.
  6. It is clear why static cannot be virtual in C++, but in C# the class types are practically objects themselves (when using reflection) and functions can be easily invoked on them. Static virtual functions would have made my life so much easier…
  7. The compiler and program make up all kind of new types as they execute, which is very confusing for a beginner.
  8. No matter whether it is the built in database with ADO.NET or SQLite, both are very slow to make a dictionary like zkanji which has to look up tens of thousands of words each second. I couldn’t achieve more than 2-3000. Scrolling the dictionary had acceptable speed, but searching while typing simply didn’t work. I will try to rewrite the whole program, either by keeping some look-up data in memory all the time if it’s possible, or creating my own data handling classes, like I did in zkanji. (I could probably port the dictionary browsing code from C++ in a few hours but then I wouldn’t learn anything.)
  9. There is no point comparing Visual Studio with Rad Studio. Both are great in some things, terrible in others. (Is there a way to look up the result of function calls in the debugger in VS without having to step into them?)
  10. Intentionally trying to write complex code just to learn something is fun. (Only depends on your idea of fun, really.)
  11. I wish I had someone to ask about C# while coding. I have no idea if I did things the orthodox way or my solutions were so crazy no wonder it was a pain to make them work.
  12. You can see the keywords like “strongly typed” a lot while learning C#, because the documentation writers and forum posters are all proudly using them. I don’t say it’s bad or good or anything, C++ is “strongly typed” too after all, but they all sound like some ad slogan to me.
  13. I don’t hate C# more than C++, even if someone might think so from reading my blog. I just stopped complaining about C++ long ago.

I could probably make up more to write if I thought about it, but I’m tired and the only real conclusion I’m serious about is that I’m not satisfied with my own performance yet. (I bet I’ll get a lot of spam for this.) I think I haven’t used most of the central C# features, or not how they were intended to be used, and instead used others that people would only try as their last resort. Or maybe not, but there is no way for me to find out.

Categories: Other projects, Rant Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: