Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Vapourware Trying to learn programming from ~0, realistic goals naturally help needed.

7h30n

Augur
Joined
Aug 14, 2012
Messages
311
THE STORY
- i am not superb or super talented. I am normal dude.
Just drop this, you don't have to be super talented or extraordinary. It all comes down to practice and willingness to improve and learn all the time.
Learning to program is easy but becoming good at it takes a lot of time and investment from your part.

Any opinions on that training program ?
I heard python is good for newbies, is that true ?
Opinions on that choice. Practicality of python in future (games, apps and stuff).
Should i start with something else instead ?
What is difference between procedural language and object based. Is it harder ? easier ? Which should be though first ? Opinions.

.

I haven't checked the training program.

Python is a good choice, it's easier more seductive. It leads to the dark side.
Ok joking aside, it is a good language. But if you become really good with it you will become spoiled when you switch to another language like Java or C#.
Another bad mark is that you are quite detached from the low level stuff which can be quite important.
Practicality of Python is very high, it can be used a scripting language in games. It is used in big companies for both web stuff and desktop GUI stuff. I worked with Python at AVL and they use it to create most of the stuff found in their simulation editors.
It really doesn't matter much what you start with if you are willing to always expand your knowledge and learn new/different stuff.

Procedural, object oriented and I would add functional programming are just styles/tools for getting the job done. I wouldn't bother with that at the moment. Python is an excellent language because it allows you to use all those tools and doesn't lock you into one style (like Java and object orientation). When you get familiar with Python then look into them.

I'm in a hurry, I'll come back later and give some more input.

Edit: I would recommend Emacs or Vim for editing code.
 

Perkel

Arcane
Joined
Mar 28, 2014
Messages
15,897
THE STORY
- i am not superb or super talented. I am normal dude.
Just drop this, you don't have to be super talented or extraordinary. It all comes down to practice and willingness to improve and learn all the time.
Learning to program is easy but becoming good at it takes a lot of time and investment from your part.

Any opinions on that training program ?
I heard python is good for newbies, is that true ?
Opinions on that choice. Practicality of python in future (games, apps and stuff).
Should i start with something else instead ?
What is difference between procedural language and object based. Is it harder ? easier ? Which should be though first ? Opinions.

.

I haven't checked the training program.

Python is a good choice, it's easier more seductive. It leads to the dark side.
Ok joking aside, it is a good language. But if you become really good with it you will become spoiled when you switch to another language like Java or C#.
Another bad mark is that you are quite detached from the low level stuff which can be quite important.
Practicality of Python is very high, it can be used a scripting language in games. It is used in big companies for both web stuff and desktop GUI stuff. I worked with Python at AVL and they use it to create most of the stuff found in their simulation editors.
It really doesn't matter much what you start with if you are willing to always expand your knowledge and learn new/different stuff.

Procedural, object oriented and I would add functional programming are just styles/tools for getting the job done. I wouldn't bother with that at the moment. Python is an excellent language because it allows you to use all those tools and doesn't lock you into one style (like Java and object orientation). When you get familiar with Python then look into them.

I'm in a hurry, I'll come back later and give some more input.

Edit: I would recommend Emacs or Vim for editing code.


Thanks for your input. So far this training programs seems to be awesome imo.
 

Goliath

Arcane
Zionist Agent
Joined
Jul 18, 2004
Messages
17,830
Programming is not for "normal dudes", sorry. I know tons of programmers and they are all high IQ autistic freaks without exception. Look into modding instead. Writing some quest scripts is realistic, writing a game from scratch is not.
Really just learn whatever "script commands" you need to learn to make characters move/attack/say things in a pre-existing game. That way you might end up creating something fun. In contrast, the chance that you will manage to build a game worth mentioning from scratch is practically zero.
Is there any way for a modder type like me to get into indie development?

What exactly do you mean? "Indie development" usually means writing games from scratch and as I said I am convinced that is not a realistic goal for most people.
 

Destroid

Arcane
Joined
May 9, 2007
Messages
16,628
Location
Australia
Programming is not for "normal dudes", sorry. I know tons of programmers and they are all high IQ autistic freaks without exception. Look into modding instead. Writing some quest scripts is realistic, writing a game from scratch is not.
Really just learn whatever "script commands" you need to learn to make characters move/attack/say things in a pre-existing game. That way you might end up creating something fun. In contrast, the chance that you will manage to build a game worth mentioning from scratch is practically zero.
Is there any way for a modder type like me to get into indie development?

