text:
Transpile ;# into your language
Related to: Make a ;# interpreter and Generate ;# code
;# - A Whirlwind Guide
This is a simple language with two commands.  Its only data structure is an accumulator, which is initialized to 0.

; Increment the accumulator
# Calculate the value of the accumulator modulo 127, and print the corresponding ASCII character.  Then, reset the accumulator to 0.

The source code may contain additional characters (printable ASCII + whitespace), but these are treated as comments and have no effect on program execution.
Challenge
Since most computers do not come with ;# preinstalled, it would be very useful to have a tool that can convert ;# code into a different language.  In this challenge, you shall write a program to accomplish this.
Input
Some ;# source code, taken via argument or STDIN.  This source code may contain (comment) characters other than ; or #.
Output
Code, in the same language as your submission, which, when executed, prints/returns the same string as the original ;# code.  This resultant code may output a trailing newline after the target string, if that is more convenient for your language.
Notes
One thing to look out for is escape sequences, such as code that prints backslashes or prints quote marks.  Also look out for ;# code that could contain things that look like keywords or commands in your language.
Additional restrictions
All programs must terminate (I normally consider this a default, but someone asked about it so I'm stating it here).
Examples
input: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
output (python): print(";#")
input: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
output (element): \'`

My computer came with ;# preinstalled...

Does the program have to stop execution? Also, can it print no-ops infinitely after the actual code?

Will the program always have at least one # character in it?

@totallyhuman I'm gonna say that all programs must eventually halt.

Please could we get a test case where the input contains a character (or characters) that aren't ; or #?

@streetster Just spam random characters in the already-existing testcases as comments

brainfuck, 126 bytes
+++[->+++++<]>[->++++>+++<<],[+<++++++[-<++++>>------<]>[<]<<[>>>>>[--<--.++>]<+.-<.<<<<]>[->>-<<]>>[[-]<]>[>>++++[-->]<[<]],]

Try it online!
The output program will fail in the TIO implementation if the ;# output exceeds 65536 characters.  I also made a 130-byte version which outputs [+] instead of <, avoiding this problem:
++[------>++>+<<]>+++++<,[+<++++++[-<++++>>------<]>[<]<<[>>>>>[--<.>]<+++.---<.>.<++.--<<<<]>[->>-<<]>>[[-]<]>[>>++++[-->]<[<]],]

Explanation
+++[->+++++<]>[->++++>+++<<]        initialize tape with 60 and 45
,[                                  for each input byte:
  +<++++++[-<++++>>------<]         subtract 35 (#) from byte
  >[<]<<[                           if byte was #
         >>>>>[--<--.++>]           output + (43) a number of times equal to accumulator
         <+.-<.<<<<                 output . (46) and < (60)
  ]
  >[->>-<<]>>                       subtract 24 from what's left of byte
  [[-]<]                            check difference and clear if nonzero
  >[                                if byte was originally 59 (;)
   >>++++[-->]<[<]                  add 4 to accumulator cell, then subtract 2 if nonzero. Since BF cells are mod 256, this creates an accumulator mod 127.
  ]
,]

Python 2, 76 69 bytes
Code
Input is surrounded by quotes.
for y in input('print').split("#")[:-1]:print`chr(y.count(";")%127)`,

Try it online!
Explanation
The first part of the output is essentially done by the input, using input('print'). We split the input on hashtags and discard the last element. We print the representation of ord(y%127), where y is the number of occurrences of the semicolon. We append the , at the end of the print to make sure that this does not print a newline.
This would give the following Python code for the Hello, World!-program:
print'H' 'e' 'l' 'l' 'o' ',' ' ' 'W' 'o' 'r' 'l' 'd' '!'

Which can be tried online.

Whitespace, 291 bytes
NSSTTNNSTNNSTNNSTTNNSSTSNSSNSNSTNTSTTTSSSTSSSTTNTSSTSNSNTSSSSNSSSTTSSSNTSSTNTSSSTNNSNTSNNSSSSSNSNNNSTSSNNSTSTNNSTSTNNSTSNNSTTNNSTSNNSTNNSTSTNNSTTNNSTNNSTNNSNTTNNSSSSTNNSTSSNNSTSNNSTTNNSTSNNSTSSNNSNTSNNSSTNSSSTSTSNTNSSNTNNSSSSNNSTNNSTNNSSNSSSTSSSSSNTNSSNTNNSSSTNNSTSNNSTSNNSSSNSSSTSSTNTNSSNTN

Replace S by space, T by tab and N by a newline.
Generating whitespace in whitespace is not the most efficient thing in the world. Generating any kind of dynamic code requires significant bit-twiddling which, in a language without bitwise operations, would cause the code size to explode. Therefore, this program does not attempt to do something smart, instead opting for just translating the source program one to one. It disassembles to the following:
early:
    call S
    call S
    call N
start:
    push  0
    dup
    ichr
    get
    push  35
    sub
    dup
    jz    hash
    push  24
    sub
    jz    semi
    jmp   start
hash:
    pop
    call SSS
    call TTT
    call TTT
    call T
    call N
    call T
    call S
    call TTT
    call N
    call S
    call S
    jmp   early
semi:
    call SSS
    call T
    call N
    call T
    call SSS
    jmp   start
N:
    push 10
    pchr
    ret
SSS:
    call S
    call S
S:
    push 32
    pchr
    ret
TTT:
    call T
    call T
T:
    push 9
    pchr
    ret

The code generated by the program looks like:
push  0
push  1
add
push  1
add
push  1
add
push  1
add
push  1
add
push  1
add
push  1
add
push  1
add
push  1
add
push  1
add
push  1
add
push  127
mod
pchr
push  0
push  1
add
...

Doesn't work for me. In the original whitespace interpreter written in Haskell, the sign bit may not be omitted from a number, so "SSN" is not a valid way to push zero.

Due to the vagueness of the specification of whitespace and the differences between the original reference interpreter and the actual specification, it is hard to judge what was to be the intended behaviour. As far as I remember several example programs listed on the original site actually did require the signless behaviour, and furthermore many other implementations do have it.
I ran into these issues several times while building my own ws JIT compiler, and in the end I decided to stick with it for compatability with other implementations

V, 19 20 28 bytes
Bugfix, broke if there was no # at the end
Bugfix, implemented mod 127
Í;û127}
éiA0Í#/0
ò/;
x

Try it online!
Try Generated Code
Explanation:
Í;û127}                            ' Delete runs of 127 `;`s (mod 127)
éi                                 ' Insert an `i` in front of input
  A<C-v><esc>0<esc>                ' Append <esc>0 to input
                   Í#/<C-v><C-v>0  ' Replace all `#` with `<C-v>0`
ò                                  ' Recursively
 /;                                ' Go to the next `;`
<C-a>                              ' Increment the next number come across

In V, in insert mode, any ASCII character can be inserted by code by using <C-v><Code>.  The V code replaces all # with <C-v>0, where the zero is a pseudo-accumulator per #.  Each # resets the accumulator to 0 so having one per works out fine.  Then the code does an increment for each semicolon found, which just increments the next number it finds, which would be the next accumulator.  The 0 is appended to the end so that the instruction doesn't fail for ;s without a following #.
Hexdump:
00000000: e969 4116 1b30 1bcd 232f 1616 300a f22f  .iA..0..#/..0../
00000010: 3b0a 7801                                ;.x.

JavaScript (ES6), 101 100 bytes
s=>`_=>'${s.replace(/[^#;]/g,``)}'.replace(/;*(#?)/g,(l,c)=>c&&String.fromCharCode(~-l.length%127))`

Given an input string, deletes all the unnecessary characters, then returns the source of the following function:
_=>'...'.replace(/;*(#?)/g,(l,c)=>c&&String.fromCharCode(~-l.length%127))

Where ... represents the cleaned ;# source. Edit: Saved 1 byte thanks to @l4m2.

/;*(#|$)/ => /;*(#?)/?

05AB1E, 20 19 18 16 bytes
-1 thanks to Adnan
-2 thanks to carusocomputing
-2 thanks to Kevin Cruijssen
'#¡¨vy';¢ƵQ%„çJJ

Try it online! (includes output of executed 05AB1E code)
'#¡              # Split on #
   ¨             # remove the last element
    vy           # For each...
      ';¢        #   count the number of ;s
         ƵQ%     #   Mod by 127
            „çJ  #   Push çJ
               J # Join stack and output implicitly

';¢ can be g, žy pushes 128, may work somehow and why not just spell the full word and surround it by quotes?

I need to use ';¢ incase there are characters other than ;. žy< is the same as 127. Printing the word surrounded by quotes will break if one of the characters is a quote.

@carusocomputing I forgot to ping you...

@carusocomputing and Riley: ƵQ is a compressed version of 127.

@Adnan why/how?

Also "çJ"} technically works instead of "ç"}'J. Odd how that ends up working but „çJ} is also a bust.

@carusocomputing That does work. Thanks!

@Riley if you remove the footer }J can also just be J. Or just change the footer to D.V»

@carusocomputing Q converted to base 255 with an offset of 101 results in 26 + 101 = 127.

You've used ƵQ in your explanation, but not in your actual code, byte-count, or TIO-link. Also, „çJ works in the new version of 05AB1E. (And your footer can be 'golfed' to }=.V,. ;p) Try it online 16 bytes

Python 2, 75 bytes
lambda s:"print"+`''.join(chr(x.count(';')%127)for x in s.split('#')[:-1])`

Try it online! (includes output from executing the transpiled Python code)
Thanks to ovs for many many bytes!
Explanation
This program transpiles the #; code by splitting on #s (s.split('#')[:-1]), counting the number of semicolons in each chunk mod 127 (x.count(';')%127for x in ...), and converting that into the respective ASCII character (chr(...)). That list is then concatenated (''.join(...)), converted into a Python representation of the string (the backticks) and inserted into a skeleton Python program for printing strings ("print"+...).

Jelly,  25 24 16  15 bytes
-1 thanks to caird coinheringaahing! (Use of p in place of ;€)
ṣ”#Ṗċ€”;%127p”Ọ

A full program printing equivalent Jelly code (as a monadic link it returns a list of lists of mixed types).
The first example is at Try it online! which yields this program.
How?
Counts up the ;s in each run between #s takes each modulo 127 and appends a cast to ordinal instruction, the monadic Ọ atom, after each.
Jelly implicitly pipes each value to STDOUT as it runs through a program like that i.e. 72Ọ101Ọ108Ọ108Ọ111Ọ44Ọ32Ọ119Ọ111Ọ114Ọ108Ọ100Ọ33Ọ would print Hello, world!.
ṣ”#Ṗċ€”;%127p”Ọ - Main link: list of characters
 ”#             - literal '#'
