Section 5.1 ActiveCode
Python programs are made interactive in HTML, on request.
A C program will only be interactive if hosted on a Runestone server.
#include <stdio.h>
int main(void)
{
puts("Hello, world!");
}
A Java program will only be interactive if hosted on a Runestone server.
import javax.swing.JFrame; //Importing class JFrame
import javax.swing.JLabel; //Importing class JLabel
public class HelloWorld {
public static void main(String[] args) {
JFrame frame = new JFrame(); //Creating frame
frame.setTitle("Hi!"); //Setting title frame
frame.add(new JLabel("Hello, world!"));//Adding text to frame
frame.pack(); //Setting size to smallest
frame.setLocationRelativeTo(null); //Centering frame
frame.setVisible(true); //Showing frame
}
}
Javascript programs are made interactive in HTML, on request.
A <program>
is not interactive, by default, no matter where it is hosted.
import javax.swing.JFrame; //Importing class JFrame
import javax.swing.JLabel; //Importing class JLabel
public class HelloWorld {
public static void main(String[] args) {
JFrame frame = new JFrame(); //Creating frame
frame.setTitle("Hi!"); //Setting title frame
frame.add(new JLabel("Hello, world!"));//Adding text to frame
frame.pack(); //Setting size to smallest
frame.setLocationRelativeTo(null); //Centering frame
frame.setVisible(true); //Showing frame
}
}
An Octave program will only be interactive if hosted on a Runestone server. Octave is meant to be a drop-in replacement for Matlab.
x = 2 + 2
printf("%d\n", x)
A language not supported by Runestone Services will be rendered static.
program HelloWorld;
begin
WriteLn('Hello, world!');
end.
A nonsense paragraph just to check on spacing. A nonsense paragraph just to check on spacing. A nonsense paragraph just to check on spacing. A nonsense paragraph just to check on spacing.