Shop OBEX P1 Docs P2 Docs Learn Events
ElfSizer: Determine your PropGCC binary size without needing SimpleIDE - Page 2 — Parallax Forums

ElfSizer: Determine your PropGCC binary size without needing SimpleIDE

2»

Comments

  • ersmith wrote: »
    "data" is the initialized data, variables that have an explicit initial value given to them when they are declared
    "bss" is the uninitialized data, variables that are declared but not given any initial value. These all get set to 0 before main starts

    For those familiar with DAT syntax, "data" is similar to using "long" to store data with specific values, whereas "bss" is like "res" - it reserves a specific amount of space once loaded, but takes no space in the executable.
  • JasonDorie wrote: »
    David Betz wrote: »
    I'm getting tired of the language wars. I'm tempted to just use Spin/PASM from any Propeller programming I do in the future.

    Spin generally ends up being more compact, but C/C++ is faster, and for certain things can actually end up smaller because of optimization, inlining, etc. I'm not strongly advocating one or the other - I like them both.

    I have found there are things that Spin does poorly that are simple in C/C++, like having a single object used in multiple other code classes. I know you can fake it with DAT sections, and parameter passing, but that's kind of a hack, and falls apart the moment you want two of them.

    On the other hand, Spin has some very cool built-ins for OUTA and DIRA (the array index and ellipsis operators), and a few other things that are pretty cool too.

    I think there's a place for both, so maybe there should be a truce instead of a war. :)
    I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.

  • DavidZemon wrote: »
    Question time: where are each of the following variables stored, assuming GCC isn't pruning unused variables:
    int global1 = 3;
    int global2;
    
    void foo () {
      int fooVar1 = 7;
      int fooVar2;
    }
    
    int main () {
      int mainVar1 = 5;
      int mainVar2;
    
      foo();
    
      return 0;
    }
    

    If I had to guess, I would say this:

    data = global1
    bss = global2
    stack = mainVar1, mainVar2, fooVar1, fooVar2

    But I could see GCC easily optimizing mainVar1 and mainVar2 into data and bss, similar to global1 and global2.

    Your first guess was correct.

    Note that the local variables, like mainVar1 and fooVar1, don't have any space reserved for them at compile time, only at run time (when the function is actually called). And to complicate things a bit, sometimes local variables will live in registers and not need stack space, but that's an implementation detail :).

    mainVar1 and mainVar2 aren't placed in data or bss because it's at least theoretically possible for main to be called recursively, in which case each iteration of main will need its own copy of the variables.
  • C is for education and hobbyists and Spin is for professionals

    Yes, it's long past time for that to be changed. Agreed David.
  • jmgjmg Posts: 15,173
    David Betz wrote: »
    I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.
    Sounds like marketing thought they had to say something, but maybe that had a dose of caution in there, when C was in the early days too....
    Best to focus on one market, and get that right, than be spread too thin.


  • David Betz wrote: »
    I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.

    I agree that sounds kind of backwards. Spin is generally easier to use, but C has more options for professional programmers. They're both fine languages, and people should use whatever they're comfortable with. It's nice that we have Basic, Forth, and other choices too.

    (I would have said Spin is lower performance, but with spin2cpp you can get the same performance range as C. Not many people use spin2cpp though, I guess I need to put a GUI in front of it.)
  • David BetzDavid Betz Posts: 14,516
    edited 2016-02-09 00:04
    ersmith wrote: »
    (I would have said Spin is lower performance, but with spin2cpp you can get the same performance range as C. Not many people use spin2cpp though, I guess I need to put a GUI in front of it.)
    That would probably help. There doesn't seem to be much tolerance for command line programs here.

  • JasonDorieJasonDorie Posts: 1,930
    edited 2016-02-09 01:26
    David Betz wrote: »
    I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.

    I think that sentiment is changing though. I don't think they understood how powerful it could be. I know Ken was surprised when I told him the ported flight controller ended up being significantly faster, while almost identical in size to the Spin version. The C/C++ toolchain was developed for their educational market, for sure, but it's useful far beyond that. I just don't think they'd seen enough "real world" examples to be comfortable recommending it.
  • JasonDorie wrote: »
    David Betz wrote: »
    I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.

    I think that sentiment is changing though. I don't think they understood how powerful it could be. I know Ken was surprised when I told him the ported flight controller ended up being significantly faster, while almost identical in size to the Spin version. The C/C++ toolchain was developed for their educational market, for sure, but it's useful far beyond that. I just don't think they'd seen enough "real world" examples to be comfortable recommending it.
    That's good to hear.

  • ersmith wrote: »
    David Betz wrote: »
    I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.

    I agree that sounds kind of backwards. Spin is generally easier to use, but C has more options for professional programmers. They're both fine languages, and people should use whatever they're comfortable with. It's nice that we have Basic, Forth, and other choices too.

    (I would have said Spin is lower performance, but with spin2cpp you can get the same performance range as C. Not many people use spin2cpp though, I guess I need to put a GUI in front of it.)

    I'd love to see PropellerIDE wrap PropWare's build system. That would accomplish your goal without having to write another IDE or rewrite the build system logic again.
Sign In or Register to comment.