Meta tags:
Headings (most frequently used words):
lisp, an, in, to, my, simple, golang, tcl, interpreter, hosts, put, lsp, your, alphabetical, linting, trivial, benchmarks, of, toy, languages, macros, are, magical, so, we, come, update, on, writing, plea, for, books, porting, game, from, cp, the, zx, spectrum, 48k, removing, last, server, email, git, repositories, static, dynamic, recent, posts,
Text of the page (most frequently used words):
the (195), and (88), that (58), for (36), you (35), was (31), #simple (30), with (27), lisp (26), this (26), which (26), but (25), can (24), 2022 (21), language (21), while (21), tcl (20), are (18), set (18), from (17), there (17), github (17), things (16), writing (15), have (15), comments (14), them (14), one (14), like (14), loop (14), test (14), interpreter (13), golang (13), blog (13), https (13), here (13), etc (13), all (12), lambda (12), now (12), functions (12), languages (11), tags (11), just (11), used (11), use (11), then (11), because (11), some (11), using (11), com (11), more (11), body (11), spectrum (10), write (10), written (10), fun (10), forth (10), print (10), define (10), steve (9), macros (9), function (9), course (9), two (9), about (9), only (9), too (9), even (9), hello (9), code (9), call (9), skx (9), iteration (9), primitive (9), object (9), game (8), need (8), email (8), into (8), time (8), these (8), run (8), number (8), z80 (8), tap (8), list (8), string (8), not (8), similar (8), those (8), recently (8), than (8), scripting (8), puts (8), kemp (7), server (7), books (7), toy (7), lsp (7), wrote (7), first (7), based (7), make (7), standard (7), means (7), output (7), text (7), primitives (7), how (7), something (7), see (7), basic (7), anyway (7), true (7), trivial (6), your (6), guess (6), probably (6), get (6), would (6), couple (6), bunch (6), past (6), file (6), small (6), screen (6), few (6), implementing (6), cur (6), max (6), name (6), lists (6), res (6), macro (6), put (5), thing (5), host (5), did (5), less (5), second (5), input (5), bit (5), result (5), emulator (5), clear (5), work (5), within (5), without (5), any (5), begin (5), always (5), specific (5), been (5), much (5), same (5), works (5), doesn (5), example (5), support (5), implementation (5), easy (5), actually (5), figured (5), func (5), last (4), july (4), alphabetical (4), november (4), maybe (4), comment (4), don (4), via (4), repository (4), added (4), current (4), dynamic (4), hosts (4), static (4), own (4), machine (4), where (4), very (4), pretty (4), itself (4), console (4), single (4), said (4), horrid (4), available (4), will (4), little (4), still (4), allows (4), key (4), done (4), having (4), level (4), happy (4), each (4), yet (4), years (4), lot (4), useful (4), other (4), expr (4), another (4), world (4), variable (4), arguments (4), really (4), experiment (4), higher (4), proc (4), var (4), obvious (4), way (4), fact (4), if2 (4), good (4), statement (4), execute (4), three (4), know (4), args (4), error (4), builtins (4), 48k (3), april (3), update (3), magical (3), linting (3), hosting (3), api (3), free (3), form (3), should (3), data (3), built (3), again (3), git (3), when (3), upon (3), return (3), most (3), org (3), they (3), repositories (3), perform (3), reading (3), line (3), over (3), word (3), brief (3), what (3), end (3), quite (3), nice (3), loaded (3), allowing (3), different (3), reason (3), love (3), load (3), step (3), pasmo (3), cls (3), instructions (3), value (3), you_pressed (3), assembly (3), out (3), started (3), working (3), being (3), such (3), had (3), programming (3), back (3), introduced (3), anything (3), either (3), once (3), syntax (3), core (3), antirez (3), enough (3), provide (3), incr (3), expanded (3), executed (3), looks (3), words (3), think (3), implement (3), repeat (3), min (3), upvalue (3), times (3), foo (3), implemented (3), new (3), editor (3), feels (3), filter (3), apply (3), numbers (3), given (3), predicate (3), emacs (3), bytecode (3), evalfilter (3), benchmark (3), monkey (3), alphavet (3), library (3), removing (2), february (2), porting (2), plea (2), may (2), june (2), come (2), september (2), benchmarks (2), october (2), recent (2), posts (2), five (2), necessary (2), stop (2), tram (2), part (2), harder (2), receive (2), submission (2), switch (2), could (2), local (2), locally (2), remote (2), files (2), deleted (2), next (2), third (2), secret (2), both (2), running (2), house (2), final (2), debian (2), aren (2), hosted (2), possible (2), finally (2), appropriate (2), replaced (2), gitbucket (2), control (2), database (2), mostly (2), broken (2), pay (2), read (2), later (2), virtual (2), down (2), retro (2), didn (2), take (2), port (2), kinda (2), bugs (2), well (2), resolution (2), wrapping (2), expect (2), reasonably (2), largely (2), unfortunate (2), contains (2), choice (2), though (2), lines (2), specifically (2), easily (2), start (2), 32768 (2), instructions_end (2), 8252 (2), wait (2), wkey (2), save (2), you_pressed_end (2), 0x1601 (2), endless (2), defb (2), please (2), press (2), create (2), following (2), install (2), assembler (2), going (2), getting (2), needed (2), routines (2), keyboard (2), project (2), let (2), details (2), cover (2), objects (2), involves (2), adventure (2), computer (2), place (2), mind (2), might (2), got (2), news (2), lighthouse (2), doom (2), 2021 (2), people (2), wouldn (2), low (2), also (2), partly (2), look (2), beyond (2), able (2), operations (2), myself (2), involved (2), runs (2), minor (2), together (2), critical (2), command (2), saw (2), approach (2), picol (2), rest (2), named (2), detail (2), minimum (2), parse (2), expansion (2), contents (2), overview (2), everything (2), give (2), remarkably (2), environment (2), consists (2), creating (2), learn (2), required (2), cases (2), bdy (2), miss (2), eval (2), doing (2), reasons (2), starting (2), week (2), previous (2), post (2), further (2), implementations (2), map (2), nat (2), natural (2), zero (2), adding (2), invoke (2), factorial (2), thinking (2), thought (2), makes (2), cute (2), neat (2), expression (2), supplied (2), blah (2), pred (2), posted (2), mean (2), nothing (2), foth (2), comes (2), results (2), quickly (2), real (2), hacked (2), niche (2), various (2), interpreters (2), order (2), half (2), talk (2), analysis (2), cos (2), sin (2), tan (2), package (2), maths (2), included (2), hover (2), completion (2), protocol (2), archive (2), web (2), created, ephemeris, containers, drop, sidestep, problem, entirely, after, whole, year, aws, existing, container, fly, apis, publicly, incoming, send, disk, include, meta, wanna, connecting, gmail, imap, copy, paste, received, filesystem, sent, add, spam, rsync, however, services, docker, fine, display, device, temperature, trams, coming, near, site, provides, endpoints, leaves, notably, archived, commercial, retired, january, administration, many, rarely, updated, care, websites, netlify, merged, removed, threw, account, gpg, encryption, access, avoid, binary, gitolite, private, bad, shutdown, reboot, trashed, internal, eventually, succumbed, google, workspace, product, dovecot, moved, mail, client, mutt, machines, dedicated, currently, cut, planning, remove, cpm, long, outstanding, unfortunately, accessed, terminal, assumed, 80x25, places, teaser, playable, isn, version, smaller, area, releases, bios, emulation, pause, prompt, rom, reworked, cope, minimally, breaks, spots, chose, loading, waiting, tape, play, menus, tell, fuse, auto, hear, xspect, quick, immed, tapbas, assemble, starts, points, length, 0x5c08, lastk, 255, change, push, show, message, ascii, character, pop, 0x0010, forever, demo, rom_open_channel, 0x0daf, rom_cls, ret, continue, pressed, apt, spectemu, x11, dependencies, walk, through, guide, demonstrates, linux, generating, favourite, messages, sample, demonstrate, lucky, capable, outputting, emulators, feeling, replace, custom, devil, sending, terminated, user, pausing, short, clearing, table, structures, locations, state, platform, replies, telephone, enter, commands, rug, recap, complete, fifteen, minutes, paw, patrol, easter, eggs, crossed, 40th, anniversary, discussed, hacker, ycombinator, item, 26946130, systems, suspect, who, collected, kept, want, case, particularly, pleased, melbourne, best, coding, usbourne, mystery, silver, mountain, amiss, book, cost, postage, finland, covering, processor, consider, dropping, hoarded, collect, request, actual, 1982, cassette, deck, bonus, wipe, clean, rez, graphics, internet, interested, computers, youth, crazy, preparing, introduce, our, child, his, feedback, welcome, quiet, isolation, legacy, recognize, their, simplicity, lead, flexibility, users, seems, fuzz, testers, lexer, parser, satisfy, least, somewhat, robust, fluid, complicated, parsing, hours, improved, original, changes, fair, partcl, tiny, writeup, follows, 550, usable, evolve, yourself, bare, perhaps, except, say, enclose, facility, lets, evaluate, blocks, happened, before, characters, square, brackets, evaluating, respectively, resulting, interpolation, generally, verbose, due, pleasant, readable, echo, saying, clever, rules, applied, consistently, flexible, reminds, sense, almost, hell, routers, guis, days, quietly, lives, piece, defense, utility, misunderstood, conclusion, flow, behaviour, inside, assert_equal, assert, story, allow, procedure, decr, hard, parent, missing, native, affect, variables, scopes, nicely, fall, hacks, unable, variadic, defining, replacing, extend, cleaned, fixed, 100, coverage, attempt, esoteric, journey, continues, looked, minimal, afield, takes, infamous, struggle, history, solve, problems, although, great, configuring, sexy, squared, odd, helpful, build, applying, specified, member, recursion, lots, cdr, car, calculate, factorials, recursively, albeit, slightly, fewer, far, tortuous, explicit, types, recurring, memory, cells, along, pair, stacks, operating, groundwork, layer, constructs, reached, point, why, experimentation, kind, minimalism, appreciate, damn, close, gone, recursive, wrap, neatness, condition, recurse, actions, shortcut, understand, building, block, rather, else, failure, clause, instead, has, parenthesis, awesome, everybody, told, repeatedly, off, despite, since, returned, visit, caught, covid, brain, fried, interesting, expected, better, honest, ast, walks, tokens, tco, efficient, bacause, essentially, looking, dictionary, maps, indexes, stack, fast, benchmarkevalfilterfactorial, 61542, 17458, benchmarkfothfactorial, 44751, 26275, benchmarkbasicfactorial, 36735, 32090, benchmarkmonkeyfactorial, 14446, 85061, benchmarkyalfactorial, 2607, 456757, benchmarktclfactorial, 292, 4085301, wins, compiles, program, shocked, blow, fairly, try, optimize, particular, felt, timings, vary, system, threading, relative, performance, comparable, matter, curious, calculating, fastest, ways, filled, helped, question, yal, basically, gobasic, engines, professional, career, public, months, linter, reports, failures, full, linters, purposes, driver, realizing, driven, called, vet, perl, script, regexp, tool, abs, personal, preference, dictates, rational, group, stick, ordering, approaches, assume, related, mid, right, left, complex, remembered, ordered, deliberately, examples, scanning, above, classes, ensure, referred, ensuring, calls, optional, parameter, recycled, extremely, parsers, vim, wee, popup, help, tested, gnu, neovim, editors, seriously, stuff, elsewhere, tliron, glsp, thankfully, found, implements, framework, serverö, beautiful, letter, practically, stab, designed, abstract, functionality, provided, ide, knows, jump, definitions, needs, launch, communicate, does, job, played, random, software, wayback, http, 20221204085629, timestamps, capture, fail, success, 2023, jan, dec, nov, oct, 2016, aug, 2026, 182, captures,
Text of the page (random words):
e statement to execute if the test was not true my if2 macro instead has three arguments the test to perform the first statement to execute if the test was true the second statement to execute if the test was true i e there is no else or failure clause this means i can write if2 blah one two rather than if blah begin one two it is simple clear and easy to understand and a good building block for writing a while function define while fun lambda predicate body if2 predicate body while fun predicate body there you see that if the condition is true then we call the supplied body and then recurse doing two actions as a result of the single if test is a neat shortcut of course we need to wrap that up in a macro for neatness define while macro expression body list while fun list lambda expression list lambda body now we re done and we can run a loop five times like so let a 5 while a 0 begin print while loop iteration s a set a a 1 true output while loop iteration 5 while loop iteration 4 while loop iteration 3 while loop iteration 2 while loop iteration 1 we ve gone from using lists to having a while loop with a couple of simple macros and one neat recursive function there are a lot of cute things you can do with macros and now i m starting to appreciate them a little more of course it s not quite as magical as forth but damn close tags forth github lisp no comments so we come to lisp 15 july 2022 13 00 recently i ve been working with simple trivial scripting languages and i guess i finally reached a point where i thought lisp why not one of the reasons for recent experimentation was thinking about the kind of minimalism that makes implementing a language less work being able to actually use the language to write itself forth is my recurring example because implementing it mostly means writing a virtual machine which consists of memory cells along with a pair of stacks and some primitives for operating upon them once you have that groundwork in place you can layer the higher level constructs such as for if etc lisp allows a similar approach albeit with slightly fewer low level details required and far less tortuous thinking lisp always feels higher level to me anyway given the explicit data types list string number etc here s something that works in my toy lisp define a function fact to calculate factorials recursively define fact lambda n if n 1 1 n fact n 1 invoke the factorial function using apply apply list 1 2 3 4 5 6 7 8 9 10 lambda x print s s x fact x the core language doesn t have helpful functions to filter lists or build up lists by applying a specified function to each member of a list but adding them is trivial using the standard car cdr and simple recursion that means you end up writing lots of small functions like this define zero lambda n if n 0 t f define even lambda n if zero n 2 t f define odd lambda n even n define sq lambda x x x once you have them you can use them in a way that feels simple and natural print even numbers from 0 10 s filter nat 11 lambda x even x print squared numbers from 0 10 s map nat 11 lambda x sq x this all feels very sexy and simple because the implementations of map apply filter are all written using the lisp and they re easy to write lisp takes things further than some other basic languages because of the infamous support for macros but even without them writing new useful functions is pretty simple where things struggle i guess i don t actually have a history of using lisp to actually solve problems although it s great for configuring my editor anyway i guess the journey continues having looked at the obvious minimal core languages i need to go further afield simple tcl like scripting language simple forth like scripting language yet another lisp in golang i ll make an attempt to look at some of the esoteric programming languages and see if any of those are fun to experiment with tags github lisp 2 comments an update on my simple golang tcl interpreter 1 july 2022 19 00 so my previous post introduced a trivial interpreter for a tcl like language in the past week or two i ve cleaned it up fixed a bunch of bugs and added 100 test coverage i m actually pretty happy with it now one of the reasons for starting this toy project was to experiment with how easy it is to extend the language using itself some things are simple for example replacing this puts 3 x 4 expr 3 4 with this puts 3 x 4 3 4 just means defining a function proc named which we can do like so proc a b expr a b of course we don t have lists or variadic arguments so this is still a bit of a toy example doing more than that is hard though without support for more primitives written in the parent language than i ve implemented the obvious thing i m missing is a native implementation of upvalue which is tcl primitive allowing you to affect update variables in higher scopes without that you can t write things as nicely as you would like and have to fall back to horrid hacks or be unable to do things define a procedure to run a body n times proc repeat n body set res while n 0 decr n set res body res test it out set foo 12 repeat 5 incr foo foo is now 17 i e 12 5 a similar story implementing the loop word which should allow you to set the contents of a variable and run a body a number of times proc loop var min max bdy result set res set the variable horrid we miss upvalue here eval set var set min run the test while set var max set res bdy this is a bit horrid we miss upvalue here and not for the first time eval incr var return the last result res loop cur 0 10 puts current iteration cur min max output is current iteration 0 0 10 current iteration 1 0 10 that said i did have fun writing some simple test cases and implementing assert assert_equal etc in conclusion i think the number of required primitives needed to implement your own control flow and run time behaviour is a bit higher than i d like writing switch repeat while and similar primitives inside tcl is harder than creating those same things in forth for example tags github golang tcl no comments writing a simple tcl interpreter in golang 21 june 2022 13 00 recently i was reading antirez s piece tcl the misunderstood again which is a nice defense of the utility and value of the tcl language tcl is one of those scripting languages which used to be used a hell of a lot in the past for scripting routers creating guis and more these days it quietly lives on but doesn t get much love that said it s a remarkably simple language to learn and experiment with using tcl always reminds me of forth in the sense that the syntax consists of words with arguments and everything is a string well not really but almost some things are lists too of course a simple overview of tcl would probably begin by saying that everything is a command and that the syntax is very free there are just a couple of clever rules which are applied consistently to give you a remarkably flexible environment to get started we ll set a string value to a variable set name steve kemp steve kemp now you can output that variable puts hello my name is name hello my name is steve kemp ok it looks a little verbose due to the use of set and puts is less pleasant than print or echo but it works it is readable next up interpolation we saw how name expanded to steve kemp within the string that s true more generally so we can do this set print pu set me ts print me hello world hello world there print and me expanded to pu and ts respectively resulting in puts hello world that expansion happened before the input was executed and works as you d expect there s another form of expansion too which involves the and characters anything within the square brackets is replaced with the contents of evaluating that body so we can do this puts 1 1 expr 1 1 1 1 2 perhaps enough detail there except to say that we can use and to enclose things that are not expanded or executed at parse time this facility lets us evaluate those blocks later so you can write a while loop like so set cur 1 set max 10 while expr cur max puts loop cur of max incr cur anyway that s enough detail much like writing a forth interpreter the key to implementing something like this is to provide the bare minimum of primitives then write the rest of the language in itself you can get a usable scripting language with only a small number of the primitives and then evolve the rest yourself antirez also did this he put together a small tcl interpreter in c named picol picol a tcl interpreter in 550 lines of c code other people have done similar things recently i saw this writeup which follows the same approach partcl a tiny command language so of course i had to do the same thing in golang https github com skx critical my code runs the original code from antirez with only minor changes and was a fair bit of fun to put together because the syntax is so fluid there s no complicated parsing involved and the core interpreter was written in only a few hours then improved step by step of course to make a language more useful you need i o beyond just writing to the console and being able to run the list operations would make it much more useful to tcl users but that said i had fun writing it it seems to work and once again i added fuzz testers to the lexer and parser to satisfy myself it was at least somewhat robust feedback welcome but even in quiet isolation it s fun to look back at these legacy languages and recognize their simplicity lead to a lot of flexibility tags github golang tcl no comments a plea for books 3 may 2022 20 00 recently i ve been getting much more interested in the retro computers of my youth partly because i ve been writing crazy code in z80 assembly language and partly because i ve been preparing to introduce our child to his first computer an actual 1982 zx spectrum cassette deck and all no internet no hi rez graphics easily available basic and as a nice bonus the keyboard is wipe clean i ve got a few books books i ve hoarded for 30 years but i d love to collect some more so here s my request if you have any books covering either the z80 processor or the zx spectrum please consider dropping me an email i d be happy to pay 5 10 each for any book i don t yet own and i d also be more than happy to cover the cost of postage to finland i d be particularly pleased to see anything from melbourne house and while low level is best the coding books from usbourne the mystery of silver mountain etc etc wouldn t go amiss either i suspect most people who have collected and kept these wouldn t want to part with them but just in case tags books spectrum z80 3 comments porting a game from cp m to the zx spectrum 48k 26 april 2022 20 00 back in april 2021 i introduced a simple text based adventure game the lighthouse of doom which i d written in z80 assembly language for cp m systems my game is on github here https github com skx lighthouse of doom it was discussed on hacker news at the time https news ycombinator com item id 26946130 as it was recently the 40th anniversary of the zx spectrum 48k the first computer i had and the reason i got into programming in the first place it crossed my mind that it might be possible to port my game from cp m to the zx spectrum to recap my game is a simple text based adventure game which you can complete in fifteen minutes or less with a bunch of paw patrol easter eggs you enter simple commands such as up down take rug etc etc you receive text based replies you can t see a telephone to use here my code is largely table based having structures that cover objects locations and similar state things most of the code involves working with those objects with only a few small platform specific routines being necessary clearing the screen pausing for a short while reading a line of input from the user sending a terminated string to the console etc my feeling was that i could replace the use of those cp m functions with something custom and i d have done the 99 of the work of course the devil is always in the details let s start to begin with i m lucky in that i m using the pasmo assembler which is capable of outputting tap files which can be loaded into zx spectrum emulators i m not going to walk through all the code here because that is available within the project repository but here s a very brief getting started guide which demonstrates writing some code on a linux host and generating a tap file which can be loaded into your favourite emulator as i needed similar routines i started working out how to read keyboard input clear the screen and output messages which is what the following sample will demonstrate first of all you ll need to install the dependencies specifically the assembler and an emulator to run the thing apt install pasmo spectemu x11 now we ll create a simple assembly language file to test things out save the following as hello z80 code starts here org 32768 clear the screen call cls output some text ld de instructions de points to the text string ld bc instructions_end instructions bc contains the length call 8252 wait for a key ld hl 0x5c08 lastk ld a 255 ld hl a wkey cp hl wait for the value to change jr z wkey get the key and save it ld a hl push af clear the screen call cls show a second message ld de you_pressed ld bc you_pressed_end you_pressed call 8252 output the ascii character in a ld a 2 call 0x1601 pop af call 0x0010 loop forever simple demo is simple endless jr endless cls ld a 2 call 0x1601 rom_open_channel call 0x0daf rom_cls ret instructions defb please press a key to continue instructions_end you_pressed defb you pressed you_pressed_end end 32768 now you can assemble that into a tap file like so pasmo tapbas hello z80 hello tap the final step is to load it in the emulator xspect quick load load immed tap hello tap the reason i specifically chose that emulator was because it allows easily loading of a tap file without waiting for the tape to play and without the use of any menus if you can tell me how to make fuse auto start like that i d love to hear i wrote a small number of cp m emulation functions allowing me to clear the screen pause prompt for input and output text which will work via the primitives available within the standard zx spectrum rom then i reworked the game a little to cope with the different screen resolution though only minimally some of the text still breaks lines in unfortunate spots bios z80 the end result is reasonably playable even if it isn t quite as nice as the cp m version largely because of the unfortunate word wrapping and smaller console area so now my repository contains a tap file which can be loaded into your emulator of choice available from the releases list here s a brief teaser of what you can expect outstanding bugs well the line input is a bit horrid and unfortunately this was written for cp m accessed over a terminal so i d assumed a standard 80x25 resolution which means that line word wrapping is broken in places that said it didn t take me too long to m...
|