Sure, grab an engine and make a game.
 

titus

Arcane
Patron
Joined
Sep 28, 2011
Messages
1,719
Location
Romania
Programming is not for "normal dudes", sorry. I know tons of programmers and they are all high IQ autistic freaks without exception. Look into modding instead. Writing some quest scripts is realistic, writing a game from scratch is not.
Really just learn whatever "script commands" you need to learn to make characters move/attack/say things in a pre-existing game. That way you might end up creating something fun. In contrast, the chance that you will manage to build a game worth mentioning from scratch is practically zero.
Is there any way for a modder type like me to get into indie development?

Sure, grab an engine and make a game.

You can't really "make" one without actually writing code. Even complex mods require scripting, not to mention making a game from scratch using an engine.
Probably only as a designer, if he has the skill. Team up with a newbie programmer, grab an engine and DESIGN a game?

As for the OP, I suggest learning procedural programming and algorithms first then OO. Then the rest lol
After you get to think like a programmer you can learn whatever language you want with relative ease. It's a long time investment.

Ofc, I write business stuff so what the fuck do I know.
 

7h30n

Augur
Joined
Aug 14, 2012
Messages
311
Ok something i don't get:

Code:
print "Welcome to Unatco Corp. Traveling system"
nights = raw_input("Please write number of nights you want to stay in hotel :")
city = raw_input("Write city you want to stay in on your trip :")


def hotel_cost(nights):
    return 140*nights

def plane_ride_cost(city):
    if city == "Charlote":
        return 183
    elif city == "Tampa":
        return 220
    elif city == "Pittsburgh":
        return 222
    elif city == "Los Angeles":
        return 475
    else:
        return "Not Available"
     
ticket_price = plane_ride_cost(city)
hotel_price = hotel_cost(nights)

trip_price = ticket_price + hotel_price

print "Thank you for using Unatco Corp. Traveling system. Your price for trip is %d $ with %d $ travel expenses to %s" (trip_price, plane_ride_cost(city), city)

interpreter says that ticket_price is string not int when i type "Tampa" which should return 220...
So i can't add ticket to hotel price in trip_price as one is int and other is string...

Any ideas ? Conversion ? I imagine that when argument is string then it also returns things as string..

What happens here is that plane_ride_cost returns integers in 4 cases but the 5th case is a string. Python is dynamically typed but strongly typed (not weakly typed like Perl), so when you do ticket_price + hotel_price you are adding a string and an integer (if "Not Available" was returned). This means every time you input a city that doesn't get matched to those in function your program will break since it will try to add string and an integer. Now, why "Tampa" isn't matched I can't tell. Probably some misspelling.

I see that you ask a lot on the first page about editors. Here's my opinion.
You have IDEs (Integrated Development Environment) and "plain text editors" (the reason why they are in quotes will be explained later).
From IDEs I would recommend Visual Studio (with plugin), PyCharm and Eclipse (with PyDev plugin). IDE does a lot of things for you, it compiles and links stuff, provides a debugger, syntax checking etc. All in one package.
On the other hand you have plain text editors. Now you probably know about Notepad++ and the like. Those suck! The ones you probably haven't heard about are Sublime, Vim and Emacs. Those text editors are the most powerful tool to write text - especially code. They can be easily customized to suit your needs and even can get part of the functionality of an IDE.
The advantage of those text editors is that they really do provide the fastest way to write code, they are blazingly fast and can be customized exactly like you want them.
The disadvantage is obvious, you don't get everything in one place and the main disadvantage in case of Vim and Emacs (those 2 being the most powerful) is the learning curve - they take a long time to learn how to use properly (Emacs being a bit easier than Vim).

