News:

Precision Simulator update 10.180 (14 October 2024) is now available.
Navburo update 13 (23 November 2022) is now available.
NG FMC and More is released.

Main Menu

lines of code

Started by Jason M Tutwiler, Fri, 10 Jul 2020 17:36

Jason M Tutwiler

Hardy,
I completely understand if you can't share, however, I'm wondering aprox how many lines of code makes up the latest version of aerowinx PSX?  Again, no biggie if it's a confidential.

Best Regards,
Jason Tutwiler
Jason M. Tutwiler

Hardy Heinlin

I haven't counted all classes, but the sum of characters is circa 13 million, and the average line is circa 40 characters long (comments excluded). So I guess it's about 300,000 lines. Approximately half of it belongs to the FMC model. The real (legacy) FMC has about 100,000 lines, if I recall correctly.


Regards,

|-|ardy

Ton van Bochove

Ton

Jeroen Hoppenbrouwers

PS1, written in TurboPascal, was spaghetti.
PSX is Java, thus object-oriented, thus ravioli.

Hoppie

Ton van Bochove

I see, but both need a lot of tomato sauce
Ton

double-alpha

Hardy is the best Chef

Toga


Hardy Heinlin

... and many rolls of toilet paper.

kiek

Quote from: Hardy Heinlin on Fri, 10 Jul 2020 18:36
..., and the average line is circa 40 characters long (comments excluded).
The best comment is the code...   ;-)

Hardy Heinlin


martin

Quote from: kiekThe best comment is the code...   ;-)

Indeed.

a = [[0 for x in range(8)] for y in range(8)]
while True: a=[[([[sum(b[y1][x1] for b in [[[((-1<x2+dx<len(a[0])) and (-1<y2+dy<len(a))) and a[y2+dy][x2+dx] or 0 for x2 in range(len(a[0]))] for y2 in range(len(a))] for (dx,dy) in [(dx,dy) for dx in [-1,0,1] for dy in [-1,0,1] if (dy!=0 or dx!=0)]]) for x1 in range(len(a[0]))] for y1 in range(len(a))][y][x]== 3 or ([[sum(c[y3][x3] for c in [[[((-1<x4+dx<len(a[0])) and (-1<y4+dy<len(a))) and a[y4+dy][x4+dx] or 0 for x4 in range(len(a[0]))] for y4 in range(len(a))] for (dx,dy) in [(dx,dy) for dx in [-1,0,1] for dy in [-1,0,1] if (dy!=0 or dx!=0)]]) for x3 in range(len(a[0]))] for y3 in range(len(a))][y][x] == 2 and a[y][x]==1)) and 1 or 0 for x in range(len(a[0]))] for y in range(len(a))]


[Hint]   ;D

cagarini

#11
Eheh martin,

looked at your "blog"...

APL was such an uncommon language by the time it was made available that I worked in an IBM 450 that had special APL keyboards to cope with the special chracters / operators :-)

I did play a bit with it - wasn't that bad ...

I don't like Python though, for many reasons I won't ellaborate here...

I do find that PASCAL, and particularly it's "modern" flavours ( Delphi ... ) is still an excellent programming language.

I did like to program in IDL too - although Python is killing IDL :-/ and I don't find it strange at all given the amounts they ask for an IDL license, even for students!

Java ? Well....

Jeroen Hoppenbrouwers

C, then?


#include <stdio.h>
main(t,_,a)
char *a;
{
return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):
1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \
){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')#\
}'+}##(!!/")
  :t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1)
    :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);
}

kiek

Quote from: martin on Sun, 12 Jul 2020 18:34


a = [[0 for x in range(8)] for y in range(8)]
while True: a=[[([[sum(b[y1][x1] for b in [[[((-1<x2+dx<len(a[0])) and (-1<y2+dy<len(a))) and a[y2+dy][x2+dx] or 0 for x2 in range(len(a[0]))] for y2 in range(len(a))] for (dx,dy) in [(dx,dy) for dx in [-1,0,1] for dy in [-1,0,1] if (dy!=0 or dx!=0)]]) for x1 in range(len(a[0]))] for y1 in range(len(a))][y][x]== 3 or ([[sum(c[y3][x3] for c in [[[((-1<x4+dx<len(a[0])) and (-1<y4+dy<len(a))) and a[y4+dy][x4+dx] or 0 for x4 in range(len(a[0]))] for y4 in range(len(a))] for (dx,dy) in [(dx,dy) for dx in [-1,0,1] for dy in [-1,0,1] if (dy!=0 or dx!=0)]]) for x3 in range(len(a[0]))] for y3 in range(len(a))][y][x] == 2 and a[y][x]==1)) and 1 or 0 for x in range(len(a[0]))] for y in range(len(a))]


