The Intellectual Wilderness There is nothing more useless than doing efficiently that which should not be done at all.

2021.10.30 12:09

Nonsensical Surveys

Filed under: Science & Tech,Society — Tags: , , , , — zxq9 @ 12:09

At the bottom of some mystery fear porn article on MSN about it being such a puzzle that Japan is doing fine despite no mandates, no lockdowns, no shutdowns, etc. this survey appeared asking readers how they felt about about Japan’s “handling” of the situation:

This is ridiculous as there is no option for “This question is stupid because there was no meaningful ‘handling’ to be done” — which was basically what the article was all about (oh, but they made sure to totally mischaracterize the vaccination program here quite thoroughly — ivermectin is the main recommendation and several types of the vaccines have been banned for safety reasons, which isn’t at all how they portray the situation in the article, same with masks). The people who handled COVID the best so far have been the Amish.

2021.10.26 11:54

Space-Based Solar Done Right

Anyone who gives a bit of honest thought to the so-called “renewable energy” market cannot escape the conclusion that the vast majority of it is fake — politicians creating a moral panic to grant themselves unquestionable authority over appropriations and then handing appropriated funds over to losing ventures run by their friends and family that they themselves retire into as directors and board members. It’s a genius scam as scams go, but suffers from the fatal flaw of all scams: it accelerates the tragedy of the commons.

Imagine that, a scam that worsens the more general category of problems it claims to make better.

That said… “sustainable energy” is a genuine issue. Why use this other term? Because words mean things and there is literally no such thing as “renewable energy” as energy use is disruptive and we live in an entropic universe that mandates that energy cannot be renewed. This isn’t just an abstract philosophical idea, it’s physical law. Energy use can, however, be sustained over any foreseeable period of a future where humanity continues to thrive and that’s something we can think seriously about and come up with solutions for.

Terrestrially it is pretty clear that we have no idea what is going on with climate in any real sense and that we have almost completely prohibited ourselves from thinking clearly about climate change by moralizing it as a political issue. I am therefore going to ignore the idea of emissions and atmospheric content for just a moment and talk strictly about two things we know from general planetary science (studying other planets and planetoids):

  • Exposure to solar radiation correlates strongly with surface temperature
  • Atmospheric pressure correlates strongly with surface temperature

This means that even if I completely ignore carbon emissions (and health) that fossil fuels and other non-petroleum hydrocarbon use releases, these sources are also finite and have their own limitations regardless of the ZOMG DA CARBONSES moral panic. This also means that while I can accept that terrestrial power generation using atomic generation makes a lot of sense from a sustainable energy perspective, it still has limitations of scale: it is imaginable that we could simply use up the finite amount of available fuels at some point and/or find it difficult to build the sheer number of plants necessary to supply all of our energy needs (much less transmit the power once generated).

Terrestrial solar energy, wind power, various forms of ethanol, tidal power, current power, hydroelectric dams, etc. are all interesting but suffer from the same finiteness and scale problems that hydrocarbons and nuclear power have, but have an even greater and very direct environmentally disruptive impact by massive conversion of land use at scales never seen in human history. It just isn’t sustainable, much less reliable 24/7.

The bottom line is we need another solution for energy resources, and there just happens to be a massive nuclear furnace just a 150 gigameters away. Plenty of people have noted the obvious problems with terrestrial solar power and thought “Oh, hey, what if we just put solar farms into space and beam it back with lasers or microwaves?” In fact, Isaac Asimov gave quite a lot of thought to the idea and recently the idea has resurfaced across pop-sci media for whatever reason.

There is just one problem: While we don’t know anything for certain about the effects of “greenhouse gasses” we are quite certain about the effects of solar radiation — and solar farms in space effectively increase the radiation collecting surface of the planet.

To be clear: Space-based solar power that is beamed back to the planet literally microwaves Earth.

We can argue back and forth all day about the effects of carbon emissions on the climate, but one thing we cannot escape is the conclusion that increasing the surface area exposed to the Sun to any economically significant degree will have a warming effect on the planet.

Oh noes! I just shot down the great salvation of the human race! However can we still run PoW cryptofarms and transcoding servers for OnlyFans camwhores in AWS and Runscape servers and sexbot factories if we can’t access the delicious space power?!? The solution is actually quite easy and obvious: Put the hot process in space along with the solar arrays.

