News for hackers. Stuff that matters.
Re:Notch's Specification for the In-Game DCPU-16 by nknight on Wednesday April 04, 2012 @08:47AM (#3797266)
Although some of the implications require experience to understand, I'd say it already is in "relatively plain English", you simply haven't been exposed to the vocabulary and concepts necessary. Trying to explain in any detail would basically be reproducing Wikipedia, so here are some links:

http://en.wikipedia.org/wiki/Program_counter

http://en.wikipedia.org/wiki/Word_(computer_architecture)

http://en.wikipedia.org/wiki/JMP_(x86_instruction)

http://en.wikipedia.org/wiki/NOP

http://en.wikipedia.org/wiki/Orthogonal#Computer_science

http://en.wikipedia.org/wiki/Address_space

http://en.wikipedia.org/wiki/Memory-mapped_I/O

http://en.wikipedia.org/wiki/Interrupt

And no, don't expect Python anytime soon. Expect a C compiler, FORTH, possibly some sort of Pascal, but a highly dynamic language is unlikely. The system is too resource-constrained to make it practical. A static language that looks kind of like Python isn't out of the question, but it won't do a lot of the things you expect from Python, Ruby, PHP, or Perl.

Re:Notch's Specification for the In-Game DCPU-16 by akavel on Wednesday April 04, 2012 @09:22AM (#3797401)
> a highly dynamic language is unlikely

Lua, perhaps? There was an article how to reduce its binary size, for an older version of the language (Lua 4.0): http://www.lua.org/notes/ltn002.html

With no reductions, and for x86 assembly, it started at ~64KB, so not very useful here; but after dropping standard libraries and parser, they got to ~24KB. Now however, some further questions arise I'm not sure about:

- whether such a virtual machine, when without parser, would be anyhow more useful than the underlying system alone?

- how much the binary code would be bigger when compiled for the "DCPU-16" instruction set instead of x86?

Re:Notch's Specification for the In-Game DCPU-16 by nknight on Wednesday April 04, 2012 @09:31AM (#3797454)
Lua is a good place to start! And the VM minus parser is useful, though it may make debugging harder. You simply write out the bytecode and upload that.

The VM is only part of the problem, though. I consider the bigger problem to be memory management. A garbage collected language operating reliably in 128KB? I'm deeply skeptical.

Re:Notch's Specification for the In-Game DCPU-16 by quadhome on Wednesday April 04, 2012 @12:38PM (#3798352)
While I don't think Lua would be the choice, it's the quantity of garbage that matters:

"Historically, languages intended for beginners, such as BASIC and Logo, have often used garbage collection for heap-allocated variable-length data types, such as strings and lists, so as not to burden programmers with manual memory management. On early microcomputers, with their limited memory and slow processors, BASIC garbage collection could often cause apparently random, inexplicable pauses in the midst of program operation. Some BASIC interpreters such as Applesoft BASIC on the Apple II family, had terribly inefficient garbage collectors for strings which repeatedly scanned the string descriptors for the string having the highest address in order to compact it toward high memory. This one-string-at-a-time processing loop resulted in O(N * N) time performance in the number of strings, which would introduce a pause more than one minute long into the execution of string-intensive programs. A replacement garbage collector for Applesoft BASIC published in Call-A.P.P.L.E. (January 1981, pages 40–45, Randy Wiggington) identified a group of strings in every pass over the heap, reducing a pause of two minutes into less than a second depending on the size of the group. Other approaches were published, but none ever made it into a new revision of the BASIC interpreter."

http://en.wikipedia.org/wiki/Garbage_collection_(computer_sc...

Re:Notch's Specification for the In-Game DCPU-16 by RodgerTheGreat on Wednesday April 04, 2012 @12:56PM (#3798475)
Garbage collection isn't necessarily that difficult, especially when you're in a single-threaded (or cooperatively multithreaded) environment and don't have to contend with an OS. Here[1] is a cons-pair system I wrote in Forth which uses tag bits to identify pointers, a mark-and-sweep garbage collector and a free-list style allocator. GC takes linear time with respect to heap size, and allocations are constant time. The allocator itself (not counting all the list utility routines) is about 60 lines long and fairly easy to understand.

[1] https://github.com/JohnEarnest/Mako/blob/master/lib/Algorith...

Re:Notch's Specification for the In-Game DCPU-16 by ac on Wednesday April 04, 2012 @11:16AM (#3797949)
A smarter way might be just implementing a new LLVM backend (gives us C via Clang, some other languages). However, even with C, the standard library probably won't leave much space for the user code itself -- so you might need something slimmer. Also, some kind of simple RTOS (www.freertos.org, maybe?) to run all these programs (I assume people would really want to run several programs at a time). I wonder if the 128k limitation was intentional, to make programming the computers more interesting. Anyway, I'm actually looking forward to seeing what kind of clever solutions the players come up with.
Re:Notch's Specification for the In-Game DCPU-16 by jmaygarden on Wednesday April 04, 2012 @01:38PM (#3798751)
An RTOS won't be of much use without interrupts. You could implement coroutines, but preemptive scheduling is not possible.
Re:Notch's Specification for the In-Game DCPU-16 by javert on Wednesday April 04, 2012 @02:09PM (#3798940)
Moreover, it would be very surprising if low-latency or deterministic timing properties would actally be useful in the game.
Re:Notch's Specification for the In-Game DCPU-16 by nknight on Wednesday April 04, 2012 @01:22PM (#3798639)
The ANSI C library is quite small. It originates in an era when 128KB of RAM was reasonably roomy. To this day, there are C libraries designed to fit comfortably within that size.

Most of the library code will never even be present anyway. Your (statically-linked) binary will simply contain those functions actually used, which is likely to be a small subset of what is available.

Re:Notch's Specification for the In-Game DCPU-16 by SoftwarePatent on Wednesday April 04, 2012 @08:54AM (#3797296)
Reading all these wikipedia pages is going to kill at least an hour of productivity today :/
Re:Notch's Specification for the In-Game DCPU-16 by ch0wn on Wednesday April 04, 2012 @09:17AM (#3797381)
Depends on what you define as being productive. I personally perceive learning as something productive.
Re:Notch's Specification for the In-Game DCPU-16 by SimHacker on Wednesday April 04, 2012 @09:14AM (#3797370)
And it will enable countless years of productivity!