Print N Squared

Shtriped, 317 bytes

While I'm making the question, I may as show off my new "purist" language.

@ f x
 d x
 f
 @ f x
+ x y
 +
  i x
 @ + y
 h x
} x y
 e 1
 i 1
 d y
 d 1
 d x
 } x y
e 0
e 2
i 2
i 2
e 6
+ 2 2 6
+ 2 6 6
e T
+ 2 2 T
+ 6 T T
e N
t N
e P
+ T 0 P
e L
i L
*
 e x
 *
  + P x x
 @ * T
 h x
~
 } N P 0
 d 0
 i L
 * P
 ~
~
#
 p N
-
 s 6
_
 @ - L
$
 #
 @ _ n
 #
 s 2
@ # N
e n
+ N 0 n
d n
d n
s 2
@ $ n
@ # N

(definitely works in v1.0.0)

There are no math operations built into Shtriped except increment and decrement. There's also no looping or conditionals, so all of these thing need to be built up from scratch in every program.

That's what my program does, e.g. @ is essentially a for loop, + is an addition function, } is >=. The actual output is only produced in the last 8 lines of the program.

There are no strings either in Shtriped. You can take in and print out strings, but they are all represented internally as arbitrary precision integers that can only be incremented and decremented. So there's no easy way get the length of the string 10 for filling in the the square center with the right amount of spaces. I had to cobble together the function ~ that effectively computes floor(log10(N)) + 1 to find the length of N in decimal.

This could probably be golfed a bit more by rearranging where and how which variables are used, but not that much more. There's no getting around Shtriped's inherent limitations. (It was never meant to be a golfing language anyway.)

Commented code (a backslash is a comment):

@ f x \ function that calls f() x times, returns 0
 d x
 f
 @ f x
+ x y \ returns x + y
 +
  i x
 @ + y
 h x
} x y \ returns 1 if x >= y, else 0
 e 1
 i 1
 d y
 d 1
 d x
 } x y

\ declare and set up variables for the numbers 0, 2, 6, 10
e 0 \ 0 is used to help copy values via +
e 2 \ 2 is used for printing newlines
i 2
i 2
e 6 \ 6 is used for printing spaces
+ 2 2 6
+ 2 6 6
e T \ 10 is used for finding the string length of N
+ 2 2 T
+ 6 T T

e N \ declare N
t N \ and set it to what the user inputs

\ all the code from here to the last ~ is for finding the length of N as a string

e P \ P is the current power of 10 (10, 100, 1000...), starting with 10
+ T 0 P
e L \ L will be the length of N in decimal digits
i L

* \ function that returns P times 10 by adding P to itself 10 times
 e x
 *
  + P x x
 @ * T
 h x

~ \ function that increments L and multiplies P by 10 until N < P, at which point L will be the string length of N
 } N P 0 \ the 0 variable can be used as a dummy now since we don't need it anymore
 d 0
 i L
 * P \ multiply P by 10 to 
 ~
~

\ helper functions for displaying the output
# \ simply prints N as a decimal integer
 p N
- \ prints a single space
 s 6
_ \ prints L spaces (L = digit length of N)
 @ - L
$ \ prints one of the central N-2 lines of the square
 #
 @ _ n
 #
 s 2

\ finally, call these functions to display the output
@ # N \ print N copies of N (top line of square)
e n \ declare n and set it to N - 2
+ N 0 n
d n
d n \ if N was 0 or 1 the program will end here, having printed nothing if 0 or just the top line if 1
s 2 \ print a newline
@ $ n \ print the central line of the square N-2 times
@ # N \ print N copies of N (bottom line of square)

\ the output always prints without a trailing newline

Seriously, 32 31 30 29 bytes

╩╜ó$╝╜Dbu╜╛*n╜¬;╛l*' *╛+╛@+n(

Try it online!

Explanation:

╩╜ó$╝╜Dbu╜╛*n╜¬;╛l*' *╛+╛@+n(
╩                              push each input to its own register
                                 (we'll call register 0 "n")
 ╜                             push n to the stack
  ó                            terminate if 0
   $╝                          push str(n) to register 1
                                 (we'll call register 1 "s")
     ╜Dbu╜╛*n                  make min(2,n) copies of s*n (the top and bottom)
                                 (this avoids an extra copy if n is 1)
             ╜¬;               push n-2 twice
                ╛l*' *         push (n-2)*len(s) spaces
                      ╛+╛@+    put s on the front and end of the string (a middle piece)
                           n   push (n-2) total copies of the middle piece
                            (  bring the top piece to the top

JavaScript (ES6), 73 82 78 bytes

Saved a4 bytes thanks to @user81655

n=>(a=n[r='repeat'](n),n<2?a:a+`
${n+' '[r](n.length*(n-2))+n}`[r](n-2)+`
`+a)

Takes a string, not a number for input.

Try it online (all browsers work)