[JASJAR, XDA Exec, MDA Pro General] vijay555:
gooroo: many thanks for your kind words.

Let me first say that I am an absolute amateur in programming on the Pocket PC. As I've said many times, there are many incredible guys (and gals!) on this site and it's a pleasure to know you all, but none of my little releases are anything compared to the stuff they bring into the world. Anything I say below is certainly full of errors, so take it all with a “pinch of salt”!

Second: I'm working very late in the office these days, but during the little free time I have, I am working on redesigning my website, hopefully to also launch a blog and ultimately a new forum (I don't host my current forum, and it goes down from time to time). The blog will carry an RSS feed to show when new releases are available, but also address the problems and lessons learnt that I encounter when programming.

But, to start you off, first some info about my “experience” or lack of!

My background is not as a programmer. I have played with computers for years, and am “self taught” in VB. Whatever anyone says about VB not being a real language, I say that it's still the best way to do quick and effective GUI based PC work. And with VB .net, it's as powerful as any other language. The kind of stuff I was doing with VB was about as far as VB could go, and I’d say it’s still a very competent language and a good one to learn from. I still program in VB daily, and built my own webbrowser in it, and I don’t use any other browser!

So, VB learnt to a reasonable degree. And I've written many little (and not so little) programs on the PC. However, after upgrading from a p900 to a Magician late last year, there were many small things that I saw weren't quite "right" with WM2003. I was quite pleased with the OS, but a few things that were clearly missing for it to be entirely satisfying. However, I was very pleased that it was a pretty “open” system, in that it was basically a system I could learn to program for. That’s the biggest difference between our phones and non-“smart” phones. Remember, it’s us that make smartphones smart!

So, I thought about using eVB, embedded Visual Basic, for the phone. But first there’s no guarantee it’s going to be supported in the future, and it relies on a “run time” to work. For anyone that doesn’t program, a run time is basically an interpreter that takes eVB code and turns it into code the phone understands, providing facilities in a kind of “library” of functions the eVB code can call upon. Although useful, this interpretation takes time, and so can be slower than non-interpreted code.

At this time I also had the pleasure of meeting a wonderful guy who works for Microsoft, David Goon. Although at the time he was showing off how amazing .net is, I asked him about the best way to start programming Today plugins (which was what I wanted to program at the time), and he said that C++ was still the most effective way. Although Today plugins can be written in .net, .net still relies on a kind of run time (called the Compact Framework) , and this can again slow things down.

Some background about .net: this is not one language, but basically an incredible idea for “unifying” languages. With .net, you can program in any language supported by it, including C++, VB, and many others (I understand there are about 20 languages or so!). These are all effectively “front ends” to a huge library of functions – the computer again “interprets” your chosen .net language into code it can understand. But what this means is that all .net languages have the same “power” since they all ultimately rely on the same “root” library.

Now, anyone learning to program should have a look at a few online tutorials and try to get the feeling for a language they like. All have strengths and weaknesses. As far as I’m concerned, I had no choice, I had to learn C++ for my Today Plugins. C++ is, as the name suggests, an extension of the C programming language (the name is a kind of joke only programmers could get away with. ++ in C means “increment”, increase by one – so C++ is C with a bit more!). But C and thus C++ are old languages! But it’s effective and powerful. It has been said that the vast majority of the Windows operating system has been programmed in C++.

So, why isn’t everyone programming in C++? Well, it’s not always the best way to do things, “new” languages are still being developed, and C++ has itself been expanded by Microsoft into a language called C# (C sharp). I can’t tell you about any languages other than my own experiences with C++ and VB. Maybe someone else can provide some details? But going from VB to C++, one of the biggest things to learn is about memory management.

VB allows programmers to be very lazy with memory. If you need some memory, you just ask for it in a rough way. In C++, at every stage, you must tell the system: “I need some memory. It needs to be this kind of memory. I’m going to use it for this long. It’s going to contain this kind of data”. That takes a lot of learning – you need to form a lot of new habits, and it’s easy to forget them, which can lead to crashes, or “memory leaks”, where you forget to “give back” the memory you asked for, so over time the system memory just “disappears”.

Because C++ is very strict about memory, it also helps it to be very precise, very fast and effective. C++ is faster than .net normally. But, one major reason why .net was developed was because of the memory problems. In C++, if you say “I need 10 bits of memory”, and then you try to put 15 bits into that space for some reason, what happens? It overflows. That overflow might not be noticed… but it might be overflowing into another important bit of information: like when you spill coffee on your white table cloth, you’ll notice it! This kind of overflow can cause major crashes, and it’s a favourite way for hackers to crash your operating system or server, put viruses onto your system, or run pirated games on your xbox. It’s an exceptionally useful technique to learn for that kind of hacking, but ask me about that another time… :)

So, “buffer overflows”, as they are known, are bad. And C++ makes it very easy for a programmer to allow them to happen if he’s not careful. And that causes crashes etc. Who’s to blame? Normally the programmer! But .net and some other languages are designed to catch this kind of stuff. They are designed to prevent these kinds of accidents to make it much harder to cause problems outside of your own programming. This makes the operating system more stable. So .net is good, at a cost of some speed. On your PC, that’s not important, your PC is fast. But your PDA is never fast enough, is it?

The kind of stuff I’m programming is called “Win32”. As the name suggest, Win32 is part of Windows – it relies on the Windows API – Application Program Interface. This is a set of functions the operating system provides to “do stuff” with the operating system. This can be things as simple as putting “…” on the end of a bit of text, or as complicated as logging onto a network and sharing files. You could technically skip Win32 and program these things yourself, but it would be very tedious, and not always compatible between one system and the next one. Software that uses the Windows API should work on any other system using the same APIs.

