This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 12 Sep 2006 09:19:50 pm    Post subject:

Let's get some action in here. Throw me some C/C++/Java to poke through and check out. Throw me a link to something you find interesting regarding this topic. Give me something to do :(

[EDIT] If the code isn't 10000 lines I'll debug/test/optimize it a bit for you. Give you some input.


Last edited by Guest on 12 Sep 2006 09:20:45 pm; edited 1 time in total
Back to top
alexrudd
pm me if you read this


Bandwidth Hog


Joined: 06 Oct 2004
Posts: 2335

Posted: 12 Sep 2006 10:44:31 pm    Post subject:

know anything about Panda3D? It's a bunch of libraries for game development in Python that I'm trying to figure out. I just figured it out a few minutes ago, but I spent 2 days trying to figure out how to use keypresses. I'm sure I'll have plenty of questions about Python.
Back to top
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 13 Sep 2006 10:25:58 am    Post subject:

No clue, I've never used Python.
Back to top
benryves


Active Member


Joined: 23 Feb 2006
Posts: 564

Posted: 13 Sep 2006 12:04:35 pm    Post subject:

Not sure what it is you're looking for, really... About the only C code I have on the Big Bad Internets is this code, for converting MUS to MIDI. The formatting is not my own (I used K&R indentation, as I cannot abide BSD/Allman).

As I'm more of a C# programmer, maybe there's something quirky (or just plain wrong) about my C code, so if that's what you're aiming to comment on, be my guest Razz


Last edited by Guest on 13 Sep 2006 12:05:09 pm; edited 1 time in total
Back to top
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 13 Sep 2006 12:25:28 pm    Post subject:

Wow that's pretty much an exact replica of my style. Same formatting, naming conventions, layout, returns, pretty much everything. Like looking at my own code.

Why can't you abide by BSD/Allman? Just seems so logical to me, everything is easy to see, in nicely laid out blocks. Just makes sense to me. Then again, it's the only one I've ever used, so I'm incredibly biased.
Back to top
benryves


Active Member


Joined: 23 Feb 2006
Posts: 564

Posted: 13 Sep 2006 01:06:24 pm    Post subject:

JoeImp wrote:
Why can't you abide by BSD/Allman?
[post="88186"]<{POST_SNAPBACK}>[/post]
It's a fairly religious issue Wink
I prefer my braces to line up with the opening statement, and sticking the brace on a new line means that instead of a code block being a complete block you have the opening statement, a space, then the main contents. It's really a visual thing, as when I see

Code:
if (xyz) {
    /* stuff */
}
...I can follow up the } and see the "if" it matches with, whereas with

