Programming

This page collects blog pages concerned with programming: the writing of code or the reading of books about the writing of code.

2021-04-20 Writing 2D Cellular Automata using uxn

Uxn is a portable 8-bit virtual computer inspired by forth-machines, capable of running simple tools and games programmable in its own esoteric assembly language. The distribution of Uxn projects is not unlike downloading a ROM for a console, as Uxn has its own emulator.

It comes with a few programs out of the box, a simple drawing program, a simple tracker, a simple editor.

It’s absolutely fascinating!

Sadly, I also don’t know how to write assembler, or how to think assembler, and I think I would need a very, very simple idea to get started. Something like a 2D game of life visualisation or something like that.

There’s this super short introduction to assembly and to uxambly, the programming language for the Uxn stack-machine. That’s all I had.

The idea was simple: have a line of cells. Every generation, a cell lives if it has at least one live neighbour and it dies if the neighbours are either both alive or both dead. Draw a dot for every live cell, draw a row for every generation.

Here’s the code that I managed to write over the last few days.

%RTN { JMP2r }
%GOTO { JMP2 }
%GOSUB { JSR2 }

( devices )

|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 }
|0140 ;Controller { vector 2 button 1 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
|0170 ;File { vector 2 pad 6 name 2 length 2 load 2 save 2 }
|01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 }

( program )

|0200 

	( theme ) #54ac =System.r #269b =System.g #378d =System.b
	,main GOTO

BRK

@main ( -- )

	( run for a few generations ) #00 #FF
	$loop
		OVR #00 SWP ,print-line GOSUB
		,compute-next GOSUB
		,copy-next GOSUB
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

BRK

( 64 cells )

@cell [ 0001 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
   	0000 0000 0000 0000 0000 0000 0000 0000
	0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
   	0000 0000 0000 0000 0000 0000 0000 0000 ]

@next [ 0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
   	0000 0000 0000 0000 0000 0000 0000 0000
	0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
   	0000 0000 0000 0000 0000 0000 0000 0000 ]

@print-line ( y -- )
	( set ) =Screen.y
	
	( loop through 64 cells ) #00 #FF
	$loop
		( copy ) OVR #00 SWP DUP2
		( pos  ) =Screen.x
		( addr ) ,cell ADD2
		( draw ) PEK2 =Screen.color
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

RTN

@compute-next ( -- )
	( loop through 62 cells ) #01 #FE
	$loop
		OVR DUP DUP ( three copies of the counter )
		#01 SUB #00 SWP ,cell ADD2 PEK2
		SWP
		#01 ADD #00 SWP ,cell ADD2 PEK2
		( the cell dies if the neighbors are either both dead or both alive, i.e. Rule 90 )
		NEQ
		( one copy of the counter and the life value )
		SWP #00 SWP ,next ADD2 POK2
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

RTN

@copy-next ( -- )

	( loop through 64 cells ) #00 #FF
	$loop
		OVR DUP ( two copies of the counter )
		#00 SWP ,next ADD2 PEK2 ( one copy of the counter and the value )
		SWP #00 SWP ,cell ADD2 POK2
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

RTN

Looks like a Sirpinski triangle

Looks like a Sierpiński triangle!

If you have suggestions for my assembler code, let me know!

Comments on 2021-04-20 Writing 2D Cellular Automata using uxn

Now with a small pseudo-random number generator!

%RTN { JMP2r }
%GOTO { JMP2 }
%GOSUB { JSR2 }

;seed { x 1 w 2 s 2 }

( devices )

|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 }
|0140 ;Controller { vector 2 button 1 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
|0170 ;File { vector 2 pad 6 name 2 length 2 load 2 save 2 }
|01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 }

( program )

|0200 

	( theme ) #2aac =System.r #269b =System.g #378d =System.b
	,main GOTO

BRK

@main ( -- )

	,seed-line GOSUB
	( run for a few generations ) #00 #FF
	$loop
		OVR #00 SWP ,print-line GOSUB
		,compute-next GOSUB
		,copy-next GOSUB
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

