TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How difficult is to rewrite rust compiler syntax to Python

1 点作者 nothrowaways4 个月前
Each new programming language comes with its own syntax and definitions<p>For example, def, fn, func,...<p>How hard is it to convert rust syntax to python so that programmers can write rust programs with python sytax?

3 条评论

gus_massa4 个月前
It depends a lot on how idiomaic you wan to the &quot;python&quot; code to look.<p>I guess you wish that a person can see it and think it&#x27;s python with a few surprising &amp;mut here and there. It will be a hard decition to select what to add to &quot;python&quot; to be able to write (almost) any program in rust.<p>Another hard decition is what python synax to remove. Do you want to support list comprehension?<p>A few years ago, Racket was rewriten to use Chez Scheme as a &quot;backend&quot;. It took 4 years (or more), and Matthew is extremly good programing. It was harder becuse the objective was to get a new version that is bug compatible and as fast as the old one. It was easier because a lot of the hard decitions were avoided becuse the programs in new version should be identical to the programs in the old one.<p>So my guess is that you need like a year.<p>(Are you planing to port the standard library? I don&#x27;t know enough about python and rust to show an example, but sometimes in one language the name of the functions or the order of the parameters is different.)
stop504 个月前
First you need a parser, since the rust parser can&#x27;t parse everything that is valid in python and it excludes whitespace.<p>After it has been parsed in an valid manner, simple scripts can be converted to rust. types that require lifetimes, pointers and generics will be much harder.
评论 #42675130 未加载
brudgers4 个月前
Getting started is the only way to find out how hard it is.<p>The key decision is what would be good enough.<p>Good luck.