stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 303

Day 303 of 365 · Expert · Month 11: Optimisation and debugging

Saving characters

When the character limit bites: short but meaningful names, comments only for the non-obvious, the game version from the IC10 coder and documentation outside the chip.

Lesson 18 min Week 44

What you learn today

  • Short names, short comments
  • Game version
  • Keep it readable

The greenhouse script from week 37 has grown: a header comment with all device names, settings, failures and a version history. All useful – and together over 4096 characters. The chip no longer accepts it.

Short names, short comments

Most characters are not in the code but in names and comments. Three levers, sorted by effect:

Leversavescosts
moving long header comments outa lotnothing if the docs live elsewhere
deleting comments behind obvious instructionsmuchalmost nothing
shortening names (temperature → temp)mediumreadability, if overdone

A comment like # switch heater on behind sbn HEATER … On 1 says nothing the code does not already say. A comment like # 20 C, heater on below behind a define, on the other hand, does – that one stays.

The game version

The IC10 coder on this site has a Game version button: it removes all comments and blank lines, adjusts jumps to line numbers and opens the result as a new file. Your detailed version stays unchanged.

That way you get both: the file with all explanations stays with you or in the library, the short version goes into the chip.

Warning

The game version also lacks the comments that would help you when changing things in the game. Whoever wants to adjust something there later has to recognise the settings – that is why meaningful define names like HEAT_ON matter more than any comment.

Keeping it readable

Shortening has a limit. HEAT_ON does not become H1, ripe does not become r. The rule: a name must stay understandable in the code without a comment. What gets shortened first is what is duplicated – explanations that are already in the name.

Put the long documentation where there is room: in the script's description in the library, in a file next to the code or as a one-line summary at the top of the chip.

Tip

A good short header fits into one line: name, version and where the rest lives. Everything else can stay outside.

Diagram

The three limits of a program Lines 74/128 Characters 3990/4096 Width 97/90 Comments and blank lines count fully. The longest line here is too wide.
The long version with all comments stays in the file, the short one goes into the chip.

Exercise

Task

The starter code is the greenhouse from week 37 with a long header comment – together over 4096 characters. Shorten the comments until the chip gets below the limit. The code itself stays unchanged and must keep passing all tests.

Hints

Hint 1

The code after the header comment is already done – the problem is only the comment lines at the top.

Hint 2

Replace the header comment with one line with name, version and a pointer to the docs.

Hint 3

The IC10 coder shows you the character count while you write.

Quiz

3 questions. You pass from 60 % – the server does the grading.

Complete the day

  • Passed the simulator exercise
  • Passed the quiz with at least 60 %

Without an account progress is saved in this browser only.

Report a mistake in this lesson

Please sign in to report. Sign in

Esc
↑ ↓ selectEnter open/ opens search anywhere