B E C O M I N G
A
G R E E N
D E V E L O P E
R
J E N L O O P E R
C L O U D D E V E L O P E R
A D V O C A T E
M I C R O S O F T
A G E N D A
- L E A R N A B O U T
S U S T A I N A B L E S O F T W A R E
D E V E L O P M E N T
- C O D E T O G E T H E R !
What is
sustainable
software
development?
An emerging discipline at the intersection of:
🌱 climate science
💻 software practices and architecture
💡electricity markets
🔌 hardware and data center design
https://principles.green/
Goals
By following certain
recommendations, a Sustainable
Software Engineer
can make decisions
that have a meaningful impact
on the carbon impact of their
applications.
Let’s look at these 8
recommendations
8 principles
1. BUILD
APPLICATIONS THAT
ARE CARBON
EFFICIENT
2. BUILD
APPLICATIONS THAT
ARE ENERGY
EFFICIENT
3. CONSUME
ELECTRICITY WITH
THE LOWEST
CARBON INTENSITY
4. BUILD
APPLICATIONS THAT
RUN ON OLDER
HARDWARE
5. RUN SERVERS AT
A HIGH RATE OF
UTILIZATION
6. REDUCE THE
AMOUNT OF DATA
AND THE DISTANCE
IT MUST TRAVEL
ACROSS THE
NETWORK
7. INSTEAD OF
SHAPING SUPPLY TO
MEET DEMAND, TRY
SHAPING DEMAND
TO MATCH SUPPLY
8. FOCUS ON END-
TO-END
OPTIMIZATIONS
THAT INCREASE
OVERALL CARBON
EFFICIENCY
Can we build a carbon-friendly app?
• Should we build a web site?
• Mobile app?
• Desktop app?
Problem: building fresh web assets that are always online
consume unnecessary energy to keep them live
Solution: cloud hosting can help spin up assets when
requested/needed, or an offline-first strategy can keep energy
requests low
A better solution
• Let’s build something that
is hosted locally
• It can answer several
‘principles’
• A browser extension!
1. BUILD APPLICATIONS
THAT ARE CARBON
EFFICIENT
2. BUILD APPLICATIONS
THAT ARE ENERGY
EFFICIENT
6. REDUCE THE AMOUNT
OF DATA AND THE
DISTANCE IT MUST
TRAVEL ACROSS THE
NETWORK
7. INSTEAD OF SHAPING
SUPPLY TO MEET
DEMAND, TRY SHAPING
DEMAND TO MATCH
SUPPLY
A green
browser
extension
Help you make
educated
decisions to
manage your
personal energy
usage choices
Hosted locally
Called ad hoc
Built with vanilla
JavaScript, very
little overhead
C A R E F U
L N O W !
T H E
G R E E N E S T
A P P = T H E
O N E Y O U
D O N ’ T
B U I L D !
Let’s build a
browser
extension
•Use the C02Signal API
•Change color of icon
based on carbon
intensity in your region
•Get a quick readout of
your region’s carbon
status
•Knowledge = power! ⚡️
💡Save
power by
boosting
knowledge!
D E M O O N
E D G E
B R O W S E R
( A L S O W O R K S
O N C H R O M E )
1. Clone the repo: https://github.com/jlooper/carbon-trigger-
extension/tree/start
** use the start branch **
2. Navigate to the root and `npm install` dependencies
3. Explore the files:
- dist/manifest.json (defaults set here)
- src/index.js (your JS code goes here)
- dist/index.html (frontend HTML markup here)
- dist/background.js (background JS here)
- dist/index.js (built JS)
Let’s build together
1. Build a copy of your
extension: `npm run
build`
2. Add extension to
Edge
Development process
1
2
3
1. Take a look at the energy map here:
https://www.electricitymap.org/map
2. Get an API key here: https://www.co2signal.com/ (the key
will be emailed to you quickly)
3. Find your zone here:
http://api.electricitymap.org/v3/zones
Complete the code: follow the 🌱
Pre-development tasks
/src/index.js
Add a check to the init() function to see if any API
key or Region is set in local storage:
🌱 1: if anything is in localStorage, pick it up
🌱
/src/index.js
In the setUpUser method, set user-entered API key and region
🌱 2. manage local storage inputs 🌱
/src/index.js
Once user inputs are set up in setUpUser, make an
API call to get the region’s carbon intensity
🌱 3. make initial call 🌱
🌱4. display usage and carbon source🌱
/src/index.js
Make the API call to get your region’s usage, and display
it
🌱 5. set icon to be generic green🌱
/src/index.js
Set the icon to a default; it will change when the API is called. This function uses the chrome runtime
built-in management methods
🌱6. calculate color of icon, based on carbon intensity🌱
/src/index.js
Calculate the appropriate color of the icon, which changes based on an active API call
🌱 7. update icon 🌱
/src/index.js
In calculateColor(), update the icon, again calling the chrome.runtime to invoke a background process
🌱 7. update icon 🌱
/dist/background.js
In the listener for ‘updateIcon’, create a browser action to redraw the icon using the Canvas HTML API
Build and
Load
Extension
Navigate to root and type `npm run
build` to build a new bundle via webpack
In the Extensions panel, refresh your
extension. Add your API key and region
and check your region’s carbon intensity.
Congratulations, now you know when to
run an errand or run the dryer! Just
consult your ad hoc browser extension!
Remember…the greenest
web asset is the slimmest,
the one with the least
overhead, and the one
that is only called ad hoc.
Plus, you built something
slim that helps you make
greener decisions!
To: An Awesome Web Developer
123 Maple Lane
Greentown, CO
00000
T H A N K
Y O U !
@JENLOOPER
JENLOOPER.CO
M