Note: The operating system on our phones is currently called Windows Mobile (it’s been renamed a few times!) which is basically a version of Windows CE, an operating system used in various types of “embedded devices”, like set top boxes, cars, shop tills and so on.

I’m using Win32 and C++ to do pretty much everything I do on the Pocket PC. There are “extensions” that work on top of Win32 to make things “easier”, eg MFC, the “Microsoft Foundation Class” Library, but my advice is learn Win32 before learning these extensions. It’s always best to know how something works under the skin before dressing it up. So, whatever language you’re learning, I suggest you become familiar with the way Win32 works, if you’re doing operating system type work. It’s incredibly boring, but a skill you’ll keep for as long as you program on Windows. The PDAs have a “subset” of the full Windows API, but much of what you learn will work on a PC and a PDA. The best ways to start learning Windows API is, in my opinion, to browse the MSDN – the Microsoft Developer's Network. This is an enormous collection of information on pretty much everything Microsoft does. I couldn’t code without it.

The second best way to learn Windows API, but also extremely useful, and essential, is to download and review the Pocket PC SDKs (Software Development Kit). These contain information necessary to learn about how to program for that particular device. You can choose which SDK you download – one for Pocket PC 2003, or Windows Mobile 5. I suggest that if you’re learning C++, you should start with the PPC2003 SDK and then move to WM5. You might as well learn to program for both, but if you only learn about WM5, it might not always be compatible with PPC2003. But PPC2003 is almost always compatible with WM5 (since the newer system has expanded the “old” one). And there are still a lot of WM2003 users out there! SDKs on MSDN.

Another good reason to learn C++ is because the programming “environment” you need is basically free! Microsoft makes eVC – embedded Visual C++, available for free from here. Again, whatever you’re programming, free is always a good price, so you might as well download it and start playing! It’s a 200mb+ download, but it contains lots of information for you to start learning.

To properly develop for WM5, and if you’re going to develop in other languages, then you’ll need to get hold of Visual Studio 2005. It’s a very nice environment to program in, particular if you’re using .net. The C++ environment is a much more basic, it doesn’t have a lot of the incredibly useful things built into the .net programming environment, but it works! And if you program in C++, you get used to pain :) And of course, VS2005 also allows you to code for the PC in the same environment.

Ok. So, at this point you’ve chosen a language, chosen a programming environment, and are ready to start learning to program. My advice now is to stop! Don’t touch the computer - go to a book shop and buy a book, a paper book, not an ebook, on your chosen language, and start reading it. I find holding the tangible book in your hands a much more reassuring way to learn and absorb since you can see how much you’ve got through and how much is left, and it’s very quick to jump from one section to the next. Most programming books come with an electronic version as well, so it’s even better (tip: most ebooks can be converted into a version you can also read on your PDA, so they’re great for long train journeys! Contact me if you need help with this).

For C++, I’m still extremely new, so I started off with “C++ for Dummies” by S. Davis. I’m sure other people would recommend other books, but I’m a Dummy, so it was very useful to me. In some places it’s a bit too brief, in others it’s too detailed. But you’ll learn at least the basics and a bit more, and be ready to move further. It’s a very good place to start! Amazon Link

Next, I suggest looking at the SDKs. They come with many example programs to demonstrate various ideas, and they’re an invaluable resource. At this point, you should also get hold of a PocketPC/Windows Mobile specific book to learn how the operating system works. “Programming Windows CE.NET” by D. Boling is probably the best way to start; he’s extremely readable and this book is excellent. (He writes a lot of the PPC stuff on MSDN!) One thing to note: it’s all non .net C++, despite the name, except for a few pages at the very end. If you want a .net reference book, get a .net book, not this one! But this book is never-the-less essential for anyone learning to program for Windows CE. Amazon Link.

I also recommend “Windows CE 3.0 Application Programming” by N Gratten and M Brain. Not as big as “Programming Windows CE.NET” but more detailed in some areas, less so in others. Amazon Link. If anyone has this book on paper, please contact me.

Ok, at this point, like me, you’ve spent a long time reading and reading and reading. Now start some coding! Learn to program “hello world”, and from there, the sky’s the limit. The website PocketPCDN will be extremely helpful to you. XDA Devs is an astonishingly useful tool for programmers and for learning good and bad habits for coding. I recommend you read every post written by the geniuses on this board. You should already know who they are :wink:

Modaco is also a very good place to search Newsgroups etc.

When you start really getting into this Windows CE programming, you may want to download the Platform Builder trial from Microsoft. Platform builder is basically the tool used by our phones’ manufactures to prepare the ROM and systems we use. You could do the same if you wanted to, but would have to write the drivers etc for the hardware. But it contains an enormous amount of code for the internal workings of Windows CE.

I’m absolutely no expert. I have no experience beyond what I’ve mentioned here. However, programming is extremely time consuming and takes a perverse dedication to a goal. It’s very rewarding when people say your code is helpful to them, because only you can really appreciate how much work goes into it! It’s helpful to be able to survive without sleep, to dream about coding and have the kind of mind that can take problems apart, and hates to give up on a challenge. I recommend that everyone should have some basic idea about coding – for guys, since we can’t create life, creating code is about as close as we get to Eve’s Burden!

I hope this information is helpful! Please comment with corrections, questions and your own helpful advice.

V

PS – if anyone wonders why I’m so egotistical about calling all my programs VJBlahBlah, it’s because I write a lot of Macros to expand Microsoft Word. But for some incredibly silly reason, the Macro dialog in Word has been non-resizable for at least the last 12 years. And when you have a lot of long filenames, it becomes almost impossible to find them. So all of my macros will always be in approximately the same place on the list..