I personally use Vim because it is very fast and allows very fast editing of code (unmatched by any IDE I ever used). Last but not least, it is well integrated into shell environment (since I use Linux as the main dev env.). From the other side, I can't stand IDEs because they hide details that I care about (compiler, linker flags etc.), in case of VS makes me locked to a single platform and they are a lot more unresponsive and tend to crash for me a lot (especially Eclipse - that is probably the worst IDE I had to work with; also XCode seems like a really good IDE but I hear it also crashes a lot).
You may be wondering what the hell then do I use for compiling and debugging answers being Makefiles and gdb/pdb. Also using Vim means I know a bit of Vi which is installed on every Linux distro and thus I can do stuff easily through ssh. (You probably won't encounter situations when you need to use ssh to connect to another server).

Overall I would recommend you experiment with an IDE, Vim and Emacs and see what suits your needs. Unfortunately all of those tools require an investment to properly asses their usefulness.
 

Perkel

Arcane
Joined
Mar 28, 2014
Messages
15,897
thanks for your input.

I talk about IDE because i know how long learning every quirk of program can take (experience though based not on programming).

Also i think for learning stuff i will later use several people advice and will try to code in for example Unity or other engine when i can see results instantly though as i said it won't be soon. I lean to that idea because iteration and practical aplication of knowledge seems to be most important part in early programming learning.
 
Self-Ejected

ScottishMartialArts

Self-Ejected
Joined
Feb 24, 2005
Messages
11,707
Location
California
Yeah this is why i keep this as goal based diary. Because if i won't set goals then motivation can quickly go to hell. Also practicallity is important becaue there is nothing more awesome than to see actually stuff you programmed to work and that there is some interaction or idea you have is actually working.

Also it will be interesting to see what codexers think about stuff i make. I mean i plan to have relatively shortly some text based adventure project because that is very simple to make as it is mostly couple of "if"s and variables and the longer game is the more ifs you need to create. But that is naturally currently not my goal. I will be back to that idea later after some basic learning. I did something like this years ago in pure C+ (when i had this idea when i was young) and first chapter allowed me to do it.

Good luck to you.

Text based adventure games are a particularly good medium for learning to think in OOP.
 

Perkel

Arcane
Joined
Mar 28, 2014
Messages
15,897
yeah i you can do simple text adventure stuff just after few lessons in programming and then later u can use it to apply practically what you learned.

I mean with what i learned in last 2 days i am safe to say that i know how to make inventory, magazine concept, text based adventure or even combat mechanics math depending on several variables. I think i would be able to create simple stat screen.
Problem for now would be tying this up, making game loop instead of writing one code that willl end when code ends and data handling for items and other stuff.

Though i don't want to speed things now as loops are yet before me.

I have few links for game creation (like that ling how to make roguelike game) or even unity tutorials which seems to be awesome (but not from programming side of things).
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,562
Location
Tampon Bay
Learn generics.

It has improved my programs in many ways. Every programming language now offers generic containers like List<Type> or Dictionary<Type, key>
Organize your instances in containers and give each one a unique key that you can for exampe generate as a GUID.
When you want to do something with them you can simply iterate with a foreach loop or pick a single element via its key.
Organizing your data that way has many advantages over the usual for(int i=0, i<n, i++) method, the speed is also almost the same, and it is very easy to read. It's a bit like having your own database of objects.
Once you understand that stuff you can also deal a bit in polymorphism (it is related to generics), though I would not go overboard.

Don't create complicated inheritance hierarchies (a common beginners mistake). Inheritance is very helpful in ccertain situations but often is not needed. I have seen too many programs where the few interesting things were buried in endless casts, for no benefit.

The most important thing as a programmer is to develop a toolset of things that you can you use for everything you need. Not premade solutions or complicated shit like Java beans.
I mean simple stuff like string replace, or how to easily store data without using anything premade again (like using data binding in cointainers that stuff is usually way too complicated).

An example how I generate different versions of my output fles, without writing a whole program with lots of string constants.
I simply store a template in a file and variables in %VARIABLE%
Load the string from a file and use string replace on all instances of %VARIABLE% and then save the modified string.
So much easier than doing it in the program, when most of the work can already be done in a text editor.

Here an example how I generate a rather complex-looking LISP file

Template:
Code:
(defun %MNL_FUNCTION%(/ mms_local_Mode)
(setvar "modemacro" "Stift%PENCIL_ID% - %PENCIL_NAME%")
(setvar "USERS2" "(%MNL_FUNCTION%) ")
(setq mms_local_Mode (getenv "ModeDraw"))
(if (= mms_local_Mode "0")
(progn
(COMMAND "_-RUN" "Mms.PenObjs.New_PidSelScr" %PENCIL_ID%)
)
(progn
(mms_modeswitch_draw)
(if (=  mms_global_result 1)
(COMMAND "_-RUN" "Mms.PenObjs.New_PidHdl" %PENCIL_ID% mms_global_newhandle)
)
)
)
)

And here how I modify it (simplified), with just a few lines of code

Code:
string text = readTemplate(path); //path is the prepared template
text = text.Replace("%PENCIL_ID%", pencil.Id);
text = text.Replace("%PENCIL_NAME%", pencil.Name);
text = text.Replace("%TB_NAME%", toolbar.Name);
...
writeFile(path2, text); // output file

extra methods like readTemplate(path), writeFile(path, text) must of course be coded separately but they are not difficult, and pretty universal.

Another tip is to use abstract class with static members that you can use like global variables.

Like

Code:
public abstract class Configuration
{
  public static bool keyboardControl = true;
  public static bool isDebug = true;
  public static bool showToolTips = false;
  public static bool optimizedDoubleBuffer = true;
}

or

public abstract class Program
{
   public static Stopwatch Stopwatch = new Stopwatch();
   public static ProgressBar ProgressBar = new ProgressBar();
}

The big advantage is that you can use
Configuration.keyboardControl
or Program.ProgressBar
from anywhere in the program without getting an instance of Configuration or Program.
Abstract classes have only 1 instance and can be accessed anytime in the program, just like a global variable.

The reason is it is very easy to come to despair over global variables in OOP. I have seen many programs who needed to pass instances of such basic classes around and it completely wrecked their code. You cannot make it global but the abstract scope does the trick. It's a breeze to use once you know what you would have to do otherwise (where can I get my instance of Configuration again .. complex code changes ensue)

Another example would be a sound library where every sound file is in such a scope, and can simply be called from anywhere.

Code:
public abstract class Sound
{
   public static Sound beapSound = new Sound("beep.wav")
   public static Sound clickSound = new Sound("click.wav")
}

Last tips, use Copy%Paste, STRG+H etc instead of typing whenever you can! Make all variables according to a schema and not confuse yourself.
 
Last edited:

J1M

Arcane
Joined
May 14, 2008
Messages
14,650
Is that abstract with static instances trick the java version of using a static class in C#?
 

Destroid

Arcane
Joined
May 9, 2007
Messages
16,628
Location
Australia
I'm not sure what the point of saying all this OO specific stuff from another language is to someone learning python.
 

7h30n

Augur
Joined
Aug 14, 2012
Messages
311
Yeah, as Destroid said the above post isn't much important to your level nor that much applicable to Python.
The closest thing in Python to generics and templates (generics being the subset of templates) would be duck typing.

But this quote:

Burning Bridges said:
Don't create complicated inheritance hierarchies (a common beginners mistake). Inheritance is very helpful in ccertain situations but often is not needed. I have seen too many programs where the few interesting things were buried in endless casts, for no benefit.

is very much true, especially in Python. In Python you can pass functions to other functions which is a lot simpler than the OOP equivalent of creating an interface class and passing an instance that implements the interface. Also duck typing helps in simplifying code (but be very careful when relying on duck typing).
 
Self-Ejected

Davaris

Self-Ejected
Developer
Joined
Mar 7, 2005
Messages
6,547
Location
Idiocracy
Agree with everyone suggesting you make a text adventure first. That was the first thing I did, when I was learning Pascal and it was a great feeling to get it working. After that I learned C++ and never used Pascal again. So assume you will do the same with Python. Once you learn one language, it is easier to learn others.

LISP on the other hand, is a whole different story. ;)
 

