Hey everyone!

I was just wondering why one would use any of the programs I mentioned above instead of VS Code to write Code.

Can someone give me a brief overview of the advantages?

Thanks in advance!

  • fiat_lux
    link
    fedilink
    11 year ago

    Very interesting. I appreciate you for this thorough research and report! I will have to try textadept out.

    • @ttmrichter
      link
      21 year ago

      The thing that made me go to it was its syntax highlighting engine. I tend to use languages that aren’t well-supported by common tools (like VSCode), and Textadept makes it simple. REALLY simple.

      As an example, I supplied the lexer for Prolog and Logtalk. Prolog is a large language and very fractious: there’s MANY dialects with some rather sizable differences. The lexer I supplied for Prolog is ~350 lines long and supplies full, detailed syntax highlighting for three (very) different dialects of Prolog: ISO, GNU, and SWI. (I’ll be adding Trealla in my Copious Free Time™ Real Soon Now™. On average it will be about another 100 lines for any decently-sized dialect.) I’ve never encountered another syntax highlighting system that can do what I did in Textadept in anywhere near that small a number of lines. If they can do them at all (most can’t cope with the dialect issue), they do them in ways that are painful and error-prone.

      And then there’s Logtalk.

      Logtalk is a cap language. It’s a declarative OOP language that uses various Prologs as a back-end. Which is to say there is, in effect, a dialect of Logtalk for each dialect of Prolog. So given that Logtalk is a superset of Prolog you’d expect the lexer file for it to be as big or bigger, right?

      Nope.

      64 lines.

      The Logtalk support—a superset of Prolog—adds only 64 lines. And it’s not like it copies the Prolog support and adds 64 lines for a total of ~420 in the file. The Logtalk lexer file is 64 lines long. Because Textadept lexers can inherit from other lexers and extend them, OOP-style. This has several implications.

      1. It seriously reduced the number of lines of code to comprehend.
      2. It made adding support for another backend dialect automatic. Originally I wrote the Prolog support for just SWI-Prolog and then wrote Logtalk in terms of the Prolog support. When I later added dialect support, adding ISO Prolog and GProlog, to the Prolog support file, Logtalk automatically got those pieces of dialect support added without any changes.

      In addition to this inheritance mechanism, take a look at this beautiful bit of bounty from the HTML lexer:

      -- Embedded JavaScript ().
      local js = lexer.load('javascript')
      local script_tag = word_match('script', true)
      local js_start_rule = #('<' * script_tag * ('>' + P(function(input, index)
        if input:find('^%s+type%s*=%s*(["\'])text/javascript%1', index) then return true end
      end))) * lex.embed_start_tag
      local js_end_rule = #('') * lex.embed_end_tag
      lex:embed(js, js_start_rule, js_end_rule)
      
      -- Embedded CoffeeScript ().
      local cs = lexer.load('coffeescript')
      script_tag = word_match('script', true)
      local cs_start_rule = #('<' * script_tag * P(function(input, index)
        if input:find('^[^>]+type%s*=%s*(["\'])text/coffeescript%1', index) then return true end
      end)) * lex.embed_start_tag
      local cs_end_rule = #('') * lex.embed_end_tag
      lex:embed(cs, cs_start_rule, cs_end_rule)
      

      You can embed other languages into a top level language. The code you read here will look for the tags that start JavaScript or CoffeeScript and, upon finding them, will process the Java/CoffeeScript with their own independent lexer before coming back to the HTML lexer. (Similar code is in the HTML lexer for CSS.)

      Similarly, for those unfortunate enough to have to work with JSP, the JSP lexer will invoke the Java lexer for embedded Java code, with similar benefits for when Java changes. Even more fun: the JSP lexer just extends the HTML lexer with that embedding. So when you edit JSP code at any given point you can be in the HTML lexer, the CSS lexer, the JavaScript lexer, the CoffeeScript lexer, or the Java Lexer and you don’t know or care why or when. It’s completely seamless, and any changes to any of the individual lexers are automatically reflected in any of the lexers that inherit from or embed another lexer.

      Out of the box, Textadept comes with lexer support for ~150 languages of which ~25 use inheritance and/or embedding giving it some pretty spiffy flexibility. And yet this is only ~15,000 LOC total, or an average of 100 lines of code per language. Again, nothing else I’ve seen comes close (and that doesn’t even address how much EASIER writing a Textadept lexer is than any other system I’ve ever seen).