10 Days of Basic Programming, Day 1: Introduction
Do you wanna become a homebrew developer? Perhaps a PSP hacker? Are you just interested in programming in general?
You’re in luck, I will be guiding you throught the process of learning programming from scratch.
To define programming in general I came up with the following: programming is the art of telling the computer what to do, and watch how it ends up doing whatever it feels like. Programming and computers in general are exact science, but not always what you write is what you think you wrote.
That’s why you have to be very careful to understand all the various terminology in programming and make sure you’re using it right.
In /talk I have a very particular signature: any fool can write code that a computer understands, good programmer write code that a human understands.
This was written by Martin Fowler. I don’t really like Martin Fowler, I consider him to be one of the reasons why C++ and Java’s OOP suck ***, but this particular sentence is as true as it can be so creadit where credit is due.
When writing code it is very important to make it as maintainable as possible: code must be very well written, not be overly-complicated, make good use of the different design patterns there are and all the clean-code rules that most good programmers use. Remember, it doesn’t matter how badass you are writing code or how amazing the stuff you do is, what matters is the quality of the code. Also, project complexity doesn’t dictate code complexity. One can create a huge project that does loads of stuff with very clean and readable code, or a small project that barely does anything with really bad and dirty code, so don’t use project size as an excuse for code complexity.
It is also important to know that software is a vast world with many different areas of expertise. Don’t expect to be able to master everything as that’s impossible. One can be generally good in most (or even all) areas, but only be a master in some areas. Nobody can deny that Linus Torvalds is an excellent programmer and one of the best OS kernel developers, but you won’t see his name in AI, graphics or other areas.
This tutorial will teach you programming and general areas where it is used, mostly game programming for homebrews, but it is up to you to find your area of expertise and dig info on it.
For the sake of genericity I will avoid using any particular language in this tutorial, I will teach you programming in general terms and see how various different languages approach the different terminologies. Some people will probably tell you to learn programming with C or C++ to become a guru. That is B-U-L-L-S-H-I-T. Though C and C++ are a must to any programmer, knowing these languages doesn’t make you a guru, and my experience tells me that most people who start learning with C or C++ tend to write bad code as these languages are really versatile as to what they allow, and in the case of C there aren’t many coding conventions, and the ones there are aren’t properly taught or even taught at all. One example of this is ARK, VHBL and TN-X. They were great pieces of software that achieved a lot, but the code was horrible and painful to read and maintain. Most of the time spent on ARK was spent refactoring the code to make it more maintainable rather than fixing it or adding features. VHBL-Reboot, which qwikrazor87 and I worked on, is essentially a more maintainable version of VHBL, not much else changes.
Generally speaking you have to think about this when writing code: if I leave my code alone for several months and go back to it, do I want to spend too much time trying to understand what I wrote myself? The answer should be just plain NO, you don’t want to spend too much time reading the code trying to understand what you were doing back then. That’s why code must be as readable and understandable as possible.
Another important aspect of programming other than code-readability is efficiency. Efficiency can be a problem, or a minor annoyance.
In general terms, the closer to the hardware, the more efficient the language you have chosen is, but also the harder it is to code.
Higher-level languages provide you with tools and syntax that lets you code really fast, but they come at the expense of efficiency. A real guru is not one that can write any code in C, but one that knows which is the best language suited for a given problem. That is why in this tutorial I will cover all from low-level to high-level programming, and show you what are (to me) the two best lanaguages of each world: C/C++ and Python, as well as some mentions to other languages. You should by all means learn as many languages as you can, but those are my personal recommendations.
At the end of this series of tutorials (which will be really LONG, I expect them to take about 3 months) I will show you one of the projects I’ve been working on for personal use: CbC, an external C preprocessor that adds many high-level features to plain C code, similar to C++, but with a much different approach. With CbC I wrote Minefield Madness with much less effort than if I had written it in plain C, without loosing C’s performance.
I have a question,how to become a ‘ps vita hacker and exploiter?’…
Once you’ve learned the basics of programming, head over to /Talk. They’ve some great tutorials on setting up development software and programming games.
Acid_Snake wrote a really great Python tutorial for the PSP there. (http://wololo.net/talk/viewtopic.php?f=5&t=13112&hilit=python)
You could also take a look at the recent webkit exploit. There’s some fun stuff you can mess around with over there.
Good work!
I’ll blame the unreadability of VHBL on m0skit0 (it’s easy, since he left the scene he won’t be around to share his version of the story…. I’m kinda lame I guess).
More seriously though, there was a huge disagreement between him and me on what constitutes readable code, and that probably led to many of the readability issues. Sometimes we would go my way, sometimes we would go his way. There were also dozens of additional contributors, and no strong rules on how the code should be written. It’s much easier to write readable code in a team of 1 or 2.
At the end of the day, there are parts of it that I never understood myself, and I probably wouldn’t put it on my resume as an example of clean code that I wrote, but you can also question your own ability to read code 😉
HBL and ARK both solve the very hard problem of working in an extremely constrained environment. This brings additional problems in the code, for example in HBL the need to use these weird global variables stored in the scratchpad, to avoid them being wiped out for some random reason.
So, these are not your typical “let’s build my own app with a friendly SDK” type of code.
VHBL was not only unreadable, it was also badly structured, ARK suffered from that too. There was no concise place to find something. This is also one of the reasons why I hate Java, the way packages and namespaces work make everything so convoluted. For example, if in python you import a module, you can’t just access all the global names directly, you still have to access them through the namespace, this makes it pretty clear where a certain class, function or variable is, in Java if you read code you never know exactly where a certain class comes from.
I don’t understand how programming in teams works tbh, im just starting out in programming (python & java). In an ide like eclipse or pycharm you create a project and start writing your program. This is done in one window, and you are working on one .py or .java or class at a time. So can you explain how working in teams works pls i dont understand?
Most teams use tools like git, svn or tfs. What these tools do is allow you to save your code not only on your local drive but also in a small cloud (a repository). Other members of your team can “checkout” this code and work on it on their local drive. When one is done editing a certain class he/she can upload it back to the repository. This way multiple members of a team can work on their individual parts of the project. Meanwhile, in the repository, it all comes together.
Good 😀
First! I would like to say nice tutorial…I would also like to learn a bit more also I’m how shall we say very ecentric. And a nerd and worked for the phone co. For 20 plus years installing switching equipment and programming the switches.but that programming is a totally different ballgame. I love to hack anything! ™
Nice can’t wait to read more got to learn objective c last thing I ever learnt was basic lolz
Great! I’ll keep an eye out for the entire series and make time to actual digest it. I’ve been learning to code on and off for more than a decade. I eventually lose interest receive conflicting recommendations and end up just putting it away to try again later.
I’m really interested in your articles because you clearly state your intentions and offer reasons for your recommendations. I usuallly get the oh do it this way because reasons… Use this, learn that because (insert some form of I was taught/learned this way). It just makes me question if I approaches until I freeze up and quit.
Thank you very much.
I commend you Acid for doing this. And what’s really interesting is that a few weeks back I wouldn’t have understood what you where talking about when referring to language and syntax. I myself decided to start learning programming and then hopefully develop something I have in mind in the future. I just want to mention that on YouTube, if you look up introduction to computer science and programming. You will come accross a course by an MIT professor. Not taking anything away from you Acid as I am looking forward to your teachings since they are geared more towards what I want in the end…best of luck
excellent .. no doubt seguire these teachings, I have always wanted to contribute to the scene’ve had ideas for me but always crashed against the wall of the lack of knowledge .. in fact recently started to study programming and these snap that will serve me. . I hope the next …
I don’t understand the emphasis on keeping things readable. I mean if you are trying to help the scene or working in a team it could save others time, but what if you are working alone? If you are making an indie game wouldn’t it be better to be messy AF to make it annoying for people trying to steal/reverse engineer your work?
This much I know… It is like going back and trying to read cursive that you yourself wrote. My writing sucks unless I take my time, so, sometimes I cant read my own writing… or atleast it makes it hard to. When I did websites, I used html instead of an editor. Trying to change a layout or just add a field where you want it to on a page is hard to do when you just jumble stuff together. I am sure the more advanced the coding, the more the effect is true. As far as getting your work stolen; if your the kind of person to do that…. guessing in theory on my side, what ever is trying to be stolen would be easy to change the required stuff just by searching keywords to change that ties it to the original author. Code can be contradicted to provide the desired outcome based on the order of requests.
Im no “guru” lol, but my understanding is that If youre worried about getting your code stolen you dont release source code, just binaries or prepackaged software that is only machine readable. So to reverse engineer the software, the original code (where readability matters) will never be seen.
What you point to is obfuscation, nothing to do with code readability.
Even then it is better. You put your game out. Homebrew is – lets face it – a small scene, not many play your game. Months pass till someone hits the final level. Game crashes. The bug is easily reproducable and looks like something you can fix in one or two hours work. It takes you two days, because you forgot how your code works and it was not helping you to get a easy reentry.
Thankyou good sir for deciding to take the time to do this. I for one will read them and try to put them to applicable use….. I say that then I willl realize how little time I have and end up not following through…. but the knowledge I will hopefully obtain will help me on small projects. Okay, been a while since I drank posted… I hope this odd thankyou comes across atleast half the way I wanted it to.
Not to spoil your effort:
1) When you want to teach you should teach something to flex your skills (and by extension contribute something new). It is really hard to get the scene-gurus to share their knowledge openly (no its not because of legal issues – its because they love the fame and hate to teach the competition).
But teaching C is not a contribution in this day and age. Go further, start at your current project and detail it. Let others bounce ideas off of you and start working (openly) together so more can join in. C is something really simple to pick up on the interwebs 😉 Take a look at Harvard – http://cs50.tv/2014/fall/ – they took the time and money to make it shiny.
2) The idea of diddling with the pre-processor is problematic. You create a “C” that others can’t use. Depending on how you do it, it has drawbacks. Trust me, you are not the first to do weird preprocessor stuff – C is OLD … all has been done 😉 Doing C OOP style (naming conventions etc.) on the other hand is a very noble effort.
3) While I agree that C on noobs creates bad code, its not really because of C … its because the noobs have not been told style. C doesn’t come with style because it was created before language creators invented it. Today you pick up ruby and you get told how you “should” do it. Ruby is a multi paradigm language. You can write stuff in n different ways – potentially. Look at C# – that thing has “ref” and “out” – I have seen people exclusively use those nasty anti OOP tools 😉
4) I still wish you da best my man! Will creep watching ya ;D
1) I can’t teach advanced stuff when most people here are strugling to learn the basis. This tutorial is for the future exploiters and homebrewers, not for exploiters and homebrewers now.
2) I believe you don’t know what CbC is. It is NOT fiddling with the C preprocessor, it is creating a sort of external, very specific, preprocessor (alrhough it functions more similarly like an IDE). It makes C code look like a TOTALLY different language, but it is still C. This can’t be achieved with the C preprocessor.
3) I agree that it’s not C’s fault that it leads to bad code, I should have mentioned that in the post. C# is NOT the example to use when talking about clean code. C# as a whole has a very modern OOP design, which C++ and Java lacks, but it still FORCES you to put everything inside classes, which IMO is the worst thing a language can do – sometimes the cleanest, simplest and most readable way to do something is a function, not a class, not a namespace, but a simple function – and it still maintains the horribly aweful classic 90’s OOP.
BUT, while I don’t like C#, I do believe C# is what Java should have been and I appreciate it as a language, specially since it is very aware of the huge flaws Java has, I just wish Microsoft would have made it a TRUE general purpose language and not a Windows-only thing with OOP up-your-*** from the very start, then it would have definitely replaced Java in every way and I’d be a happier man today.
I’ve always felt like those who create, exploit, tinker and mod are the true “geniuses/wizards”. I’ve been following PSP homebrew scene since 07 and was really proud of my first pandora battery and CFW flash. But, I have a desire to be part of the group that forwards the scene, instead of following it. Even if I don’t end up doing it, gaining any knowledge and understand is a desire of mine.
I’m rambling, but what I want to say is thank you Acid for taking the time to make this tutorial. I’ll be following this series!
…and we’ll be expecting for this article to become more “readable and understandable”…
-reader
Very interesting! ill be reading all the tutorials, for sure.
Its a big commitment. Great work!
will keep an eye on this. hope this tutorials become a permanent section , so we can boost the scene a little.
It’s good that you are introducing basic programming, but for a 10 day guide, you’ll only at most cover up to function calls. There’s just too many things to introduce that play key roles in analyzing software and developing. You would have to introduce segmentation faults, overflows, pointers, vectors/arrays, race conditions ect ect. Data types should be your day 2 guide, you have to definitely explain what types are available for people to use. Then you follow up with modularity and how it’s useful to write reusable functions that can be included in other programs.. ect ect. Introduce some basic things like while loops, for loops, break statements, continue, if, else if, and some recursion too so people don’t end up writing 100 lines of code just to code to 100….
This is actually going to be a 40 days features, but they are split up into 10 days a month, each month covering different levels. And the blog post is not the only place where we’ll be covering this. All the theory will be here, but the practice will be in the blog section. And trust me, it only takes 10 articles to cover all the way up to structural programming in terms of theory.
plz dude go for ps vita hacker and exploid i like to know bout vita hack or exploid
psp hack is fun too i thing its be great if you learn us psp hack
becuse you know every thing about psp .
plz start with psp hack
every one have psp or if they dont they can buy becouse that is chep
psp hack is great start for start
SMILES ALOT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Very much looking forward to the rest of the series, I can see this being very useful for me. Thanks Acid _ snake!
I love illuminated key boards never had one in my life though… 🙁
I wouldn’t start like this. From what experience I know, the best possible thing you can share, when you introduce person to a programming is understanding and visualization of algorithm. Because there’s nothing more pathetic in programming than a person who can write code, but doesn’t understand what’s the actual point in writing that $s = s+1;
Algorithmia – calculating complexity, avid algorithms, backtracking, etc – is defeinitely something not for beginners.
calculating time complexity isnt very difficult and if youre working with python which is what most beginners first learn then it should be fairly straight forwar considering how python is like english..
Now I get the idea that you have ZERO knowledge of what algorithmia is. What the heck does Python have to do with complexity? Algorithmia as a whole is language independent.
I don’t say to go *** deep into this stuff, but getting to know what a conditional branch is would be awesome and universal knowledge
I don’t say to start with complex stuff. Knowing branches and loops is universal knowledge for a programmer. For example, I’ve never coded in C, but when I saw code snippet from one of previous news, I knew what it did the moment I read it. Just because I understand syntax.
P.S. Not sure why my previous comment just disappeared. I didn’t violate any rules.
Although it is very early in the tutorial for people new to programming, I did want to pass this site on to others and the op in case he wants to use it similar to a guide. Mainly because he walks through the code (assuming you have somewhat of an Idea of how c++ works) and it ends up with the user creating their own 2-dimension space shooter game using the Allegro Library.
tl:dr; – Here is a tutorial for 2-d game dev. with c++ and the Allegro Library
site link: http://fixbyproximity.com/2d-game-development-course/
WHY do people keep on complaining, when valuable, informative, useful, helpful content like this is blogged on the Wololo front page?
Can everyone stop FORCING their useless, invalid opinions and actually lay down your own opinions as alternative; rather than direct critism? Good.
This is a very useful guide, Acid_Snake. I’ve always appreciated your efforts, as much as Yifanlu.
When will lessons to follow be delivered?
Thanks!
That’s what I’d like to know. There’s already 4 days uploaded, it’s up to wololo to publish them