Building a Traffic Light System in Julia Programming Language

← Go Back Software
403 Words • ~3 Minute Reading Time
Building a Traffic Light System in Julia Programming Language by Eric David Smith
Click image to view on GitHub

Traffic Lights - Julia Programming Language


A simple traffic light simulator written in the Julia programming language. The program will output the current light color and how long it will stay that color. The program will continue to cycle through the lights until the program is stopped.

Why?


I've been learning Julia and this seemed like a fun project to create.

Julia Highlights


Fast


Julia was designed from the beginning for high performance. Julia programs compile to efficient native code for multiple platforms via LLVM.

Dynamic


Julia is dynamically typed, feels like a scripting language, and has good support for interactive use.

Reproducible


Reproducible environments make it possible to recreate the same Julia environment every time, across platforms, with pre-built binaries.

Composable


Julia uses multiple dispatch as a paradigm, making it easy to express many object-oriented and functional programming patterns. The talk on the Unreasonable Effectiveness of Multiple Dispatch explains why it works so well.

General


Julia provides asynchronous I/O, metaprogramming, debugging, logging, profiling, a package manager, and more. One can build entire Applications and Microservices in Julia.

Open source


Julia is an open source project with over 1,000 contributors. It is made available under the MIT license. The source code is available on GitHub.

Requirements


  • Julia v1.9.2 - (July 5, 2023)

Instal Julia


brew install --cask julia

or

Download and install from julialang.org

Usage


julia src/main.jl

Example Output


Below is a sample output of the program.

➜  julia_playground julia src/main.jl
Cycle 1: Light is Red for 55 seconds
Cycle 2: Light is Green for 60 seconds
Cycle 3: Light is Yellow for 5 seconds
Cycle 4: Light is Red for 55 seconds

Testing


julia test/runtests.jl

License


This project is licensed under the MIT License - see the LICENSE file for details.

Contributing


If you find this useful as is please let me know. If you find any bugs, please feel free to submit a pull request or open an issue. If you have any questions, you can contact me.

Supporting My Work


Please consider Buying Me A Coffee. I work hard to bring you my best content and any support would be greatly appreciated. Thank you for your support!


Eric David Smith
Father / Software Engineer / Musician / Entrepreneur

Discover More (16) Software


Blog Tags