BRK

( cells )

@cell [ 0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
   	0000 0000 0000 0000 0000 0000 0000 0000
	0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
   	0000 0000 0000 0000 0000 0000 0000 0000 ]

@next [ 0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
   	0000 0000 0000 0000 0000 0000 0000 0000
	0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
        0000 0000 0000 0000 0000 0000 0000 0000
   	0000 0000 0000 0000 0000 0000 0000 0000 ]

@print-line ( y -- )
	( set ) =Screen.y
	
	( loop through cells ) #00 #FF
	$loop
		( copy ) OVR #00 SWP DUP2
		( pos  ) =Screen.x
		( addr ) ,cell ADD2
		( draw ) PEK2 =Screen.color
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

RTN

@compute-next ( -- )
	( loop through 62 cells ) #01 #FE
	$loop
		OVR DUP DUP ( three copies of the counter )
		#01 SUB #00 SWP ,cell ADD2 PEK2
		SWP
		#01 ADD #00 SWP ,cell ADD2 PEK2
		( the cell dies if the neighbors are either both dead or both alive, i.e. Rule 90 )
		NEQ
		( one copy of the counter and the life value )
		SWP #00 SWP ,next ADD2 POK2
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

RTN

@copy-next ( -- )

	( loop through cells ) #00 #FF
	$loop
		OVR DUP ( two copies of the counter )
		#00 SWP ,next ADD2 PEK2 ( one copy of the counter and the value )
		SWP #00 SWP ,cell ADD2 POK2
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

RTN

@seed-line ( -- )
	#00 =DateTime.refresh
	~DateTime.second =seed.x #0000 =seed.w #e2a9 =seed.s
	( loop through cells ) #01 #FE
	$loop
		OVR ( one copy of the counter )
		,rand GOSUB
		#10 AND ( pick a bit )
		SWP #00 SWP ,cell ADD2 POK2
		( incr ) SWP #01 ADD SWP
		( loop ) DUP2 LTH ^$loop JNZ
	POP2

RTN

