pouët.net

Go to bottom

Good tips n tricks to learn coding ?

category: code [glöplog]
Hi all

I would like to start learning how to code today but i'm asking myself some questions and i wish some of you could answer me.

From year to year, coding always attracted me but i was always stuck on some chapters when trying to learn (pointers and this kind of thing) when i was at school so i never learned.

Now, i'm mostly 30 years old, and i'm working as a Solaris/Unix Systems Engineer since.. 5 years (was a Windows Eng before for 4 years, blame me for that :p)
Those last years, i did a lot of scripting (mostly only bash-scripting, awk etc.) as any unix admin, and i really love that, i think my "code" (if i can call that code..) is pretty neat now.
At work i began working on developping a small intranet in PHP/MySQL, and i really enjoy this too, i spend all my days coding while i should be configuring Ldap and Dns servers :p

Today, i really wanna learn to code in a real langage (i suppose C is the better approach but i know that good coders can code in any langage) and give it a last try ! (all previous tries failed by lack of motivation and/or bad comprehension of some things).

Btw, some things frighten me a little bit and i'd have like your suggestions. i have a few questions about it :

1. first, Maths are faaar behind me now, it's been so many years i didn't work with maths, and i don't even remember what a sinus or cosinus was.., does this thing can "block" me learning how to code now ? or will it block me coding 3d things (opengl etc.) ?

2. secondly, what kind of books/methods/websites/anything would you recommend for a good start today ?

3. should i learn a low-level langage before learning C (or any kind of langage, but i wish i knew C, really, and i'd help me a lot at work to understand unix systems better), like learning ASM 68000 or other ? will it help me understanding memory access etc.. better ?

naturlly, i already know lots of "basic things" because of studies & my work (unix systems calls, + all basics about vars loops functions etc.) but i was in the past always "stuck" because of those damn pointers and some particular chapters and i don't wanna be afraid of this today again.
so i'm opened to any suggestion/hints that could help me to "try again" and see this with another kind of "approach".

Thanks again

sorry for my faulty english

regards,

Olivier
added on the 2011-05-12 20:49:27 by bull bull
It depends on what you want to code, really.
For generic getting-comfortable-with-pixels stuff, I'd recommend Processing for the ease of setting it up. Later on there's the question of platform, which is mostly a watershed when it comes to choosing language/API.

I also have a collection of old effects (written in Processing, with source) if you feel lost.
added on the 2011-05-12 20:57:53 by Gargaj Gargaj
It's hard to tell what's blocking you. If you do scripts and all you should be able to code without much problems, but maybe you lack understanding on how the machine or comiling process works. It's true that when you master something you don't realize how it's a mass of knowledge working together at all times.
I think pointers are not something to be afraid of but it seems some people cant help it. Don't.
You know what? I'll tell you:
Your few gigs of RAM are a big array of cells. In each cell you can store a byte value.
The cells are numbered from 0 to the end.
When you declare a variable (i) you do nothing else than telling that you reserve a cell for this variable. What we call the address (&i) of that variabe is the number of this cell from the beginning of your ram.
A pointer is another variable, somewhere else, whose contents is set to this number (p=&i).
The use of pointers is to be able to access the contents of the first variable using the second name (by writing *p) ( *p gives i).
Thats it.
In assembly all this doesnt even need such notation, you just have numbers, you do what you want with them.

Personally my path has been basic, pascal, asm, then at school eiffel, java, then c and c++. Weird.

I would highly recommend understanding asm, registers, adressing, the stack and the adress space for coding well in C. However, one can probably do without that. Keep in mind that not many people know asm and it's often (wrongly) regarded as hard, elitist, and useless nowadays. So you maybe don't want to go that far.

I'm an asm lover, often the problem with people not liking it is that they have bad memories of inelegant x86 16 bit masm.
Maybe find a 32 bit nasm package, I don't know, long time I was into that.
Or you can begin with some simple hello world in C and go slowly from there.

I also don't know what you want to do.
You can do a big bunch of things with no math at all besides plus minus mul div.
For graphics you will need some of them for almost everything nontrivial and much of them for modern advanced things.

Object language are imho another different league.
There is always more to learn, especially in C++.
No need to rush.

Imho programming is a long, untrivial road with a huge amount of diverse knowledge involved, and people who say the contrary are either pretentious or ignorant.

Good luck mate.
I still did not give an answer for what language you should try first.

I don't know.

I remember thinking that the first language you learn had marked you forever, but as time passes I can't say it's forever.

Know what?

Maybe I'd still recommend basic.
However I'm not sure there's a nice environment today for learning in basic.
And if you have done some scripts, I think you're already well beyond these steps.

Again depends on what you want to do.
1. Be prepared to fail.
2. Take things step-by-step.
3. When you get stuck, ask stuff on forums.
4. Find tutorials - there are lots of them on the web.
5. Learn by doing.
6. Above all, have fun!
added on the 2011-05-12 21:40:35 by trc_wm trc_wm
I was kind of in the same boat maybe 5 years back. I'd tried to learn java, c++ etc a few times, and just hit a wall. I was also doing lots of .bat/sh stuff, and also wrote some sits in php. Right now I'm writing some nice openGL stuff in C, so there is hope :) Here's roughly what I did:

