Shop OBEX P1 Docs P2 Docs Learn Events
Stripping objects down to bare bones - Does it help to delete the unused parts? — Parallax Forums

Stripping objects down to bare bones - Does it help to delete the unused parts?

ElectricAyeElectricAye Posts: 4,561
edited 2008-09-26 20:47 in Propeller 1
Hi all,

My program calls up about 8 objects I got from the Object Exchange. But for some of these objects, I might only use one or two methods that do not seem to call up other methods within the object. My question is: when you compile the whole program, does the computer know to strip off the unused parts of code, or does it load up the whole object into the Propeller?

If the compiler does not strip off the unused methods, does it therefore make sense to manually remove the unused code so the objects use up less memory in the Propeller?

thanks,
Mark

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-26 13:10
    1) The compiler does not strip out individual methods if they are not used. The whole object is used.

    2) If your program doesn't fit in memory and you are trying to shrink it, then removed unused methods from referenced objects is an excellent way to reduce the memory requirement. If you've got plenty of memory available, why bother?
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-09-26 13:15
    If you strip down "standard" objects, be kind enough to make a note in the top
    of the modified object that it has been modified. That way someone grabbing a
    quick copy of the same from their library doesn't mistake it for the original.
    Even adding your initials to the name isn't a bad idea.. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • PyrotomPyrotom Posts: 84
    edited 2008-09-26 15:34
    Has Parallax ever commented on the possibility of having the Prop Tool strip unused methods? This seems to be coming up more frequently as we write more robust objects. Rokicki recently commented that many possible features for his fsrw object will not be implemented due to concern about object bloat. I'm currently working on expanding my MidiIn object into a full Midi Kit, but have some of the same concerns. Dead code stripping (or at least unreferenced method stripping) would be a real boon to those of us who would like to provide full featured robust objects without chewing up all of your memory for unused features.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-26 17:25
    Thanks, Mike, it's comforting to know that, if I ever have to peel down my code, there's nothing inherently wrong with doing so.

    OBC, that's a good idea. I would certainly want to mark any stripped down code to make sure it didn't get "out there" where it might be confused with the real (unstripped) thing.

    And Pyro, yours is an excellent idea! If it's possible for Parallax to implement such a feature in their Prop Tool, that would certainly encourage people from feeling like the Propeller might be too small for future expansion. Right now, for my own application, I've only used about half the RAM that's available, but I'm looking down the road at some bells and whistles and the dancing girls to whom I would like to attach all those bells and.... well, it would be nice if something could automatically strip them all bare...

    My spin objects, that is.


    tongue.gif
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-26 17:28
    Here is a link to my CLEAN preprocessor (both command line and Windows versions), which will strip out unused objects, methods, and even certain CASEs without affecting the original code. It also includes a method for compiling too-large programs in the Propeller Tool, in case there are syntax errors that CLEAN itself is unable to flag effectively.

    Nonetheless, as Mike says, if the program fits anyway, why bother? Having the extra stuff in there won't affect performance.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • hippyhippy Posts: 1,981
    edited 2008-09-26 17:48
    Also see the recent discussion in -

    http://forums.parallax.com/showthread.php?p=751450

    There's a dichotomy between code-stripping, dead code removal and so on, and the way the PropTool keeps only one copy of duplicated objects that has to be considered but that doesn't mean it's not possible to remove completely unused methods and code ( whether manually or have the compiler do that ).

    Perhaps the real issue is that people tend to take object library code "as is" and use it that way with all the bloat it may bring. It doesn't matter as Mike and Phil say when space isn't a concern, but I've always considered library objects ( not just with the Propeller ) to be taken, saved as my own libraries and pruned to just what I need anyway.

    Maybe we just need to be clearer or more explicit that library objects aren't sacrosanct; they are reference designs. That taking them, hacking them about, removing and adding things is nothing to worry over, in fact, something to be encouraged.

    Post Edited (hippy) : 9/26/2008 5:53:23 PM GMT
  • PyrotomPyrotom Posts: 84
    edited 2008-09-26 20:14
    hippy - the reason I like to use objects as distributed is made pretty clear by the recent bug fix Rokicki has distributed for fsrw. If I'm running a modified version, I now have to go in and do a bunch of code comparison to figure out what got changed and port those changes to my version. If I'm using it as distributed, I just put in the new version and I'm good to go. Of course that does not stop me from using modified versions when I have to.... devil.gif
  • hippyhippy Posts: 1,981
    edited 2008-09-26 20:47
    @ Pyrotom : I'll agree there, it is quite problematic when that happens and I've been bitten by it.
Sign In or Register to comment.