My prediction is that humanity will eventually begin building not just some, but the majority of server farms, data mines, and even industrial production sites in space. Continuing to put it all at the bottom of the terrestrial gravity well that we have a very strong desire to preserve is clearly not a sustainable idea. Space-based industry eliminates pollution issues, emissions concerns, is truly sustainable, and won’t microwave the planet.

The main problem with this idea is that people are retarded and don’t understand how non-crazy this concept is, and probably won’t until someone already has a set of self-powering and massively profitable space-based data services and perhaps even fabrication facilities in space — at which point the public will turn on them as “greedy rich people” and start moralizing about [random distraction] until the whole thing breaks down and has to be remade.

Anyway, that’s all I’ve got for today. Enjoy the crash!

2021.06.11 10:42

Building Erlang 23.3.4.3 on Devuan/Debian/Ubuntu

Filed under: Computing,Science & Tech — Tags: , , , , , , , , — zxq9 @ 10:42

Erlang R24 is out! …but there are, as usual with a version X.0 release, a few rough edges (enough of them around the important-but-annoying WX and OpenGL updates that I’ll be writing another post about that shortly…).

In the meantime, R23.3.4.3 is excellent and quite reliable. The steps for building with kerl are nearly identical as for R22, but it is worth re-posting them with the relevant version updates (or if you like the video version, Dr. Kumar made a few demonstrating his home Erlang + ZX build). Also, if you’re in a part of the world where erlang.org’s docs are occasionally really really sloooooooowwww don’t forget the R23 docs mirror (or my Erlang page with linky links to everything).

sudo apt update
sudo apt upgrade
sudo apt install \
    gcc curl g++ dpkg-dev build-essential automake autoconf \
    libncurses5-dev libssl-dev flex xsltproc libwxgtk3.0-dev \
    wget vim git
mkdir vcs bin
cd vcs
git clone https://github.com/kerl/kerl.git
cd ..
ln -s ~/vcs/kerl/kerl bin/kerl
kerl update releases
kerl build 23.3.4.3 23.3.4.3
kerl install 23.3.4.3 ~/.erts/23.3.4.3
echo '. "$HOME"/.erts/23.3.4.3/activate' >> .bashrc
. ~/.erts/23.3.4.3/activate
wget -q https://zxq9.com/projects/zomp/get_zx && bash get_zx

As usual, the ~/vcs/ directory is just my convention for version-controlled code that my $HOME sync scripts know to ignore, and you might want to install Erlang to some place global on your system like /opt/erts/ or whatever. The steps above work without root privileges with the exception of the apt commands. Remember if you are on Devuan or Debian that you need to perform the sudo commands actually as root unless you configure sudo on your system, then the rest as your normal local user account.

2021.06.4 09:26

確率事象

いくつかの無駄な考え:

  1. 天地万物はプランク限界でピクセル化されています。
  2. エベレットとボーアの解釈はどちらも正しい: 宇宙は遅延評価され、未来は「記憶」するには費用がかかりすぎる.
  3. 相対論的効果は、イベントの評価に必要な伝播遅延と削減バジェットのために発生する創発現象です。
  4. 確率は文脈から外れて滑らかに見えますが、ピクセル化とイベント順序の依存関係により、無限に小さな確率のイベントが実際に発生することが制限されます。
  5. 実数は偽物であり、有理数は実数です。 すべての数値には有限の解像度があります。
  6. 上記の点のために、残念ながらかなり多くの数学が間違っています (たとえば、真のタンジェントは、単一の値ではなく、そのスコープによって制限される範囲です)。 しかし、偽の数学は、その大部分が真っ赤な嘘であると認めれば、工学を完成させるのに十分に妥当な近似値です。
  7. 人は、自分の幻覚に夢中になりすぎて、上記のことを注意深く考えることができません。

2021.05.4 17:56

Tsuriai: Now engaging in smart contract work

I never thought I’d see the day, but Tsuriai (the tiny Japanese software company I work for) is now in the Ethereum smart contract market as a developer — which means I am now in that same market.

Need a smart contract or blockchain/IPFS-based project developers/consultants/educators*?
Just shoot the office an email at info@tsuriai.jp and they’ll hook you up.
They can even accept payment in ETH now, which makes it a lot easier to contract from overseas.

What a world!

[*Or, as always, Erlang developers or consultants, distributed systems analysis, and pretty much any other BEAM-related services, education or assistance!]