Code:
if (xyz)
{
    /* stuff */
}
...the } matches up with a {, which tells me nothing, so I need to look up a line.

Thankfully modern IDEs will reformat code to your own personal preference when you paste it in, so it's not too much of a hassle any more. Smile
Back to top
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 13 Sep 2006 05:42:11 pm    Post subject:

When you have nested crap, I think this format makes it a lot easier to get a grasp on what is going on. Everything lines up perfectly, easily showing what code goes to what control structure.

[EDIT] - I've typed like 5 different paragraphs on why I feel this is better, but I've deleted all of them because I can't fully explain what I'm thinking. It just feels right. :P

[EDIT 2] - I'd rather have an easier time grasping a complicated section of code than worrying about having to read an extra line above. Should be able to pretty much instantly read/analyze the lines that are on the screen and then proceed to understanding the logic, which is where this formatting aids.


Code:
if ( var1 < 3)
{
    blah;

    if (var2 != 3456)
    {
        function();
        function2();

        if (!function3(blah2))
        {
            int blah3 = 3;
            int blah4 = 6;

            if (function4() != 3)
            {
                function5();
            }
        }
    }
}


Last edited by Guest on 13 Sep 2006 05:51:54 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 13 Sep 2006 06:06:18 pm    Post subject:


Code:
if ( var1 < 3 ) {
    blah;

    if ( var2 != 3456 ) {
        function();
        function2();

        if ( !function3( blah2 ) ) {
            int blah3 = 3;
            int blah4 = 6;

            if ( function4() != 3 ) {
                function5();
            }

        }

    }

}
Back to top
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 13 Sep 2006 07:27:39 pm    Post subject:

Except the code blocks blend together with the if statements creating one big block which then must be disassembled and not in any way more helpful to your comprehension of the code.

[EDIT] - And when you have actual code, lines of different length and composition, it becomes even harder to read, whereas mine is not affected.


Last edited by Guest on 13 Sep 2006 07:29:13 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 13 Sep 2006 07:39:25 pm    Post subject:

Doesn't the indent take care of all that?
Back to top
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 13 Sep 2006 07:54:18 pm    Post subject:

Yes, the same way as the indent in mine takes care of it. We're talking such a small change, just the position of one brace. I feel moving that brace down a line does more good than just leaving it useless at the end of the line.

Last edited by Guest on 13 Sep 2006 07:54:30 pm; edited 1 time in total
Back to top
sgm


Calc Guru


Joined: 04 Sep 2003
Posts: 1265

Posted: 13 Sep 2006 08:07:06 pm    Post subject:

The opening brace in K&R style tends to get lost against the right parenthesis.

Really the only thing K&R has going for it is that you can see more source lines at once.


Last edited by Guest on 13 Sep 2006 08:08:15 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 13 Sep 2006 08:22:02 pm    Post subject:

JoeImp wrote:
Yes, the same way as the indent in mine takes care of it. We're talking such a small change, just the position of one brace. I feel moving that brace down a line does more good than just leaving it useless at the end of the line.
[post="88225"]<{POST_SNAPBACK}>[/post]
And the parenthesis/character spaces.

How about


Code:
if ( lawl )      {
     ohnoez!
     ohnoez!
     ohnoez!
}
if ( more
      lawl
      than
      fits
      !??? )       {
          !!!!!!!!
          !!!!!!!!
          !!!!!!!!
}
Back to top
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 13 Sep 2006 08:56:05 pm    Post subject:


Code:
if ( more
     lawl
     than
     fits
     !??? )       {
         !!!!!!!!
         !!!!!!!!
         !!!!!!!!
}


|
v


Code:
if ( abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
         abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw
         abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw
         abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw )      
{
         !!!!!!!!
         !!!!!!!!
         !!!!!!!!
}


[EDIT]

Quote:
Really the only thing K&R has going for it is that you can see more source lines at once.


Last edited by Guest on 13 Sep 2006 08:59:42 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 14 Sep 2006 12:58:10 am    Post subject:

And not having to look up one or more lines to see when a block of code is being run.
Back to top
benryves


Active Member


Joined: 23 Feb 2006
Posts: 564

Posted: 14 Sep 2006 06:19:35 am    Post subject:

sigma wrote:
The opening brace in K&R style tends to get lost against the right parenthesis.
[post="88228"]<{POST_SNAPBACK}>[/post]

Yes, and that's a good thing. You don't need to see it, one can assume it's there. ;)

Unless, of course, you are fond of doing crazy things like:


Code:
if (x < 0)
    x *= -1;

...which I prefer as:

Code:
if (x < 0) x *= -1;
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 14 Sep 2006 07:20:51 am    Post subject:

And which won't have a closing brace. : )
Back to top
elfprince13
Retired


Super Elite (Last Title)


Joined: 11 Apr 2005
Posts: 3500

Posted: 14 Sep 2006 08:55:44 am    Post subject:

hehe, I love K&R, although I'll skip If statements altogether if they're just being used for assignment and go with ternary operators.....
Back to top
Tiberious726


Advanced Member


Joined: 07 Oct 2005
Posts: 284

Posted: 14 Sep 2006 04:22:49 pm    Post subject:

i prefer K&R because the statement looks like it is a part of the conditional operator; it feels more natrual that way; at least more so than having the conditon above and then the statement starting all the way below it; tho i am quite biased as K&R is the only formate I have used signifitcantly (which ill define to be over 1500 lines)

also when i program on school computer which have a lousy 800x600 size screen having that extra 4 or 5 lines really helps
Back to top
JoeImp
Enlightened


Active Member


Joined: 24 May 2003
Posts: 747

Posted: 14 Sep 2006 05:14:07 pm    Post subject:

Eh, well, I've been using C++ for 7 or 8 years now. The 4 books I have that use only C++ all use BSD/Allman, every Professor I've had all used BSD/Allman, even my highschool C++ teacher used BSD/Allman. I'm majoring in Software Engineering and minoring in Computer Science, very few of my colleagues use K&R. Since C++ is object oriented, I see moving to a more object orientated coding/formatting approach as sensible rather than trying to blend code blocks into other code to get an extra 4 or 5 lines out of my screen.

To be fair I've had one professor that used K&R. He was programming in java and was a CS major ... don't know what that says Very Happy
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement