# New vs instantiate vs make-object

**URL:** <https://racket.discourse.group/t/new-vs-instantiate-vs-make-object/1230>\
**Category:** Questions & Answers\
**Tags:** object-oriented, class, object\
**Created:** [August 15, 2022, 3:56pm UTC](https://racket.discourse.group/t/new-vs-instantiate-vs-make-object/1230 "2022-08-15T15:56:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dstorrs](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@dstorrs](https://racket.discourse.group/u/dstorrs)\
**Post date:** [August 15, 2022, 3:56pm UTC](https://racket.discourse.group/t/new-vs-instantiate-vs-make-object/1230/1 "2022-08-15T15:56:01Z")

</div>

[6.3&nbsp;Creating Objects](https://docs.racket-lang.org/reference/objcreation.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._instantiate%29%29) shows three separate methods for creating objects:

```scheme
(make-object class init-v ...) → object?
(new class-expr (id by-name-expr) ...)
(instantiate class-expr (by-pos-expr ...) (id by-name-expr) ...)

```

If I'm reading this right, there are three differences between these methods:

A) `make-object` uses all positional initialization, `new` uses all named initialization, and `instantiate` allows you to mix the two styles  
B) `make-object` is a procedure, the other two are syntactic forms  
C) `make-object` takes a class as its first argument while the other two take class expressions.

This leaves me with some questions:

1. Are there other differences?
2. Should I prefer one approach over another?
3. What is the difference between a 'class' and a 'class expression' in this context? My understanding is that when an expression is validated the system works from the inside out, so by the time `make-object` or `new` are being evaluated there should be a class value sitting in that first slot.

In regular code I tend to prefer keywords for anything that has more than 2-3 arguments, so I instinctively lean away from `make-object` but maybe there's a reason not to.

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [August 15, 2022, 4:25pm UTC](https://racket.discourse.group/t/new-vs-instantiate-vs-make-object/1230/2 "2022-08-15T16:25:22Z")

</div>

The difference between "class" and "class expression" is just about function vs macro. You can put an expression that evaluates to a class as the first argument to `make-object` because function application takes arbitrary expressions.

In general, you should use `new` and named init arguments, everything else is legacy.

---

<div class="post-metadata">

**Author:** ![dstorrs](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@dstorrs](https://racket.discourse.group/u/dstorrs)\
**Post date:** [August 15, 2022, 4:26pm UTC](https://racket.discourse.group/t/new-vs-instantiate-vs-make-object/1230/3 "2022-08-15T16:26:30Z")

</div>

Brilliant. Thanks, Sam.
