Portable scripting language for a multi-server admin?

后端 未结 7 1797
误落风尘
误落风尘 2021-02-14 03:44

Please Note: Portable as in portableapps.com, not in the traditional sense of a language that can be used on multiple architectures or operating systems. Whoeve

相关标签:
7条回答
  • 2021-02-14 04:08

    Looking at wikipedia's exhaustive list of portable software There's Tiny C compiler, again on Wikipedia here, and its own homepage here.

    To summarize by quoting from wikipedia's list of features:

    • Small - can compile and execute C code everywhere, for example on rescue disks (about 100KB for x86 TCC executable, including C preprocessor, C compiler, assembler and linker).
    • Fast - tcc generates optimized x86 code. No byte code overhead. It compiles, assembles and links about 9 times faster than GCC.
    • Any C dynamic library can be used directly. TCC is heading towards full ISOC99 compliance. TCC can of course compile itself.
    • Includes an optional memory and bound checker. Bound checked code can be mixed freely with standard code.
    • Compile and execute C source directly. No linking or assembly necessary. Full C preprocessor and GNU-like assembler included.
    • C script is supported: just add '#!/usr/local/bin/tcc -run' at the first line of your C source, and execute it directly from the command line.
    • With libtcc, you can use TCC as a backend for dynamic code generation.
    • Few dependencies. It includes its own hand-written lexer, and it is implemented using a recursive descent parser. Thus, building TCC requires few other libraries.
    • Its LGPL license permits anyone to use, modify, and/or redistribute the software, and it can be used to develop either open source or proprietary software.

    Hope this helps and would be of use, Best regards, Tom.

    0 讨论(0)
  • 2021-02-14 04:11

    In addition to the Lua suggestion, there is also Idle. It is basically a superset of Lua 5.1, with both the language (and libraries) and the implementation based on Lua. It was originally created to be a more complete scripting solution for Windows: because Lua is primarly intended for embedding, it has a rather small standard library and it is usually expected that the embedding application provides a rich library to Lua.

    This makes sense for an embedded language, because, after all, there isn't much common functionality between, say Adobe Lightroom, Nginx and World of Warcraft, so there simply is nothing you can put in a standard library. But for a more general purpose OS scripting language, one would want a slightly larger library. Thus, Idle bundles a couple of libraries that are third-party (and sometimes hard to get to work on Windows) in Lua in its standard library.

    Some of the things that the Idle standard library adds over Lua are tight Win32 integration, SQLite3 support, networking support, a PEG parser generator and archive support.

    Also, Idle has support for embedding Perl and C code into your Idle programs.

    0 讨论(0)
  • 2021-02-14 04:17

    Tclkit is a single-file, self-contained Tcl/Tk system. The mac version I have is about 3.8 megs. You can get a version for just about any modern OS. I carry around a thumb drive that has mac, windows and linux binaries so I can run my scripts on any platform. No install is required, just copy one file wherever you want.

    The only thing it's missing from your original spec is MS SQL Server / ODBC support out of the box. I know people use tcl for that but I think you'll have to add an extra library or something. See the Tcl'ers wiki entry on MS SQL Server for more information.

    0 讨论(0)
  • 2021-02-14 04:19

    I urge you to try Lua. Regarding your requirements:

    • Tiny footprint (56 source files, under 150K compiled)
    • Runs everywhere (uses only ANSI C)
    • No installer needed; you compile from source (there's also a "batteries included" package that I haven't explored
    • Doesn't need JVM and works with any ANSI C compiler, so you can compile with Visual Studio, not Cygwin
    • Works with external processes and files but only to the extent supported by ANSI C. If POSIX popen is provided then that is supported also.

    And your bonus points:

    • Open source (MIT license)
    • FFI to C is brilliantly conceived and executed—not quite as simple as Tcl but loads more powerful. Much better integration with C than Python or Ruby.
    • GUI support is mixed but there are good bindings for wx widgets. QT support was there at one time but I don't know if it has been maintained.
    • Linux is supported
    • Language/compiler features:
      • Dynamic
      • Functional
      • Prototype-based objects and inheritance through metamethods (you'll want to see examples in the book below
      • Fastest bytecode compiler in the West
      • Interactive read-eval-print loop; load new code dynamically
    • Able to package scripts into executables; either use Luiz de Figueiredo's srlua, or I can send you a 120-line Lua script that converts Lua source to a .c file that you link in with your app and the interpreter to make an executable.

    Additional bonus points:

    • Very crisp, clean, well-designed language.
    • Small enough to master in its entirety and to be productive within a day.
    • Superb book Programming in Lua (check out the previous edition free online)
    0 讨论(0)
  • 2021-02-14 04:21

    For tcl, apart from Tclkit, freewrap is another small portable, self-contained interpreter for tcl.

    Just rename the freewrap executable to something else will convert it to a stand-alone interpreter. Renaming it back to freewrap will convert it to a script wrapper.

    Also, freewrapped apps contain a tcl interpreter. In dire emergencies you can try opening the app as a zip file and edit/replace the tcl code contained within (just remember to make a copy first). This has saved me several times when I'm at a client site without development tools but need to troubleshoot something. I just make a copy of one of my deployed app and presto - instant development environment!

    0 讨论(0)
  • 2021-02-14 04:24

    Every somewhat modern Windows version comes pre-installed with both VBScript and JScript. The doesn't meet all your features (compile to an executable comes to mind), but they certainly have an unbeatable advantage with the installation size: it's hard to beat 0.

    0 讨论(0)
提交回复
热议问题