5 ms·
Just a nitpick: you can live code in imperative languages and functional languages can require compilation. That has more to do with your design, framework, and
by SomeStupidPoint 10y ago
Just a nitpick: you can live code in imperative languages and functional languages can require compilation. That has more to do with your design, framework, and tooling than the language itself. It mostly is a divide between compiled and interpreted languages, though that distinction gets blurrier over time.
That said, Im a big fan of functional languages for game scripts (and got in to that myself using LISP on text MUDs).
- throwaway7645 10y agoCan you go into detail on using LISP for text MUDS? I have an appreciation for text based games. I find the simplicity to be elegant.
- escherize 10y agoHere's a talk about it: https://www.youtube.com/watch?v=lql2yFXzKUs https://www.youtube.com/watch?v=lql2yFXzKUs
- SomeStupidPoint 10y agoI was only a lowly content builder and quest manager, so I can't speak much to how the server mechanics worked. But essentially, each entity (usually a mob) would have a set of event scripts (attached to some kind of internal lookup table), and each time an event happened, it would call the appropriate scripts/function/macro. So what I did was logic such as "game tick -> wander one step in a random direction" or "player enters room -> attack", but also slightly more complex ones such as "combat round -> if low health, flee". The cool feature of the server was that you could specify multiple options in the template, and it would randomly pick one for a newly created instance, giving some variety to behaviors (eg, some guards flee and some fight to the death). Each instance could also be given a specific one after instantiated, which was how we constructed special events. (That is, use an existing template, tweak a couple behaviors of the instance, and then redecorate it.) This is mostly just a benefit of first-class functions and LISP's ability to switch strings to code. LISP was mostly just nice in that you could often one-line fairly complex behavior, so you could build in-game over telnet. Honestly, I really miss text MUDs, but does anyone actually want to read anymore?
- philipov 10y agoI too was a mobprogs builder, but I hung around diku-based muds, and none of those used lisp. I loved the SMAUG codebase in particular. There was a NO_FLOOR property, and I discovered that there was an brief input delay on hitting the floor, during which your commands would be completely thrown out of the buffer. If you made an On Entry script in the destination room to immediately teleport the player back to the room with no floor, you'd trap them in an infinite loop that didn't buffer overflow, and completely ignored their commands. They would fall, hit the floor, and before their input block had ended, they would be falling again. Now, did you know that SMAUG's mudprogs ignored level restrictions, but could be activated by any IMM's force command? So when you force the mob to mpteleport a player, it doesn't check that you're only level 55 and the mpteleport target is level 65... so I called that a prison for gods. I think I spent more time trying to break the code than actually producing content.
- SomeStupidPoint 10y agoFor anyone reading: this is basically how all hacking works and why security is hard -- you have to think out every way several components might interact.
- pdpi 10y agoI, for one, do. I have many fun memories playing in some MUDs, but never really read as much as I'd like about the development side of it.
- throwaway7645 10y agoI love text games. Looking forward to taustation which is going into alpha soon and written by a prolific perl author. Good stuff. Check out the blog articles.
- aptwebapps 10y agoThe first code I ever wrote that was actually used by (not very many) people was in LPC ... good times.
- GavinMcG 10y agoThis may not be what you're looking for, but it's a nifty example of building a small text adventure system in Racket and then leveraging its language building tools. http://queue.acm.org/detail.cfm?id=2068896 http://queue.acm.org/detail.cfm?id=2068896
- binthere 10y agoI believe that on Unreal Engine 4, you use C++ and it does have a feature that mimics "live coding" where it recompiles and hot-reload your game even while playing. edit: here it is https://youtu.be/MOvfn1p92_8?t=580 https://youtu.be/MOvfn1p92_8?t=580 (jump to 9:40 if it doesn't load at this point automatically)
- iopq 10y agoI've seen a C++ program get changed while it was running.
- fdb 10y agoHandmade Hero implements a live coding workflow in C++: https://www.youtube.com/watch?v=WMSBRk5WG58 https://www.youtube.com/watch?v=WMSBRk5WG58
- davexunit 10y agoThat's a far cry from a REPL.
- ramseynasser 10y agoFair, but there's an important difference between a tool where live coding is technically possible and a tool designed to support it. Clojure is built from the ground up for the REPL experience and supports e.g. redefining functions seamlessly. The fact that it's functional helps a lot, too, since that means that the order things are defined or executed in matters less.
- SomeStupidPoint 10y agoPython is an example of an OO + imperative language with a built in REPL. My point was that it has to do with if there's an interpreter for the language, and if the interpreter works with your toolchain. And that with the advent of JIT, that distinction becomes increasingly blurry, because the techniques to compile and link small blocks of code can be used by languages without an interpreter, per se.
- ramseynasser 10y agoRight, Clojure is always compiled and achieves live coding by running on top of VMs that support dynamic code emission. Python REPLs are quite good, but in my experience order dependent state-mutating code can get tricky in an interactive context. FP helps a lot here.