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: How can I, as a web developer, learn about compilers?

3 pointsby zwaragabout 4 years ago
I have reached a point where I would like to understand more about compilers. The reason for this is that I am working on a JS framework that has become very complex, and I need to find a way to simplify migration of versions for my colleagues.<p>When my team makes an update, all the teams (which I now call customers) that use our framework have to follow. They might have to look at what functions become deprecated, adapt to new signatures and so on.<p>So assuming a function is renamed, it should be possible to rename this function automatically at the customers&#x27; codebase with a program that builds and AST, finds the function and replaces it with the new function name.<p>Also, we want to make sure, that our customers do not write smelly code. A trivial example of this would be, to no longer declare variables via &quot;var&quot; but only via &quot;let&quot; or &quot;const&quot;. Of course, a tool like ESLint is perfect for this and I would like to write my own rules for ESLint.<p>My question now is, how do I, as a web developer, learn this domain.<p>From what I&#x27;ve found, most books about compiler and AST are directed to low level languages like C or higher ones like Java.<p>But I&#x27;m looking for something more directed to web programming. Just to summeraize, my goals are: * Write migration programs that help customer update theyr code automatically. Where no automatic migration is possible, possibly leave a comment and point out that manual adjustments are necessary. * Develop a &quot;DevTool&quot; that helps our customers to follow best practices and not write smelly code.<p>I&#x27;m curious to what you guys think would be a good way to enter this domain. Just to clarify. I&#x27;m not against learning this, by going the - what might be considered - proper way and learning how to write a lowlevel compiler for B to learn the basics. And then move on to more specific compilers for higher languages. I just wanted to see if this achivable in a way, that stays closer to the web domain.

3 comments

speedgooseabout 4 years ago
Hi,<p>Indeed it&#x27;s difficult to find documentation and books between the low level stuff like the old flex&#x2F;bison and high level tools like Xtext or even MPS.<p>For your use case I think you could simply write a set of eslint rules. This short document is a good start <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;sindresorhus&#x2F;1656c46f23545deff8cc713649dcff26" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;sindresorhus&#x2F;1656c46f23545deff8cc713...</a><p><a href="https:&#x2F;&#x2F;astexplorer.net" rel="nofollow">https:&#x2F;&#x2F;astexplorer.net</a> is recommended and a good resource.
评论 #26967543 未加载
评论 #26967402 未加载
austincheneyabout 4 years ago
A compiler transforms instructions from one language to another. You are wanting to produce an interpreter which is a different beast.<p>Neither of those will satisfy the problems you described. The problem, as you described and which is extremely common in large organizations, is a failure to scale. This is largely due to people making a series of really bad decisions independently and once the pieces are put together those pieces don’t play well together.<p>The solution to that problem is eliminating complexity. Complexity is easy just as simplicity isn’t. That means setting rules that will make people unhappy. They will call you draconian and do everything they can to spit on you because complexity elimination exposes all the things people do to find comfort in that which they find challenging. This needs to be done via automation as much as possible so prevent bias and really hammer in that nail.
评论 #26967493 未加载
WalterGRabout 4 years ago
Actually you asked this question at a good time! Using hn.algolia.com, which is this site&#x27;s search function -<p><a href="https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=pastWeek&amp;page=0&amp;prefix=true&amp;query=compiler&amp;sort=byDate&amp;type=story" rel="nofollow">https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=pastWeek&amp;page=0&amp;prefix=tru...</a><p>I found this <i>very recent</i> post, which I knew I bookmarked somewhere, but didn&#x27;t have the link handy!<p>Resources for Amateur Compiler Writers (<a href="https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;bib&#x2F;" rel="nofollow">https:&#x2F;&#x2F;c9x.me&#x2F;compile&#x2F;bib&#x2F;</a>)<p>336 points | kilodeca | 4 days ago | 88 comments<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26925314" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26925314</a>