[Hint]   ;D
That's badly written code. Comments will not help ;-)

Jeroen Hoppenbrouwers

Suppose you have well-written code.

One of the function call arguments is, say, a dictionary of key:value pairs. Somebody does not like that API and wants it to be a list of alternating key, value, key, value. Same content, just slightly different structure.

So the well-written code is copied and the copied function renamed and slightly altered to accept a list. Both the original function and the copied function are individually well-written.

What is the resulting code as a whole now?


Hoppie

Hardy Heinlin

Quote from: Jeroen Hoppenbrouwers on Mon, 13 Jul 2020 15:40
Somebody does not like that API and wants it to be ...

I would add many more comments in my code if it were used by multiple coders. As I'm the only one, my few comments are mostly just references to external information about unusual 744 features (page numbers etc.).


|-|ardy

Jeroen Hoppenbrouwers

Your memory must be much better than mine. When writing code, comments are me talking to my future self, in 6-60 months from now, when I open the code again and wonder who wrote it.


Hoppie

Hardy Heinlin

What does your typical comment explain? An unusal code trick, like "this array is linked with that"? Or an unusal job the code does, like "this will simulate the coffee water"?

Can you show an example of such a comment that talks to your future self?


|-|ardy


float coffeeWater = outputTank1 + outputTank2 + rainWaterRemaining; // no comment required

Jeroen Hoppenbrouwers

Here's a random selection of actual production code comments, from a non-flying thing I wrote a few years ago to manage system requirements. It is Tcl. Nowadays I would write it in Python.


# hatch: Hoppie's Requirements Compiler, almost, but not quite, entirely
# unlike DOORS.
# All references to the "Hoppenbrowser" are considered bad style.

# The tdom library is used to generate HTML "the sane way". It may look
# weird at first, but is extremely easy to use in Tcl once you get the hang
# of it. See printDocTrace() for a good example how simple it becomes.

array set DB {}  ;# (id)={text sources headings pics}
                  # "Text" includes tags at the end. "Sources" is a list of
                  # identifiers. "Headings" is a list of headings in
                  # hierarchical order (h1, h2, h3, ...). "Pics"
                  # contains file names of pictures associated to the
                  # requirement.

# hatch learns which requirement types (SR, HLR, LLR, ...) are children of
# which parent types, by simply storing the first parent type it sees and
# forbidding any other parent type(s) after that.

  # Run over all requirements, fish out all @tags, and dump them
  # alphabetically. Can do both flat text and HTML output.
  # <in> htmlDir = Optionally, if given, produce HTML instead of output.

  # Remember: "Premature optimization is the mother of all evil".
  # A significant optimization may be made by including a second parameter
  # in this call that indicates in which class of requirement the children
  # must be sought. Or, look that up ourselves from PARENT.

  # This is for Microsoft Word, which understands CSS styles only if they
  # are included in the tag; it does not work with a style segment in the
  # HTML file.

  # Dump the traceability from sup to sub, and from sub to sup, in a HTML
  # file ready for copy/paste into Word.
  # NOTE: This procedure can cope with skips, so you can make traceability
  # from SR to TC without anything in between. --doc does not produce such
  # tables.


And this is a good example from flying code why I think that in many, not all, cases the ratio comments:code should approach 1:1. What the code does is usually totally clear. It is the why and especially why not X that is the killer if you leave it out.


    RSSI {
      # Our modem gives us a new measured signal level. We are interested in
      # the situation that we come out of a zero signal state, as we may
      # have missed a few Ring Alerts, and we want to do an unsollicited
      # mailbox check (UMC).
      set pRssi $CH($ch.prevRssi)
      set CH($ch.prevRssi) $evVal
      if { ($pRssi==0) && ($evVal>0) } {
        # Signal came out of zero!
        # We are in READY, so not doing any SBD.  Kick a check in 10 seconds
        # to be reasonably sure that the signal is properly back.
        # If somebody else is quicker, this timer will be destroyed.
        setTimer $ch sbdCheck 10000
      }
    }



Hoppie

Hardy Heinlin

The comment "come out of a zero signal state" is something that I would probably put into one of the related variable names, e.g. "tryToGetOutOfZeroSignalState" :-)


#ardy