Advertising (This ad goes away for registered users. You can Login or Register)

Learning to code: python, lua, C (for Vita homebrew)?

Open discussions on programming specifically for the PS Vita.
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
CPUzX
Moderator
Posts: 276
Joined: Thu Nov 28, 2013 8:25 pm
Location: United Kingdom

Learning to code: python, lua, C (for Vita homebrew)?

Post by CPUzX »

This forum of all may not be suitable in the least for a topic such as this, but since I'm now a moderator, I'm not sure about having a topic as a question posted by a mod, as it would be unprofessional or just seen as degrading, but since HENkaku's rapid development and success to the scene, it's really pushed me to finally spark back the interest in programming again. Ever since a kid at 10 in 2005 I've owned a PSP, and in 2009 I'd finally "hacked" it, but thought to myself back then that I was too young & incapable of learning how to program/code/develop/create homebrew, or espeically of all - learn a coding language (at all). I'd get too annoyed too fast and give up, and things would be way too confusing; which reinforced the idea that a young age made it even more impossible to learn how to code.

I'm currently reading "Learn Python The Hard Way" and it's going to take some time. C, LUA & Python seem to be the 3 most effective coding languages I've noticed so far.
As a complete noob who has never compiled anything, I'd like to provide more to the scene than just being a moderator. As a moderator, I'd like to at least be able to comprehend some of the things that people ask and also be able to assist them with some of the questions they may have. It seems reasonable to be knowledgable in the aspect of moderating a forum of that interest. It seems as if just researching casually on the internet is not quite enough to comprehend some of the things people are asking in the programming/support forums, and it's really inspired to strive towards more of an understanding of coding & development for the PS Vita and programming in general.

I'd really like to keep the text here minimal, so apologies. It's already gone way out of that perspective.
Some aspects of my question has already been asked in various places around the forum and in other places, but I'd like to just confirm the following in the most basic terms:

To create a homebrew application for the Vita, is C programming language the most effective?

What is the very best way to start from scratch for expanding on the knowledge required to program in general and to develop Vita homebrew? (would it be best to start attempting to learn C programming language before anything else)?
-How do you compile a Vita homebrew application?
-How do you compile the VitaSDK - can it even be compiled, or does the Vita SDK exist for templates/examples(?)
-Is the VitaSDK more of a command-line type of executable?
-Can you use Notepad++ to program homebrew for the Vita, (in C)? Notepad++ for what I remember Rinnegatamante saying in response to another question.lol
-How are Vita homebrews actually compiled into vpks?

I feel a little shamed & pathetic right now for asking what could be very simple questions for knowledge that doesn't even need to be asked, which is also another reason for posting here, instead of in the public forum.
We've all got to start from the beginning, but maybe asking questions like this isn't the right way to go about it.
A bit shameful that I'm asking all of this as a moderator.
Truly determined right now to learn to code and to progress where I failed as a kid with a PSP.
Being the least knowledgable moderator is not something I wish to keep up with.dang.
Hopefully this thread can also provide insight & information/knowledge to everyone wanting to start from square one.

Thanks for taking the time to read this, and for helping out answer and point me (and hopefully other beginners) in the right direction. It's much appreciated.

edit: I've read up on Yifanlu's blog all about how the Vita was exploited, but it's a bit difficult to comprehend with such limited knowledge of the concept behind what language was used or how the exploit was exactly executed, but there's also ARM code - the Vita's processor code set, so maybe ARM is a very important point to consider when it comes to the Vita specifically?

Thanks for everything, guys! :? :x :cry: :evil:
Advertising
fate6
Big Beholder
Posts: 7599
Joined: Fri Mar 09, 2012 1:18 am
Location: [fate6@Canterlot ~]$

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by fate6 »

Ok first off python is a good start but please limit yourself to one language first, shiz gets confusing fast if you try multiple languages when you are starting.
The real important thing is thinking like a programmer so try and get the concepts down first.

C is best but C++11 is getting pushed in to the SDK by davee iirc.

Anywhoo

1)Start on PC, Learn how to code on PC first then move to closed devices like the Vita, Tho if you must then take a look at the source to other homebrew and see how they used functions or achieved specific tasks.

2) You install the open Vita SDK and the ARM compiler, The SDK has the functions and tools to develop while the compiler puts it all together so the Vita can actually read it.

3) Yes it needs to be compiled but its all mostly automated sorta... You install the ARM compiler then run makefile for the SDK
This is horrendously over simplified way of putting it but you don't have to compile it, there are pre built versions available so all you do is drop the SDK anywhere then add its location to your PATH.

4) Yes everything it does would be CLI(Command Line Interface) unless someone mad a GUI for it tho in most cases thats pointless.

5) any source files are just text ya know, You can use any text editor you want but yea N++ is good since it highlights the text for easy reading.

6)Well first you compile which gives you your elf then using a tool in the SDK convert that to self, Next setup your directory structure and add any assets it needs, Now you need to generate se_sys which is the icons and an xml file that tells it the name of the buble and such(look at anything vita and just copy theirs if ya want), Finally you just zip it all up and rename the zip to vpk.

I am terrible at explaining things so I know all of this probably makes no sense which is why im going to suggest asking on the forums, Nothing to be ashamed about IMHO and heck I don't know all that much myself, I just picked up info along the way.

Just because you are on staff doesn't mean you need to be a dev, im sure as heck not one.
But yea open up a thread in S++ or in the public forum and if anyone tries to give you lip then remind them that the mods are always right and arguing with admin is their own bad time.

Alternatively PM hgoel0974, he is a former mod and a friend of mine that I like to bug about stuff since he is an actual dev and knows what he's doing. If you post this in the Securty++ subforum it will summon him, I can assure you.
Advertising
Image
anon wrote:If you can't trust a 600 year old vampire in a prepubescent girl's body, who can you trust?
CPUzX
Moderator
Posts: 276
Joined: Thu Nov 28, 2013 8:25 pm
Location: United Kingdom

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by CPUzX »

Thanks, man. You know more than I thought!
Moved to Security ++ for now. Might decide to move to the public programming forum later on...

So perhaps C will be the best language to learn to start off, right?
The first language being the one that Windows operates by.
It's cool that the Vita has homebrew written in C/C++ too, well, ARM, as that already simplifies many aspects of narrowing down what is required to research and learn, but it's not going to be easy either way.

That's a good point. Every programming language is different, that's one thing I do know. But learning more than one at the same time would be even more confusing. As a kid, it's probably trying to dive straight into how to program for the PSP that made it all the more confusing. It's best to start with C - the language built upon Windows first, huh. Thanks for the confirmation on that. Awesome. If C is the primary language for use with the Vita, it'll also be simplified upon gradual knowledge to do with Windows OS too.
I expect coding to be nothing like using cheat engine or modifying save files, or hexadecimal values. Those are the only things I'm actually good at, and you don't even have to be a pro to do any of that.lol.

That's awesome, source code can be read in any text editor, I've actually got to try that. Even with barely any knowledge in this department, it should be relatively comprehendable to a slight degree through all of these years of messing around with stuff; even though I'm not a developer. Something so simple and I didn't even know that. Nice. Always thought you had to open source code in a compiler, (but that was assuming it was an actual compiler, not a text viewer/editor.

So the Vita SDK has a "makeafile" file in it that you place into the ARM compiler to initialize the use of the SDK?
I've seen a bit of information about "makeafile", but I mostly just assumed it was what you ran when you were about to compile a program/homebrew(?)

Thanks for the help, that clears up quite a few things. Even if you have limited knowledge with all of this, it's far more than any average modder/hacker - the kind who download other people's work and replace files, or like in the PSP days, create a magic memory stick & pandora battery with information readily available). To a complete noob like me, you're already talking like a developer. Bet you could create your own homebrew too, it's already awesome how you know all of this yourself. It's obviously very simple knowledge to other developers, but it's a good start, and I appreciate the help. I think I'll focus on learning C for the very first task. It shouldn't be an ordeal if it's interesting, (which it is). I guess it should also be slightly easier to learn C than Japanese too. I'll PM hgoel0974 if there are any complications upon attempting any homebrew builds/tests as I go along. I expect there will be many failures at first, but they must be overcome with patience & determination. All of the developers here are magical. How does it all function, how do you know that, how did you get it to do that, what kind of god are you to break the security of the vita and it's just overwhelming information that is difficult to process all at once. Step by step...
Thanks also for the reassurance. 8-)
fate6
Big Beholder
Posts: 7599
Joined: Fri Mar 09, 2012 1:18 am
Location: [fate6@Canterlot ~]$

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by fate6 »