Becoming a Green Developer

  • 1.
    B E CO M I N G A G R E E N D E V E L O P E R J E N L O O P E R C L O U D D E V E L O P E R A D V O C A T E M I C R O S O F T
  • 2.
    A G EN D A - L E A R N A B O U T S U S T A I N A B L E S O F T W A R E D E V E L O P M E N T - C O D E T O G E T H E R !
  • 3.
    What is sustainable software development? An emergingdiscipline at the intersection of: 🌱 climate science 💻 software practices and architecture 💡electricity markets 🔌 hardware and data center design https://principles.green/
  • 4.
    Goals By following certain recommendations,a Sustainable Software Engineer can make decisions that have a meaningful impact on the carbon impact of their applications. Let’s look at these 8 recommendations
  • 5.
    8 principles 1. BUILD APPLICATIONSTHAT ARE CARBON EFFICIENT 2. BUILD APPLICATIONS THAT ARE ENERGY EFFICIENT 3. CONSUME ELECTRICITY WITH THE LOWEST CARBON INTENSITY 4. BUILD APPLICATIONS THAT RUN ON OLDER HARDWARE 5. RUN SERVERS AT A HIGH RATE OF UTILIZATION 6. REDUCE THE AMOUNT OF DATA AND THE DISTANCE IT MUST TRAVEL ACROSS THE NETWORK 7. INSTEAD OF SHAPING SUPPLY TO MEET DEMAND, TRY SHAPING DEMAND TO MATCH SUPPLY 8. FOCUS ON END- TO-END OPTIMIZATIONS THAT INCREASE OVERALL CARBON EFFICIENCY
  • 6.
    Can we builda carbon-friendly app? • Should we build a web site? • Mobile app? • Desktop app? Problem: building fresh web assets that are always online consume unnecessary energy to keep them live Solution: cloud hosting can help spin up assets when requested/needed, or an offline-first strategy can keep energy requests low
  • 7.
    A better solution •Let’s build something that is hosted locally • It can answer several ‘principles’ • A browser extension! 1. BUILD APPLICATIONS THAT ARE CARBON EFFICIENT 2. BUILD APPLICATIONS THAT ARE ENERGY EFFICIENT 6. REDUCE THE AMOUNT OF DATA AND THE DISTANCE IT MUST TRAVEL ACROSS THE NETWORK 7. INSTEAD OF SHAPING SUPPLY TO MEET DEMAND, TRY SHAPING DEMAND TO MATCH SUPPLY
  • 8.
    A green browser extension Help youmake educated decisions to manage your personal energy usage choices Hosted locally Called ad hoc Built with vanilla JavaScript, very little overhead
  • 9.
    C A RE F U L N O W !
  • 10.
    T H E GR E E N E S T A P P = T H E O N E Y O U D O N ’ T B U I L D !
  • 11.
    Let’s build a browser extension •Usethe C02Signal API •Change color of icon based on carbon intensity in your region •Get a quick readout of your region’s carbon status •Knowledge = power! ⚡️ 💡Save power by boosting knowledge!
  • 12.
    D E MO O N E D G E B R O W S E R ( A L S O W O R K S O N C H R O M E )
  • 13.
    1. Clone therepo: https://github.com/jlooper/carbon-trigger- extension/tree/start ** use the start branch ** 2. Navigate to the root and `npm install` dependencies 3. Explore the files: - dist/manifest.json (defaults set here) - src/index.js (your JS code goes here) - dist/index.html (frontend HTML markup here) - dist/background.js (background JS here) - dist/index.js (built JS) Let’s build together
  • 14.
    1. Build acopy of your extension: `npm run build` 2. Add extension to Edge Development process 1 2 3
  • 15.
    1. Take alook at the energy map here: https://www.electricitymap.org/map 2. Get an API key here: https://www.co2signal.com/ (the key will be emailed to you quickly) 3. Find your zone here: http://api.electricitymap.org/v3/zones Complete the code: follow the 🌱 Pre-development tasks
  • 16.
    /src/index.js Add a checkto the init() function to see if any API key or Region is set in local storage: 🌱 1: if anything is in localStorage, pick it up 🌱
  • 17.
    /src/index.js In the setUpUsermethod, set user-entered API key and region 🌱 2. manage local storage inputs 🌱
  • 18.
    /src/index.js Once user inputsare set up in setUpUser, make an API call to get the region’s carbon intensity 🌱 3. make initial call 🌱
  • 19.
    🌱4. display usageand carbon source🌱 /src/index.js Make the API call to get your region’s usage, and display it
  • 20.
    🌱 5. seticon to be generic green🌱 /src/index.js Set the icon to a default; it will change when the API is called. This function uses the chrome runtime built-in management methods
  • 21.
    🌱6. calculate colorof icon, based on carbon intensity🌱 /src/index.js Calculate the appropriate color of the icon, which changes based on an active API call
  • 22.
    🌱 7. updateicon 🌱 /src/index.js In calculateColor(), update the icon, again calling the chrome.runtime to invoke a background process
  • 23.
    🌱 7. updateicon 🌱 /dist/background.js In the listener for ‘updateIcon’, create a browser action to redraw the icon using the Canvas HTML API
  • 24.
    Build and Load Extension Navigate toroot and type `npm run build` to build a new bundle via webpack In the Extensions panel, refresh your extension. Add your API key and region and check your region’s carbon intensity. Congratulations, now you know when to run an errand or run the dryer! Just consult your ad hoc browser extension!
  • 25.
    Remember…the greenest web assetis the slimmest, the one with the least overhead, and the one that is only called ad hoc. Plus, you built something slim that helps you make greener decisions! To: An Awesome Web Developer 123 Maple Lane Greentown, CO 00000
  • 26.
    T H AN K Y O U ! @JENLOOPER JENLOOPER.CO M