CODE SIZE

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
Mike Horsten
Posts: 79
Joined: Tue Dec 01, 2020 8:50 am

CODE SIZE

#1 Post by Mike Horsten »

Hi All,

I was wondering if there is any effect if the code is optimized with getting rid of all the returns, loose spaces and more. Will this make things faster? will it allow more things to be done. or is it no issue so coding should be clean.

Just wondering, in the old days of little mem we used to optimize the code i dont know if this is needed.

Sorry for the noob question

Mike
Building a home Cessna 172SP Steam. X-plane/MFS2020
(ex Name on Airmanager forum Polarair)

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: CODE SIZE

#2 Post by Sling »

Yes code can still be optimised. However removing spaces or return lines from the text editor will not speed things up. They are only there to make it easier for us humans to read and deciper. Only what gets executed will have an effect on performance. So doing something in 10 lines when it could be achieved in one line will take longer to execute. For you to notice the performace hit on PC hardware though it generally needs one or some of the following things. With lesser hardware such as the Rpi these factors become more important because it struggles at the best of times, let alone with these factors at play.

A lot of code
A lot of data
A lot of iteration

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: CODE SIZE

#3 Post by jph »

Mike Horsten wrote: Fri Feb 19, 2021 11:28 am Hi All,

I was wondering if there is any effect if the code is optimized with getting rid of all the returns, loose spaces and more. Will this make things faster? will it allow more things to be done. or is it no issue so coding should be clean.

Just wondering, in the old days of little mem we used to optimize the code i dont know if this is needed.

Sorry for the noob question

Mike
Hi Mike,
The best code - really - for AM on a PC, is one that YOU can read and understand. Even if it is not #optimised# .
However 'good' one is at programming, looking at code written 6 months before can be totally bewildering ;)
Best advice is to comment, and then to comment, and then to comment more.

Get it to work,
then, if it is needed - debateable - then you could try to optimise it. Even if you choose this route - the three rules are - comment, comment, comment.
There are some amazingly good 'technical' programmers here. However, I see little commenting which is extremely bad practice (imho of course).
Commenting all the way though - including code that doesn't work and has been hashed out - is excellent.
One difference I Note between, for example, the Arduino community and the AM community is that Arduino tends to have amazing support and comments etc, whereas, AM does not.
However, a lot can be learned from looking at other's code.
Superbly written and optimised code becomes moot when it is not commented.
The fully commented - NON optimised code wins every time.
Joe.
Joe. CISSP, MSc.

Mike Horsten
Posts: 79
Joined: Tue Dec 01, 2020 8:50 am

Re: CODE SIZE

#4 Post by Mike Horsten »

Thanks to both, Comments, and i will comment comment and use the comment to document my work.
Mike
Building a home Cessna 172SP Steam. X-plane/MFS2020
(ex Name on Airmanager forum Polarair)

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: CODE SIZE

#5 Post by jph »

Mike Horsten wrote: Fri Feb 19, 2021 1:51 pm Thanks to both, Comments, and i will comment comment and use the comment to document my work.
Mike
Nice one MIke :lol:
Joe. CISSP, MSc.

Post Reply