( https://en.wikipedia.org/wiki/Middle-square_method )

@rand ( -- 1 )
	~seed.x #00 SWP DUP2 MUL2
	~seed.w ~seed.s ADD2
	DUP2 =seed.w
	ADD2
	#04 SFT SWP #40 SFT ADD
	DUP =seed
RTN

Random noise

– Alex 2021-04-22 18:49 UTC


Related stuff by @eloquence:

– Alex 2021-04-23 09:31 UTC

Add Comment

2021-02-02 Skip the first two files in the shell

On my Windows box, when I’m not using Emacs, I often listen to music using Cygwin and mpg123.exe... Yikes, but also yay‽

I have a folder full of mp3 files and want to start playback with the second file but all I know is this: mpg321 *.mp3. Is there some bash thing to shift that list of expansions by one, two or three?

This works:

IFS=$'\n'
mpg123 $(ls Music/Rachmaninov/All-night\ Vigil/*.mp3|tail +3)

Thanks, @Whidou, @specter, @craigmaloney.

This also works, using arrays:

readarray -d '' files < <(printf '%s\0' Music/Rachmaninov/All-night\ Vigil/*.mp3)
mpg123 "${files[@]:9}"

Thanks, @notclacke.

I finally discovered my initial attempt with set -- *.mp3; shift; mpg123 "$*" didn’t work. I need to use "$@" instead!

set -- Giana\ My\ Invisible\ Friend/*.mp3
shift 2
mpg123 "$@"

Thanks, @etam.

Various looping constructs where also suggested:

i=0; for f in *; do i=$((i+1)); if [[ $i -lt 2 ]]; then continue; fi; mpg123 "$f"; done

That one has the benefit of being as easy to understand as the ls/tail construct above! Thanks, @dredmorbius.

Add Comment

2020-12-17 Drafts

Recently, JFM was wondering about drafts. Do you use drafts? I don’t. My brain doesn’t register my own typos and missing words. Sometimes a kind soul like Björn Buckwalter edits my wiki and fixes some of my typos. Thank you so much! So what that means is that I publish early and I publish often.

As soon as most of what I want to say is there, I save it, and by saving it I also publish it. And then I reread it. It looks different when I read it outside of my regular editing buffer. Perhaps it’s the line wrapping, who knows. And I often return to posts after a day or two, and then if it was interesting, I’ll return even later. I’ll edit the main page if that’s what needs changes, and I’ll add comments if I found new material, sometimes just links and excerpts.

For a while, I was worried about the feed. These days, I try to use the following strategy: the first edit is a “major” edit and gets noticed in the default feed and is what you’ll see in the default list of Recent Changes. Future edits of my own pages are marked as “minor” edits, excluding them from the default feed, and from Recent Changes. There are ways to find them, and to subscribe to them, but I think for casual readers that’s not too important. Any comments I leave always count as a major change, but the default feed doesn’t list comment pages.

Back when I thought I needed drafts I implemented a system I felt was “simpler”: the wiki simply offered a single draft file per user as determined by your username (which isn’t protected). But then I ended up never using it. And I don’t edit text files locally with the intention of saving them “eventually”. I’m typing this here, without saving it, hoping that my editor makes automatic backups, and then I’ll post it, immediately.

JFM mentioned how hard it was to work on multiple drafts in a folder of essentially independent files using a version control software that uses change sets. That makes sense to me. I guess what I would do is use RCS, the predecessor of CVS. It’s a single file version control system. The only strange thing is that per default, there are no files in your working directory. It’s empty, except for the invisible “.RCS” directory. You use “rcs checkout FILE” to check out a read-only copy of FILE. Now you have a file to read. You use “rcs checkout -l FILE” to lock the file (important on a multi-user system). Now you can make changes to the file and when you’re happy, use “rcs checkin FILE” to commit the file. You’ll be asked for a commit message. And then the file is gone again. You’re free to checkout a read-only copy again, of course.

The commands “ci” and “co” do the same thing with less typing.

It’s weird to see that this super old version control system is still available on my system. Good times! 😀

Anyway, for the longest time I kept my config files using RCS. Their changes are all independent of each other, after all. But these days I use git for everything. It’s just less of a mental burden, I guess.

Comments on 2020-12-17 Drafts

As I’ve mentioned before (in the comments to Blogging Spirit) I think one of the coolest things about your blog is that it is a wiki. The coolest is your thoughtful and sincere writing, of course! 🙂

– Björn Buckwalter 2020-12-20 13:57 UTC


Thank you for the kind words! 😀

– Alex 2020-12-20 15:10 UTC

Add Comment

2020-12-12 Computer Competency

Recently, @hisham_hm wrote: “We need dumb tech and smart users, and not the other way around.” He expanded on that on his blog: Smart tech — smart for whom? He talks about the distinction between smart devices and computers and picks game consoles as an example:

… they are not universal machines for you, the owner. For me, my Nintendo Switch is just a game console. For Nintendo, it is a computer: they can install any kind of software in it in their next software update. … From Nintendo’s perspective, the Switch is a universal machine, but not from mine.

At the time, I was more interested in the concept of smart users. @phoe asked: “Is there any industry standard for ensuring that we get smart users? Any best practices to follow?”

What do you think enables smart users? Good question! I’d say allowing people to use a tool without a simplified interface, and to share both data (files, URLs) and behavioural changes (Excel macros, configuration files, Emacs lisp files, and so on) are two examples for independent expertise growth. People can figure something out, add functionality in some way, and communicate this improvement to others without having to ask anybody for their blessing. You don’t have to recompile the tool, and the tool provides a way to extend itself in a shareable way. Expertise can develop, and the transfer from person to person means that domain-specific expertise can develop. You can adapt the editor for your team. You can write Excel sheets for your department.

@dredmorbius wrote something related about the minimal viable user on Reddit. It’s not the same thing, but it’s related. There, he explores the problems that arise in software development. One of them is complexity. A solution should be as simple as possible but no simpler. Conversely a complex problem requires a complex solution. You can cut every Gordian Knot. And yes, there are always places where complexity arises by necessity: whenever interfacing with complex domains: shells, editors, development environments, databases, emails.

Rereading that collection of thoughts brings back the OECD report. It’s devastating, and raises the question of what “smart users” might actually mean. The Nielsen Norman Group has a great summary. They count four levels of proficiency, if you know how to use a computer. This is important, because a full 26% of the adult population was unable to use a computer. A quarter! 14% are “below level 1”. They can perform a simple, straight forward tasks like “delete this email message.” That’s 40% of the adult population. 29% of the population are at level 1. They can use a widely used tool like email software or a web browser. They can perform straight forward tasks like “find all emails from John Smith.” That’s 69% of the adult population. Another 26% of the population are at level 2. They can perform multi-step tasks like “find a sustainability-related document that was sent to you by John Smith in October last year.” That’s 95% of the population. Only the remaining 5% can solve problems that involve setting sub-goals and assessing progress, evaluating relevance, reliability and so on. The example task provided is to determine “what percentage of the emails sent by John Smith last month were about sustainability.”

5%. This is underappreciated. I certainly did not appreciate this.

To me, this means that I’ve made peace with the fact that there will forever be different tech stacks, sadly. There is no point in getting people to use GNU/Linux and Emacs and all that, unless they’re extremely simplified. I’m not saying that Windows or macOS are specifically better because they’re also hard to use. These kinds of general machines are hard to use. All of them. These people are confused by the note-taking app on your phone because it magically involves your email account via IMAP. Even I find that confusing!

What makes is fundamentally impossible to solve this problem? Why is computing so much harder than driving a car? @yaaps said, “computer technologies have actively sabotaged the capacities of the user base.” And that is true. But that’s not the only problem. A computer is not a car. Many people know how to drive a car. Is it because of a grand unified user interface, good manuals, the ability to tinker with cars? Not at all.

In my experience, everything other than the pedals is random. Manual transmission or not, where the lights and the window wipes are, how to drive backwards, and so on. I remember sitting in a rental car with my wife in France and we couldn’t leave the parking lot. A certain sequence of actions was required to start it up and we didn’t know it. And yet, the number of controls of a car is minuscule compared to a computer.

The computer is more complex than a car, and people have much less experience. There is an “embodiment” in the car driving experience: here you are in the car. Turn a wheel, make a curve. Here’s the road. Here’s a car. Here’s a parking lot. All these things we know from walking around, from play, from life as kids. They relate through each other through space and physics, and we can observe their interactions. We can infer the rules of speed, of momentum, of breaking and turning, from experience, from our body reacting to physical forces. We all start without that on a computer. Or at least my generation did. And older people are worse – and I’m not convinced that people get better.

Turning back to the OECD report on computer skill levels. Even if computers are being designed like simple tools, dumbed down, how much more gain can we expect in computer skill levels by changing that design? 7% instead 5% would be a 40% gain! But what about all the people that don’t know how to use a computer. They aren’t being helped. How will they get the experience people have with roads and cars whether they want it or not? I don’t think there is a way. Not any more. These people have lives and jobs, families and responsibilities, and they don’t need computers, they don’t want computers, and they don’t benefit from computers.

Maybe if we made people fear computers for spying on them, if we forced them to use computers to partake in civil life, like they need a car to go shopping in some parts of the world. Sadly, we’re getting there, slowly, and I’m not liking it.

That is why I end up being OK with simple devices for people with other priorities in life and old style personal computers – universal machines – for people who want and need them.

And we can have all these elements at play, all at the same time. I love text. I love programming. That’s why I use a laptop with GNU/Linux and Emacs. I don’t love tinkering with graphic cards and I don’t like upgrading my computers. That’s why I buy a gaming console every one or two decades and use them to play games. I think I stopped gaming on the PC after … Wing Commander II or something like that! 😁

That reminds me of something @rafial recently posted:

「Random insight of the night: every couple years, someone stands up and bemoans the fact that programming is still primarily done through the medium of text. And surely with all the power of modern graphical systems there must be a better way. But consider:

  • the most powerful tool we have as humans for handling abstract concepts is language
  • our brains have several hundred millennia of optimizations for processing language
  • we have about 5 millennia of experimenting with ways to represent language outside our heads, using media (paper, parchment, clay, cave walls) that don’t prejudice any particular form of representation at least in two dimensions
  • the most wildly successful and enduring scheme we have stuck with over all that time is linear strings of symbols. Which is text.

So it is no great surprise that text is well adapted to our latest adventure in encoding and manipulating abstract concepts.」

So true! And it brings back the discussion of the limitations of graphical user interfaces in the essay about the “minimal viable user”. Interesting discussions all around!

Comments on 2020-12-12 Computer Competency

@dredmorbius added the following tidbit worth remembering regarding computer skills: they depend on literary skills, and those challenges are actually well understood. He writes:

「Most advanced countries have basic literacy rates of 95--100%. But basic literacy is simply the baseline. The US has a four-grade rating:

  • Proficient: 13%
  • Intermediate: 44%
  • Basic: 29%
  • Below Basic: 14%

Source: 2003 National Assessment of Adult Literacy.

One third of US adults are at or below “basic” prose literacy.

Mind: A fair portion of these are nonnative speakers of English. Some border regions especially in Texas have remarkably low English literacy, they may be proficient in other languages.

But that’s a third of the population with a major impediment to significant computer proficiency, on what is a principally text-and-language-based interface.

Keep in mind that secondary school graduation rates have been well above 90% since the 1950s. Educational access shouldn’t be a major driver.」

I agree, if people can’t read and write well enough, and we seem to be incapable of raising that number, that puts an upper limit on what we can expect in terms of computer literacy.

As for what is possible, @clacke has a different take on the numbers:

「What I’m seeing is that 60% have reasonable to amazing literacy and yet they aren’t capable of combining simple programs into slightly less simple programs.

I blame mostly the programs and how we combine them.」

That goes back to a point @yaaps was making:

「 … computer technologies have actively sabotaged the capacities of the user base … People aren’t stupid and computing isn’t intrinsically hard. We’ve just created a computing environment hostile to learning … digital technology is hyper-fuckery struggling to achieve interplanetary scale」

Somewhere in here is our wriggling room.

– 2020-12-13 10:59 UTC

Add Comment

2020-11-20 Small computer

I’m interested in small computers. It’s hard to put it into words. In terms of aesthetics, I have this to offer: I like to log onto my laptop, use Emacs full-screen, with 20t font size. I know it’s not for everybody, but I like it.

My laptop running Emacs

One day… Emacs standing alone on a Linux Kernel. 😂 I must confess I like the fonts and colours of a graphical display. I use them sparingly, but I like them to be there. I don’t want to go back to the old terminals.

Anyway, using mostly Emacs, maximized and big, feels a bit like the earliest computers I had: first the ZX Spectrum 48k and then the C64. It’s weird: I’m booting a multi-user system, with a gazillion layers: there’s the kernel, the encrypted filysystem, the display manager, the window manager, layers upon layers, and then Emacs, Lisp, fonts, colours – it’s fantastic and dizzying.

But the old aesthetic is still there. Single user systems that boot quickly and then you’re not in a shell but in some sort of BASIC programming environment. A read-eval-print loop (REPL) of some kind.

I had such things on my Mastodon timeline and so I started to collect some links.

I’m not trying to stoke the fires of consumerism, honest! 😀 More than anything I’m looking for happy stories of people using them, not of people buying them, if that makes sense. Like, does your kid use it? Do you?

@tsturm said: “I have a Spectrum Next and I program for it on occasion as a fun little diversion from “normal” programming. I’ve done some Basic tutorials with the kid (10yr) and he enjoyed playing with it - and also enjoyed some of the 35-year-old games we were loading up.” Yay! This is exactly the kind of story I was hoping for!

@TauPan says: “The Cosmo is my daily driver right now and it’s really nice to have a proper keyboard with emacs org-mode, python2 and a proper shell with tmux and openssh always with me (via termux).”

All of this was triggered by me seeing posts about the DevTerm. Let’s have some links.

Links

DevTerm: “ClockworkPi v3.14 integrates up to 12 interfaces in the ultra-small size of 95x77mm, ensuring sufficient connectivity for your work and entertainment. Following an easy-to-upgrade modular design of CPU and memory, clockworkPi v3.14 allows you to freely choose a suitable “Core” for various application scenarios.”

The C64 (on a website that doesn’t work without Javascript): “The C64 is back, this time full-sized with a working keyboard for the dedicated retro home-computer fan. Featuring three switchable modes – C64, VIC 20, and Games Carousel. Connect to any modern TV via HDMI for crisp 720p HD visuals, at 60 Hz or 50 Hz.”

Spectrum Next: “an updated and enhanced version of the ZX Spectrum totally compatible with the original, featuring the major hardware developments of the past many years packed inside a simple (and beautiful) design by the original designer, Rick Dickinson, inspired by his seminal work at Sinclair Research.”

MakerLisp Machine: “a portable, modular computer system, designed to recapture the feel of classic computing, with modern hardware. The CPU is a Zilog eZ80 running at 50 MHz, which supports up to 16 MB of zero wait state RAM. The system software is ’MakerLisp’, a ’Lisp on Bare Metal’ system that allows direct access to system hardware, while providing the concise expressive power of a functionally complete Lisp environment.”

Raspberry Pi 400: “Featuring a quad-core 64-bit processor, 4GB of RAM, wireless networking, dual-display output, and 4K video playback, as well as a 40-pin GPIO header, Raspberry Pi 400 is a powerful, easy-to-use computer built into a neat and portable keyboard.”

BMC64: “a bare metal fork of VICE’s C64 emulator optimized for the Raspberry Pi. It has 50hz/60hz smooth scrolling, low video/audio latency and a number of other features that make it perfect for building your own C64 replica machine. For more details visit the github link below.”

RISC OS: “It’s small. It’s fast. RISC OS is a full desktop OS, where the core system including windowing system and a few apps fits inside 6MB. It was developed at a time when the fastest desktop computer was an 8MHz ARM2 with 512KB of RAM. That means it’s fast and responsive on modern hardware. The memory taken by apps is usually counted in the kilobytes. A 700MHz 256MB Raspberry Pi is luxury - what to do with all that memory?”

Gemini PDA and Cosmo Communicator: “The size of a smartphone, with the capabilities of a laptop. Work, create and socialise on the move with a single device.”

Comments on 2020-11-20 Small computer

2020-11-20 Geolocation using Exif data and Open Street Map

As I’ve shared this Perl script twice, now, I figured perhaps it should be on the blog as well. It allows me to tell where a picture was taken, if and only if the picture contains geolocation metadata, which most cell phone images should. I also used to have a regular camera with a built-in GPS, but then I bought a camera that took better pictures and had no GPS…

#!/usr/bin/env perl
use Modern::Perl;
use Image::ExifTool;
use Geo::Coder::OSM;
use JSON;
use Data::Dumper;
binmode(STDOUT, ':utf8'); # force UTF-8 output
my $geocoder = Geo::Coder::OSM->new;
my $exifTool = Image::ExifTool->new;
$exifTool->Options(CoordFormat => q{%+.6f},
		   DateFormat => "%Y-%m-%d %H:%M:%S");
for my $file (@ARGV) {
  die "Cannot read $file" unless -f "$file";
  say "$file";
  $exifTool->ExtractInfo("$file");
  # Date
  my $date = $exifTool->GetValue('CreateDate', '');
  say $date if $date;
  # City
  my $lat = $exifTool->GetValue('GPSLatitude', '');
  my $long = $exifTool->GetValue('GPSLongitude', '');
  my $location = $geocoder->reverse_geocode(lat => $lat, lon => $long);
  die "No location data found\n" unless $geocoder->response;
  my $json = decode_json($geocoder->response->content);
  die $json->{error} . " $lat/$long\n" if $json->{error};
  say $location->{display_name} if $location;
}

Add Comment

2020-11-14 Computerless Computer Science

@zens has been sharing a ton of links about computerless computering on Mastodon. It all started with @neauoire asking for “anything relevant to paper computing, diy punchards machines, graph-paper coding, vedic mathematics, mechanical programming, and other things you have stumbled upon that you found interesting related to computerless computing?”

The Curta hand crank calculator, where multiplication is done by repeated addition.

Slide rules are graphical analogue calculators “At its simplest, each number to be multiplied is represented by a length on a sliding ruler. As the rulers each have a logarithmic scale, it is possible to align them to read the sum of the logarithms, and hence calculate the product of the two numbers.”

The whole Abacus field, including Chinese Suanpan and Japanese Soroban is super fascinating. The Roman section on the Abacus page has a picture where you can see the use of pebbles (calculi).

The entire complex of tools built relating to the stars is fascinating, from the Antikythera Mechanism to the Sextant and the Astrolabe.

The MONIAC: “The MONIAC (Monetary National Income Analogue Computer) … was created in 1949 … to model the national economic processes … The MONIAC was an analogue computer which used fluidic logic to model the workings of an economy.”

Ramakrishnan VU3RDD @vu3rdd linked me to CS Unplugged which appears to be something in the same vein, where kids are taught CS concepts without using a computer.

Add Comment

2020-10-31 Quadtree fractals, again

A few days ago I wrote about @l3kn’s quad.

I decided to write a little stand-alone web application to do something similar. It was a fun project, and I didn’t want to do it in C. 😅

I’ve named it Sitelen Musi, that is “entertaining pictures”. It’s a stand-alone HTML file with some Javascript, everything happens inside your browser.

Here’s the code for “The War of the Triangles”:

1a 3 1b 2 1c 2 1d 2
2a white 2c 2 2b 2 2d 2
3c white 3a 3 3b 3 3d 3

Screenshot

Add Comment

2020-10-18 Fractals

@neauoire’s dotgrid, and the C variant, seems to have inspired @l3kn to write a similar small C program called quad using the SDL library to create fractals. You can read more about the general idea on Leon’s blog post Quadtree Grammars. Anyway, I decided to download the program and give it a whirl!

The first problem was that my laptop monitor is too small. I therefore had to halve the constants for SIZE, MENU_SIZE and MENU_WIDTH. (Note that this is now much improved: you can provide the size on the command line as an argument!)

The next problem was the user interface with no explanation. (Note that this is now also much improved!) You basically have to stare at the definition in the menu on the left and reproduce it in order to get it: start with the first square; into the four quadrants you either drag some patterns from above, or you drag one of the tiny squares from elsewhere in the menu, and do that recursively – in order to generate the sub-quadrants... recursively. It is a fractal, after all. Essentially, you have eight “rules” to generate the four quadrants and you start with the first one.

Here’s a little progression of increasingly complex fractals:

Image 1 Image 2 Image 3

As I recently mentioned Postscript, also note the Quadtree Grammars using Postscript blog post. So cool!

Tags:

Comments on 2020-10-18 Fractals

Here’s a simple variant coded up as a web app: Sitelen Musi.

– Alex Schroeder 2020-10-29 23:42 UTC


Things I’d like to add: png export at higher resolutions; recomputing as you type; export url.

– Alex Schroeder 2020-10-30 10:16 UTC

Add Comment

More...

Comments


Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Just say HELLO