News for hackers. Stuff that matters.
Re:Programming Languages Are Simply Not Powerful Enough by SomeCallMeTim on Friday March 01, 2013 @01:13AM (#5303091)
I would add Lua to the latter group (a language used as a tool to build the language you need).

Not NEARLY as cool of an implementation as implementing TCP using ASCII art, but there's a command-line option parser that parses the help text to determine the command line options. [1] For example:

    -- scale.lua
      require 'lapp'
      local args = lapp [[
      Does some calculations
        -o,--offset (default 0.0)  Offset to add to scaled number
        -s,--scale  (number)  Scaling factor
         <number> (number )  Number to be scaled
      ]]

      print(args.offset + args.scale * args.number)
[1] http://lua-users.org/wiki/LappFramework
Re:Programming Languages Are Simply Not Powerful Enough by spc476 on Friday March 01, 2013 @04:39AM (#5303526)
Threre's also LPeg [1], which I find much nicer than lex and yacc (or flex and bison) for writing parsers. I just finished up a quick hack to pull out a single file from a git repository into its own repository, and the parsing of the "git fast-export" output is 70 lines of Lua/LPeg. It may sound like quite a bit, but it's a near dump of the BNF you find on the man page [2]. From there, it was simple enough to grovel through the in-memory representation of the git repository and output only what I needed.

[1] http://www.inf.puc-rio.br/~roberto/lpeg/ [3]

[2] http://kernel.org/pub/software/scm/git/docs/git-fast-import....

[3] I actually use the re module [4] as I find the results more readable, and only use the LPeg module when I need something that the re module can't provide.

[4] http://www.inf.puc-rio.br/~roberto/lpeg/re.html

Re:Programming Languages Are Simply Not Powerful Enough by chubot on Friday March 01, 2013 @04:07AM (#5303463)
That can be done in basically any dynamic language: see http://docopt.org/
Re:Programming Languages Are Simply Not Powerful Enough by SomeCallMeTim on Friday March 01, 2013 @01:47PM (#5306098)
That's a pretty cool project. Sure you CAN do it in any language (as another commenter points out, you can do it in C too). Anything that's turing-complete can do it. You could also use C to parse ASCII art and have that create a TCP implementation. It's not the natural way you'd do it in that language, though.

lapp has been around for four years; docopt is (looking at git commits) less than a year old. It strikes me as a natural way to do things in Lua, which is why (I suspect) it was done in Lua earlier.

Re:Programming Languages Are Simply Not Powerful Enough by masklinn on Friday March 01, 2013 @07:03AM (#5303841)
It can even be done in static languages with an intermediate compilation step.
Re:Programming Languages Are Simply Not Powerful Enough by ufo on Friday March 01, 2013 @08:52AM (#5304175)
My problem with Lua DSLs is the verbose function syntax (`function foo() return end`). I'm thinking about experimenting more with Metalua to see if it helps in that regard.

One thing that positively impressed me were coroutines though. You can do some very interesting DSL things with it.