It is pretty well known that I don’t think smart contracts are going to save the world from itself because the problems in the US, Europe and China have everything to do with violations of social trust by government and lack of faith in people among the people themselves (as well as lack of faith in culture and tradition), but… smart contracts actually are kind of fun to write and our workflow is pretty darn fast.

There are clear use cases that fit the Ethereum-style computing paradigm and even some that clearly benefit from deployment on something like IPFS rather than a traditional server back end, and we can talk the client through the pros and cons. I suppose the most common thing to want to implement is NFTs at the moment, and some forms of NFTs (especially distributed name registry systems <hint!> <hint!>) are clearly extremely valuable solutions to otherwise difficult to administer problems.

2021.04.30 09:10

Valgrind “Hello, World!”: Python 3.6 VS Python 2.7 VS Erlang R23

I’ll just leave this here…

Python 3.6

ceverett@icecream:~/Code/python$ cat hello.py
#! /usr/bin/python3

print("Hello, world!")
ceverett@icecream:~/Code/python$ ./hello.py
Hello, world!
ceverett@icecream:~/Code/python$ valgrind ./hello.py
...
==19264== HEAP SUMMARY:
==19264==     in use at exit: 320,946 bytes in 166 blocks
==19264==   total heap usage: 1,698 allocs, 1,532 frees, 2,505,946 bytes allocated
==19264== 
==19264== LEAK SUMMARY:
==19264==    definitely lost: 0 bytes in 0 blocks
==19264==    indirectly lost: 0 bytes in 0 blocks
==19264==      possibly lost: 5,608 bytes in 10 blocks
==19264==    still reachable: 315,338 bytes in 156 blocks
==19264==         suppressed: 0 bytes in 0 blocks
...
==19264== ERROR SUMMARY: 8163 errors from 116 contexts (suppressed: 0 from 0)
ceverett@icecream:~/Code/python$

Python 2.7

ceverett@icecream:~/Code/python$ cat hello2.py 
#! /usr/bin/python

print "Hello, world!"
ceverett@icecream:~/Code/python$ ./hello2.py
Hello, world!
ceverett@icecream:~/Code/python$ valgrind ./hello2.py
...
==19416== HEAP SUMMARY:
==19416==     in use at exit: 417,246 bytes in 199 blocks
==19416==   total heap usage: 2,958 allocs, 2,759 frees, 3,085,205 bytes allocated
==19416== 
==19416== LEAK SUMMARY:
==19416==    definitely lost: 0 bytes in 0 blocks
==19416==    indirectly lost: 0 bytes in 0 blocks
==19416==      possibly lost: 528 bytes in 1 blocks
==19416==    still reachable: 416,718 bytes in 198 blocks
==19416==         suppressed: 0 bytes in 0 blocks
...
==19416== ERROR SUMMARY: 489 errors from 30 contexts (suppressed: 0 from 0)
ceverett@icecream:~/Code/python$

Erlang R23

(On this one I can include the entire output.)

ceverett@icecream:~/Code/erlang$ cat hello_world 
#! /usr/bin/env escript

% Example of an escript
-mode(compile).

main(_) ->
    ok = io:setopts([{encoding, unicode}]),
    io:format("Hello, world!~n").
ceverett@icecream:~/Code/erlang$ ./hello_world 
Hello, world!
ceverett@icecream:~/Code/erlang$ valgrind ./hello_world
==25872== Memcheck, a memory error detector
==25872== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==25872== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==25872== Command: ./hello_world
==25872== 
Hello, world!
ceverett@icecream:~/Code/erlang$

Hey, Python! What the actual fsck is going on here?!? Jeebus… The Good Idea Fairy came along and convinced the webtarded among you to start throwing kitchen sink features in (“walrus operator” — yeah, great idea, that, and totally worth losing the sober guidance of Guido over…) along with 8163 memory errors. Sweet! Oh how far the great have fallen…

Honorable mention: Ruby 2.5

I didn’t expect much better from Ruby as the Good Idea Fairy has been forwarding all xer mail there for years, but wow… just wow

ceverett@icecream:~/Code/ruby$ cat hello_world.rb 
#! /usr/bin/ruby

