CGI programming in D - cgi

I am interested learning more about the D programming programming language, and especially using it for CGI programs. I have had a look at the standard libraries (Phobos) and did not see any support for CGI. Does anyone know of any good examples of CGI programs written in D?

Adam Ruppe's library is probably the most complete CGI D solution at the moment:
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff

Here is a cgi library for D I have written as a support library for a larger project. MIT licensed, free to use however you want.
https://github.com/josephRice/cgi_d

Related

Difference between scripting and non scripting language

I am wondering what is difference between scripting and non scripting language. For example like LUA and C++. Because in game development I often read that they are hiring programmer who must know scripting language. Thank you!
Some of this is somewhat historical in nature.
Non-scripted languages like C and C++ are compiled into "raw machine code" (RMC).
That RMC is then run directly on the machine. Note that RMC is typically
very specific to the underlying CPU/hardware AND to the supporting Operating
System. So if you want to run a C program on both linux and windows, it has to be
compiled for each (two copies to maintain and distribute).
A scripted language is typically NOT compiled. Instead, the source
code is passed to an interpreter that understands the language. The
interpreter itself is typically written in a language that is
itself compiled to RMC. The interpreter's task is to read the
scripted language, and translate that into operations done by RMC.
The line has blurred in recent years (decades?) with the advent of
systems like Java. With languages like Java, source code is
compiled to an intermediate/portable language, and the Java Virtual
Machine handles the translation of that portable language into
operations for the target CPU/OS.

What are my language choices for lego NXT?

It is unclear from wikipedia etc (without installing a bunch of crap and testing) which languages I can use to write programs which can be copied and run standalone on the NXT brick. What languages are currently supported? I'd probably want to go with something high-level like haskell, or at the very least a well-recognized language such as C, as opposed to NXT-G and NXC etc.
These are some very common languages used to program the Mindstorms NXT:
You could try ROBOTC, which will enable you to write programs in C
for the Mindstorms NXT. (NXC is C like, yet not completely C, hence
Not Exactly C)
Otherwise you could try leJOS, which will enable you to write
programs in Java for the Mindstorms NXT.
I am a big fan of MSRDS. It's free (unlike ROBOTC) and if you are handy with C# the learning curve isn't to gnarly. I noticed it wasn't on that list :( so I thought I would throw in my two cents.

Extending an Objective-C program with a scripting language

Is there a ready-made implementation of an interpreter for ObjC. Basically, I need my program to be extendable via a scripting language.
I'm not sure if this is already provided by some kind of framework, or perhaps I can implement AppleScript internally - not sure how I would do that tho. It seems to only apply to automating the program itself, not for extending its own functionality.
Something similar to mIRC's means of interfacing with a scripting language.
You bet there is. It's called FScript; it's open-source and includes a console with a REPL in which you can interact with Cocoa objects. The syntax is Smalltalk-like, which is very similar to Objective-C -- the main difference is no square brackets. Here's some snippets from their tutorial. Notice that variables don't have to be explicitly typed!
> imageLocation := NSURL fileURLWithPath:'/Library/Desktop Pictures/Nature/Clown Fish.jpg'.
> image := CIImage imageWithContentsOfURL:imageLocation.
> image drawInRect:(200<>80 extent:600<>400) fromRect:image extent operation:NSCompositeSourceOver fraction:1.
You will be interested in their Embedding FScript Into Cocoa Applications Guide.
Do you just want your program to be scriptable? If so, then you should probably add AppleScript support. See Introduction to Cocoa Scripting Guide for information on how to do this.
Python and Ruby can interact with the Objective C calls so you can use them to extend the program's functionality.
Objective C is not a scripting language, so it has no interpreter. It can only be compiled to machine codes.
If you want to use scripting language is suggest Lua. It is really easy and lightweight but still very powerful. You can use it with you native C/C++ programs and there are also ObjC bindings.
Anyway any scripting language (Python, Lua, AppleScript etc.) is built on top of some native programming language (usually C or C++) and if you want to extend your program with new features you still need to implement them first using native language.
Fot you to start: how to bind Lua. It is for C++, but it is the same for C and ObjC (as it is a superset of C)

What is a good VM for developing a hobby language?

I'm thinking about writing my own little language.
I found a few options, but feel free to suggest more.
JVM
Parrot
OSA
A lot of languages are using the JVM, but unless you write a Java-ish language, all the power the stdlib gives you is going to feel ugly; It's not very good at dynamic stuff either.
Parrot seems a good VM for developing languages, but it has a little abandoned/unfinished/hobby project smell to it.
OSA is what powers Applescript, not a particularly well known VM, but I use Mac, and it offers good system integration.
CLR+Mac doesn't seem a good combination...
My language is going to be an object orientated functional concurrent dataflow language with strong typing and a mix of Python and Lisp syntax.
Sounds good, eh?
[edit]
I accepted Python for now, but I'd like to hear more about OSA and Parrot.
One approach I've played with is to use the Python ast module to build an abstract syntax tree representing the code to run. The Python compile function can compile an AST into Python bytecode, which exec can then run. This is a bit higher level than directly generating bytecode, but you will have to deal with some quirks of the Python language (for example, the fundamental difference between statements and expressions).
In doing this I've also written a "deparse" module that attempts to convert an AST back to equivalent Python source code, just for debugging. You can find code in the psil repository if you're interested.
Have a look at LLVM. It's not a pure VM as such, more a framework with it's own IR that allows you to build high level VMs. Has nice stuff like static code analysis and JIT support
Lua has a small, well-written and fast VM
Python VM - you can really attach a new language to it if you want. Or write (use?) something like tinypy which is a small and simple implementation of the Python VM.
Both options above have access to useful standard libraries that will save you work, and are coded in relatively clean and modular C, so they shouldn't be hard to connect to.
That said, I disagree that Parrot is abandoned/hobby. It's quite mature, and has some very strong developers working on it. Furthermore, it's specifically a VM designed to be targeted by multiple dynamic languages. Thus, is was designed with flexibility in mind.
Have you considered Pypy? From what I've read, in addition to being a Python JIT Compiler, it also has the capability to handle other languages. For example there is a tutorial which explains how to create a Brainfuck JIT compiler using Pypy.

Why have language interpreters be written in the target language? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Bootstrapping a language
What's the importance of having an interpreter for a given language written in the target language (for example, PyPy)?
It's not so much about writing the interpreter in itself - more about writing the interpreter in a high-level language, not in C. Ideally, doing so allows to change details of the implementation, and making the interpreter more modular.
For the specific case of PyPy, writing the interpreter and the core objects in (R)Python allows to retarget PyPy for targets (C, JVM, .NET, JavaScript, etc), and also allows to replace aspects such as the garbage collector.
I'm sure there are many different reasons for doing it. In some cases, it's because you truly believe the language is the best tool... so writing the language interpreter or compiler in the language itself can be seen as a form of dogfooding. If you are really interested in this subject, the following article is a really amazing read about the development of squeak. The current version of squeak is a smalltalk runtime written in smalltalk.
http://users.ipa.net/~dwighth/squeak/oopsla_squeak.html
An added benefit is that if you implement good debugers and IDEs for your target language, they also work for your source language.
This way, you can prove that the target language is serious business, because being able to make it compile something is a sign that it is a good language.
OK, C++ and Java produce compilers as well... so maybe that argument is only half as good as it may seem.