Showing posts with label microsoft. Show all posts
Showing posts with label microsoft. Show all posts

Monday, 30 May 2011

Why I like C++

I am no C++ expert. In fact, my knowledge barely goes beyond pointers, arrays and classes. I couldn't create a fully fledged desktop application with it to the same degree that I can do in Java or C#, but I am gradually learning the Windows Development Process - even if it is a nightmare at first, especially with no MFC (Microsoft Foundation Classes - you need the full version of Visual Studio to get these). However, I have found that learning and coding with C++ is actually quite enjoyable.

The Syntax makes sense

A Java programmer can look at C# or C++ and get it. A C# programmer can look at C++ or Java and get it. A C++ programmer can look at C# or Java and get it. The reasoning for this is the syntax is nice. Everything is tabbed, variable decelerations happen based on type, initiation is easy, classes are easy. Blocks of codes are surrounded by curly brackets {}. Everything is easy to code. Even a beginner can look at some C++ code and make sense of it - there are only really a few basics to learn before a programmer can do an awful lot.

It's extensible

Some programming languages are incredibly limited because they do not allow for easy extensibility. C++ is not one of these languages. The default libraries for C++ are incredible, and development with these is neat, tidy and professional. These libraries can be extended upon by libraries provided by either sources, such as Operating Systems or SDKs.

Programs are lightweight

When I compile a program that does something simple (say a simple Math game) it is only a few KB in its compiled form. In Java it can be a few times more and in C# it can be dramatically bigger due to the .Net framework. C++ is not like this. Not only are the files themselves lightweight, the strain on the processor is lower and C++ programs tend to run faster because they use less resources.

It's compatible

When I write a simple C++ program I can re-compile it for many systems purely because there are compilers for those systems, and in fact there are C++ compilers for almost every system. Even if I'm coding a UI based application I can still recompile it with little modification thanks to the huge number of libraries like GTK that allow for interfaces to be created easily.

People actually use it

If I have a problem with C++, I can easily go and Google for the solution because so many people use C++, support simply exists. After all, the less popular a language is, the less support there is because there are less people to support it, but as one of the most popular languages, C++ is instantly helpful.

Learning is easy

Once you have learned the basics of C++ you can easily extend your knowledge because there is a global understanding of how it works, and all C++ programmers know to write their code in an easy-to-read way so that continuing to develop in the language is easy. A good example of this is learning Windows development in C++. Creating a Window does bring in different libraries and classes, however there are no really complex requirements for initialising a Window.

Saturday, 28 May 2011

OpenGL vs DirectX

OpenGL really is quite incredible. It has the honor of being used for nearly every 3D environment, or at least a variation of it is used for nearly every 3D environment. Its libraries are used across phones, games consoles, TVs, computers and hundreds of other devices. Despite this incredible success, is it really the best tool for 3D today in applications?

DirectX is what Microsoft likes to sell to the world. It is used in Windows, Windows Phone and XBOX. DirectX has frequently been the choice of games developers working on Windows because it has a wide set of libraries and integrates incredibly well into Windows. It is currently being used to render Windows Presentation Foundation (WPF) applications built with the .Net framework and these are frequently faster than their WinForms counterparts.

However, both DirectX and OpenGL have advantages and disadvantages. The problem with both is that when you are using the other on a platform that they both exist on (basically Windows) there is no reason not to use either of them. DirectX is just as good as OpenGL for most tasks and vice verse. However, there is a reason to use OpenGL over DirectX: its lightweight.

I hadn't really dabbled much in OpenGL programming with C++ before, however I realized that my compiler already had all the tools that I needed to get started, and I did. However, if I wanted to get started with DirectX development on my computer, I would have to download the enormous DirectX SDK, and I don't really want to have to do that.

Not only is OpenGL already there, but it isn't difficult either. Creating windows with C++ is hardly hard work - it can be done in about 30 lines of code and with a bit more work you can add OpenGL support. My IDE on my laptop, Dev-C++, comes with an OpenGL sample of a triangle spinning round and this is just 191 lines of code. What's more is that even an OpenGL beginner like me can read the code, it is all just basic functions and numbers - no complex pointers or anything.

OpenGL also has the advantage that it can be used in just about any programming language, even JavaScript now, whereas DirectX has a very limited portfolio.

I can't really say that I am into 3D graphics programming, however it is very interesting, and I am sure that I will consider it more in the future.