Centering and vertically-aligning two side-by-side listings
This may well not be the most minimal solution but it works, I think.
\documentclass{article}
\usepackage{listings}
\usepackage{caption}
\usepackage{adjustbox}
\begin{document}
\begin{figure}[ht]
\centering
\begin{adjustbox}{valign=t,minipage=0.45\linewidth}
\centering
\begin{tabular}{c}
\begin{lstlisting}
here is some code
that is not as long
as the other code
\end{lstlisting}
\end{tabular}
\end{adjustbox}
\begin{adjustbox}{valign=t,minipage=0.45\linewidth}
\centering
\begin{tabular}{c}
\begin{lstlisting}
here is some code
that is a bit longer
than the other code
so I would like the
two listings to be
vertically aligned
at the top
\end{lstlisting}
\end{tabular}
\end{adjustbox}
\caption{test}
\end{figure}
\end{document}