ṣ               - split the result at #s
   Ṗ            - pop (remove the last result, list of trailing non-# characters)
      ”;        - literal ';'
    ċ€          - count for €ach
        %127    - modulo 127 (vectorises)
             ”Ọ - literal 'Ọ' (Jelly's cast to ordinal monadic atom)
            p   - Cartesian product - making a list of lists like [[72,'Ọ'],[101,'Ọ'],...]
                - implicit print (this smashes, printing something like: 72Ọ101Ọ...)

A note regarding input: Jelly can take string input in Python format (it will first attempt to evaluate input as Python code). The empty program may be input as "", and the hash-only programs as "#", "##", etc. Escape sequences are required for input containing backslashes and quotes.

-1 byte

Nice golf @cairdcoinheringaahing, thanks!

Haskell, 106 102 bytes
';'!(x:a)=x+1:a;'#'!a=0:a;_!a=a;h s="main=putStr"++(show$""++(toEnum.(`mod`127)<$>init(foldr(!)[0]s)))

Try it online!
Ungolfed
step ';' (x:acc) = x+1:acc
step '#' acc = 0:acc
step _ acc = acc;

semicolonHash s = toEnum . (`mod` 127) <$> init (foldr step [0] s)

toHaskell s = "main = putStr " ++ (show $ "" ++ semicolonHash s)

Cubically, 138 137 bytes
+1/1+54@6:5+1/1+5@6/1+52@6:4/1+5@6:1/1+54@6:4/1+5@6:5+2/1+4@6(~-61/1=7&6+5/1+51=7?6{+3/1+5@6}:5+3/1+3=7?6{+52@6:5+1@6-1@6+1@6:5+2/1+4@6})

Try it online!
Note: You may need to replace &6 with ?6& for it to work on TIO. &6 is in the language spec, though.
How it works
+1/1+54@6        Output 'R'
:5+1/1+5@6       Output '3'
/1+52@6          Output 'D'
:4/1+5@6         Output '1'
:1/1+54@6        Output 'R'
:4/1+5@6         Output '1'
:5+2/1+4@6       Output '+'
(                Loop indefinitely
  ~                Get next character
  -61/1=7&6        If input is -1 (EOF), exit program
  +5/1+51=7?6{     If input is `;`
    +3/1+5@6         Output '0'
  }                End if
  :5+3/1+3=7?6{   If input is '#'
    +52@6            Output '@'
    :5+1@6           Output '6'
    -1@6             Output '-'
    +1@6             Output '6'
    :5+2/1+4@6       Output '+'
  }                End if
)                End loop

Output program:
R3D1R1           Set top face to 1
+00...           Add top face to notepad, aka increment notepad
@6               Output notepad as character
-6               Set notepad to 0
...

Save a lot of bytes removing the arguments from @6, %6 and -6. Commands that previously didn't do anything when called implicitly now use the notepad. So @ is the same as @6, % is the same as %6, etc.

Brachylog, 33 bytes
{";"∧"+₁"|"#"∧"%₁₂₇g~ạw0"}ˢ;"0"↔c

Try it online!
I felt too tired to explain this two years ago, but Razetime reminded me.
                           ;"0"↔c    Prepend a 0 to
{                        }ˢ          each element of the input
     "+₁"                            mapped to +₁
 ";"∧                                if it's a semicolon,
         |"#"                        if it's a hash
             ∧"%₁₂₇g~ạw0"            %₁₂₇g~ạw0,
                          ˢ          or nothing otherwise.

      +₁                             add 1

              %₁₂₇                   mod 127,
                  g~ạ                convert from codepoint to character,
                     w               print,
                      0              start over from 0

I am droppinga comment to remind unrelated string

Jelly, 26 bytes
”‘x
f”;L%127Ç;“Ọø”
ṣ”#Ç€ṙ-

Try it online!
And try that Jelly code here!
ṣ”#Ç€ṙ-      Main link, input is a string of ";;;;;;#lala;;;;;;;;;#"
ṣ”#          Split input on char #
   Ç€        Call helper link 1 for each segment
     ṙ-      Rotate returns 1 to the right (SPLIT introduces an empty element which is moved up front)

f”;L%127Ç;“Ọø”  Helper link 1, determines the number of increments
f”;             Throw out all but semicolons
   L%127        Take the count mod 127
        Ç       Call helper 2
         ;“Ọø”  Add a Jelly link that prints characters and splits print statements

”‘x             Helper 2, receives the count of ;'s
”‘              Return the character ‘ (Jelly's increment command
  x             Once for each ; in the input

The Jelly output becomes code like Ọø‘‘‘‘‘‘‘‘‘‘‘‘‘Ọø‘‘‘‘‘‘‘‘‘‘Ọø, which prints chr(13)+chr(10)

Weird example to use (printing only white space) that confused me.

@JonathanAllan Added examples with links to TIO.

C, 98 96 99 98 97 bytes
+3 bytes because I forgot C isn't interpreted :(
c,a;f(){printf("f(){puts(\"");for(;~c;c=getchar())c==59?a++:c==35?a=!printf(&a):a;puts("\");}");}

Running with:
echo ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#" | ./a.out

Will print:
f(){puts("Hello, World!");}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;# produces f(){puts(""");}, which is invalid. The challenge specifically calls out "One thing to look out for is escape sequences, such as code that prints backslashes or prints quote marks."

@hvd Fixing....

><>, 106 81 77 bytes
This is my first golf in ><> (fish)! A pretty interesting language I have to say. A lot of fun!
0n01.
>i:1+?!v:";"=?v"#"=?v
^ ;o";"<   .37<
^oo"1+"
^oooooooo'"~"1+%o0' <

Welcome to the pond ! You can shorten i:1+?! into i:0(?, and I also feel like you could save a few bytes if you constructed the result on the stack and waited for the end of the input to output it. I mean, that's a lot of os ;)

PHP, 72 bytes
for(;~$c=$argn[$i++];)echo[Z=>'$n++;',B=>'echo~$n=~chr($n%127);'][a^$c];

C# 169 Bytes
Golfed:
class P{static int Main(string[] args){var r="Console.Write(";foreach(var y in args[0].Split('#')){r+=(char)(-1+y.Split(';').Length%127);}System.Console.Write(r+");");}}

Human readable version:
class P
{
    static int Main(string[] args)
    {
        var r="Console.Write(\"";
        foreach (var y in args[0].Split('#'))
        {
            r +=(char)(-1+y.Split(';').Length% 127);
        }
        System.Console.Write(r+"\");");
    }
}

MATL, 32 28 bytes
35lF4$Yb"@g59=z]xv127\!&D99h

Try it online!
Completely different approach based on strsplit rather than an automaton-type program.
      Yb % strsplit
    4$   %  with 4 inputs, namely:
35       %   Split on '#'
  lF     %   Do not (F) collapse delimiters (l).
         %   And of course the implicit program input.

"@g    ] % Loop over strings, convert each to a normal char array
   59=z  % How many equal to 59 ';'?

xv!127\  % Delete last element, concatenate and flip to horizontal, mod 127
&D       % Convert to MATL representation
  99h    % Append a 'c' to output ASCII.

MathGolf, 17 bytes
⌡(¶{gÉ'8=£♣(%$''\

Try it online!
Explanation
⌡                      decrement twice
 (                     decrement
                       this transforms ";;;#;;#" -> "888 88 "
  ¶                    split string on spaces
   {                   foreach...
    gÉ                 filter using next 3 characters
      '8               push single character "8"
        =              pop(a, b), push(a==b)
                       this filters out all non-";"
         £             length of array/string with pop
          ♣            push 128
           (           decrement
            %          modulo
             $         pop(a), push ord(a) or char(a) (gets character with code)
              ''       push single character "'"
                \      swap top elements

Since any character can be put on the stack (and thus the output) using '<char>, this will output a sequence of such code blocks.

Forgot how to create a chat.. Anyway,   (discard everything except for the top of the stack) is currently bugged. It gives a Python FileNotFoundError.

@KevinCruijssen Check the README! I switched that character in the code page, to avoid having two space characters. The new character is Þ.

Yeah, @JoKing indeed said it was changed to Þ. (The docs I use still state the old value however.)

@KevinCruijssen Oh, that doc needs to be updated, thanks for the reminder! I'll try to write a script to keep them both updated. I'd suggest using this one until I've gotten that in place.

Nim, 97 bytes
var a=0
for c in stdin.readAll:
 if c==';':a+=1
 if c=='#':echo "stdout.write chr ",a mod 127;a=0

Try it online!
Example resulting code

Vyxal Ṫ, 18 bytes
\#€Ṫƛ\;O₇‹%\C+\₴+,

Good, but definitely could be improved.
Outputs the codepoint, followed by a C to convert to a character, and then a print symbol.
Try it Online!

15 bytes

@lyxal I don't know how I missed the char for removing elements in a that weren't in b, but I have some questions. Does this code not fail for instances with a single ;, ie: ";#" which should print out byte 1, but your code interprets that as two prints of a null byte. Additionally, using "," as your print would output the characters with new lines between them, rather than inline, no?

Thunno 2, 16 bytes
';'⁺Ṇ'#"ṇȷ%C¢"WṆ

Try it online!
or verify the resulting Thunno 2 code
Explanation
';'⁺Ṇ'#"ṇȷ%C¢"WṆ  '# Implicit input
';'⁺Ṇ              # Transliterate ";" -> "⁺"
   ⁺               #   Increment top of stack
                   #   (which starts at 0)
     '#"ṇȷ%C¢"WṆ  '# Transliterate "#" -> "ṇȷ%C¢"
        ṇȷ         #   Push compressed integer 127
          %        #   And modulo top of stack by that
           C       #   Cast to character using ASCII value
            ¢      #   And print it without a newline
                   # Implicit output

ARBLE, 57 bytes
"print%q"%gsub(a,".-#",#char(len(gsub(e,"[^;]",""))%128))

Explained
"print%q"%gsub(a,".-#",#char(len(gsub(e,"[^;]",""))%128))
          gsub(a,".-#",                                 )  -- Replace all groups of characters followed by a # in the input with...
                                 gsub(e,"[^;]","")         -- Remove all non-; characters, removing comments
                             len(                 )        -- Effectively count all ; in the group
                        char(                      %128)   -- Modulo 128, convert to a char.
                       #                                   -- As a function. Effectively runs the ;# code.
"print%q"%                                                 -- returns a string consisting of print followed by the string-formatted ;# code.

Try it online!

Actually, 25 bytes
'#@s⌠';@c7╙D@%⌡MdX$"♂cΣ"o

Try it online! (includes output from executing the transpiled Actually code)
Explanation:
'#@s⌠';@c7╙D@%⌡MdX$"♂cΣ"o
'#@s                       split on "#"
    ⌠';@c7╙D@%⌡M           for each chunk:
     ';@c                    count ";"s
         7╙D@%               mod by 127 (2**7-1)
                dX         discard last value
                  $        stringify
                   "♂cΣ"o  append "♂cΣ":
                    ♂c       convert each value to an ASCII character
                      Σ      concatenate

shortC, 48 bytes
c,a;AR"AP\"");O;~c;c=G)c==59?a++:c==35?a=!R&a):a

Can you add the expanded form?

@CalculatorFeline already done.

Pyth, 25 23 24 bytes
j\\+"jk["mC%/d\;127Pcw\#

+1 bytes thanks to @FryAmTheEggman
Try it!
handles characters that have to be escaped by only using 1-char-strings.
Sample outputs:
jk[\"

jk[\H\e\l\l\o\,\ \W\o\r\l\d\!

Uses my ;# interpreter.

This doesn't work if there are no # in the input, as it will print 0. You can fix this with jk instead of s.

Fourier, 32 bytes
$(I~S{59}{`^`}S{35}{`%127a0`}&i)

Try it on FourIDE!
This was quite an easy challenge since Fourier is basically a superset of ;#:
;# command > Fourier equivalent
; > ^ (Increment the accumulator)
# > %127a0 (Modulo accumulator by 127, output corresponding code point and set accumulator to zero)

Ruby, 47+1=48 bytes
$_=gsub(/.*?#/){"$><<#{$&.count(?;)%127}.chr;"}

+1 byte for -p.
Try it online!
-30 bytes thanks to @manatwork!

Unfortunately this not plays nice with the “This source code may contain (comment) characters other than ; or #.” part of requirement.

@manatwork Fixed, will make golfier later.

Was enough to change the regular expression /;+#/ → /.*?#/ and the code block s.length-1 → s.count(?;). BTW, your math is also wrong, as % has higher priority than -, so should be (s.length-1)%127. And in .gsub's code block you can access the captured groups with $&, $1, … so the |s| code block parameter usually is not feasible. And the string interpolation stringifies: {"$><<#{$&.count(?;)%127}.chr;"}. Try it online!

@manatwork thank you so much! I think your comment has doubled my ruby knowledge.

It's late, but the code challenge itself was bumped recently by a modified answer so whatever. gsub modifies $_ directly, which means that you don't need to re-assign it. HOWEVER, you have issues if you have comment characters after your last #... see here

Here's a working solution in 58 bytes to get you started with re-golfing

CJam, 14 bytes
q'#/);';fe=:c`

Explanation:
q               e# Read input
 '#/            e# Split on '#'
    );          e# Delete last element
      ';fe=     e# Count occurrences of ';' in each
           :c   e# Convert each to character (code point)
             `  e# Escape

This needs a 127% as you should calculate "the value of the accumulator modulo 127"

APL, 31 bytes
{⍕'⎕UCS',⌽127|+/¨';'=⍵⊂⍨'#'=⍵}⌽

Output:
      ({⍕'⎕UCS',⌽127|+/¨';'=⍵⊂⍨'#'=⍵}⌽) ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#'
⎕UCS 59 35
      ⍝ evaluate the output
      ⍎({⍕'⎕UCS',⌽127|+/¨';'=⍵⊂⍨'#'=⍵}⌽) ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#'
;#

Explanation:

⌽: reverse the input
{...}: pass it to this function:

⍵⊂⍨'#'=⍵: partition at each # in the string (from the beginning, which is why it had to be reversed first)
+/¨';'=: count the ;s in each partition
127|: modulo 127
⌽: reverse it again
'⎕UCS',: prepend the string ⎕UCS, which is the Unicode function.
⍕: string representation

You can remove the ⍕ as the actual output to STDOUT is the same.

C, 150 bytes
#include<stdio.h>
c;n=0;main(){puts("#include<stdio.h>\nmain(){");while(~(c=getchar()))c-35?c-59?:n++:(printf("putchar(%d);",n%127)&(n=0));puts("}");}

Expanded:

#include<stdio.h>
c;
n=0;
main(){
        puts("#include<stdio.h>\nmain(){");
        while( ~(
            c=getchar()
        ))
                c-35?
                        c-59?
                                :
                                n++
                        :
                        ( printf("putchar(%d);",n%127)
                        &(n=0))
                ;
        puts("}");
}

It's a complete program that (should) terminate, ignore comments and produce always correct output code.
I assume EOF=-1
Tested on SystemResque-Cd 4.9.6, compiled with gcc 4.9.4

braingasm, 40 bytes
,[35-z["[127-s[127+.>]]<0*".]24-z[43.],]

Gotta say, that's surprisingly short.
,[                                    ,]     Read a byte until end of input
  35-                                          Subtract 35.
     z[                     ]                  If the result is zero,
       "[127-s[127+.>]]<0*".                     print the code for `#`.
                             24-               Subtract 24.
                                z[   ]         If the result is zero,
                                  43.            print the code for `;`

The generated code for ; is a +, which increments the current cell.
The generated code for # contains an akward, manual modulo operation
[127-s[127+.>]]<0*
[             ]       While current cell is not zero
 127-                   Subtract 127
     s[      ]          If result is negative
       127+.              Add 127 again and print current cell
            >             Step to next cell to break the loop
               <0*      Step back to first cell and clear it

Braingolf, 55 bytes
V#0VR&,l1-MvMR[R.#;e"+1"MM|.##e"@%+1~#"MMMMMM|$_vv]Rv&@

Try it online!
Basically replaces ; with 1+, # with #~1+%@ and pre-pends the whole thing with a 0 because monadic + operator is broken right now.
1+ adds 1 to the last item in the stack.
#~1+%@ pushes the char value of ~ (126), adds 1 to make 127, modulus with other item on stack, then pop and print as char.
Explanation
V#0VR&,l1-MvMR                         Implicit input of each char to stack
[R.#;e"+1"MM|.##e"@%+1~#"MMMMMM|$_vv]
Rv&@

V#0                                    Create stack2, push char value of 0
   VR                                  Create stack3, return to stack1
     &,                                Reverse stack
       l1-                             Push length of stack - 1
          MvMR                         Move length to stack2, switch to stack 2
                                       Move length to stack3, switch back to stack1
[R................................vv]  Do-While loop, will run l times
                                       where l is length of input
  .#;                                  Duplicate last item and push char value of semicolon
     e                                 Pop last 2 items, if they are equal..
      "+1"                             ..Push char values of +1 in that order
          MM                           ..Move last 2 items to stack2
            |                          endif
             .##                       Duplicate last item and push char value of hash
                e                      Pop last 2 items, if they are equal..
                 "@%+1~#"              ..Push char values of @%+1~# in that order
                         MMMMMM        ..Move last 6 chars to stack2
                               |       endif
                                $_     Silently pop last item
Rv                                     Switch to stack2
  &@                                   Greedy char print, print every item in stack as char

Perl 5 -n0, 78 58 bytes
say'say"',(map{$_=chr y/;//%127;s/\W/\\$&/r}/[^#]*#/g),'"'

Try it online!

q/kdb+, 42 bytes
Solution:
{-1_"c"$mod[;127](#:)@/:"#"vs x inter"#;"}

Examples:
Note that the , is used to signify a list (versus atom) as "\"" is a list of one element, rather than being an atom.
q){-1_"c"$mod[;127](#:)@/:"#"vs x inter"#;"}";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#"
";#"
q){-1_"c"$mod[;127](#:)@/:"#"vs x inter"#;"}";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#"
,"\""

Explanation:
Take input string, remove anything that isnt a # or a ;, split into lists on #, count number of elements in each list, perform mod 127 on the result and cast to a string:
{-1_"c"$mod[;127]count each"#"vs x inter"#;"} / ungolfed
{                                           } / lambda function
                                 x inter"#;"  / intersection of input and ';#' to clear out any 'comments'
                           "#"vs              / split string on hash
                 count each                   / length of each sub-list
        mod[;127]                             / 127 modulo result (vectorised)
    "c"$                                      / cast back to string
 -1_                                          / drop last character (assuming terminated string)

Notes:

Assumes that input is terminated by a #, otherwise the last chunk will be erroneously dropped by the -1_.
Could be 10 bytes shorter if input was guaranteed to only contain ;#.

Ly, 52 bytes
0ui[[";"=[pp"+1"oo2$]p"#"=[pp"(127)%o0"&o2$]]i]";"o;

Try it online!

Common Lisp, 165 156 bytes
(with-output-to-string(v)(princ"(princ\""v)(do((a 0)(c #\ (read-char()())))((not c))(case c(#\;(incf a))(#\#(princ(code-char a)v)(setf a 0))))(princ"\")"v))

Try it online!
For instance, when applied to:
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#"

produces:
(PRINC";#")

that prints ;#

Ahead, 41 bytes
rW"127%o"<
~>jvi:'#=n';=s~
lW~>'@o@~"1+"<

Converts ;# code into its direct Ahead equivalent, so you get long code consisting mostly of 1+. One byte shorter, but output is very long.
Try it online!

Ahead, 42 bytes
roo''%721$<
~> jli:'#=n';=+~
   >"@ooKu"W@

Figures out which characters to print and writes a program that will push and print all of them with the ' function. Generates much shorter output at the cost of 1 byte. This version was surprisingly hard to golf.
Try it online!

Microscript II, 50 45 bytes
0`IK#>s{<d59=(`s1+`)35=(128s`%p0`"Kp"p)>}*"h"

Google Sheets, 120
Closing parens already discounted.

A1: input
A2: #
B2: "
A3: =JOIN(,ArrayFormula(CHAR(MOD(LEN(SPLIT(A1,A2))-LEN(SUBSTITUTE(SPLIT(A1,A2),";",)),127))))

Broken down:
=JOIN(,                                 Like Concatenate, but shorter
 ArrayFormula(
  CHAR(                                 Convert length to character
   MOD(
    LEN(SPLIT(A1,A2))-
    LEN(SUBSTITUTE(SPLIT(A1,A2),";",)), Subtract commented characters
   127
))))                                    Pile on parens at the end to exploit autocomplete

A4: ="="""&SUBSTITUTE(A3,B2,B2&B2)&B2 - Needs two "s to escape, hence the substitution.

JavaScript (Node.js), 81 bytes
s=>`_=>String.fromCharCode(${s.match(/.*?#/gs).map(c=>~-c.split`;`.length%127)})`

Try it online!
JavaScript (Node.js), 86 bytes, allowing nop(no #)
s=>`_=>String.fromCharCode(${s.split`#`.slice(0,-1).map(c=>~-c.split`;`.length%127)})`

Try it online!

8086 DOS machine code, 47 bytes
Input is from stdin (terminated by a newline), output is directly to the console (cannot be redirected to a file, workaround provided)
0CD5:0100  31 DB B4 08 CD 21 3C 0D-74 20 3C 3B 75 06 43 80 1....!<.t <;u.C.
0CD5:0110  FB 7F 74 EC 3C 23 75 EA-B0 B0 CD 29 88 D8 CD 29 ..t.<#u....)...)
0CD5:0120  B0 CD CD 29 B0 29 CD 29-EB D6 B0 C3 CD 29 C3    ...).).).....).

Commented assembly:
        // nasm syntax with C comments because SE sucks

        // Because I use int 29h, you can't redirect the output with >.
        // Defining REDIRECTABLE will swap out the int 29h with an equivalent
        // int 21h:02h which can be redirected.
        // Unscored.
%ifdef REDIRECTABLE
%macro INT_29H
        push    ax
        push    dx
        mov     dl, al
        mov     ah, 0x02
        int     0x21
        pop     dx
        pop     ax
%endm
%else
%macro INT_29H
        int     0x29
%endm
%endif

        section .text
        [org 0x100]
        global start
start:
.reset:
        // Reset the accumulator
        xor     bx, bx
        // Main loop
.loop:
        // int 29h:08h: read char to AL (no echo)
        mov     ah, 0x08
        int     0x21
        // check for \r, if so, quit.
        cmp     al, 13
        je      .finalize
        // Check for semicolon
        cmp     al, ';'
        jne     .next
.semicolon:
        // Increment accumulator
        inc     bx
        // If we reach 127, reset the accumulator to 0.
        // This is the same as modulo 127 and
        // doesn't require an AAM or DIV setup.
        cmp     bl, 127
        je      .reset
.next:
        // Check for '#', if not, loop again
        cmp     al, '#'
        jne     .loop
.hash:
        // '#': print out code
        // mov al, <hardcoded acc>
        mov     al, 0xB0
        INT_29H
        mov     al, bl
        INT_29H
        // int 0x29
        mov     al, 0xCD
        INT_29H
        mov     al, 0x29
        INT_29H
        // Now reset the accumulator to 0
        jmp     .reset
.finalize:
        // Output ret instruction
        mov     al, 0xC3
        INT_29H
        // And exit
        ret

This program will evaluate the program, and emit a program that prints the output byte by byte using int 29h.
So for example, the ;# test case will emit the machine code for this:
start:
        mov     al, ';'
        int     0x29
        mov     al, '#'
        int     0x29
        ret

I'd like to find a way to do this smaller. Calling int 29h that many times is rather annoying, all because I can't do int 21h:09h because a $ might appear in the output.
Additionally, outputting a parser instead seems to be larger.

GNU AWK, 84 bytes
BEGIN{FS=";";RS="#";printf"BEGIN{printf\42"}RT{printf"%c",NF-1%127}END{printf"\42}"}

Try it online!
Simply got this interpreter and added AWK's syntax.

Knight (with ASCII), 62 bytes
;=a 0;W=xP Wx;=zAx;I?59z=a%+aT127I?35z=a+0O+";O A"aF=xSxF1""O0

Try it online!
Interpreter is patched to follow the spec for ASCII and removes trailing newlines in input (a known bug with that version).
With the new ASCII function being near standardized, this becomes very easy.
The program is input to standard input followed by a blank line.
# initialize acc with 0
; = acc 0
# loop for all non-empty lines in stdin,
# assigning to line
; WHILE (= line PROMPT)
: {
    # Loop through all chars in line
    : WHILE line
    : {
        # Grab the ASCII value of the first char in line, store in chr
        ; = chr ASCII(line)
        # First test for ASCII 59, ";"
        ; IF (? ASCII(";") chr)
        : {
            # acc = (acc + 1) % 127
            : = acc % (+ acc 1) 127
        : }
        # ELSE
        : {
            # check for ASCII 35, "#"
            : IF (? ASCII("#") chr)
            : {
                  # output ";O A" + ASCII value of acc
                 ; OUTPUT(+ ";O A" acc)
                 : = acc 0
            : }
            # ELSE nop
                 : FALSE
       : }
       # Pop front char from line
       : = line SUBSTITUTE(line 0 1 "")
    : }
: }
# ; executes two statements; for the last one,
# just do a NOP.
: OUTPUT(0)

Not sure if &/| makes a difference here.

Python 3, 81 bytes
for c in input("a=0;"):print({";":"a+=1","#":"print(end=chr(a%127));a=0"}.get(c))


text:
Dump stack to array
I'm new to this code-golfing thing and I'm very interested in CJam.
Is there a way to get all the current stack as an array? I think I can do it with something like [1$ 2$...n$] but I would have to get the stack's length and use some kind of iterator (or use a fixed length stack... useless). But is there a way to achieve this with a single operator?
The thing is I want to iterate over all the stack's elements.
Sorry if the question is obvious or seems stupid, but I'm new to this and I couldn't find anything...

or use a fixed length stack... useless Oftentimes you do know how many items are going to be on the stack at a given time.

This would probably be more on-topic for Stack Overflow.

@Challenger5 Tips questions in general are perfectly on topic here. While some esoteric languages have found a way to SO, I doubt CJam questions would be well-received.

Welcome to PPCG! This is covered on https://cjam.readthedocs.io/en/latest/, which you'll probably find useful if you're interested in learning CJam. By the way, once you earn 20 reputation, you'll be able to join us in chat. Simple questions like this one will be answered quickly in The Nineteenth Byte.

@Dennis Thanks. (That 11 below my username is actually my reputation, isn't it? idk I don't really understand how all this StackExchange thing work)

Yes, it is. You can also see your reputation in your profile.

@Dennis What do you mean by well-recieved? AFAIK it's on-topic, but I don't think it would be answered.

@Challenger5 Get downvoted or, worse, left unanswered. If it's unlikely to get answered on SO, there really is no reason to post it there.

@Dennis What happened to the [esoteric] tag?

@Challenger5 Mind joining me in TNB?

An unmatched ] command will make the entire stack into an array.
1 2 3 4 ] -> [1 2 3 4]

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Print invisible text
Given a string as input, output a number of whitespace characters (0x0A and 0x20) equal to the length of the string.
For example, given the string Hello, World! your code would need to output exactly 13 whitespace characters and nothing else. These can be any mix of spaces and newlines.
Your code should not output any additional trailing newlines or spaces.
Testcases:
     Input      -> Amount of whitespace to output
"Hello, World!" -> 13
"Hi"            -> 2
"   Don't
Forget about
Existing
Whitespace!   " -> 45
""              -> 0
"             " -> 13
"
"               -> 1

Scoring:
This is code-golf so fewest bytes wins!

I don't get what you mean with that “0x0A”. Where should that be output? Should that be kept, so “a␠b␊c” becomes “␠␠␠␊␠”?

@manatwork 0x0A and 0x20 are the hexadecimal values for the Newline and Space characters respectively

“output a number of whitespace characters (0x0A and 0x20)” – Where in the output should those newline characters be?

These can be any mix of spaces and newlines
Your output can be any mix of spaces and newlines, you can just output spaces if you want, like everyone else, or you can just output newlines. It's up to you

Can we assume the input will only have printable characters?

@LuisMendo yes you can.

Related

Can we replace existing line breaks with spaces or do we need to retain line breaks?

@ThomasWard you don't need to retain anything but the length of the input string

If we print the correct number of spaces, is a trailing newline acceptable (as this is how the language outputs)

This seems related to output with the same length as the code, the difference: There the input is static, here it is not static.

Isn't this answered in whitespace?

Whitespace, 311 150 77 68 65 46 41 38 bytes
-3 bytes thanks to Kevin Cruijssen
-27 bytes thanks to Ephphatha

Try it online!
A visible format
'\n  \n   \t \t \n \n  \n \t\n\t \t\t\t\n\t  \n\t\n  \n \n\n'

Explanation (s = space, t = tab, n = new line)
nssn     # label(NULL) - loop start
ssststsn # push 10 in the stack -> [10]
sns      # duplicate the top of the stack -> [10, 10]
sns      # duplicate the top of the stack -> [10, 10, 10]
tnts     # read a single char from input, pop the stack and store at that address -> [10, 10] [10:<char that was read>]
ttt      # pop the stack and put the value at that adress on stack -> [10,<char>] [10:<char>]
ntssn    # jump to label(0) - since label(0) is not defined, the interpreter jumps to the end of the program - if the top of the stack (char) is 0 -> [10] [10:<char>]
tnss     # pop the top of the stack and print as ascii -> [] [10:<char>]
nsnn     # go back to the label(NULL)

Assuming this does actually work, this definitely wins my vote for most creative answer

Wait where is the answer? Is it invisible too?

WHAT BLACK MAGIC IS THIS. Your code is not even there! -1

@Christopher more like WHITEspace MAGIC

@Rod That was just a horrible pun.

I knew someone would answer this question with a whitespace program

This should be a meta.ppcg meme.

You can remove the three ending newlines.

@KevinCruijssen I tried without, but it was crashing :c

@Rod Hmmm.. Probably depends on the compiler, as it stated in the tip-answer I've linked. I have used the TIO compiler for Whitespace in the past and there I was able to remove the three trailing new-lines. Btw, why did you state it doesn't work on TIO? Your test case of 1234 does output four spaces. ;) Hmm, your code does work in TIO without the three trailing new-lines.

@KevinCruijssen indeed, I was too focuses on the Debug tab @.@

48 bytes edit: can't add newlines in comments apparently. This pushes the value 10 (ascii newline) to the stack, duplicates the value to use as the heap address for reading input, checks input wasn't a null byte, duplicates the 10 and outputs a newline then loops to the first duplicate command

Turns out you can use a null label, that saves two bytes for 46 - Try it online!

@Ephphatha wow, that's awesome

This is the first time I interact with this community, but... I absolutely had to upvote this...

Turns out the TIO interpreter handles jumping to an undefined label as jumping to the end of the program. This lets us drop one of the define label statements and after redefining the remaining jumps/labels it ends up saving 5 bytes for a total of 41 - Try it online!

There's actually no need to preseed the stack outside the loop. if we move the push after the label, we can just copy it as many times as needed for a full loop which removes one of the duplicates. 38 bytes

Japt, 1 byte
ç

Try it online!

Does japt seriously have a builtin for this? Damn...

@Mayube well it has a builtin to replace all characters in a string with another, and the default replacement is a space ;)

Very nice! For those running the program, you can add the -Q flag into the input to put quotes around the output. TIO

Haskell, 7 bytes
(>>" ")

Try it online! Usage: (>>" ") "Hello, world!".
Given two lists (and strings are lists of characters in Haskell) the >> operator will repeat the second list as many times as the first list has elements. Setting " " as second argument means we concatenate as many spaces as the input string is long.

Alternative (same byte count):
(' '<$)

Try it online! Usage: (' '<$) "Hello, world!".
Given some value and a list, the <$ operator replaces each value in the list with the given value. Thus 5 <$ "abc" results in [5,5,5], and ' ' <$ "abc" in "   ".
The function can equivalently be written as  (<$)' ', in case you want to find some more marine creatures in my code.

Its like an adorable little finless fish

dang this blows my haskell answer out of the water haha

brainfuck, 18 bytes
++++++++++>,[<.>,]

Try it online!
Prints one newline for each byte of input.  Printing spaces instead would add 4 bytes.

For posterity: Mika Lammi posted a clever 16-byte answer that got buried. ,[>++++++++++.,]

Python, 19 bytes
lambda s:' '*len(s)

Brainfuck, 16 bytes
Prints newlines.
,[>++++++++++.,]

Retina, 3 4 bytes
S\`.

Old version, doesn't work because Retina prints a trailing line feed.

.

(The second line contains a space).

The retina TIO is quite easy to use.  Here is your answer

Unfortunately, Retina prints a trailing linefeed by default. You'll need to prepend \\`` to avoid that. Then it's shorter to use S\. though, which replaces each character with a linefeed (because it splits the input around each character).

@MartinEnder Ahhh wasn't sure if that was  a Retina or TIO thing. Thanks for the help on saving a byte there though!

sed, 7 bytes
s/./ /g

Try it online!

C#, 28 24 bytes
s=>"".PadLeft(s.Length);

Old version using the string constructor for 28 bytes:
s=>new string(' ',s.Length);

Wanted to do exactly the same

@StefanDelport Gotta be quick with C# when I'm around :) There's Linq approaches to do the same but they're all a LOT longer...

Given adequate type context, couldn't this just be s=>new(' ',s.Length)?

JavaScript ES6, 22 bytes
a=>a.replace(/./g," ")

f=a=>a.replace(/./g," ");

var test = f("Hello, World!");
console.log(test, test.length);

Huh, I thought "oh darn, it'd have to be s=>s.replace(/[^]/g," "), a byte longer than the other solution". It didn't occur to me that newlines are allowed in the output :P

Retina, 5 bytes
\`.
¶

Try it online! Changes everything into newlines. The \` suppresses the extra newline Retina would normally output.

Mathematica, 21 bytes
StringReplace[_->" "]

If charlist input was allowed, this could be #/._->" "&. Sadly, the input is a string and Characters[] makes it one byte longer than your solution :(

Doesn't this need a # and a & in it? E.g. StringReplace[#,_->" "]&

@IanMiller Not in Mathematica 10.4 or 11. http://reference.wolfram.com/language/ref/StringReplace.html

Ah ok. I only have 10.3. Maybe time to upgrade...

C, 31 bytes
f(char*c){puts(""),*c++&&f(c);}

How does this differ from your other C answer? Clearly this one is shorter, but should you have simply edited the other one? Should it just be one answer with two solutions?

@Tas First of all, I guess in some sense I feel this is not as good as the other one eventhough it's shorter, because it doesn't actually compile as-is. It's just a function so you need to write some main routine around it. However, it is shorter and others seems to post just functions. Clearly it's two very different solutions. One is not the refinement of the other, so to me it makes sense that it should be two different answers. However, I'm new to this community. Is the consensus that one user only posts one answer? If so I will do that next time.

Should the comma really be a comma and not a semicolon?

@OskarSkog well, in this case it doesn't matter that much because there is no lhs

@OskarSkog Yes, it should be a comma. As @cat says, it doesn't really matter in this case but I chose comma for variation :) The comma operator evaluates two expressions (e.g. i++, j++ in a for loop) and returns the rightmost one. An important detail is that the recursion has to stop somehow. && doesn't evaluate it's rhs if it's lhs is false. *c++ evaluates false when it points to the null-termination of the string.

05AB1E, 3 bytes
vð?

Try it online!
v   # For each character...
 ð? #    Output a space without a newline

Other 3 byte solutions (Thanks Magic Octopus Urn and Kevin Cruijssen for most of these)
v¶? # For each character print a newline (without adding a newline)
võ, # For each character print the empty string with a newline
gð× # Get the length, concatenate that many copies of space
g¶× # Get the length, concatenate that many copies of newline
Sð: # Split, push a space, replace each char in input with a space
ðs∍ # Push ' ', swap, make the string of spaces as long as the input was
võJ # For each char, push a space and ''.join(stack)
v¶J # For each char, push a newline and ''.join(stack)
€ðJ # For each char, push a space. Then ''.join(stack)
€¶J # For each char, push a newline. Then ''.join(stack)

Other solution: gð×, the rest I came up with were above 3 like: õ‚.B¤

Another fun one: Sð:

More fun: ðs∍

Some more alternative 3-byters: võJ/v¶J; €ðJ/€¶J. And since a sequence of characters as I/O is allowed by default when strings I/O is asked, some 2-byte versions are possible: €ð/€¶/εð/ε¶ and ð:/¶:. Although since this is a pretty old challenge and all other answers use actual strings, I could understand if you kept it as string I/O.

Excel VBA, 17 15 Bytes
Anonymous VBE immediate window funtion that takes input from cell [A1] and outputs spaces of length of the input to the VBE immediate window
?Spc([Len(A1)])

PHP, 28 Bytes
for(;a&$argn[$i++];)echo" ";

Try it online!
PHP, 29 Bytes
<?=str_pad('',strlen($argn));

Try it online!

JavaScript (ES6), 23 bytes
s=>" ".repeat(s.length)

Octave, 14 bytes
@(a)["" 0*a+32]

CJam, 4 bytes
q,S*

Try it online!
Explanation
q     e# Read input
 ,    e# Length
  S*  e# Repeat space that many times

V, 2 bytes
Ò

Try it online!
Note the trailing space!

C, 45 bytes
Using main. Compile with gcc, ignore warnings.
main(c,v)char**v;{while(*(v[1]++))puts("");}

Usage:
$./a.out "Hello, World!"

Any reason why you can't put char**v in main(c,v)?

@CalculatorFeline At least GCC 6.3.1 compiling simply with gcc main.c doesn't seem to allow mixing ANSI function definition with K&R function definition, so main(c,char**v) won't compile. I either have to do main(int c,char**v) or main(c,v)char**v; of which the latter is 3 bytes shorter. You wouldn't by chance know any flag or something which allows mixing these styles?

No, you can't mix 'em. There's no flag that allows that. K&R style is long obsolete, used only for code golfing and obfuscation purposes.

And I'm guessing removing char**v entirely doesn't compile either.

@CalculatorFeline If you omit char** entirely the compiler will interpret it as int. If I'm not mistaken you get an error trying to dereference an int and even if you didn't the program wouldn't do what you expected it to do since an int consumes several chars and therefore you never get a NULL value.

I think you could just do main(char**v){...}, if I'm not mistaken

How would you be able to do that, @conor? The first parameter to main is an int. Your declaration is missing the first parameter!

@CodyGray my mistake. I thought I remembered reading that using only argv as a parameter was valid somewhere

Python 2, 25 bytes
exec'print;'*len(input())

-2 bytes thanks to Loovjo
-2 bytes in the invalid code thanks to totallyhuman :p
-3 bytes

You can remove the parens after exec since it's a keyword in Python 2

@Loovjo Oh right, Python 2. Thanks!

I know this is old and stuff but exec'print;'*len(input()) works.

@totallyhuman oh true, thanks :P

Oh, my bad, didn't think of that.

Actually, it doesn't work. input() in python2 evaluates the contents. So this errors with SyntaxError: unexpected EOF while parsing for Hello, World!. You need to use raw_input().

@TheMatt Actually, thanks for pointing that out; thanks to current policies, that actually does work (and allows newlines) because you can request for input to be enclosed in quotes or whatever is required for the language specs in that respect

Ah ok, can you please point out where it says enclosed in quotes is valid. I am just not seeing it. Also, for what it is worth, print' '*(len(input())-1) is also 25 bytes.

@TheMatt it's probably not in the problem specs but it's one of the default acceptable input methods. Try looking on meta, I don't want to go looking for it right now

Perl 5, 7 bytes
-1 byte thanks to @Xcali
6 bytes of code + -p flag.
y// /c

Try it online!
Quite straight forward : replaces every character with a space.

y// /c is one byte shorter.

Excel, 18 bytes
=REPT(" ",LEN(A1))

Pretty boring and one byte longer than the VBA answer.

><>, 7 bytes
i0(?;ao

The program is a loop
i         //Push a character from the input onto the stack
 0        //Add a 0 to the stack
  (       //Pop the top two values of the stack, and push a 1 if the second is less than the first (In this case, the input has all been read), else push a 0
   ?      //Pop the top of the stack. If the value is a 0, skip the next instruction
    ;     // Terminate the program
     a    // Add a newline to the stack
      o   // Pop the top character of the stack and print it

Pyth, 3 bytes
*dl

Try it!
Python equivalent: len(input())*" "
jmk

Try this!
Python equivalent: "\n".join(map("", input()))
smb

Try that!
Python equivalent: "".join(map("\n",input())
VQk

Try!
Python equivalent: For N in input():print("")

@StanStrum: It outputs newlines. Newlines are also allowed per the challenge description above. You can see this better from this example input

Hexagony, 12 11 bytes
-1 byte thanks to Martin Ender
,<.;.M@.>~8

Try it online!
Here is the expanded hex:
  , < .
 ; . M @
. > ~ 8 .
 . . . .
  . . .

While there is input, this code runs:
,        # Get input
 <       # Turn right (SE) if we didn't get EOF
  M8     # Set the memory edge to 778 which is 10 (mod 256)
    ;    # Print as a character (newline)
     >   # Redirect East
      ~  # Multiply by -1. This makes the pointer go to the top when it runs off the edge
       8 # Effectively a no-op.

When EOF is reached:
,    # Get input
 <   # Turn left (NE)
  8  # Effectively a no-op
   @ # End program

You can print a linefeed in three bytes with M8; (which gives 778 = 10 (mod 256)). That should allow you to move the ~ where the ; is right now, saving a byte.

PHP, 36 bytes
<?=str_repeat('
',strlen($argv[1]));

Try it online!
Outputs newlines because spaces are too mainstream

$argn instead of $argv[1] save 4 bytes. Run with the -F option

Jelly, 2 bytes
⁶ṁ

Try it online!

C (tcc), 31 bytes
I opted to output newlines since it's shorter...

f(char*s){for(;*s++;puts(""));}

Try it online!

Cubix, 6 bytes
Wahoo a 6 byter!
wi?@oS

Cubified
  w
i ? @ o
  S

i gets input
? test top of stack

if negative (EOI) redirect onto w lane change which umps to the @ halt
if 0 (null) halt this shouldn't be hit
if positive Sow push space to the stack, output and change lane onto i

Try it online!

Sweet, it's not too often a Cubix program is this short :-)

C, 32 bytes
Try Online modifying characters into spaces
f(char*t){(*t=*t?32:0)&&f(t+1);}

C, 37 bytes
Try Online Left-padding the end-of-string with its length
f(char*t){printf("%*c",strlen(t),0);}

29

APL (Dyalog) 13.2, 1 byte
Prints only spaces.
∊ prototype (numbers become zeros, characters become spaces)
Try it online!

Pepe, 46 37 bytes
REEeRREeeeREEEEErEeeEeeeeerEEeeeEreee

Try it online!
Explanation:
REEe       # Input (string) in R
RREeee     # Push reverse pointer position, or length of input - 1
           # R flag: push in beginning
REEEEE     # ...add 1
rEeeEeeeee # Push space in r
rEEeeeE    # ...R times
reee       # Output whole stack

Poetic, 81 bytes
the berenstein bears
i remember a series i spelled wrong
o m gee,i do remember it

Try it online!
The misspelling is intentional. (...or is it?)

Gema, 4 characters
?=\

(There is a space at the end of code.)
Sample run:
bash-4.4$ echo -n 'Hello, World!' | gema '?=\ '
             bash-4.4$ echo -n 'Hello, World!' | gema '?=\ ' | wc
      0       0      13

APL (Dyalog), 3 bytes
Prints only newlines.
0/⍪

Try it online!
⍪ table (makes string into column matrix)
0/ replicate each column zero times

Scala, 15 bytes
s=>" "*s.length

I created a Try it online for your program.

dc, 25 18 bytes
-1 byte thanks to brhfl
Z[1-d0<L32P]sLd0<L

Try it online!
Explanation:
Z[1-d0<L32P]sLd0<L
                    Implicit input
Z                   Get length
 [         ]sL      Create a funcion and saves in L
              d0<L  If length > 0, call L
  1-                Subtract 1 from the length
    d0<L            If length > 0, call L
        32P         Print space

Woah! It's worse than German. It would be neat if you explained how it works ;)

@NieDzejkob there :D

@Felipe You can shave off one byte by using the ASCII code point for a space instead of a string containing a space: 32P instead of [ ]P. I doubt it can be golfed down much further...

@brhfl didn't know i could do that, thanks

shortC, 16 bytes
f(C*a){W*a++)P'

Note the trailing space at end of code.
Conversions in this program:

C -> char
W -> while(
P -> putchar(

The resulting program looks like this:
f(char *a){while(*a++)putchar(' ');}

How that works:

while(*a++) loops until it reaches the last index of the string a.
putchar(' '); prints a space for each index of a.

Try it online!

Java 8, 24 bytes
s->s.replaceAll("."," ")

Try it here.
Java 7, 49 bytes
String c(String s){return s.replaceAll("."," ");}

Try it here.

Shell utils, 14 12 bytes
tr ' -~' ' '

tr translates characters in the first parameter, into the corresponding one in the second parameter. (space)-~ is a range for space (32) to tilda (126), the first and last printable ASCII characters. They are mapped into a space; tr duplicates the last character in the output list if it is shorter than the input list.

You could shave off a couple of bytes with different quoting styles (\ -~ instead of ' -~') and you could even get away without quoting the first parameter at all if you use a control-character byte.

That brings it down to 9 bytes: tr ␁-~ \  (␁=^A)

Chip, 2 bytes
*f

Try it online!
Chip reads in a byte, does whatever calculations are in the code, and writes a byte. So, for each byte of input, we ignore the input and write 0x20 instead. The empty Chip program would replace each byte of input with a null byte of output.
*    Source element, activates any neighbor elements
 f   Output element for the bit 0x20, when active this bit is set in the output

Transposing the two characters would result in the same thing. I opted to use spaces, since 0x20 requires only one bit to be set. 0x0a requires setting two bits. Code for that could be:
b*d

Powershell, 18 12 bytes
-6 bytes thanks @Julian
$args|%{' '}

Try it online!
Testscript (use LF only mode in your editor):
$f = {
$args|% t*y|%{' '}
}

@(
,(13, "Hello, World!")
,(2, "Hi")
,(45, "   Don't
Forget about
Existing
Whitespace!   ")
,(0, "")
,(13, "             ")
,(1,"
")
) | % {
    $len,$source=$_
    $r = &$f $source
    $l=$r.length
    "$($l-eq$len): $l"
}

Output:
True: 13
True: 2
True: 45
True: 0
True: 13
True: 1

Powershell + Regex, 20 bytes
$args-replace'.',' '

You can go down 6 bytes using splatting ?
Try it online!

Thanks. Three years ago we didn't use splatting. Thanks again.

Ruby -p, 10 bytes
$_=$/*~/$/

Try it online!
Explanation:
$_=          Output equals
   $/        the output separator (defaults to newline)
     *       repeated a number of times equal to
      ~      the index in the input of the first match of
        /$/  the regular expression for "end of line"

Trilangle, 11 bytes
i7#'@"o.:2L

Unfolds to this:
    i
   7 #
  ' @ "
 o . : 2
L . . . .

This has to be the most creative way I've used @ yet: when hit in one direction, it ends the program; when hit in a different direction, it's divided by 2 to get a space.
Roughly equivalent to this C code:
#include <stdio.h>

int main() {
    while (getchar() != EOF) {
        printf(" ");
    }
}

APL, 11 6 bytes
5 bytes saved thanks to @Adám
' '⍴⍨≢

Uses the Dyalog Classical character set.

You can golf this significantly. First, swap the arguments of rho to remove the parentheses:  {' '⍴⍨⍴,⍵}, then use tally rather than rho to remove the comma: {' '⍴⍨≢⍵}, and finally, make it into a train to remove the braces and omega: ' '⍴⍨≢.

@Adám thanks! never seen the tally before

No problem. I'll be happy to teach you more over in the APL chat room.

How is this 5 bytes?

@EriktheOutgolfer fixed, thanks. it counts 6 with the Dyalog char set

PowerShell, 21 bytes
[char[]]"$args"|%{""}

Try it online!
prints newlines.

.....I like it!

@briantist thanks for the TIO link, need to get into the habit of doing them myself.

can't go wrong, it creates the whole post for you. That's why I use it even when the code itself can't run in TIO

Perl 6, 10 bytes
{S:g/./ /}

Basic string substitution.

JavaScript (ES8), 22 bytes
s=>"".padEnd(s.length)

Convex, 2 bytes
,*

Try it online!
Simply takes the length of the input and multiplies by newlines (which are at the bottom of the stack)

Bash, 16 bytes
printf %*s ${#1}

Try it online!
Uses parameter expansion count the length of the argument ${#1}, and then printf to output an empty string space-padded to that same length.

printf %${#1}s is 14 bytes; tr -c '' \  (with input from the standard input stream) is 11

Aceto, 5 bytes
Trivial in Aceto:
p
,'O

Reads a character, pushes a space, prints it, and goes back to the start.

q/kdb+, 14 9 bytes
Solution:
{" "}each

Example:
q){" "}each"Hello, World"
"            "

Explanation:
Returns " " for each character of the input.
Notes:
I've made a shorter version (7 bytes) that does something similar:
{y}'" "

... but you have to prepend the input rather than append:
q)"hello world"{y}'" "
"           "

Using one of the k's, 2 bytes is possible as "", e.g. this ngn/k version.

Perl 5, 6 + 1 = 7 bytes
Uses the -p flag.
y// /c

y/// is the transliteration operator: the first list is translated to the corresponding character in the second list. Without the c, this does nothing, but the c complements the first list, so all characters are transliterated to a space.

T-SQL, 32 bytes
SELECT SPACE(LEN(a+'x')-1)FROM t

Microsoft SQL's LEN function ignores trailing spaces, so this hacky workaround is required.
Input is stored in varchar column a in pre-existing table t, per our input rules.

TI-Basic, 13 bytes
For(I,2,length(Ans
Disp "
End

Loop starts at 2 because an additional newline is printed before Done at the end of the program.

MATL, 3 4 bytes
nqZ"

Try it online!
Today I learnt that MATLAB has a function for creating a string of spaces!
n - count the number of bytes in input string
q - decrement by 1, because the implicit disp at the end adds a newline (so the number of spaces required is string length - 1)
Z" - blanks command: create a string with the specified number of spaces in it
(Implicit output at end, with trailing newline.)

R, 37 23 bytes
gsub("."," ",scan(,""))

Try it online!
14 bytes saved by ngm.

apart from using gsub, strrep exists as well, so strrep(" ",nchar(scan,""))) would work (even though it's longer than @ngm 's suggestion)

@Giuseppe Is this a recent function? I can't believe I'm hearing about it for the first time.

It appears to have been added in 3.3.0. I haven't really found a great use for it; usually the first thing I do when I see a string is to utf8ToInt it and then I can just use rep for mostly the same purpose, and rep has finer control beyond just times, with each, length.out

J, 4 bytes
LF"0

Try it online!
Converts each cell (each character in this case) to the linefeed character. LF is a built-in noun for '\n'. "0 attached to a noun converts it to a verb with the given rank.

Runic Enchantments, 9 bytes
" "il͍*@

Try it online!
Note that spaces and newlines need to be escaped in the input, as input is automatically split otherwise.

Cascade, 14 11 9 8 bytes
? .'
,^\

Try it online!
-1 byte thanks to Jo King realizing it's shorter to just turn into two lines
Since the program never uses the return values of anything other than , and ', and the order spaces are printed in doesn't matter (since they're indistinguishable), ^ can be used backwards: instead of printing a space then recurring, this recurs then prints a space.
Ungolfed, this looks something like:
 @
 ?
 |\
 , \
    ^
   / \
  /   .
 |    \
 |     '
 |

If tabs are legal whitespace alongside spaces and newlines:
Cascade, 7 bytes
? .
,^9

Try it online!
thanks to Jo King.

Note that this uses ? over _ because end of input returns -1, and ? tests for a positive center, but _ only tests for a left not equal to 0.

Gol><>, 5 bytes
iEH~a

Try it online!
Explanation
i      Push 1 char from the input to the stack
 E     If EOF was reached execute next, else skip 1
  H    Output the entire stack as chars and halt
   ~a  Discard the last read char and push 0x0a to the stack

Since Gol><> is actually a 2D language the programm counter loops back to the other side when it hits a border.
This is used to loop back to the beginning after the discard & 0x0a push step.

Labyrinth, 6 bytes
 ,
\"@

Try it online!
A character input command, a newline-printing command, a halt command, and a three-way junction for branching. I don't think we can do better than that. (A conditional halt without a three-way junction should involve division by zero, which gets unnecessarily verbose)
    Start at the first valid command
,   Take a character input (-1 on EOF)
"   A no-op at 3-way junction: turn left if negative, turn right if positive
    (we can assume the input string consists of printable ASCII, which is > 0)

\   If positive: print a newline, turn backwards
"   3-way junction: top > 0, so turn right (which is reflected to left by a wall)
,   Repeat from the start of the program until it hits EOF

@   If EOF, halt

GolfScript, 3 bytes
,n*

Try it online!
pretty self explanatory, and I don't think there is a way to make it smaller unless there is some really weird thing with % or /.

It's not “self-explanatory” for those who don't know GolfScript…

@xigoi well, it is as far as golfscript programs go. The comma gets the length of the input, the n is a newline, and the * repeats the string.

K (ngn/k), 14 13 bytes
{x,(1+#x)#""}

Try it online!
-1 byte thanks to ngn!
Dead simple.
Explanations:
{x,(1+#x)#""}    Main function. Takes x as input
 x,              x concat with
          ""     An empty string (Implicit whitespace)
         #       Duplicate with the amount of
   (  #x)        Length of x
    1+           + 1 times

reshaping a space " " is the same as reshaping the empty string ""

str, 1 byte
s

Try it online!
Since str manipulates streams byte-by-byte, this outputs 1 space for each input character.

makina, 28 bytes
v>>>n0;
>wPH
vO*OL
ti ^C
> ;

Uses a few clever tricks, like using the space literal to stop the input instruction. Sadly, it's pretty difficult to explain makina, but you can look at the esolangs.org page if you want to figure out how this program works.

Japt -m, 1 byte
S

Try it
S     :Implicit map of each character in input string
S     :Literal space

Less Trivial (w/o flag), 3 bytes
r.S

Try it
r.S     :Implicit input of string
r       :Replace
 .      :RegEx /./g
  S     :With space

Even Less Trivial, 6 bytes
©SißUÅ

Try it
©SißUÅ     :Implicit input of string U
©          :Logical AND with
 Si        :Space prepended with
   ß       :  Recursive call with argument
    UÅ     :    U with first character removed

SmileBASIC 3, 22 bytes
Asks for a string from the console as input, then prints length spaces. PRINT (or ? here) adds a trailing newline by default, so we use the ; to disable it.
LINPUT A$?" "*LEN(A$);

This technically isn't valid since LINPUT doesn't accept newlines, so you'll have to define a function (also ; isn't required because PRINT doesn't really output newlines)

Mathematica, 30 bytes
Row@Table[" ",StringLength@#]&

Lua, 25 bytes
for i=1,#...do
print()end

Same length as:
io.write((' '):rep(#...))

Try it online!

Test output length here

tcl, 19
regsub -all . $s \

demo
To test it, click "Run it" button and then select the white space on the white bottom area. A better test is to add a space and a letter before the ] as I describe:
puts [regsub -all . $s \  x]
                        ^^ Two spaces here

and it will output the count of characters of each string exactly equal to the ones on the question.

Rust, 23 bytes
|s|" ".repeat(s.len());

First time using Rust so not 100% sure I've got everything correct, let me know if I need to change anything. I couldn't work out how to test this, as I'm still new to it, but judging from the documentation it should work. Also any improvements are more than welcome!

Hi fellow newbie! I tried to rig up enough surrounding code to make a Try It Online link for this answer (and any similar Rust entries). I did get somewhere but I needed to add a type declaration at the cost of an extra 5 bytes (for a total of 28 bytes) to get it to compile.

ZX80 (4K ROM version with sanity check)
~58 bytes (listing)
 1 INPUT A$
 2 IF A$="" THEN GO TO 1
 3 PRINT " ";
 4 LET A$=TL$(A$)
 5 IF A$="" THEN STOP
 6 GO TO 3

Line 2 can be removed to save RAMs. However, if an empty string is entered without line 2 then it will PRINT one space.

It is now later.

Brain-Flak, 28 bytes
{{}<>((()()()()()){})<>}<>{}

Try it online!
{{}                    }     # For every input character...
     ((()()()()()){})        #    Push 10...
   <>                <>      #    on the other stack
                        <>   # Switch to the stack with all of the newlines
                          {} # Pop a newline because the interpreter prints a newline :(

pb - 17 bytes
^w[B!0]{>}<vb[32]

Goes to the last character of the input and puts a space on the canvas cell representing it. Because output in pb is 2D, the empty cells before it are automatically filled in with spaces when it's outputted.

x64 ASSEMBLY (linux nasm) - 131 bytes
mov r8, [rsp+16]
mov rdi, 1
mov rdx, 1
mov rax, 1
mov rsi,n
l:syscall
inc r8
cmp byte [r8],0x00
jnz l
mov rax,60
syscall
n: db " "

build and run with:
nasm -felf64 invisible_golfed.asm
ld invisible_golfed.asm
./a.out

This will give the warning
ld: warning: cannot find entry symbol _start; defaulting to 00000000000400080

warning free version below
without warnings - 152
global _start
_start:mov r8, [rsp+16]
mov rdi, 1
mov rdx, 1
mov rax, 1
mov rsi,n
l:syscall
inc r8
cmp byte [r8],0x00
jnz l
mov rax,60
syscall
n: db " "

When I give the program "When I give the program" on STDIN, it only prints a single space. I suggest your read the I/O defaults and revise your answer. Essentially, revise your code to take input from STDIN.

My bad I have it reading from the command line. I'll fix that tomorow when I get the chance.

Your byte-counting is not correct. With assembly language, we count th bytes of the machine code that is generated, not the characters in the instruction mnemonics. Beyond that problem, there's lots of room for optimization here. Save several bytes by changing instructions of the form MOV Rxx, x to MOV Exx, x, where x is an immediate value <= 32 bits, taking advantage of the fact that the upper 32-bits of a 64-bit register are implicitly cleared. I also don't know why you define n separately, instead of embedding it into the instruction: MOV ESI, ' '. That gets me down to 48 bytes.

You can save even more by changing all but the first instruction in the MOV reg, 1 sequence to a reg-reg move, which has a much shorter encoding: mov eax, 1+mov edx, eax+mov edi, eax. That's only 36 bytes.

C, 57 33 30 bytes
-3 thanks to Tas.
f(int*a){while(*a++)puts("");}

Try it online!

PowerShell, 18 bytes
' '*"$args".Length

Try it online!

Python, 23 bytes
print(''*len(input()))

First time

Assuming where input comes from is usually frowned upon here. You need to wrap the code in a program/method or ask the user for input.

@TheLethalCoder fixed!

You don't need the space between , and ' in your second version. However, that second version isn't a full program - you need a print call, and you need to fix your str.replace call (not enough arguments).

Lua, 17 Bytes
s=s:gsub("."," ")
Simple regular expression substitution, replaces any character found with a space.

Befunge-98 (PyFunge), 5 bytes
#@~a,

Try it online!
For every character in the input (#@~), this prints a new line (a,).

Z80Golf, 9 bytes
00000000: d5cd 0380 3001 763e 20                   ....0.v>

Try it online!
Disassembly:
  push de     ; push $0000
  call $8003  ; getchar(A)
  jr nc, k    ; jump if not EOF
  halt
k:ld a, ' '   ; replace A with space
              ; memory from $000a through $7fff is $00=NOP...
              ; PC reaches $8000=putchar(A) and RETs to pushed address.

(If you remove the last two bytes, this is a cat program.)

Julia 0.6, 15 bytes
s->" "^endof(s)

Try it online!
^ applied to strings is the repetition operator, and endof gives the last index of the string, which is equal to the length of the string (since Julia indexing is 1-based).

dc, 12 bytes
Z256r^25.5/P

Try it online!
Takes input from the stack, outputs newlines to stdin.
I know there's two dc answers here already, but this one uses a different approach, with math! Plus it's 6 bytes shorter, so I guess that's all right.
Explanation
One of dc's three explicit printing commands is P, which takes a number and outputs it as a base 256 (technically base UCHAR_MAX+1, works on my machine) byte stream. So I need to feed it the number (where n is the length of the given string, and 10 is the codepoint of the linefeed character):
   10*256^(n-1) + 10*256^(n-2) + ... + 10
 = 10 * (256^(n-1) + 256^(n-2) + ... + 1)   (factoring out 10)
 = 10 * (256^n - 1) / (256 - 1)             (geometric series formula)
 = (256^n - 1) / 25.5                       (combining constants)
~= (256^n) / 25.5                           (because dc's default precision is 0)

The code is a straightforward calculation of this number, followed by P.

Argh, doesn't handle the empty string (P outputs a NUL when it pops a 0). I guess I could say it's outputting a null-terminated string...seems like a stretch though.

Also, it's only on TIO that you can tell. On my machine a NUL gets eaten silently so it works. I still feel badly about it.

Octave / Matlab, 25 23 bytes
@(x)repmat(' ',size(x))

Saved 2 bytes thanks to Giuseppe
Try it online!

I think the f= is unnecessary; anonymous functions / function handles are perfectly acceptable on PPCG.

You can also include a link to Try it online! for Octave so others can test your answer.

Java (JDK), 84 bytes
static String m(String n){int i=0;String d="";while(i++<n.length())d+=" ";return d;}

Try it online!

Updated Sir @JoKing.

This does not address my other concerns, i.e. initialising d and reusing the function. Also, wouldn't it be shorter to use an anonymous lambda?

Your suggestions are so useful, Thanks @JoKing

Brain-Flak, 28 bytes
{}{{}<>((()()()()()){})<>}<>

Try it online!
{}                  pop one input character (because Brain-Flak always outputs a trailing newline
{                   for each input character
  {}                pop that character
  <>                switch to other stack
  ((()()()()()){})  push 10 (newline)
  <>                back to input stack
}
<>                  switch to other stack. This is printed implicitly when the program ends

Keg,-lp -ir, 3 bytes
( ,

Try it online!
This takes input as characters and prints a space for each character
The -lp flag makes the length() function take input if the stack is empty and the -ir  flag ensures that the implicit input is as characters.

Wren, 22 bytes
Multiply the space by the length of the string.
Fn.new{|a|" "*a.count}

Try it online!

x86-16 ASM, IBM PC DOS, 11 bytes
Binary:
00000000: 8a0e 8000 49b8 200a cd10 c3              ....I. ....

Unassembled:
D1 EE       SHR  SI, 1          ; SI to 80H (SI intialized at 100H)
AC          LODSB               ; load string length into AL
91          XCHG AX, CX         ; put input string length into CX
49          DEC  CX             ; remove leading whitespace from length
AC          LODSB               ; load whitespace delimiter into AL
B4 0A       MOV  AH, 0AH        ; BIOS "write character CX number of times" function
CD 10       INT  10H            ; call BIOS, display to console
C3          RET                 ; return to DOS

Explanation:
Input is via command line, though all that's important is the length.  Command line input length is always stored at memory address DS:0080H in DOS, so put that into CX.  DOS includes the space between the executable name and the command line args string in this number.
For example: in FOO.COM Hello, length is 6 and command line string is " Hello", or calling as FOO.COM/Hello, command line string is "/Hello" (Note: those are the the only valid characters for the character immediately after the executable name).  This first character (will be a space when called normally) is what is displayed as the "invisible text" for output.  This builds in a handy little "debug mode" where you can use a slash instead of a space to actually be able to test your output is the right length.
Then, use the IBM PC BIOS's INT 10H "Write character only at cursor position" (0AH) function that writes the same character CX number of times.
Example Output:
Admittedly, displaying 13 chars of whitespace is not very interesting in a screenshot.  However, by using a slash instead of a space ("debug mode") you can actually see that you are displaying the right number of chars.

naz, 40 bytes
2a2x1v1x1f1r3x1v2e0m4a8m1o1f0x1x2f0a0x1f

Works for any input string terminated with the control character STX (U+0002).
Explanation (with 0x commands removed)
2a2x1v                 # Set variable 1 equal to 2
1x1f1r3x1v2e           # Function 1
                       # Read a byte of input
                       # Jump to function 2 if it equals variable 1
            0m4a8m1o1f # Otherwise, output a space and jump back to the start of function 1
1x2f0a                 # Function 2
                       # Add 0 to the register
1f                     # Call function 1

GolfScript, 5 bytes
Port of CJam answer.
," "*

Try it online!

Ahead, 12 bytes
S0d3-' \k:W@

Try it online!

Python 3, 23 bytes
print(' '*len(input()))

Try it online!

Java, 24 bytes
s->s.replaceAll("."," ")

TIO

Flurry -bnb, 42 bytes
[]{(){}{}}[]{({})}<((({<({}){}>})){}){}{}>

Try it online!
Run example (using Haskell interpreter)
$ printf "Hello World!" | ./flurry -bnb a.flr

$ printf "Hello World!" | ./flurry -bnb a.flr | wc -c
12

It takes 24 bytes just to construct a single space (32): <((({<({}){}>})){}){}{}>. Even worse is that it takes 2 more byets to construct a single newline (10): (<><<>()>)<(<({}){}>{}){}>...
The algorithm is: empty the stack, preserving the value of stack height, and then push space that many times.
main = height pop-I height push-I 32

// Return self, popping and discarding one item from stack
pop-I = \x. K x pop
// (height pop-I height) returns original stack height with
// the stack emptied as a side effect

// Return self, pushing itself to the stack once
push-I = \x. push x

32 = 2**2 * 2**2 * 2
= <(2 2)(2 2)2>
= <(push ((push (push 2)) pop)) pop pop>

Rockstar, 27 bytes
listen to S
cut S
say " "*S

Try it here (Code will need to be pasted in)
Replace the last line with the below to wrap the output in single quotes.
say "'"+" "*S+"'"

Husk, 4 bytes
R' L

Try it online! (Note: prints xs instead of spaces so that the output is visible; change the x to   to [not] see the real version)

Nim, 38 bytes
for _ in stdin.readAll:stdout.write" "

Try it online!
Since Nim is style-insensitive, something like this also works:
fOr _ iN sTdIn.rEaDaLl:sTdOuT.wRiTe" "

Try it online!

05AB1E, 3 bytes
gð×

Try it online!
gð×  # full program
 ð   # a space...
  ×  # repeated...
g    # length of input...
  ×  # times

...nice, but quite similar to this...

Vyxal, 2 bytes
LI

Try it Online!
Vyxal S, 2 bytes
v¤

Try it Online!
If we want to port the Jelly answer, then:
Vyxal rs, 3 bytes
fð•

Try it Online!

C (gcc), 50 36 bytes
Totally pays off that printf doesn't automatically print a newline.
36 bytes by ceilingcat
f(char*n){for(;printf(" "+!*n++););}

Nibbles, 2.5 bytes (5 nibbles)
.$' '

A function that returns a string of spaces the same length as its argument.
(This won't work as a full program, since Nibbles will write a newline at the end of its output).
.                   # map over
 $                  # characters of the argument
  ' '               # returning a space for each

Obviously the output is invisible, but we can call this function from within a program that wraps the output into quotes to see the output string:
;~                  # save this function:
  .$' '             # <convert to invisible text>
         :'"'$      # prepend saved function results with a quote
        :     '"'   # and append that with another quote

Nibbles, 3.5 bytes (7 nibbles)
>>.$' '

Full program.
We can't stop Nibbles from writing the trailing newline at the end of its output, so we shorten the invisible string by one character.
  .                 # map over
   $                # characters of the argument
    ' '             # returning a space for each
>>                  # and then remove the first character

Python 3, 36 bytes
lambda x:re.sub('.',' ',x)
import re

Try it online!

Go, 66 bytes
import."strings"
func f(s string)string{return Repeat(" ",len(s))}

Attempt This Online!
As far as I'm aware, you can't multiply strings and numbers to repeat a string in Go - you have to use strings.Repeat.

(,) 40 34 Chars or \$34\log_{256}(3)\approx6.74\$ Bytes
(,,,()()()()()()()()()(),((()())))

Or, printing spaces (54 Chars or 10.7 Bytes):
((),()()()()()()()())(,,,(())(())(())(()),((()())),())

TI-BASIC, 27 bytes
Input Str1
For(X,1,length(Str1
Disp "
End

I love TI-84 because it completes my parentheses and quotes for me.
At the same time, it is quite annoying indeed how there is no string repeat (as far as I know). Even more annoying is that (as far as I know) all input is int not str and any text passed will result in a single newline. I hope this is still valid despite that. That was my bad. I was using an int variable.
Bytecount on TI-BASIC is kind of complex, the best way that I know of is going to TI Connect [CE] and looking for your program there.
Explained:
Input Str1                Ask for input and store in string variable

  length(Str1             Length of Str1
For(X,1,...               Loop through following code that many times
Disp "                    Display a blank string (with newline)
End                       End loop, go back to the For.

Test cases:
Typing on a TI-84 Plus CE is hard.
In these examples "-" is displayed instead of newline so you don't have to count.

REXX 27 Bytes
say left("",length(arg(1)))

Powershell, 22 Bytes
' '*(Read-Host).length

Not sure if Read-Host counts for input but " "*"$args".length is shorter anyway. Also there is not len property. That should be printing nulls.

Length property and Len are same

"hello".Len is null on my system because that is a non-existent property where as "hello".Length returns 5. If that works for you then you have an alias or extent that I, and most, do not have.

Ok...That explains it

Clojurescript, 27 bytes
#(apply str(map(fn[]" ")%))

Because it's based on js, clojurescript doesn't care about arity errors. That saves one byte over the clojure eqivalent.

Check, 6 bytes
," "*o

Pass the input by the command-line arguments as a list of code points, i.e. [72,101,108,108,111,44,32,87,111,114,108,100,33].
Explanation:

, gets the length of the input.
" " pushes an array containing 32 (for space).
* repeats that array as many times as the length of the input.
o displays the result as a list of characters.

Bash + Coreutils, 11 Bytes
tr -c \  \

Windows batch, 115 bytes
@set i=%~1
@set p=0
@set/ac=-1
:N
@call set t=%%i:~%p%,1%%
@set/ac+=1
@set/ap+=1
@if "%t%" NEQ "" @goto N
@echo %c%

Re-used code from my answer in Is the checkbox not not unchecked?

Ruby, 12 11+1 = 13 12 bytes
Uses the -p flag. -1 byte from Martin Ender.
gsub /./,$/

Try it online!

TXR Lisp, 22 19 bytes:
(op regsub #/./" ")

Previously:
(op mapcar(ret[" "0]))

That is a function to which we can pass a string:
REPL:
1> (op regsub #/./" ")
#<interpreted fun: lambda #:rest-0164>
2> [*1 "abc"]
"   "

"   "

J, 6 bytes
' '#~#

Try it online!
Explanation
' '#~#
   #~    repeat
' '      spaces
     #   for length of input

4 bytes ''"0 outputs n newlines.

@FrownyFrog You should make your own answer, it's quite different from mine

Common Lisp, 32 bytes
(format t"~va"(length(read))#\ )

Try it online!

Carrot, 12 bytes
#^//()/gS" "

Try it online! (append a ^@^v@ after the code to see the spaces bounded between @s)
Explanation
#^            Set the stack-string to be equal to the input
/             Get matches of this regex
 /()/g         any position (not character) in the string (shorter than /\b|\B/ by 3 bytes)
              If the length of the string is 3, this returns a 4-element array
               consisting of empty strings
S" "          Join on spaces, so the example 4-element array will result in 3 spaces

The space can even be replaced with a literal newline or tab for the same bytecount.

dc, 18 bytes
?Zd[9P1-d0<r]sr0<r

Try it online!

Ly, 9 bytes
iy[' o,];

Try it online!
Explanation:
iy[' o,];

iy        # push length of input
  [    ]  # while loop
   ' o    # output a space
      ,   # decrement input length
        ; # terminate (avoids implicit output)

RProgN 2, 3 bytes
L•*

Uncreative solution is uncreative.
Just gets the length of the input, and multiplies •, which is predefined to be a space, by it.
Try it online!

Jq 1.5, 69 68 66 64  bytes
def L:length;$x|if L<1then empty elif L<2then""else L-1|.*" "end

This is longer then usual to compensate for newline jq normally emits and the odd behavior of * with N<2
Sample runs:
$ jq -Mrn --arg x 'Hello, World!' 'def L:length;$x|if L<1then empty elif L<2then""else L-1|.*" "end'

$ jq -Mrn --arg x 'Hello, World!' 'def L:length;$x|if L<1then empty elif L<2then""else L-1|.*" "end' | wc -c
      13
$ echo -n 'def L:length;$x|if L<1then empty elif L<2then""else L-1|.*" "end' | wc -c
      64

Shout out to Jonathan Frech for finding 3 superfluous spaces!

I do not know jq, but as then""else is syntactically valid, it seems like you could also omit the space in " " end.

As variables probably cannot begin with a digit, the spaces in <1 then and <2 then may also be superfluous.

Vim, 4 bytes
VGr

(a trailing space)

Yabasic, 37 bytes
Takes input, and outputs as many new lines as the length of the input
Line Input""s$
For i=1TO Len(s$)?Next

Try it online!

C# .NET, 84 bytes
class P{static void Main(string[]a){System.Console.Write("".PadLeft(a[0].Length));}}

Try Online

Kotlin, 20 bytes
{" ".repeat(length)}

{" ".repeat           // repeat space
           (length)}  // length of input

Try it online!

Vyxal, 3 bytes
Lð*

Try it Online!
Command-line usage:
python3 Vyxal.py file_name "" input_string

Explained
L    # Push the length of the implicit input
  ð  # Push a space character
   * # Multiply that space by the length and output.

Forth (gforth), 9 bytes
typewhite

Try it online!
It is a gforth built-in. A string in gforth is commonly represented as addr length, and typewhite consumes addr length and prints length spaces.

forth golfing language confirmed?!

Add++, 21 bytes
D,f,@@,bL*
$f>" ">?
o

Try it online!

Duocentehexaquinquagesimal, 7 bytes
1Â×^c¤E

Try it online!

Zsh, 12 bytes
<<<${1//?/ }

Try it online!

<<<: print
${1}: the input,
///: replacing
?: any character
 : with a space

Factor, 20 bytes
[ [ drop bl ] each ]

Try it online!
For each character in the input string, drop it from the data stack and output a space.

Fig, \$4\log_{256}(96)\approx\$ 3.292 bytes
;M/

Try it online!
Note the space at the end.
;M/<space>
;M         # Replace all in the input
  /<space> # With a space
;          # Print without newline

Are you sure this doesn't output a trailing newline?  This is what it looks like when I run it... (I only checked because the same annoying thing was happening for my own attempt in Nibbles...)

@DominicvanEssen ah yes, it does output with a newline. I missed that part of the spec. will update

If you can use the same code in the context of a function, maybe the returned string would be Ok...

@DominicvanEssen all the other golflang answers seem to do that too...

Pascal, 82 B
This program merely requires a processor complying to ISO standard 7185 “Pascal”.
Since it is not guaranteed that writeLn produces exactly one character (on some platforms the line separator is CR+LF), we’ll have to use write(' '):
program p(input,output);begin while not EOF do begin write(' ');get(input)end end.

If input was simply a string value, when an ISO standard 10206 “Extended Pascal” processor is used the following is the shortest solution (≥ 24 B):
writeStr(outputStringVariable, '':length(inputMyString))

The :someNonNegativeIntegerValue after the empty string '' will (left) pad the given argument to the specified width using space characters (' ').
A complete demonstration:
program paddingDemo(output); begin write('':length('Hello, World!')) end.

Thunno, \$ 6 \log_{256}(96) \approx \$ 4.94 bytes
L1-A_*

Attempt This Online!
Note: A\ will also work instead of A_ if you want newlines rather than spaces.
Explanation
L1-A_*  # Implicit input
L       # Length
 1-     # Minus one
     *  # Multiplied by
   A_   # A space
        # Implicit print
        # with a newline

Thunno 2, 3 bytes
l⁻ṣ

Attempt This Online!
Explanation
l⁻ṣ  # Implicit input
l    # Length
 ⁻   # Decrement
  ṣ  # Spaces
     # Implicit output with newline

authors: набиячлэвэлиь

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/