POV-Ray : Newsgroups : povray.off-topic : How to read source code? Server Time
28 Jul 2024 18:18:12 EDT (-0400)
  How to read source code? (Message 1 to 10 of 27)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Kenneth
Subject: How to read source code?
Date: 6 Feb 2013 14:35:00
Message: <web.5112aeed6746932ec2d977c20@news.povray.org>
Not how to 'understand' source code ;-)

Just wondering what kind of little Windows app I could download to actually
*see* (take a look at) the source code for a program (well, one that has
publicly-available source code, anyway--like POV-Ray.) I've never thought of
doing so before now, and don't know what's involved. Not to EDIT the stuff, or
compile/recompile it; that's way beyond me.

From what I've read, some 'text' editors can do this. Or would it require a 'hex
editor'?  Or perhaps something like Notepad++, which apparently can open and
display programs written in C, C++ etc?

What I would basically like to do is see the code the way the original developer
saw it, while writing it (in whatever programming language that happened to be.)
I might even learn a few things!


Post a reply to this message

From: Le Forgeron
Subject: Re: How to read source code?
Date: 6 Feb 2013 15:09:39
Message: <5112b883$1@news.povray.org>
Le 06/02/2013 20:30, Kenneth nous fit lire :
> Not how to 'understand' source code ;-)
> 
> Just wondering what kind of little Windows app I could download to actually
> *see* (take a look at) the source code for a program (well, one that has
> publicly-available source code, anyway--like POV-Ray.) I've never thought of
> doing so before now, and don't know what's involved. Not to EDIT the stuff, or
> compile/recompile it; that's way beyond me.
> 
> From what I've read, some 'text' editors can do this. Or would it require a 'hex
> editor'?  Or perhaps something like Notepad++, which apparently can open and
> display programs written in C, C++ etc?
> 

Any text editor (not wordprocessor) should do.
You might enjoy an easy to use search function (just to spot all the
occurrence of a variable, or finding a function)
An optional line numbering might help too.

> What I would basically like to do is see the code the way the original developer
> saw it, while writing it (in whatever programming language that happened to be.)
> I might even learn a few things!