Perkel

Arcane
Joined
Mar 28, 2014
Messages
15,897
Thanks for responses.

Yesterday was not effective day (ton of stuff to do IRL)
Today is more or less the same but i find short 15-30minutes programming rather enjoyable.

Yeah that OO part was this " Yeah i know some of those words"-blackguy moment.

I am doing currently while/for loops in that training and now i use it to all kinds of fuckery with lists and dictionaries.
So far imo this is the most interesting lesson. It opened up many question for me like how to create proper game loop (if i can say something like this at this level)

One thing is sure i need to practice lists and dictionary ton of cases where i will need to mix and match all kinds of different things. Lists in lists. Dictionaries with lists with lists and so on.
Though i think I/O mentioned earlier would be far more effective than to use math to create something i can just type in excel sheet.

So far getting keys and values of different parts in created hierarchical data structure is kind of confusing and i can easily miss one loop or another and get different data i need. I mean for example if i have List in list in list i need essentially 3 loops to print out complete content and i will still be confused how to print out actually for example one thing from list at the bottom of this "container". But i guess it is something that i will learn in future.


edit:

Though i think using math will be far more effective than I/O if i want to create anything procedural like for example weapon system where materials are created randomly in game world upon creation same as weapon types. Something like this would impossible to do via excel.
 
