• Advertisement

Archived

This topic is now archived and is closed to further replies.

How do you read other peoples code

This topic is 4976 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am super new to Code and stuff, And have spent time reading C books and want to jump into a project of www.blender3d.org But when ever I go to try and do anything the source code over welms me and I getlost to quickly, not one of my C books covers this subject at all, they just tell you haw to make new stuff, but no way to read someon elses code. Also is there any Graphical or visual tool for C to kinda help out with how on eaarth this stuff relates with its self ? I am not from the Code world, just happy visual flippy fun stuff and colors ! ^v^

Share this post


Link to post
Share on other sites
Advertisement
as you learn more of the language other people's code will make more sense. it's always a bit of a task figuring out how someone's code works, but worry about writing your own code first. it's not helpful looking at other people's code before you know the basics of the language. you'll just confuse yourself and slow down your learning curve.

-me

[edited by - Palidine on June 8, 2004 8:41:29 PM]

Share this post


Link to post
Share on other sites
Thay might be using a graphics api such as directx and that will make it harder for you to read it. Or they could be using c++ and not c.

I read other peoples code all the time I find it a good way to learn something you cant find in a tutorial.

Share this post


Link to post
Share on other sites
This is the kind of things you just need to practice with. If you''re having trouble reading others'' code, try getting some more advanced books first. Also, it help if you don''t look at an entire project all at once.

It can take alot of time to ease into someone else''s code. Take little pieces at a time, look at the docs if there are any. Take it slow.

Share this post


Link to post
Share on other sites
also, if you are "super new to Code and stuff" starting with a blender project is probably reaching to high. i would reccommend not just reading through the books, but also actually writing/compiling/running some of the book''s assignments or test problems. after you work your way to the end of the book, you should pick a simple project to start with, like a text based game. after that eveyone''s favorite progression is pong -> tetris -> whatever you like.

be aware that in order to work on a 3D project you will also need to know at least some basic linear algebra (understand vectors & matrices at the very least). without that, some one else''s code will never make sense because a decent part of their code will be implementations of those mathematics.

-me

Share this post


Link to post
Share on other sites
ctags is an awesome tool for navigating code. You can find info on the website, but basically, once you have ctags set up, you can move the cursor over a function call, press control-], and then BAM, the definition of that function pops up. Or you can move the cursor over a variable, press control-], and BAM, you go straight to the declaration. Or instead of control-], you can press control-}, and the definition will pop up in a tiny little preview window (so that it doesn't take you away from the file you're working on.)

Note that all of those key shortcuts are actually from Vi. Ctags doesn't really work on its own- you need a cool text editor like Vi or Emacs that can understand the 'tags' file that Ctags generates. If you want Vi, get gVim, and if you want Emacs, get Xemacs.

There's another tool, cscope, which I haven't used yet, but seems to provide even more features than ctags. Both emacs and vi also have built-in support for cscope.

And yeah- my implied suggestion is to get an awesome text editor. Both Vi and Emacs are awesome. Both will take a little time to get used to (Vi actually takes a LOT of time to get used to), but it will pay off in the long run.

[edited by - pinacolada on June 8, 2004 9:39:39 PM]

Share this post


Link to post
Share on other sites
Goto a site such as allegro.cc; there are tons of games on the depot with source code.

Share this post


Link to post
Share on other sites
quote:
Original post by pinacolada
ctags is an awesome tool for navigating code. You can find info on the website, but basically, once you have ctags set up, you can move the cursor over a function call, press control-], and then BAM, the definition of that function pops up. Or you can move the cursor over a variable, press control-], and BAM, you go straight to the declaration. Or instead of control-], you can press control-}, and the definition will pop up in a tiny little preview window (so that it doesn''t take you away from the file you''re working on.)

Note that all of those key shortcuts are actually from Vi. Ctags doesn''t really work on its own- you need a cool text editor like Vi or Emacs that can understand the ''tags'' file that Ctags generates. If you want Vi, get gVim, and if you want Emacs, get Xemacs.