Hmm OK lets try an clear some misconceptions first. Windows is codded in all sorts of languages, It's kinda a mess these days which is where the many problems in W10 come from.

C is a very common language for being a powerful yet portable language, Powerful since you can code just about anything with it yet portable since you can compile C for just about anything. Remember that hardware can't read C or any human readable language, all it knows is on or off which is why you write your program in a human readable language(like c) then the compiler translates it to specific hardware architectures, so in the case of PC the compiler will translate it to x86 while the Vita runs ARM so it gets translated to that, This is one of the reasons you can't just run like a PS2 game on PC without an emulator(which emulates the PS2's architecture among other things). There is then the linker and stuff but im not going to get into that right now.

Look up the "Sams Teach Yourself" series of programing books, I read up the C++11 one earlier this year and it does a fantastic job of easing you into a language and even teaches you the basics of how the compiling process works.

EDIT: Oh and make files are just sets of instruction for the compiler so its a good idea to have but for small projects its not 100% necessary.
Image
anon wrote:If you can't trust a 600 year old vampire in a prepubescent girl's body, who can you trust?
CPUzX
Moderator
Posts: 276
Joined: Thu Nov 28, 2013 8:25 pm
Location: United Kingdom

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by CPUzX »

fate6 wrote:Hmm OK lets try an clear some misconceptions first. Windows is codded in all sorts of languages, It's kinda a mess these days which is where the many problems in W10 come from.

C is a very common language for being a powerful yet portable language, Powerful since you can code just about anything with it yet portable since you can compile C for just about anything. Remember that hardware can't read C or any human readable language, all it knows is on or off which is why you write your program in a human readable language(like c) then the compiler translates it to specific hardware architectures, so in the case of PC the compiler will translate it to x86 while the Vita runs ARM so it gets translated to that, This is one of the reasons you can't just run like a PS2 game on PC without an emulator(which emulates the PS2's architecture among other things). There is then the linker and stuff but im not going to get into that right now.

Look up the "Sams Teach Yourself" series of programing books, I read up the C++11 one earlier this year and it does a fantastic job of easing you into a language and even teaches you the basics of how the compiling process works.

EDIT: Oh and make files are just sets of instruction for the compiler so its a good idea to have but for small projects its not 100% necessary.
Thanks for clearing that up.
Yeah, the processor architecture differing from Gamecube, PS2 & original Xbox being a pentium III.
PPC for the Xbox360.

I'll look into that series.
Have you ever thought about creating a test homebrew on the vita just to see if you can?
How about a simple PC trainer, for an example?
I'd probably feel as if everything was too overcomplicated and wouldn't know where to start right now if you hadn't of guided me in the right direction. Thanks for the info!
fate6
Big Beholder
Posts: 7599
Joined: Fri Mar 09, 2012 1:18 am
Location: [fate6@Canterlot ~]$

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by fate6 »

Gamecube and Xbox 360 are both PPC variants while PS2 was MIPS iirc
The OG XBox was x86 but its custom GPU is what makes it a nightmare since it has a booty load of undocumented functions iirc

And IDK I probably could make something and have made a few PC programs and even make mods for BethSoft games from time to time but im not all that interested in programming, im more a fan of design and debugging which might sound like some kinda masochistic desire to more then a few devs.
Image
anon wrote:If you can't trust a 600 year old vampire in a prepubescent girl's body, who can you trust?
CPUzX
Moderator
Posts: 276
Joined: Thu Nov 28, 2013 8:25 pm
Location: United Kingdom

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by CPUzX »

fate6 wrote:Gamecube and Xbox 360 are both PPC variants while PS2 was MIPS iirc
The OG XBox was x86 but its custom GPU is what makes it a nightmare since it has a booty load of undocumented functions iirc

And IDK I probably could make something and have made a few PC programs and even make mods for BethSoft games from time to time but im not all that interested in programming, im more a fan of design and debugging which might sound like some kinda masochistic desire to more then a few devs.
I've seen that Visual Basic is supposed to be a kind of user-friendly compiler, which helps for those who are new or inexperienced to coding in C and C++, so maybe that can simplify some of the learning, perhaps

Would it be safe to put this whole thread into the public programming section as it is right now, or maybe brush up the thread first?
fate6
Big Beholder
Posts: 7599
Joined: Fri Mar 09, 2012 1:18 am
Location: [fate6@Canterlot ~]$

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by fate6 »

You could move it if you want or start a new thread if you want to rewrite the OP, Up to you.

The problem with an IDE is it hides things from you like with VS you have a text editor and in it you write your code then just hit the compile button, Done.
Take the IDE away and you would have to either write up a batch script to run the compiler or open up the command line and type it out yourself.

This gets more complicated with switches and optimizations and stuff but yee.

Another big problem is that in the case of say Visual Studio its a Windows only IDE so if you only learn how to use that then you are stuck on Windows.
Same for XCode on MACs. They try and lock you in so you only make apps for their OS.

With a random text editor and the command line you would have the knowledge to code for and on any system but yes it requires a little more learning.
Image
anon wrote:If you can't trust a 600 year old vampire in a prepubescent girl's body, who can you trust?
CPUzX
Moderator
Posts: 276
Joined: Thu Nov 28, 2013 8:25 pm
Location: United Kingdom

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by CPUzX »

fate6 wrote:You could move it if you want or start a new thread if you want to rewrite the OP, Up to you.

The problem with an IDE is it hides things from you like with VS you have a text editor and in it you write your code then just hit the compile button, Done.
Take the IDE away and you would have to either write up a batch script to run the compiler or open up the command line and type it out yourself.

This gets more complicated with switches and optimizations and stuff but yee.

Another big problem is that in the case of say Visual Studio its a Windows only IDE so if you only learn how to use that then you are stuck on Windows.
Same for XCode on MACs. They try and lock you in so you only make apps for their OS.

With a random text editor and the command line you would have the knowledge to code for and on any system but yes it requires a little more learning.
Not good. I'd always seen visual studio to be a noob-friendly alternative to learning the hard way, but there is no easy route with learning to code.
Thanks, think I'll stick to a text based solution rather than an IDE.
hgoel0974
Retired Mod
Posts: 2155
Joined: Mon Jul 23, 2012 11:42 pm
Location: New York

Re: Learning to code: python, lua, C (for Vita homebrew)?

Post by hgoel0974 »

I intended to reply earlier, but got caught up with other stuff.
So, for starters, don't worry about asking programming questions as a moderator, people will most likely actually end up responding to you faster/in a better way to get on your good side :P (going by how I started out at least).

As for writing homebrew for the Vita, as it stands, things are still pretty new and so there is very little documentation to go by, which is why most developers have experience working with other systems. Getting up and running however, isn't too hard if you have your basics down well. Namely, if you can understand simple makefiles and can write basic C code, you're ready to at least give it a shot. I would recommend practicing writing code for say Linux, or for Windows with an Msys environment. This should help you get used to makefiles and building from the command line, while also giving you some confidence working with C.

As for choice of an editor, I tend to use Sublime Text 2 for C/C++ but you can use pretty much anything you want (except something like Visual Studio - which doesn't let you easily use makefiles, dunno about XCode), source code is just a plain text file which means it can be opened in anything (this is one of those things Windows tries to hide from people, back when I started out, the idea that I could theoretically open any file in a text editor, or a hex editor was pretty surprising to me too).

I didn't actually rely on any books to learn most of what I know so I can't recommend any books, but on the Freenode IRC network, you'll find the ##c channel to be helpful for any C programming related questions, as well as #henkaku for henkaku specific questions.
"If the truth is a cruel mistress, then a lie must be a nice girl"
Locked

Return to “Programming and Security”