print "Hello, World!\n"
ceverett@icecream:~/Code/ruby$ ./hello_world.rb 
Hello, World!
ceverett@icecream:~/Code/ruby$ valgrind ./hello_world.rb
...
==27051== HEAP SUMMARY:
==27051==     in use at exit: 2,921,234 bytes in 20,690 blocks
==27051==   total heap usage: 65,312 allocs, 44,622 frees, 16,447,358 bytes allocated
==27051== 
==27051== LEAK SUMMARY:
==27051==    definitely lost: 385,479 bytes in 4,421 blocks
==27051==    indirectly lost: 640,953 bytes in 5,808 blocks
==27051==      possibly lost: 1,626,429 bytes in 9,663 blocks
==27051==    still reachable: 268,373 bytes in 798 blocks
==27051==         suppressed: 0 bytes in 0 blocks
...
==27051== ERROR SUMMARY: 162050 errors from 402 contexts (suppressed: 0 from 0)
ceverett@icecream:~/Code/ruby$

162,050 memory errors. For Hello, World. How can there even be 162,050 instructions in the resulting set of commands to the system?

2021.04.5 20:25

Erlang: Socket experiments preliminary to writing a web server from scratch

Filed under: Computing,Science & Tech — Tags: , , , , , , , — zxq9 @ 20:25

A relative newcomer to networking in Erlang, Dr. Ajay Kumar, has started a self-educational project to create a web server from scratch in Erlang to give himself some first-hand insight into how TCP sockets work in Erlang and how web servers work in general. Web servers are a thing almost everyone has written against or for, but few have tried to implement on their own because socket programming sounds scary and time consuming to learn.

This video is quite short but incidentally demonstrates how not scary socket programming is and how easy it is to experiment with networking concepts on your own. Go experiment! Write networky things! It’s fun!

As an aside to this… I have a two-part explanation video that explains everything that is going on inside the service at he is basing his web server on. In the first part I explain what is going on within the default chat server that ZX templates as a network service project (kind of slow, covers basics for Erlang and ZX newcomers), and in the second part I explain how I used that as a basis for creating a telnet chat service that implements global shouts, channels, permissions, and other basic features needed for a real chat service (a bit better paced if you already know your way around Erlang and discusses some higher-level concepts such as service structure and the “service -> worker pattern“).

2020.12.19 17:16

Erlang: Writing a Tetris clone Part 2 – Gameplay mechanics

Last night I was able to make the second video in my series about implementing a Tetris clone in Erlang. Yay!

In this video I start where I left off in the first video where I had ended with a data abstraction to represent the play field (called the “well” in Tetris lingo), a data abstraction for the game pieces, some colored sprites to draw the game board with, and a GUI that could draw a game board and a single random piece every time it was opened as well as print to stdout any key press events that I made.

Oh but by the way…

I have a small confession to make — I didn’t actually start where I left off. I mentioned the stopping point (the “Draw the board with a random piece on it” commit), then I mentioned the next thing I did which was implement basic movement (the “Basic (unsafe) movement” commit), then I completely blew past it and never explained the way I implemented unsafe movement in the first place. The trouble with having skipped that is that I had intended to discuss how keystroke capture actually works, where it is in the GUI code, and follow the event through the system so that people could get that idea into their head earlier than later because it is so basic to making a game!

So instead I’ll explain how that works and point out where it is in the code here in this post and cover it at the beginning of the third video.

Getting Input

If we look at the “Basic (unsafe) movement” commit there is a file called ertltris/src/et_gui.erl that is the code for the GUI process. In the init/1 function we see the wx server get started, a “frame” is created (the main window in wx parlance), some various widget elements and things are all established and on line 112 we see this:

ok = wxPanel:connect(Frame, char_hook),

This is connecting the Frame to a window manager event called char_hook. I do mention this in the video, but it is important to point this out here. I should also point out that I’m mistakenly calling wxPanel:connect/2 instead of wxFrame:connect/2 — which is technically incorrect, but due to the nature of the underlying inheritance among the C++ classes that make up wx and the way that’s all masked in the generated library wrappers that make up wxErlang, it actually doesn’t cause any errors. wxPanel and wxFrame are all ancestors of wxEventHandler.

Anyway… what connecting to this event does is tells wx that whenever the frame is the focus it should relay keystroke events to the program. Inside Erlang they arrive as messages that carry a #wx{} record that includes an event element that carries another record that provides all the relevant information about the event. You can receive these in the handle_event/2 callback function of wx_object. Pretty nice. This means you can deal with GUI events in very much the same way you can handle network events as well as inter-process messages within the Erlang runtime: everything is a message.

IDIOMS IDIOMS IDIOMS!

As I often say: Develop idioms.

A common idiom I use in wxErlang code is to match on an event type in handle_event/2, assign any relevant event data to variables, and then within a case inside the handle_event clause that matched that event type determine where we want to dispatch the event (if at all). You can see a very clear example of this on lines 191-203 of this commit.

handle_event(#wx{event = #wxKey{keyCode = Code}}, State = #s{frame = Frame}) ->
    ok =
        case Code of
             32 -> et_con:random_piece();
             88 -> et_con:rotate(l);
             90 -> et_con:rotate(r);
            314 -> et_con:move(l);
            315 -> et_con:rotate(r);
            316 -> et_con:move(r);
            317 -> et_con:move(d);
            _  -> tell("KeyCode: ~p", [Code])
        end,
    {noreply, State};

I could have made each one of those dispatch decisions inside the function head instead of using a case statement within a clause, but I find it much easier to read this particular style where we open a very compact dispatch span per event type we’re looking for than have a ton of handle_event clauses. In complex GUI applications you can wind up with a lot of special keystroke events and it becomes super cumbersome to match them all as function heads. Not just writing the function heads, but trying to find a specific event gets kind of messy because the code starts looking so scrambled.

Each of the different key codes matched in the dispatching part of that function correspond to some gameplay event. Note that the GUI doesn’t really care what the status of the game is at all, it just cares that it is relaying the mapped commands to the game control process and then carries on doing GUI stuff.

This is important to point out: Nearly all communication between the controller and the GUI is asynchronous. You almost never want blocking calls to pass between them. There may be a need for a blocking call in some special code, but this is almost always a bad idea.

Buh bye!

That pretty much sums up what I wanted to cover that I forgot to mention in the video. Input handling is really important. If you want to jump ahead, check out the way the handle_event/2 function evolved in the latest commits to see how menu commands are intercepted, or go check out the handle_event/2 function in the Erlang Minesweeper clone!

Don’t forget to give me all the delicious likes and stars and channel subs! BWAHAHA! I’ll catch you magnificent nerds in the next video!

2020.12.15 17:16

Erlang: Writing a Tetris clone Part 1 – Data types and basic GUI display

Over the last few days I wrote an Erlang implementation of the classic puzzle game Tetris and decided to do a few videos to explain how it works and why. This is part one of a three-part series.

  1. Data types and basic GUI display [this page]
  2. Gameplay mechanics
  3. Gameplay rules, final features, and deployment

This first video covers how I started the project (cheating using ZX to template a GUI project for me, of course), what data types I thought I would probably need from the outset (the game board and the game pieces), and my initial stab at getting pixels on the screen in a reasonably pretty way.

The videos roughly trace the commit history of the project as I developed it, with this first video covering the first 3 commits which get me from a GUI project template to displaying the game board and drawing a random piece in it each time I start the program (as well as catching keystrokes so I can examine what their values are).

2020.08.15 20:35

Building Erlang R23.0 on Debian/Ubuntu

Filed under: Computing,Science & Tech — Tags: , , , , , , , — zxq9 @ 20:35

As an update to my previous notes on building R22.2, my current notes for building Erlang R23.0 and installing ZX using kerl on a fresh system (Kubuntu 18.04 LTS) are below. The same instructions (or very nearly the same) should work for any Debian or Ubuntu version within a few years of 18.04 LTS.

sudo apt update
sudo apt upgrade
sudo apt install \
    gcc curl g++ dpkg-dev build-essential automake autoconf \
    libncurses5-dev libssl-dev flex xsltproc libwxgtk3.0-dev \
    wget vim git
mkdir vcs bin
cd vcs
git clone https://github.com/kerl/kerl.git
cd ..
ln -s ~/vcs/kerl/kerl bin/kerl
kerl update releases
kerl build 23.0 23.0
kerl install 23.0 ~/.erts/23.0
echo '. "$HOME"/.erts/23.0/activate' >> .bashrc
. ~/.erts/23.0/activate
wget -q https://zxq9.com/projects/zomp/get_zx && bash get_zx

[NOTE: ~/vcs/ is where I usually put “version control system” managed code and my backup and sync scripts know to never copy or update that one.]

And that’s that. If you’re on a full desktop installation some of the packages in the apt install [stuff...] may be redundant, of course (who doesn’t already have wget and git?), but that’s no big deal.

Older Posts »

Powered by WordPress