How to recreate \newenvironment and \newcommand with \NewDocumentEnvironment and \NewDocumentCommand in LaTeX3

I don't see the point why you would want to tokenize the arguments, just to pass them on. Instead, just curry the \NewDocumentCommand.

\documentclass{article}

\usepackage{xparse}

\newcommand\mycommand[1]{\expandafter\NewDocumentCommand\csname#1\endcsname}
\newcommand\myenvironment{\NewDocumentEnvironment}

\begin{document}

\mycommand{hello}{}{world}

\hello

\myenvironment{foo}{m}{
  \typeout{#1}
}{}

\begin{foo}{abc}

\end{foo}

\end{document}

Avoid doing general definitions inside document. And remember to issue \ExplSyntaxOff when you're done with the code part.

You could make \NewDocumentCommand to accept a string instead of a control sequence. The question is: why? It just obfuscates code, generally speaking.

Anyway, \exp_args:Nc is the construct to use. It tells LaTeX to build a control sequence from the braced argument following the next token and then it disappears. It's the same, in “oldstyle” TeX programming as

\expandafter\token\csname string\endcsname

Note also that your \myenvironment has an optional final argument, so it should be given in brackets [] rather than in braces {}.

\documentclass[a4paper]{article}

\usepackage{expl3}
\usepackage{xparse}

\ExplSyntaxOn

\NewDocumentCommand{\mycommand}{m +m +m}
 {
  \exp_args:Nc \NewDocumentCommand{#1}{#2}{#3}
 }

\mycommand{myenvironment}{m +m +m +O{}}
 {
  \NewDocumentEnvironment{#1}{#2}{#3}{#4}
 }

\ExplSyntaxOff

\myenvironment{foo}{m}
 {%
  \typeout{#1}%
 }

\mycommand{baz}{m}{X#1X}

\begin{document}

\baz{Y}

\begin{foo}{abc}
Something inside
\end{foo}

\end{document}

The \mycommand macro should be defined as

\NewDocumentCommand{\mycommand}{mm+m} {%
  \expandafter\NewDocumentCommand\csname #1\endcsname{#2}{#3}%
}

since the #1 must become the argument name, so the typical \expandafter\NewDocumentCommand\csname #1\endcsname.

The 3rd. argument 'must' be +m in order to allow for the definition code of \foo, which is more likely to contain just more than one paragraph.

The same is true for the 3rd and 4th argument of \myenvironment.

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xparse}


\begin{document}

\NewDocumentCommand{\mycommand}{mm+m} {%
  \expandafter\NewDocumentCommand\csname #1\endcsname{#2}{#3}%
}

\mycommand{myenvironment}{mm+m+O{}} {%
  \NewDocumentEnvironment{#1}{#2}{#3}{#4}
}

\myenvironment{foo}{m}{%
  \typeout{#1}
}{}

\begin{foo}{abc}

\end{foo}

\mycommand{foobar}{om}{%
  \IfValueT{#1}{Yes, there is an opt. argument: #1}

  Mandatory Argument: #2

}

\foobar{Hello World}

\foobar[And now for something completely different]{Hello World}

\end{document}

enter image description here