<start holy war>
* PFE (programmer's File Editor)
* use eclipse with C/C++ or Java setting
* use Microsoft Visual Studio (or whatever its name), if available as
free edition on your OS (IIRC, MSVC 2012 need something like Vista or 7
and won't install on XP)



Tag line: beware of expecting to learn a language by studying existing
code, you would be disappointed.


Post a reply to this message

From: Stephen
Subject: Re: How to read source code?
Date: 6 Feb 2013 16:02:28
Message: <5112c4e4$1@news.povray.org>
On 06/02/2013 8:09 PM, Le_Forgeron wrote:
> <start holy war>
> * PFE (programmer's File Editor)
> * use eclipse with C/C++ or Java setting
> * use Microsoft Visual Studio (or whatever its name), if available as
> free edition on your OS (IIRC, MSVC 2012 need something like Vista or 7
> and won't install on XP)

Em! Why not mention PovRay's own editor? (Windoze version, anyway.)

 From the manual:

1.2.6.6 Configuring the Internal Editor

The built-in editor is extensively customizable. It utilizes syntax 
highlighting and understands .POV and .INC files as being in POV syntax. 
You can change the color settings used from the properties dialog (Alt + 
Enter).

It also has built-in syntax highlighting for C, C++, Java, Basic, 
Pascal, SQL, HTML and XML.


-- 
Regards
     Stephen


Post a reply to this message

From: clipka
Subject: Re: How to read source code?
Date: 6 Feb 2013 17:04:33
Message: <5112d371$1@news.povray.org>
Am 06.02.2013 20:30, schrieb Kenneth:
> Not how to 'understand' source code ;-)
>
> Just wondering what kind of little Windows app I could download to actually
> *see* (take a look at) the source code for a program (well, one that has
> publicly-available source code, anyway--like POV-Ray.) I've never thought of
> doing so before now, and don't know what's involved. Not to EDIT the stuff, or
> compile/recompile it; that's way beyond me.
>
>  From what I've read, some 'text' editors can do this. Or would it require a 'hex
> editor'?  Or perhaps something like Notepad++, which apparently can open and
> display programs written in C, C++ etc?

Actually /any/ text editor will do, even the Windows Notepad, as 
virtually all contemporary programming languages still use plain vanilla 
ASCII files.

You'll probably want something with "syntax highlighting" though. 
Notepad++ indeed sounds like a good idea.


That said, you'll soon find that "how to 'understand' source code" is a 
question worthwhile asking, too :-)


Post a reply to this message

From: clipka
Subject: Re: How to read source code?
Date: 6 Feb 2013 17:06:39
Message: <5112d3ef$1@news.povray.org>
Am 06.02.2013 22:01, schrieb Stephen:
> On 06/02/2013 8:09 PM, Le_Forgeron wrote:
>> <start holy war>
>> * PFE (programmer's File Editor)
>> * use eclipse with C/C++ or Java setting
>> * use Microsoft Visual Studio (or whatever its name), if available as
>> free edition on your OS (IIRC, MSVC 2012 need something like Vista or 7
>> and won't install on XP)
>
> Em! Why not mention PovRay's own editor? (Windoze version, anyway.)

That would be off-topic here :-P

But you're making a totally valid point. Never thought of it.


Post a reply to this message

From: Warp
Subject: Re: How to read source code?
Date: 6 Feb 2013 18:14:28
Message: <5112e3d4@news.povray.org>
Kenneth <kdw### [at] gmailcom> wrote:
> From what I've read, some 'text' editors can do this. Or would it require a 'hex
> editor'?  Or perhaps something like Notepad++, which apparently can open and
> display programs written in C, C++ etc?

I'm not sure you understand what program source code is. It's just ascii
text, like this very text I'm writing and posting here. It will look like
for example:

    int someFunction(int parameter)
    {
        return parameter + 1;
    }

Many programming languages are compiled to a binary file (usually containing
raw machine code, as well as slightly higher-level stuff like relocation
data and other kind of data for the dynamic linker.) Such compiled binary
files are not conversible back to the original source code.

-- 
                                                          - Warp


Post a reply to this message

From: Kenneth
Subject: Re: How to read source code?
Date: 6 Feb 2013 18:25:00
Message: <web.5112e48bf5f10c30c2d977c20@news.povray.org>
Hey, this is really fantastic! So I downloaded POV-Ray's 3.62 source code, and
it shows up in Windows Notepad, EditPadLite--even in POV-Ray itself! (I think
the latter is my favorite 'reading platform' so far.)

Thanks to everyone who posted about this. I didn't know it was so easy.

Hey, there are LOTS of separate source code files for POV-Ray! Where to begin...
 I naively thought that *whatever makes POV run* would be just one big file. Am
I correct in thinking that the program's source code is actually split up into
lots of little (therefore manageable) chunks?

One other thing: Does POV-Ray (or any of the other text reader apps I mentioned)
need ...uh... built-in 'code libraries' or something, to show *correct*
C/C++/whatever syntax? In other words, does a particular app 'substitute' its
own syntax for the correct one, if it doesn't have certain code libraries? (I
hope I'm asking this in a meaningful way.) Am I *seeing* the code correctly?
These questions are based on something I read on a Wikipedia page:

"Notepad++ supports syntax highlighting and code folding for over 50
programming, scripting, and markup languages. It attempts to automatically
detect the language that a given file uses, using a modifiable list of file
extension bindings. Users may also manually set the current language, overriding
the extension's default language."

Or does that mean just what it says--only for "syntax highlighting and code
folding"? If so...no problem! (Clipka's response re: ASCII makes me think so
anyway.)

Off-off-topic: While I was doing my research into this stuff, I read about 'hex
editors.' Apparently they can open an executable (.exe) file for editing?? (Not
in a higher-level language, of course.)


Post a reply to this message

From: clipka
Subject: Re: How to read source code?
Date: 6 Feb 2013 18:49:43
Message: <5112ec17$1@news.povray.org>
Am 07.02.2013 00:19, schrieb Kenneth:

> Hey, there are LOTS of separate source code files for POV-Ray! Where to begin...
>   I naively thought that *whatever makes POV run* would be just one big file. Am
> I correct in thinking that the program's source code is actually split up into
> lots of little (therefore manageable) chunks?

Absolutely.

> One other thing: Does POV-Ray (or any of the other text reader apps I mentioned)
> need ...uh... built-in 'code libraries' or something, to show *correct*
> C/C++/whatever syntax? In other words, does a particular app 'substitute' its
> own syntax for the correct one, if it doesn't have certain code libraries? (I
> hope I'm asking this in a meaningful way.) Am I *seeing* the code correctly?

Yes, you are. /All/ text editors show the code correctly. Some editors 
can automatically identify certain syntactical elements to show them in 
different colors (syntax highlighting), or provide you with ways of 
hiding code sections (code folding), but that's just sugar, and as a 
matter of fact it is /not/ part of the real .cpp and .h source code 
files. They just contain the raw uncolored text.

> Off-off-topic: While I was doing my research into this stuff, I read about 'hex
> editors.' Apparently they can open an executable (.exe) file for editing?? (Not
> in a higher-level language, of course.)

Uh... yes, but such procedure is /not/ recommended in the least. With a 
hex editor, you can visualize (and manipulate) the /true/ content of 
/any/ file, byte by byte.


Post a reply to this message

From: Kenneth
Subject: Re: How to read source code?
Date: 6 Feb 2013 19:10:00
Message: <web.5112f011f5f10c30c2d977c20@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

>
> > Off-off-topic: While I was doing my research into this stuff, I read about
> > 'hex editors.' Apparently they can open an executable (.exe) file for
> > editing?? (Not in a higher-level language, of course.)
>
> Uh... yes, but such procedure is /not/ recommended in the least. With a
> hex editor, you can visualize (and manipulate) the /true/ content of
> /any/ file, byte by byte.

Sounds dangerous (in MANY ways)...especially in my neophyte hands! ;-)


Post a reply to this message

From: Kenneth
Subject: Re: How to read source code?
Date: 6 Feb 2013 19:15:01
Message: <web.5112f19df5f10c30c2d977c20@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:

>
> I'm not sure you understand what program source code is. It's just ascii
> text, like this very text I'm writing and posting here.

Yeah, *that* very thing was an unknown/mysterious concept to me, before now. I
had no idea it would turn out to be so. Kind of magical, actually. (I always
thought POV-Ray's SDL--and its built-in text editor--was a 'special case'!)

Duh!!


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.