# Why does PApplet fail silently when you don't implement draw()?

**URL:** <https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906>\
**Category:** Processing\
**Created:** [August 25, 2021, 2:47am UTC](https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906 "2021-08-25T02:47:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeWorth](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codeWorth](https://discourse.processing.org/u/codeWorth)\
**Post date:** [August 25, 2021, 2:47am UTC](https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906/1 "2021-08-25T02:47:32Z")

</div>

Looking at the source, this is draw’s implementation in PApplet:

```auto
public void draw() {
    // if no draw method, then shut things down
    //System.out.println("no draw method, goodbye");
    finished = true;
}

```

What’s the point of shutting things down silently here? Since an empty `draw()` function is valid, this seems pointless and counter-intuitive.

Perhaps PApplet should be an abstract class, and `setup()` and `draw()` should be abstract methods. This would help new users understand which methods they should implement. Alternatively, `draw()` could print a message explaining why the program has been halted. Thoughts?

---

<div class="post-metadata">

**Author:** ![agreyson](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@agreyson](https://discourse.processing.org/u/agreyson)\
**Post date:** [August 25, 2021, 4:39am UTC](https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906/2 "2021-08-25T04:39:04Z")

</div>

I agree that making PApplet, setup, and draw abstract would clarify requirements for users. But how about us CS teachers who would like to use Processing as an IDE from the beginning of their course, but begin with console input/output before easing into a GUI? A modification of this suggestion would be to keep PApplet as is, but not “shut things down” if the subclass doesn’t override draw. At the very least, please uncomment the helpful error message “no draw method, goodbye” in the current version of draw.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 6, 2021, 3:06am UTC](https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906/3 "2021-09-06T03:06:38Z")

</div>

> [@codeWorth](#):
>
> This would help new users understand which methods they should implement.

Are you talking about Processing PDE new users, writing in the processing language, or are you talking about Java developers who are importing Processing as a library? I’m asking because there are tutorials and documentation for each, but the documentation is different and use cases are different. Part of the reason PApplet works as it does is because its primary use case is PDE and the Processing to Java preprocessor. New Processing users of this kind don’t use PApplet at all; their code is transpiled to PApplet, and draw is usually overridden either explicitly or implicitly depending on the code style. One of the major design decisions very early on in Processing was that `draw()` would be optional in the Processing language, but writing a sketch without draw (immediate mode) would result in static rather than looping / animated output.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 6, 2021, 3:07am UTC](https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906/4 "2021-09-06T03:07:16Z")

</div>

> [@agreyson](#):
>
> begin with console input/output before easing into a GUI

Processing immediate mode / direct mode does this already – you can leave out `setup()` and `draw()`, and just write lines, which are assumed to be the contents of a single draw iteration (no loop). So this is a valid Processing sketch:

```auto
rect(20, 20, 60, 40);

```

You might also be interested in the Processing REPL mode!

> **[GitHub - joelmoniz/REPLmode: This repository will hold a new mode for...](https://github.com/joelmoniz/REPLmode)**
>
> This repository will hold a new mode for Processing- the REPL mode - GitHub - joelmoniz/REPLmode: This repository will hold a new mode for Processing- the REPL mode

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/12038/a-new-mode-for-processing-the-repl-mode-with-hints-of-live-coding)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

 ![Screen Shot 2021-09-05 at 7.56.09 PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5606debad40c201a0b46ced28196daae2be6bd05.png)

---

<div class="post-metadata">

**Author:** ![rapatski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rapatski/32/5164_2.png) [@rapatski](https://discourse.processing.org/u/rapatski)\
**Post date:** [September 6, 2021, 7:58pm UTC](https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906/5 "2021-09-06T19:58:01Z")

</div>

I love this is posted in the Beginners category.

---

<div class="post-metadata">

**Author:** ![codeWorth](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codeWorth](https://discourse.processing.org/u/codeWorth)\
**Post date:** [September 9, 2021, 4:40am UTC](https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906/6 "2021-09-09T04:40:41Z")

</div>

I was talking about importing Processing as a library. I didn’t know about the concept of static output, that makes a lot of sense!

---

<div class="post-metadata">

**Author:** ![codeWorth](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codeWorth](https://discourse.processing.org/u/codeWorth)\
**Post date:** [September 9, 2021, 4:45am UTC](https://discourse.processing.org/t/why-does-papplet-fail-silently-when-you-dont-implement-draw/31906/7 "2021-09-09T04:45:41Z")

</div>

Sorry about that haha, I’m relatively experienced with Java, but very inexperienced with Processing and the forums… oops
