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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: Writng a transpiler – What language/runtime should I target?

1 点作者 prmph大约 1 年前
I&#x27;m wanting to design a language (similar to JS&#x2F;Ocaml&#x2F;Rust, but which fixes a lot of gripes I have about these), and write a transpiler for it. I am aiming for a transpiler because I just want to innovate in syntax and semantics, not the implementation of those on an actual machine.<p>*What target language and&#x2F;or runtime would you recommend?*<p>With JS there is very little learning curve for me, but I have come to really hate that ecosystem, and I need true concurrency. Ocaml seems elegant, but the language has weird corners, and the tooling is atrocious. Rust seems too unnecessarily dense and lacking cohesion and focus. Other options are wasm, erlang, .net.<p><i>BTW, below are some features I am designing for:</i><p>- Mostly but not purely functional: Everything is an expression; Pattern matching; Immutability; Result sum type instead of exceptions, etc.<p>- Functions and types are first class, just like values. No type inference, other than to assume that the type of literal values are themselves as a unit type. For example, x = 2 means just that; there is no assumption that x is a number, or x is a positive integer, etc. So if a function is defined that returns 2, then the return type of the function is not a number, but the unit type [2]. Such unit types can be determined to satisfy or inhabit&#x2F;satisfy one or more other types.<p>- Reactivity is built-in at the language level. All mutable state (variables, etc) can be observed and reacted to automatically by the rest of the app.<p>- Support for use of JSX to express composable function calls built-in (no dependency on React). This is naturally relevant to front-end UIs, but useful for other things as well.<p>- Syntax can be expressed in any parser-less format: JSX, JSON, XML, Yaml, Toml, and more traditional statement formats that have a simple transformation to&#x2F;from these formats, with automatic translation between these formats provided by binary and&#x2F;or language server.<p>- Avoidance of code coloring problems.<p>- Localizable keywords, with automatic traslation provided by binary and&#x2F;or language server.<p>- Two kinds of files: _Modules_ (Exports only pure&#x2F;impure functions, constants, and types; No side effects at the module level; Can only import from other modules), and _Activities_ (For doing stuff; May contain invocations, functions, constants, types, etc, but does not export anything).<p>- Packages are modules shared on the cloud repository. All packages are namespaced. Automatic async lazy imports supported, with pure dependency injection

2 条评论

sargstuff大约 1 年前
Alternate interpretation of topic:<p>On the strictly theory side, changing c source code to fortran source code in an automated&#x2F;direct 1:1 transform would involve using bnf&#x2F;ebnf definition of c language and defining how that corresponds to the equivalent enbf&#x2F;ebnf definition of fortran or parser combinator[3].<p>Fortran language bindings to be able to use C inside of a fortran program bit easier to manage.<p>BFNC can generate a compiler from bnf&#x2F;ebnf definition.[1]<p>So, mess around with c as subset of python till get bnf&#x2F;ebnf grammar that corresponds to bnf&#x2F;enbf fortran. Convert the aforementioned C subset to fortran program into ebnf&#x2F;bnf format. use bnfc[1][2] to create a compilter that will transform c source code into fortran source code.<p>----<p>compiling vs. transpiling: <a href="https:&#x2F;&#x2F;crystallize.com&#x2F;answers&#x2F;tech-dev&#x2F;compiling-vs-transpiling" rel="nofollow">https:&#x2F;&#x2F;crystallize.com&#x2F;answers&#x2F;tech-dev&#x2F;compiling-vs-transp...</a><p>[1] : <a href="https:&#x2F;&#x2F;bnfc.digitalgrammars.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bnfc.digitalgrammars.com&#x2F;</a><p>[2] : <a href="https:&#x2F;&#x2F;citeseerx.ist.psu.edu&#x2F;document?repid=rep1&amp;type=pdf&amp;doi=171c79e76f9056675496a69f622917bd0c623983" rel="nofollow">https:&#x2F;&#x2F;citeseerx.ist.psu.edu&#x2F;document?repid=rep1&amp;type=pdf&amp;d...</a><p>[3] : <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Parser_combinator" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Parser_combinator</a>
pgen大约 1 年前
C?
评论 #39468243 未加载
评论 #39468054 未加载
评论 #39468671 未加载