There''s another tool, cscope, which I haven''t used yet, but seems to provide even more features than ctags. Both emacs and vi also have built-in support for cscope.

And yeah- my implied suggestion is to get an awesome text editor. Both Vi and Emacs are awesome. Both will take a little time to get used to (Vi actually takes a LOT of time to get used to), but it will pay off in the long run.

[edited by - pinacolada on June 8, 2004 9:39:39 PM]



Oooo Those are sweet I never knew I had those tools on my command line :D It will help with definitions.

Share this post


Link to post
Share on other sites
quote:
Original post by nonnus29
Goto a site such as allegro.cc; there are tons of games on the depot with source code.


Sweet! I will stare at those but it still suffers from the , reading someone elses code syndrome

Share this post


Link to post
Share on other sites
quote:
Original post by pinacolada
ctags is an awesome tool for navigating code. You can find info on the website, but basically, once you have ctags set up, you can move the cursor over a function call, press control-], and then BAM, the definition of that function pops up. Or you can move the cursor over a variable, press control-], and BAM, you go straight to the declaration. Or instead of control-], you can press control-}, and the definition will pop up in a tiny little preview window (so that it doesn''t take you away from the file you''re working on.)

Note that all of those key shortcuts are actually from Vi. Ctags doesn''t really work on its own- you need a cool text editor like Vi or Emacs that can understand the ''tags'' file that Ctags generates. If you want Vi, get gVim, and if you want Emacs, get Xemacs.

There''s another tool, cscope, which I haven''t used yet, but seems to provide even more features than ctags. Both emacs and vi also have built-in support for cscope.

And yeah- my implied suggestion is to get an awesome text editor. Both Vi and Emacs are awesome. Both will take a little time to get used to (Vi actually takes a LOT of time to get used to), but it will pay off in the long run.

[edited by - pinacolada on June 8, 2004 9:39:39 PM]


DO they have anything like for the VS 6.0 text editor?

Share this post


Link to post
Share on other sites
I also suggest not to start with such a professional system like blender3d. the code is way to good optimised, as that you could really understand it as a nooby. Also, if you could get the sence of their code, you couldn''t really write for it, bc. as a beginner, you will never reach the necessary optimisation level.

Share this post


Link to post
Share on other sites
Yes, VS6 has something like ctags built in. Ctrl-] does paren matching, ctr-k will jump to the enclosing #ifdef (if there is one). Right-click a function name and pick "Go To Definition" to find the definition of a function (don''t know the keyboard accelerator for that one). For VS6 to find a symbol, it has to show up in the project. The other one I use is find in files (I bind this to ctrl-shift-F).

Share this post


Link to post
Share on other sites
When it comes to reading other people''s code, it''s not enough to understand the language. You have to start from the beginning and learn how the author programs. The way I prefer to do it is to first realize what the program does. What I then do is think of the different ways that I could make a program like that... the better you become at programming, the better you will become at this. Once I have a list (in my head.. I don''t spend more than half a minute on it), I look through the source for their implementation of these techniques.. everything else usually falls into place. Problems arise when I''m looking at things I''m not familiar with.. when it comes to that, I''ll either read up on the techniques that the game uses or try to crawl through the code and figure out what the heck the author was doing.

Share this post


Link to post
Share on other sites
quote:
Original post by fooman
I also suggest not to start with such a professional system like blender3d. the code is way to good optimised, as that you could really understand it as a nooby. Also, if you could get the sence of their code, you couldn't really write for it, bc. as a beginner, you will never reach the necessary optimisation level.


HA AHA HAHHAH A HA HH AH AH AH HAhAH Sorry I just had to get that on print :D

The problem I have talked to with others is that Blender is rudely under optimised ,and commented at.
True though I will never get it understood, and might as well make my own shtuff by scratch instead as others tend to do. And then try my best to ram it in, sigh...

[edited by - low_rider_bunny on June 9, 2004 5:44:04 PM]

Share this post


Link to post
Share on other sites

  • Advertisement