This post explores a shift in thinking about programming languages from individual entities to sets or families of languages. Instead of focusing on a single language's specific features, the author advocates for considering the shared characteristics and relationships between languages within a broader group. This approach involves recognizing core concepts and abstractions that transcend individual syntax, allowing for easier transfer of knowledge and the development of tools that can operate across multiple languages within a set. The author uses examples like the ML language family and the Lisp dialects to illustrate how shared underlying principles can unify seemingly disparate languages, leading to a more powerful and adaptable approach to programming.
The blog post details methods for eliminating left and mutual recursion in context-free grammars, crucial for parser construction. Left recursion, where a non-terminal derives itself as the leftmost symbol, is problematic for top-down parsers. The post demonstrates how to remove direct left recursion using factorization and substitution. It then explains how to handle indirect left recursion by ordering non-terminals and systematically applying the direct recursion removal technique. Finally, it addresses mutual recursion, where two or more non-terminals derive each other, converting it into direct left recursion, which can then be eliminated using the previously described methods. The post uses concrete examples to illustrate these transformations, making it easier to understand the process of converting a grammar into a parser-friendly form.
Hacker News users discussed the potential inefficiency of the presented left-recursion elimination algorithm, particularly its reliance on repeated string concatenation. They suggested alternative approaches using stacks or accumulating results in a list for better performance. Some commenters questioned the necessity of fully eliminating left recursion in all cases, pointing out that modern parsing techniques, like packrat parsing, can handle left-recursive grammars directly. The lack of formal proofs or performance comparisons with established methods was also noted. A few users discussed the benefits and drawbacks of different parsing libraries and techniques, including ANTLR and various parser combinator libraries.
Summary of Comments ( 20 )
https://news.ycombinator.com/item?id=43360287
The Hacker News comments discuss the concept of "language sets" introduced in the linked gist. Several commenters express skepticism about the practical value and novelty of the idea, questioning whether it genuinely offers advantages over existing programming paradigms like macros, polymorphism, or code generation. Some find the examples unconvincing and overly complex, suggesting simpler solutions could achieve the same results. Others point out potential performance implications and the added cognitive load of managing language sets. However, a few commenters express interest, seeing potential applications in areas like DSL design and metaprogramming, though they also acknowledge the need for further development and clearer examples to demonstrate its usefulness. Overall, the reception is mixed, with many unconvinced but a few intrigued by the possibilities.
The Hacker News post "From Languages to Language Sets" sparks a discussion around the linked gist, which proposes the idea of "language sets" – combining multiple programming languages for different parts of a project based on their strengths. The comments section is moderately active, containing a mix of agreement, disagreement, and explorations of related concepts.
Several commenters express enthusiasm for the idea, highlighting the potential benefits of using specialized languages for specific tasks. One commenter points out how this approach mirrors existing practices, such as using SQL for database interactions within a larger application written in a different language. They argue that explicitly recognizing and formalizing these "language sets" could lead to better tool development and more structured project organization. Another commenter emphasizes the productivity gains that could be achieved by choosing the right language for each job, rather than being constrained by a single language's limitations. They also suggest that improved tooling around language sets could simplify the process of integrating different languages.
Others express skepticism or raise concerns. One commenter questions the novelty of the idea, suggesting that it simply describes the status quo of using multiple languages within a project. They argue that the term "language set" doesn't add much to the existing understanding of polyglot programming. Another commenter raises the issue of increased complexity when managing multiple languages, particularly regarding tooling, debugging, and team communication. They acknowledge the potential benefits but caution against overlooking the practical challenges.
The discussion also delves into related topics. One commenter mentions the concept of "internal DSLs" (Domain-Specific Languages) and suggests that creating small, specialized languages within a larger project could be a more effective alternative to full-blown language sets. Another commenter draws parallels to the microservices architecture pattern, arguing that language sets could be seen as a similar approach applied to programming languages rather than services.
Overall, the comments reflect a mixed reception to the idea of "language sets." While some see it as a valuable way to formalize and improve existing polyglot programming practices, others question its novelty and express concerns about increased complexity. The discussion also touches upon related concepts like internal DSLs and microservices, enriching the conversation around the central theme of choosing the right tools for the job.