What got me started mostly was quartz composer on the mac. It's kind of a visual graphics tool, more or less a demo tool (think werkzeug, maybe less powerful but a lot more flexible). I'd say quartz is a bit like processing, but without the java so it's easier to star, and with other stuff to grow into. With it, you can learn your way around graphics and how effects are built up with no coding. Cool to learn from and play around. Once you start pushing it though, you have to use the javascript features and do a little light coding. Then for more advanced effects, there's a handy glsl window, and a few basic meshes where you can write much more advanced stuff. I still use that for prototyping regularly.

So that kind of gave me a grounding in making effects, and it gave me some skills with writing shaders, and some javascript. I found there was stuff I couldn't do though, so I wanted to make a plugin for it. That meant obj-C (with it being mac). I just picked up a book for that, and didn't find it too challenging. It's pretty good to learn, none of the syntax horror of c++, and you use pointers and stuff for a while before you even know they're pointers. It's based on C, and most of the lower level system stuff you need to access sooner or later is in pure C, so it leads into C nicely (again, I got a book - it's more challenging than obj-c I'd say, but by this point I understood most of the concepts).

I also did a smalltalk course some years before at uni, and while that's not exactly a cool language (and I've not touched it since!) it did teach me enough to understand OOP. You really need to learn some object oriented stuff, and it can be a bit of a stumbling block, so I think that really helped with obj-c.

One important thing I've found is to learn different languages. PHP was nice to learn as it's fairly simple, javascript adds a bit more. Smalltalk brings OOP to the mix, while still being quite easy. Obj-C brings all that together, and adds quite a bit. C takes quite a bit away, still takes some learning, but you're prepared for it.
added on the 2011-05-12 21:44:58 by psonice psonice
@gargaj :

thanks for your message, i'll take a look at this langage, but it seems i can't create exe's ? it's just java applets ?

@HelloWorld :

first, thanks for taking some time to answer me, and thanks a lot for your explanation about pointers, it seems a lil bit more clear now to my mind :)
and what's the "goal" of using those pointers, instead of using a "basic" variable ? (i mean why using this "second name" instead of using the first var ?)

second, thanks for your hints, i see that ASM could be a good start, even not coding big things, but just beeing able to understand the ASM code, and have a better knowledge of registers/adressing etc.. as you said.. because those words are mostly.. chinese for me at the moment.

i found a few links on the web to learn ASM 68000 (particularly french ones from Laurent Piechocki) but it's atari-only apparently, i think i have to look @ x86 assembler (i don't know shit about this :p and even the differences between asm's, i'll google that)

what i wanna do ? well.. just beeing able to code mostly.. anything, beginning with commandline programs, small software/windowed programs, and naturlly opengl progs if my skills are good enough... demoscene is so.. attractive..

thanks a LOT for your advices, it's really appreciated
added on the 2011-05-12 21:50:11 by bull bull
Oh, one other thing about QC i found really good: there's a community built around it, with lots of other newbies to discuss things with and share examples and stuff, but also some really experienced people who can answer the tough questions and point you in the right direction. That REALLY helps with learning.

You could say the same about the demoscene, but I wouldn't call pouet all that useful (it can be, but not always ;) Anyway, when you get stuff made, share it (but not in the pouet prods database!)
added on the 2011-05-12 21:50:16 by psonice psonice
@saga musix : excellent link, thanks :)

@trc_wrm : that's exactly what i've always beeing doing with scripting, php coding etc.. searching the web/pdf's/forums/docs for hours to finally get the things working fine, so i know i'll have to do it again with my programs :p

@psonic : thanks for your feedback ! it's very interresting too. i see that "trying many langages" can be a good thing to see the things differently and maybe understand some things better with a certain type of langage. i've always noticed this when learning a little bit of awk, perl, bash, php, blitz3d etc.. i understood some things easily in some langages while i never understood those same things in another langage, and it helped me a lot implementing them in the langage i was afraid of at the beginning (am i clear enough ? xD), i'm gonna have a look at your quartz composer :) (i'm going to have a macbook air soon so maybe it's the time to try :p)
added on the 2011-05-12 21:58:55 by bull bull
SpeedTriple: x86 assembler is unfortunately quite a messy business. I'd even recommend running an Atari emulator before getting down with that. Check out http://www.6502asm.com/ - it's actually a very nice way to get hands-on experience with 6502 assembler in your web browser. :-)

As for stuff like 3D, to do anything non-trivial you need to be able to work with trigonometry, as well as have a basic understanding of linear algebra - but don't worry, those things will come with time.
added on the 2011-05-12 22:03:29 by Radiant Radiant
Quote:
what's the "goal" of using those pointers, instead of using a "basic" variable ? (i mean why using this "second name" instead of using the first var ?)


Basically, pointers are used to keep track of where things are in memory.

A pointer (memory location) is used whenever the data you want to manipulate does not fit into the CPU's internal registers, which are mostly 64 bits wide in modern Intel CPUs.

A "C" integer fits into an internal register, and you don't _have_ to use a pointer, but you can!

A string or an array does not fit into an internal register. Therefore, when you want to change a string, the CPU will retrieve the characters in the string one-by-one using a pointer. Most high-level languages will hide this from you, but C does not.

More simply put, pointers are used to manipulate chunks/blocks of memory.
added on the 2011-05-12 22:04:41 by trc_wm trc_wm
Quote:
@gargaj :

thanks for your message, i'll take a look at this langage, but it seems i can't create exe's ? it's just java applets ?

You're learning to code, and at that point that's what it matters ;) You can care about EXE's later once you're comfortable.
added on the 2011-05-12 22:07:15 by Gargaj Gargaj
speed: if you want to try it, just install the xcode development tools from the OSX dvd [or flash drive?]. Then find it with spotlight, or buried somewhere in the /Developer/ folder.

And yep I get what you mean with the different languages. I think it's just that they're mostly the same, but each one adds something new, so you learn the language quite fast but you do learn useful stuff too.
added on the 2011-05-12 22:24:36 by psonice psonice
Someone already said two great advises:

Quote:
5. Learn by doing.
6. Above all, have fun!


And I agree wholeheartedly.
added on the 2011-05-12 23:40:49 by ham ham
Quote:
what's the "goal" of using those pointers, instead of using a "basic" variable ? (i mean why using this "second name" instead of using the first var ?)


It's true I didnt say why on Earth one would want to do this :)

As has been said, for a variable like an integer it doesnt seem very useful, but for bigger variabes it can be.
For example in C you can declare a bigger variable (struct) that contains two integers and three letters.
If you want some function in your program to communicate this variable to another function, copying the pointer, which is smaller than the whole variable, is better.

It has other uses too even just for intgers, cause having the pointer to the variable means one can overwrite this original variable if wanted, a thing you cant do if the second function received a copy of the variable.

In facts, arrays are pointers too, pointers that point to the first element.
After all arrays are big variables containing a bunch of smaller ones.

I don't know if you understand types, but this is important too.

Now I want to say that after all you should maybe not (well, not now) dive into asm (x86 asm) cause even if I said it's not hard, well... It's a bit hard :) ; well, there are a lot of things to know when you start. I don't want you to hit a wall and be discouraged. x86 in particular is kind of not that sexy, even if, well, it's my first love and I will never forget it :). Beside, I cant deny that some people have their mind naturally made to understand and love assembly, like me, and love to see things from a hardware point of view ; but some other do not. Some other prefer the abstraction of high level languages and don't like lower stuff.

I'm influenced by the path I took, but I'd say first things would be to use a simple procedural language like basic or maybe simple java to make quite some experiments like working with strings, arrays, functions, sorting numbers, reading inputs and moving things on screen; this gives you a good understanding of algorithms and how basic things are done. But maybe you're already past that point. Then move to C or lower and understand what I said (adress space, stack etc). By then you'll already have come a long way.
Remember, the processor does nothing else than reading numbers from memory, calculating things and writing to memory. NOTHING else.
Just, reading or writing to some particular memory adresses do things like reading the keyboard, writing to the disk or writing to the screen (okay, thats a bit simplified).

Then a whole other thing is to understand how the OS works.
And then GUIs are another topic.
And that's not mentioning 3D.
Yes, learn by doing.
You can read and understand many books...
And then stand in front of a blank editor, and sweat like you've never sweat before, and that's when you learn everything.
That doesnt mean you mustnt read or that you have to reinvent the wheel, you must read, but you must also, well...reinvent the wheel :)

