1. Home
  2. /
  3. Modula3 Typing Test
  4. /
  5. Modula-3 Counter and Theme Toggle

Modula-3 Counter and Theme Toggle - Modula3 Typing CST Test

Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
MODULE CounterTheme;

IMPORT IO;

VAR
count: INTEGER := 0;
isDark: BOOLEAN := FALSE;

PROCEDURE updateUI():=BEGIN
IO.Put("Counter: "); IO.PutInt(count, 0); IO.PutLn();
IF isDark THEN
IO.PutLn("Theme: Dark")
ELSE
IO.PutLn("Theme: Light")
END;
END updateUI;

PROCEDURE increment():=BEGIN
count := count + 1;
updateUI();
END increment;

PROCEDURE decrement():=BEGIN
count := count - 1;
updateUI();
END decrement;

PROCEDURE reset():=BEGIN
count := 0;
updateUI();
END reset;

PROCEDURE toggleTheme():=BEGIN
isDark := NOT isDark;
updateUI();
END toggleTheme;

BEGIN
updateUI();
increment();
increment();
toggleTheme();
decrement();
reset();
END CounterTheme.
Coding works best on desktop or with an external keyboard.
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.

Modula-3 Counter and Theme Toggle — Modula3 Code

Demonstrates a simple counter with theme toggling using Modula-3 variables, procedures, and safe I/O.

MODULE CounterTheme;

IMPORT IO;

VAR
	count: INTEGER := 0;
	isDark: BOOLEAN := FALSE;

PROCEDURE updateUI():=BEGIN
	IO.Put("Counter: "); IO.PutInt(count, 0); IO.PutLn();
	IF isDark THEN
		IO.PutLn("Theme: Dark")
	ELSE
		IO.PutLn("Theme: Light")
	END;
END updateUI;

PROCEDURE increment():=BEGIN
	count := count + 1;
	updateUI();
END increment;

PROCEDURE decrement():=BEGIN
	count := count - 1;
	updateUI();
END decrement;

PROCEDURE reset():=BEGIN
	count := 0;
	updateUI();
END reset;

PROCEDURE toggleTheme():=BEGIN
	isDark := NOT isDark;
	updateUI();
END toggleTheme;

BEGIN
	updateUI();
	increment();
	increment();
	toggleTheme();
	decrement();
	reset();
END CounterTheme.

Modula3 Language Guide

Modula-3 is a high-level, statically typed programming language designed for safe systems programming, modularity, and object-oriented programming. It emphasizes simplicity, safety, and readability while providing features suitable for building large, robust software systems.

Primary Use Cases

  • ▸Safe systems programming
  • ▸Concurrent applications
  • ▸Compiler development
  • ▸Networked and distributed systems
  • ▸Educational projects on modular programming

Notable Features

  • ▸Strong static typing with safety guarantees
  • ▸Module system for large-scale software organization
  • ▸Garbage collection for memory safety
  • ▸Exception handling and concurrency primitives
  • ▸Support for objects, generics, and interfaces

Origin & Creator

Modula-3 was developed in the late 1980s by the DEC Systems Research Center and Olivetti Research Center, building on ideas from Modula-2 and Pascal, with contributions from several academic and industry researchers.

Industrial Note

Modula-3 is used primarily in academic research, legacy systems, and projects requiring safe and concurrent programming in a modular architecture.

Quick Explain

  • ▸Modula-3 allows developers to write modular, maintainable code with strong type safety.
  • ▸It supports object-oriented programming, generics, and concurrent programming.
  • ▸Commonly used for systems software, compilers, networked applications, and research projects.

Core Features

  • ▸Modules for encapsulation
  • ▸Objects and interfaces for abstraction
  • ▸Automatic memory management (garbage collection)
  • ▸Strong type system preventing unsafe operations
  • ▸Concurrent programming with threads and monitors

Learning Path

  • ▸Understand basic Modula-3 syntax and types
  • ▸Learn module system and interface definitions
  • ▸Practice object-oriented design in Modula-3
  • ▸Implement concurrency with threads and monitors
  • ▸Build and link modular applications

