Tuesday, 3 April 2012

5 ways to get around "programmers block"

It has happened to us all.

Everything is going swell. Your program is shaping up great. You are writing line after line of good code, almost on autopilot - then BAM. How do you go about doing that? Let's try using gotos instead of a for loop... nope, that's not worked. How about loads of if loops instead of that switch... nope, not compiling. After a while, this can get really frustrating, and make you feel like giving up. I call this programmers block.

5) Google, THEN ask
Try googling the error code you get, or google a certain function. Look at the first two pages of search results, and if you can't find what you are looking for, THEN ask. I cannot emphasize how important it is to properly search before you ask and waste someones time. If you fail to google properly, you will annoy everyone and just get loads of lmgtfy.com replies. A good website to ask for help is http://stackoverflow.com/ - the community over there is really friendly.

4) Get inspiration
Go to freecode.com or pastebin.com and search for a program that is similar to yours, or has an interesting way of doing a certain thing. Remember, never copy and paste code. You will not learn from this, and next time you come across a similar problem you will become stumped again.

3) Rewrite the program a different way
This can be a frustrating option, but sometimes its the only way. Sometimes you don't have to rewrite the whole program, but instead re-structure it.

2) Get some sleep
This suggestion may seem a little bit strange, but studies have shown that sleeping can help you make decisions. Just sleep, or even forget about the project for a few days - when you next come to the project you may find a solution that has been strikingly obvious, but you never thought about it.

1) Learn more
All programmers are still learning, even the really experienced ones. Read about more functions and library.I recommend buying a book about the language you are writing in above guides on the internet. The books are usually higher quality than a .pdf on the internet as anyone can write a .pdf, but a book must be of a certain standard to be published. Also, you can read a book anywhere, but need a to be in front of a computer to be on the internet.

It is really important that you don't give up. You will feel good once you have beaten programmers block, and it will prove a valuable learning experience for future encounters.

Thanks for reading :)

Monday, 2 April 2012

IM spammer

Sup :) This has got to be the most difficult program I have ever written.It is an Instant Messager Spammer that I wrote quite a while ago. It took me many hours and questions on stack overflow. Its worth it though, because usually the harder and more time consuming a program is, the more satisfaction you get at the end. Oh yeah, and a spammer is really funny, I almost crashed one of my friends computers while spamming him.

I tried to use some C style writing for this one, as I thought it would be good practice. My dad had an old book about C (He doesn't program, I have no idea why he had it), and after a few minuets reading I thought I should probably practice some. It took some adjustment to get used to things like "scanf" and "printf" instead of "cin <<" and "cout >>". The TypeMessage() function was the most difficult to write, but then again it is the main part of the program.

Anyway, yeah, check out the source code at http://pastebin.com/8iry9xEk. You can download it in the downloads section, along with source codes and descriptions for my other programs.

Thanks for reading :)

PS. We have a twitter account. Follow @teenprogramming. Thanks :)

Sunday, 1 April 2012

What is 'the cancer that is killing /b/'?

Every day, patriotic 'oldfags' complain about 'newfags' ruining 4chan's random board. Anything that contains a meme or a smiley face will cause a shitstorm of people posting "Back to reddit". In fact, /b/ has been redesigned to curb shit posting, and 'bring /b/ back to its roots'. Now, you cannot change your name, and you have an ID within a thread. Of course, this didn't change anything, and /b/ is still full of ponies and rage comics.



But are bronies and Redditors really killing /b/? No. The people who are killing /b/ are people who have been lurking the site for a few months and consider themselves oldfags. For some reason, wasting years of your life on that image board is seen as a good thing in the 4chan community, and if you haven't spend days in the basement on /b/ then you are an outcast. Anyway, /b/ has turned into an oldfag pissing contest, with people leaping at the chance to prove how much of their lives they have spend on the site.

Oh yeah, and bronies.

Saturday, 31 March 2012

The best programming language

"What is the best programming language?"
"Which programming language shall I learn?"

These question is asked on Yahoo Answers at least three times a day.