Plus believe me, you'll get incredible pleasure by seeing YOUR things work.
That pleasure my friend, you wont get it by reading and understanding books.
Maybe even begin with C#, who knows...
I don't know it but I bet one can get things up and running in no time with a simple language and a decent syntax (but, you'll probably have to use some objects for this)
learn asm if you want know more how cpu/hardware works. c++ or c# if you want more higher-level, which is easier to grasp, because their language has improved alot throughout the years. assembler is the hardest, but you learn how machine and memory works better. its a good thing to know a little about electronics if you want know assembler (altleast boolean algebra, binary system, gates, etc.). assembler today is probably the same as it where before except that some tools have gotten better, but it still is basically the same programming flow.

for example if someone asks what language should he/her use if he/her want to make games, they would have to know what for what hardware/os/platform etc. find out what platform you wanna work with, then and find out if you like low-level programming or high-level programming. get some idea of what you like to code. you can start with small projects like rotating lines, fire-effect, plasma,. there are some tutorials on the net, unfortunately some tutorials are too old and compilation wont work unless you change the code, which may be a bit hard for someone who havent coded before. but read books and articles on how things work then you can implement that in your code. you just have to learn the syntax of the language you use. pointers are not a big deal in C#. so that is my advice. you can set up a directdraw/directx window in C# and render to it if you want code oldschool effects. or you can do d3d stuff there. theres no way around math, you just have to learn how some math works or you wont get anywhere. if youre going to make some visuals then programming without math is a dead end.
added on the 2011-05-13 00:44:59 by rudi rudi
sinus and cosinus is just like a function. you input some value and you get some value out.

input value is in radians, from 0 to 2pi.. this are the position on the wave as it goes in a wave-form.
some other programming languages have input from 0 to 360 degrees.
output value is the sinewave-"height" you get when dividing the opposite side with the hypotenuse of a "virtual"-triangle that has its points from origo to the sinewave position to the x-axis.
added on the 2011-05-13 00:56:08 by rudi rudi
My personal view is that you should just jump into whatever you want to be doing. If you want to be coding demos in C, great! Find some existing graphics code in C, pick it apart, modify it, figure out what's going on.

In my experience, some aspects of programming can't really be understood until you either experiment with the new idea, or have a good understanding of the building blocks the new idea is made of. For you, this could be pointers. I'm confident that if you understood assembly (or the concept of pointers in another language) or just put aside your fears and jumped in, you'd get the hang of it quickly.

I agree with most of what rudi said, but I don't like naming something as the "hardest". In fact, I shied away from learning assembly for a while just because I listened when other people said it was hard. Eventually I came to realize that it's not hard at all, just different :)

Summary: The only thing to fear, is fear itself :P

HeLLoWorld: wow, I forgot eiffel even existed! :D
added on the 2011-05-13 05:16:18 by shuffle2 shuffle2
The primary purpose of pointers in C is "call by reference". That means, you don't pass the values to a function, but you pass pointers to the locations in memory where these values are stored. That's necessary for passing strings and other types of arrays - it would, for one, be troublesome to pass all the individual characters by value, and the other reason is that the number of characters of the string can be variable if you use call by reference. It's simply a very elegant way of passing parameters.

Sine, cosine, tangent are trigonometric functions. They deal with properties in a right triangle. In a right triangle, you have three sides. Two of them are called legs, and one is called hypotenuse. The legs are orthogonal to each other, while the angles between the hypotenuse and each of the legs are non-orthogonal. Let's take the angle beta between leg a and hypotenuse c. The other leg is called b. For this angle, the following formula apply:

Code:tan beta = b / a sin beta = b / c cos beta = a / c

It's really as simple as that. What's the use of this? These trigonometric functions can be used for oscillations. If the angle beta = 0 degrees, then sin beta = 0; if beta = 90 degrees, then sin beta = 1; if beta = 180 degrees, then sin beta = 0 again; and so on. If you continually increase the angle from 0 to 180 degrees, then jump back to 0 degrees and repeat the procedure, you'll get a nice "sine wave".
added on the 2011-05-13 06:10:28 by Adok Adok
I'd go for C# or any other CLR supported language. It has by far the most extensive and helpful documentation available.
I taught myself x86asm and then later C - if you go down either of those roads I'd suggest that order, after asm C is a doddle - all the calls & registers make a lot more sense.
Just my 2c.
added on the 2011-05-13 11:47:01 by ringofyre ringofyre
I taught myself C and x86 Assembler in parallel - I have no idea with what I started. Yes, it does make sense, for the reasons mentioned by ringofyre. Moreover, you can combine the two languages by putting inline Assembler code into your C programs.
added on the 2011-05-13 12:00:56 by Adok Adok

login

Go to top