Practical Examples

  • ▸Building a modular text editor
  • ▸Implementing a concurrent server
  • ▸Designing a compiler front-end
  • ▸Developing network protocol simulations
  • ▸Prototyping educational systems programming exercises

Comparisons

  • ▸Safer than C or C++ due to garbage collection and strong typing
  • ▸More modular than Pascal or early Modula-2
  • ▸Concurrency primitives built-in unlike many older languages
  • ▸Less popular than mainstream languages like Java or C#
  • ▸Designed for systems and research rather than general scripting

Strengths

  • ▸High-level abstraction with system-level control
  • ▸Safe and reliable code through static typing and garbage collection
  • ▸Supports modular and object-oriented design
  • ▸Concurrency built into the language
  • ▸Readable and maintainable syntax

Limitations

  • ▸Smaller community compared to mainstream languages
  • ▸Limited library ecosystem and tooling
  • ▸Primarily academic or research use
  • ▸Not widely used in modern commercial software
  • ▸Performance can be impacted by garbage collection

When NOT to Use

  • ▸Rapid web development
  • ▸Mobile app development
  • ▸Large enterprise applications needing modern libraries
  • ▸High-performance low-level embedded systems
  • ▸Projects requiring large third-party ecosystem

Cheat Sheet

  • ▸MODULE MyModule;
  • ▸INTERFACE IMyInterface = ... ;
  • ▸IMPLEMENTATION ... END MyModule;
  • ▸VAR x: INTEGER;
  • ▸EXCEPTION SomeError;

FAQ

  • ▸Is Modula-3 still used?
  • ▸Primarily in research, legacy systems, and education.
  • ▸Does Modula-3 have garbage collection?
  • ▸Yes, automatic memory management is built-in.
  • ▸Can Modula-3 handle concurrency?
  • ▸Yes, with built-in threads and monitors.
  • ▸Is Modula-3 object-oriented?
  • ▸Yes, supports objects, classes, and interfaces.
  • ▸Is Modula-3 suitable for modern enterprise software?
  • ▸Rarely; mainly used for research and teaching.

30-Day Skill Plan

  • ▸Week 1: Syntax, variables, and basic modules
  • ▸Week 2: Objects, interfaces, and classes
  • ▸Week 3: Exceptions and type safety
  • ▸Week 4: Concurrency primitives and threads
  • ▸Week 5: Large modular program design and compilation

Final Summary

  • ▸Modula-3 is a safe, modular, statically typed language for systems programming and research.
  • ▸It provides garbage collection, strong typing, object-orientation, and concurrency primitives.
  • ▸Ideal for building reliable, modular, and concurrent software with a focus on maintainability.
  • ▸Mostly used in academic, educational, and legacy systems contexts.

Project Structure

  • ▸src/ - Modula-3 source code
  • ▸lib/ - library modules
  • ▸bin/ - compiled executables
  • ▸tests/ - unit tests and validation scripts
  • ▸docs/ - documentation and design notes

Monetization

  • ▸Primarily academic and research usage
  • ▸Educational tools and teaching software
  • ▸Niche commercial systems requiring safety
  • ▸Prototyping modular software
  • ▸Compiler or systems toolchains

Productivity Tips

  • ▸Plan module interfaces before implementation
  • ▸Leverage garbage collection for memory safety
  • ▸Encapsulate state in modules and objects
  • ▸Use concurrency primitives efficiently
  • ▸Document modules to ease maintenance

Basic Concepts

  • ▸Modules, interfaces, and implementations
  • ▸Strong typing and type inference
  • ▸Objects and inheritance
  • ▸Exceptions and concurrency primitives
  • ▸Memory management with garbage collection

Official Docs

  • ▸Modula-3 Language Reference Manual
  • ▸DEC SRC Modula-3 Compiler Documentation
  • ▸Research papers and academic tutorials

More Modula3 Typing Exercises

Modula-3 Random Number GeneratorModula-3 Todo ListModula-3 Dice RollerModula-3 Countdown TimerModula-3 Prime CheckerModula-3 Temperature ConverterModula-3 Shopping CartModula-3 Name GreetingModula-3 Stopwatch

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher