Friday, July 23, 2010

 

Assembly Language Sounds Fun!

Well I don't know what sounds better then actually talking to hardware in the PC using small code, but it looks fun too learn!

Yes even though C++ is a high level language you don't have the flexibility too actually communicate to the CPU and tell it what too do exactly then maybe doing a math problem using C++.

So for right now I'm currently studying and writing notes on Assembly Language, then maybe I can play around with it and create something interesting. It would be a nice change too since I can maybe do really neat stuff as for example creating my own language and a compiler too convert my language into assembly! ASM->OBJ->exe!

I know I sound like I'm rushing into things, but it sounds like a fun idea after some good time spent with Assembly. Even a very small OS that just talks too the ram and video card would be a nice refreshing thing.

Plus it would look really cool on a resume.

Thank you, Andrew!

Thursday, July 22, 2010

 

Why I Don't Like Some C++ Programming Books

There are some reasons why I don't like some of them.. Here are some flaws with those books...

1. Most source code in the book doesn't use precompiled headers when creating a big project or even a project that has more then 3 files.

2. Some source code in the book don't use classes in the best places as possible too avoid namespace pollution when making a project.

3. Some books don't even talk about some methods that could speed up compiling! Like adding classes or groups of functions in their own file(s).

4. I don't think a lot of advanced topic books talk about how hard it can be with out telling the reader in the description what books would be good too read first before they read that one.

So why?

1. Precompiled Header:
"In computer programming, a pre-compiled header is a technique used by some C or C++ compilers to reduce compilation time.
" -Wikipedia

It's great too use this, since this will speed up compile time and it's very easy too create and use. So if precompiled header looks like this:

#ifndef STDAFX_H
#define STDAFX_H

#include <iostream>
#include <stdio.h>
#include <windows.h>

#endif

Then we don't have too add all the required headers needed for every single source file you made, like so!

main.cpp:
#include "stdafx.h"
#include "someHeader.h"

int main()
{
//...
return 0;
}


Not bad right? Thats what all beginner level books should be teaching as well! So we don't have people creating projects that are spammed with header files all over the place with long compile time! believe me this will drastically improve compile when working with large projects!

2. Classes are the best things ever invented in C++! They do so much for us!

One of the top reasons why we should is that, lets face it! Microsoft maybe already came up with a name for it in Win32 or your using someones code. One of you could have came up with the same name for a function, variable, pointer, etc! That means you would have too rename and remember more then you should with your own source code!

NOTE: You can always learn too use the #undef for a function and rename it something else.

Too make life easier for everyone we use classes because they work like structs, but classes are much more flexible too work with. We can add functions, variables, etc in them and just call a function like this or a variable:

MyClass m_MyClass;

m_MyClass.SendMessage("Hello World!");
m_MyClass.NumberOfMessages++;

Since that sendMessage function is already being used by Win32 and perhaps we are using the API we can just make that function listed in our class! It will make the compiler not get confused as well!

3. Like stated there are some things that could speed compiling like I mentioned a few times! But some compilers work differently such as Visual Studios can compile a tiny bit faster if we sort our variable types in structs/classes. Such as smallest to biggest variables that use more bytes.

4. I don't see a lot of books saying this is too advanced for you if your completely new. I know they won't say this, because they want you too buy the book, but if they say "hey buy this beginner level book first by the same publisher or writer first". Then they could make more money!

One the reader will want too buy a book they can understand first off! Second if you help your readers learn the basics then you could get more money from them buying two books from you if you also suggest what books would be good for them to read next!

I hope you find this article interesting and I appreciate you reading it!

Thanks, Andrew.

 

Formating Code Examples (For All Programmers)

I think every new programmer needs to learn how to do formatting in their code after some time with using the command line for creating their software!

Reason:
Have you ever looked at a bad blog by some whinny teenager complaining about something or some idiot who doesn't look like is familiar with the English language and has NO formatting in the paragraphs?

Then after a minute or a few seconds you looking at the post you click the back button instead of reading the hole thing?

Well imagine having to look at someones code that is like that! But every freaking line has code in it! No white spacing between certain functions or if statements!

That would be a nightmare for me having too read it.

In this second blog post I will give examples of bad formatting and some good examples!

BAD Example With Braces:

//...

if(true){
//...
}else{
//...
}


GOOD

         //...

if(true)
{
//...
}
else
{
//...
}
Did you notice what happened in the good example? Did you find it easier to look at?

Well a few things changed, one being that the braces have their own line, two the comment line is now five spaces more then the braces! The reason why we do that so it makes it much easier to tell if that line of code goes inside the set of braces! Three is that we pushed the hole if statement area five space more then the code!

Things like that can make a big difference too! You will be kinda surprised making changes like that will improve a lot of things on how you see code and write it for other people to view!

Here is a messy example:

BAD

//...


while(true)
{
//...
if(true)
{
//...
}
//...
}


GOOD

//...

while(true)
{
//...

if(true)
{
//...
}

//...

} //While
As you can see we basicly applied the same methods as the last example, but did you see whats different? We basically commented the ending brace. So why do we do that? Whens the best time too do that?

We do that, so it's easier too tell from braces go to what. Believe me you will run into problems such as braces being place in the wrong area or there is too little or not enough ending braces that cause compiling errors or problems for you because of your code being too messy or big.

The best time too apply these braces is to functions, big loops (while, for, foreach) that will have a lot of steps in them. It will make your life and other programmers life's happy too be able too tell what braces go to which! :D

Use Comment Lines!

Comment lines will not compile with your code! If it does then your compiler your using isn't good...

Its real nice too comment on functions that may do complicating things or return lots of data. Give a description about the function or structure your making in your code! It will let you and other users able too go back and have fun looking at your code then spending more time going through every piece of line. Of course format the comments as well along your code. :)


Nice Formatting Tools:

All I know is how to use Visual Studio and Notepad, but Google search "IDE editors" or "Scripting Editors"! There are millions of them for every language almost! Most of them freeware or really cheap.

Visual Studio Tip:
Auto Formatting
1. On the source code press Ctrl + a or select the area you want to format correct.

2. Press Ctrl + k first, then press Ctrl + f! Simple as that!

Wednesday, July 21, 2010

 

Hello World!

Hello everyone!

I will be posting projects, thoughts, ideas, and maybe some tutorials too read that I hope you find interesting!

I'm currently using these APIs (Application Programming Interfaces):
OpenGL, MySQL Connector C++, Winsock, Win32, FMOD.

I will be mainly talking about things in C++, I haven't used Java, or C# for a long time so don't expect too much.

I'm in love with C++. It's the most simplest language I have ever seen that's understandable as well, kinda ironic now to me since most people say it's difficult.

More then likely they haven't used many languages like I have...

I will also like to add is that I WILL quote user's on forums that help me out! So if I make a blog and add something you say, I will give credit to the user on the side of the quote. :)


Thank you, Andrew.

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]