Last edited:

7h30n

Augur
Joined
Aug 14, 2012
Messages
311
This topic is triggering me

You too? I get a PTSD as soon as I see anything that resembles Java code... How about we start a Patreon?

@Parkel, don't worry. It will all come with time and practice. Just be sure to fully understand at this early stage what is passed by value and what by reference in Python and what that means.
The usual game loop consists of something like this:
Code:
while True:
  process_input()
  update_game_logic()
  render_frame()
In this case, this is an infinite loop, but you can make it check for a condition which quits the game or break it some other way. Ofcourse on exit you want to cleanup any stuff that needs cleaning.
 

Perkel

Arcane
Joined
Mar 28, 2014
Messages
15,897
Now i have raging boner to do some combat system that will generate proceduraly weapons made out of different materials with different values (like density etc) and test them via simple combat math. Hell even something like crafting thanks to loops and list/dictionaries seems to be in my reach without using I/O.

Ok i think i have second GOAL. After i will end this training i will create some template for system and try to code it. This may change though because i don't know what is next for me in that training program.

@7h30n

That was mainly about different syntax and functions i didn't know what they do.
Code itself is rather readable and doesn't scare me.
 

Perkel

Arcane
Joined
Mar 28, 2014
Messages
15,897
Now i have actually valid question.

Does functions used between languages are more or less the same or they can be completely different ?

I mean probably something like sum() in java or other languages is the same as in python but does something like randint which is taken from actual library have near or the same name in other language ? or zip() ?
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
Of course they can be different, the devil is in the details. But math functions at least try to be standard (the devil is in the details).
 

7h30n

Augur
Joined
Aug 14, 2012
Messages
311
Pretty much what SCO said. They tend to have same names but for example map() in c++ is transform(), reduce() is accumulate() in C++ but fold in Haskell. You can easily find the equivalent functions in other languages by googling the function you are familiar with from python for their variations in another language. The problem is that Python will spoil you - other languages might not have equivalent stuff or if they have it might be worse in use. For example map() is so easy to use in Python and Haskell and it is an extremely useful function since it abstracts the for loop away for you, but using std::transform() in C++ can be really ugly and unwieldly.
 

Perkel

Arcane
Joined
Mar 28, 2014
Messages
15,897
I guess this python (spoiling) vs c++(fuck you work hard) is low high language thing ?
Is it just build in libraries, support or just different take on functions ?

I mean i am not yet programmer but i dabbled in "programming abc knowledge" and the higher language you use generally the easier is to code and the less things you control and the less performance you can get going outside of standard stuff.
 

SCO

Arcane
In My Safe Space
Joined
Feb 3, 2009
Messages
16,320
Shadorwun: Hong Kong
Not it's just a terrible language thing.
It's caused by different features leading to different suggested styles. For instance until java 8, programming 'functionally' in java was a pain because the language didn't have closures (functions that can be injected into functions instead of a full object).

Being broad featured isn't a universally good thing either. If you look at the evolution of a haskell programmer page
with a bit of cynicism, you'll reach the conclusion that the 'tenured professor' solution is the best, that's the main reason 60% of programmers hate c++ (myself included).
 

Perkel

Arcane
Joined
Mar 28, 2014
Messages
15,897
Not it's just a terrible language thing.

Well that was unexpected.

On other topic i have read about multicore programming as it gives shit ton of trouble to people. Does some of you actually tried that are actually creating multicore code ? Opinions on that ?

I know that some things are hard to divide other are easy but never i heard someone going more deeply into that problem. On other hand i "heard" that some devs just make almost everything as "jobs" to do.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom