TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Javascript code generation library?

3 pointsby adatta02over 14 years ago
I'm looking for a Javascript code generation library that is written in Javascript. I've used CodeModel in Java - https://codemodel.dev.java.net/ - and was hoping to find something similar (or better) for Javascript.<p>What I'm trying to do is create a visual programming environment where a user would drag and drop blocks to generate Javascript code. If anyone has used the LEGO Mindstorm IDE from a few years ago, I want to basically duplicate that but for Javascript.<p>I tried Googl'ing but the results are completely overwhelmed by SEO spam and things to generate buttons.<p>Edit: added an explanation of what I'm trying to accomplish.

2 comments

tswicegoodover 14 years ago
For those of us not familiar with CodeModel it would be more useful if we had an idea of what you're trying to do?<p>Are you looking to generate code because you want to write a DSL (or full language) and have it spit out valid JavaScript? Jison (<a href="http://zaach.github.com/jison/" rel="nofollow">http://zaach.github.com/jison/</a>) does that.<p>If you're looking for code generation just because you're coming from Java and think you need to generate code because everything is so complex and that simple tasks require 5+ classes, each implementing more interfaces than that, and… well, you're in luck. JavaScript is <i>much</i> simpler than that. Welcome to modern languages. :-)
_deliriumover 14 years ago
Ometa/JS (<a href="http://www.tinlizzie.org/ometa/" rel="nofollow">http://www.tinlizzie.org/ometa/</a>) can be used for code generation, though it's fairly general rather than tailored specifically to that. It's a generalization of a PEG parser that can go the other way as well: it can match on sequences of characters to build up an AST, and can also match sequences of Javascript objects (like nested lists representing an AST) to convert them to other things. It doesn't have the big library of built-in expression types that CodeModel looks like it has, though (JForLoop, JConditional, etc.).