Me and my friend was debating this question the other day. His name is Conor. Anyway, Conor writes in Java, and he was claiming Java was the best, as it is easy to write GUI and it is easy to learn etc etc. I disagreed, saying that the C languages are better as they are faster, less memory intensive and a better standard library.

Then, I had another debate with another friend called Callum. He uses flash, and he says Actionscript is the best as it is super easy to make games. I dismissed this, saying that Actionscript isn't even a real programming language.

Then, I had ANOTHER one with my brother, who doesn't program but at one point he 'wrote' in Scratch. He said scratch is the best beginner programming language, but I disagreed saying its OK for children to introduce them to the world of programming, but python is much better as it is actually something you can write in and it is still really easy.

So what is the best programming language?

There isn't one. Java and Actionscript are best for writing games, or anything with graphics. Python is best for quickly and easily writing a program that will do an equation for you, Scratch is good for animating and introducing people to programming, and the C languages are best for writing console programs or text games. It depends on what you want the program to do.

Thanks for reading :)

Friday, 30 March 2012

Starting out with C++

C++ looks really difficult to learn. So many parenthesis, semi-colons, numbers; what do they all mean? Why is there a hash there? What does 'x' do?

This is exactly what I was thinking when I read some C++ source code. My dad tried to learn it ages ago, but he "couldn't get his head around it". Being the younger me, I always liked to one up my dad. I already had a pretty good grip on Python and LUA, and decided to learn to write in C++. We were all beginners at the start - however, most people have college courses and seminars to teach them to program.

I had a .pdf file I downloaded off the internet.

It was brilliant though. I would definitely recommend it to anyone starting out with C++. It was clear-cut, easy to understand, and it taught me to program (it can be found at http://www.cplusplus.com/files/tutorial.pdf). Every day I would spend atleast 2 hours a day infront of a computer screen reading and programming.

C++ has many many advantages:
-Stable has hell
-Faster than the road runner when his laptop battery is on 5%
-Versatile and flexible
-Portable
-Garbage collection
-Object orientated

It can get very frustrating though. The error messages you can get are very unhelpful (compiler-dependent).

Is C++ a good language to learn? IMHO, yes. It is probably the best of the C languages, but you should consider learning Java. I don't know anything about Java though, and can't say anything about it.

Thanks for reading :)

Python - good or bad?

Hello again :)

This blog is only 4 days old, and yet its already reached 1000 hits! And it's all thanks to you guys, thanks for viewing :) You may have noticed I have made a downloads page, where you can get my programs without needing a compiler.

Anyway, Python - some people love it, some people hate it. Its a very simple but versatile language, and anything you can do with C++ you can do with python. Personally, it was the first programming language I ever learnt. It introduced me into the world of programming, and for that, I owe it a lot. I would recommend it to any beginner programmers.

It, however, is not flawless. It only has one IDE, and it is very memory intensive. Also, it 'compiles' to a .pyc file that can only be run from computers that have Python installed (you can get a tool called PY2EXE, but this is very unstable).

Despite this, it is very very easy to learn and can easily introduce you to a C language or Java; and its far far better than the alternative beginner programming language, Scratch. Scratch is fine for children and very young programmers, but its more of a game than a programming language.

Thanks for reading :)

Thursday, 29 March 2012

Lobster pots game- saving highscores

Sup :)

It was the end of term and in maths we celebrated by playing a game called "Lobster pots". It was actually pretty fun (I screwed up and failed) but at the end of class I thought it would be a good idea to spend a portion of my holiday sitting in front of a computer programming.

It was easy, there is nothing complicated in here - however, it was the first program I ever wrote that wrote to a text file. I wrote it a few months ago, and I'm not being big headed or anything but I'm pretty proud of myself. I managed to make it concise and efficient (the whole thing is in 86 lines, a few of those are blank), but it has it's flaws. Check it out - any feedback is appreciated :)

The source can be found here:
http://pastebin.com/hCJMpTXj

An explanation of the game can be found here:
http://www.bbc.co.uk/dna/onthefuture/A912494

Thanks for reading :)