Results 1 to 10 of 10

Thread: Lines of code (or: What the hell have you been doing for two years)

  1. #1
    Join Date
    Mar 2006
    Location
    Ambient Design
    Posts
    3,936

    Lines of code (or: What the hell have you been doing for two years)

    After a big product release I like to do a comparison of lines of code between the previous version and the current version.
    ArtRage 4.5 was released just over two years ago. Here's some analysis of the code changes between then and now.
    (Thanks to Cloc source code line counting tool: http://cloc.sourceforge.net/)
    First column is file changes, other columns are lines in files.
    Code:
    ===============================================================================
    ArtRage 4.5                  files          blank        comment           code
    -------------------------------------------------------------------------------
    SUM:                          1010          81698         105015         290963
    -------------------------------------------------------------------------------
    
    
    ===============================================================================
    ArtRage 5.0                  files          blank        comment           code
    -------------------------------------------------------------------------------
    SUM:                          1080          89834         117855         317880
    -------------------------------------------------------------------------------
    This shows how many files and lines were modified.
    Code:
    ===============================================================================
    Comparison		     files          blank        comment           code
    -------------------------------------------------------------------------------
     same                          535              0          99456         268493
     modified                      473              0            717           9280
     added                          72           9611          17682          40107
     removed                         2           1475           4842          13190
    Compare that to Lord of the Rings trilogy by J. R. R. Tolkien
    Page count:
    423 - Fellowship of the Ring.
    352 - The Two Towers
    311 - Return of the King
    = 1086 pages.
    43 lines per page = 46,698 lines of text.
    So... we've added more code and comments than Lord of the Rings. Add in the changed lines and it's another book in the trilogy.

    So what does ArtRage code look like? Here's a very typical cut'n'paste from one of the ArtRage 5.0 source files. This is part of the code relating to the user-defined guidelines. All ArtRage code is similar style to this. Yes, every line of code has a comment - the short amount of time it takes to explain what you're doing to your future self saves hours of debugging time.
    Code:
    // Do Y hit testing.
    // Find the closest gridline in the Y axis array.
    fHoriz = true;                                                                         // Assume we're going to hit a horizontal line.
    if (m_aGuideY.GetSize() > 0) {                                                         // Some Vertical guidelines to test against.
        cgTest.m_nLoc = RoundReal(ptPoint.y);                                              // Set location member (but dont rebuild images)
        const int32 nIndex = m_aGuideY.GetIndexOfElementLeq(&cgTest);                      // Find the guide less-than-or-equal to this one.
        if (nIndex == -1) {                                                                // There are no guides smaller than the test position
            if ((m_aGuideY[0]->m_nLoc - cgTest.m_nLoc) < rHitDist) return 0;               // Y is close enough to the first gridline to hit.
        }
        else if (nIndex == m_aGuideY.GetSize() - 1) {                                      // We're past the last guide - check it.
            if ((cgTest.m_nLoc - m_aGuideY[m_aGuideY.GetSize() - 1]->m_nLoc) < rHitDist)   // Y is close enough to the first last to hit.
                    return m_aGuideY.GetSize() - 1;                                        // Hit this index
        }
        else {                                                                             // Otherwise we're between two gridlines. Hit the closest within hit distance.
            const int32 nLowDelta = cgTest.m_nLoc - m_aGuideY[nIndex]->m_nLoc;             // Distance to lower guide
            const int32 nHiDelta = m_aGuideY[nIndex + 1]->m_nLoc - cgTest.m_nLoc;          // Distance to higher guide
            if (nLowDelta < rHitDist) {                                                    // Hit Low value
                return nLowDelta < nHiDelta ? nIndex : nIndex + 1;                         // Which of the two guides do we Hit. Must be one of the two, as we're definitly in range of Low, but high might be even closer.
            }
            else if (nHiDelta < rHitDist) return nIndex + 1;                               // Hit the high point (but we know we haven't hit the low point)
            // else... no Y hit at all.
        }
    }
    AndyRage's mantra for graphics engine code:
    "Sure - how hard can it be?"

  2. #2
    Join Date
    Dec 2013
    Location
    Reno, Nevada
    Posts
    328
    Absolutely awesome work AR Gods!

    People on the street who don't know anything about programming don't have a clue how difficult this code is to read and work with. Indented if's, memory addresses, variable naming conventions, type casting, yada, yada, yada. It goes on forever. Programming mumbo jumbo.

    To help everyone understand better, all of the code for my business, a 3rd party logistics firm of 25 years has been running on about 152,000 lines of code and about 90 exe's/programs.

    AR is twice as large as my business and we paint with it! This is really hard stuff to work with and maintain. AR is a bargain based upon the amount of dedication and work that goes into it. I really appreciate the work that goes on behind the scenes team!

    Thank you! Your numbers are something to be proud of! It has been noticed.
    Last edited by HwyStar; 02-11-2017 at 12:05 AM.
    Robert Hopkins

  3. #3
    Join Date
    May 2014
    Location
    Portsmouth UK
    Posts
    739
    I have been a software engineer now for almost 20 years and deal with mostly interfacing to hardware and fairly minor maintenance and small improvements to our legacy codebase. Although at several million lines of code we have nothing that compares to the complexity of the calculations that must go into your awesome software.

    Many times I have gone through the classic software engineering stages of requirement definition, design, implementation, test, debug, rework, requirements change, more implementation, more bugs, hang on I'm sure I fixed that!, well that should never have worked!, I'm sure I tested that, I'm sure that used to work, oh I seem to have broken that now , fixed it just in time for release, phew, do you really have to test it?, Oh don't test that bit, it worked! I knew it would , a show stopper!., but that code didn't change!, well I didn't change it, it must have been someone working in a parallel branch, lets revert the build, now it works, but it shouldn't have, ok lets code review line by line, there we go the = should be a ==, should we put the fix in? don't we need to retest?, well it has to go in otherwise we can't release, we will have to put some extra hours in, fixed and delivered, yay!, the customer just rang!, it's not what they want , but they agreed to the requirements!, what do you mean they didn't read the requirements!, So you want us to implement some last minute changes, ok......, I will work the weekend.....

    Anyway enough of that, I'm glad to see that your code is well commented

  4. #4
    Join Date
    Mar 2006
    Location
    Ambient Design
    Posts
    3,936
    Mr. RedSaucers, I've been a coder for over thirty years. Everything you said is exactly true and how software development actually works.
    Some recent comments in the ArtRage code illustrate it exactly.
    A few days prior to release I was dealing with a strange bug relating to the transform tool. Something was being set-up twice;

    Code:
    // AMB 4/2/2017  - This block was commented out to resolve bugs on paste with Dynamic render destination being smaller than output image.
    // It apparently isn't needed as the attachment of transform rig does the required setup anyway.  I'm sure this will come back to bite me.
    I tested everything I could think of related to the fix and the code passed through our QA process. Then after we released there was a crash bug - surprisingly the only crash bug we've seen with the release of ArtRage 5 so far. When I tracked down the crash...

    Code:
    // AMB 8/2/2017 - Yup, it came back to bite me.  This is required for pasted content from a cut selection (where the content creates a smaller sub layer).
    The original problem wasn't where I thought it was.
    But, you know, it's all part of the fun of the job.
    AndyRage's mantra for graphics engine code:
    "Sure - how hard can it be?"

  5. #5
    Join Date
    May 2014
    Location
    Portsmouth UK
    Posts
    739
    Haha, I have put in one or two comments like those and the thing is it always comes back to bite you even though you do everything humanly possible to mitigate it!, the coding gods are often against us.

  6. #6
    Join Date
    May 2013
    Location
    England
    Posts
    143
    Thank you for posting this, it is fascinating ...

    In the end it all comes down to lines of code ...

  7. #7
    Join Date
    Mar 2006
    Location
    New Zealand
    Posts
    3,215
    In addition to the volume of code we rewrote there was another pile of work that went in to the redesign of the overall interface style, the structure of the panels, and the refocusing of the old workbench on a more standard docking mode. I started trying to get together some information on the documents that went in to the design process as well but it's hard to quantify that quite as clearly as you can the code.

    The style changes made to the ArtRage 5 interface were started on Christmas Day 2015 when I sat down with a shot of the old gradient designer and started work on cleaning it up, and didn't really finish until we were ready for release - There was always another tweak that needed doing.

    The initial style document is a PSD that currently has 285 layers over 73 groups, but that's just for one panel, and there are another 437 layers in a repository document in which I redid all of our icons to fit the new style. Most of the major panels have their own design document, with the Layers panel itself being one of the more comprehensive redesigns covering 180 layers and a number of iterations before I hit the final structure.

    The shift from ArtRage 4 to ArtRage 5 has been the largest single rework of the interface system I think we've ever done. The original shift from 2 to 3 introduced a number of elements like floating panels but those remained pretty much the same through ArtRage 4, while for ArtRage I completely rewrote my approach to the floating panel system in order to cope with docking trays and, more important, a shift towards dynamic interface elements that are created on the fly rather than pre-processed using bitmaps. Aside from the icons themselves, almost every element in the ArtRage 5 interface is generated internally rather than pre-rendered, which means we can create pixel perfect reconstructions at larger scale, allowing us to work on supporting higher resolution monitors properly. This change also required a rewrite of the system we use for generating interface resources (the eagle-eyed and curious among you may have noticed that we've added an icons file to our resources folder...) which happened over the period of a week while I was away in Tokyo and looking for something to do in the early mornings before the humidity set in for the day...

    All in all, it has been a mammoth undertaking getting this update out but I'm very happy with how it has ended up. There are always things I would like to change, of course, but having a solid foundation for that change is a really nice feeling.

  8. #8
    Join Date
    Jul 2006
    Posts
    25,098
    Phew! Greatly appreciated. And pretty darn clean from what shows up in the usage. Congrats and thanks for sharing. Shines some light behind the scenes.

    "Not a bit is wasted and the best is yet to come. . ." -- remembered from a dream

  9. #9

    Computational fluid dynamics

    Seems ArtRage has reached the last milestone, very interesting, congrats, I've been an ArtRage user for many years, and nowdays I was wondering what's Ambient Design position related to the Adobe-Nvidia Real-Time 3D Oil Painting Simulator proyect or other dynamic of fluids packages like Rebelle, Expresii or Verve Painter. I really look forward to participate in the Reddit AMA, hope this question is not out of topic, congrats again, great software.
    Last edited by eduardobedoya; 02-14-2017 at 06:08 PM.

  10. #10
    I have no idea what the code says but it amazes me how you get such a simple, calm and graceful end product from all that crazy calculation! And the impeccable commenting - it must take just as long to write that as it does the code!

    For what it's worth I think this is without question the best upgrade yet, well done to you all.
    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •