Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

CobraPy: baby steps

Some con­text: I am do­ing a sort of mod­ern retro-pro­gram­ming en­vi­ron­men­t-thingie.

So ... I caved. I caved and start­ed typ­ing.

It's still just ex­plorato­ry, fool­ing around, but I want­ed to see whether the vague ideas I had about how this could, maybe work were right, and hey, they are!

Text Mode

I want­ed a text mod­e. Some­thing with N rows and M col­umns where you could just say "put this text there". Done. In the most ba­sic pos­si­ble way that work­s.

Implemented a print_at function that takes row, column and text, and does what it says in the label.

Immediate Graphics Mode

In these old com­put­ers you could just draw in the graph­ics mem­o­ry. In 2020 ... not so much. So, I im­ple­ment­ed a sort of off­screen buf­fer. You draw there, and it gets blit­ted a lot to screen. Ends up work­ing like a flick­er-free dou­ble-buffered screen! Nice!

Implemented ellipse which ... draws an ellipse. I know, surprising.

Interpreter / Prompt

It would not be 80s-­like if you could not do those things in­ter­ac­tive­ly. So, yes, you can.

Now that was in­ter­est­ing. you see, nowa­days you are sup­posed to have an event loop. The com­put­er is there, idling and when some­thing hap­pen­s, then it does some­thing. So, you clicked? It re­act­s. 10 mil­lisec­onds passed? It does its thing.

In the 80s it was not like that. Your pro­gram start­ed and it owned the ma­chine. It went through your code, run­ning it as fast as it could with its lit­tle two-mega­herz-­heart un­til it ran out of code and then it was done.

So, how to make it act like that?

  • Start the event loop.
  • Start a sec­ond thread with a promp­t.
  • Have the us­er in­ter­act with the promp­t.
  • When the user presses Enter ... send the command to the event loop via a queue.
  • When the event ar­rives, do the thing.

And yes, it work­s! It's prob­a­bly hor­ri­ble for per­for­mance, but it does work just fine, and it's much, much eas­i­er to make a work­ing pro­gram fast than it is to make a fast pro­gram work.

So, what's nex­t?

The Future

I may try to in­te­grate the prompt and the win­dow where the text and such is dis­played (right now it's in a ter­mi­nal) ... maybe sprites.

Af­ter that:

  • Make the API nice and use­ful (a few weeks of work)
  • Make the thing run well (a few days of work)
  • Do the jan­i­to­ri­al work to make it us­able by some­one else (a cou­ple days of work)
  • Sup­port it, doc­u­ment it, etc (8 to 30 years of work)

The Nerdy Details

  • To do the graph­ics I am us­ing py­glet
  • To do off­screen draw­ing I am us­ing Pil­low
  • Tool­ing in­cludes the usu­al sus­pect­s: Python 3.8, po­et­ry, pylin­t, flake8
  • Code (all 50 lines or so!) in GitHub

Yes, this means this "80s" thing is ac­tu­al­ly mul­ti­thread­ed hard­ware-ac­cel­er­at­ed OpenGL graph­ic­s. I know, I know.

Possible New Project

I'm Old

I have not start­ed a re­al se­ri­ous open source project in a while. Ok, that's a lie. I have start­ed a num­ber of things and aban­doned them, but the last soft­ware project I start­ed that had last­ing pow­er was Niko­la and that was in 2012!

I turned 7**2 a couple weeks ago, so I am officially old (it's the law!) and us olds get bored because we don't get all the tiktok and whatever you youn'uns do.

So, I am get­ting itchy, and have been think­ing of start­ing some­thing. Af­ter see­ing a num­ber of retro­com­put­ing videos, it turns out the ZX-81 of my child­hood is vin­tage enough that they are ac­tu­al­ly old­er than ENI­AC was when I got it.

And it got me think­ing ... was there any­thing in that kind of com­put­ers that is worth sav­ing for some­thing oth­er than nos­tal­gia's sake? Sure, play­ing Mon­ty on The Run is as fun as al­ways and peo­ple still re­lease soft­ware for C64 and sim­i­lar an­cient com­put­er­s.

How­ev­er ... well, that sort of reeks of masochis­m, be­cause de­vel­op­ing for those sys­tem was ab­surd­ly painful. You can get the same lev­el of pain cod­ing for pi­co8 and peo­ple can play your games much eas­i­er.

There's al­so the retro-hard­ware thing but ... hon­est­ly, I like mod­ern hard­ware much bet­ter! For ex­am­ple, a Col­or Maximite looks much more fun that a C64 to de­vel­op in.

But stil­l.

There is this feel­ing that cur­rent com­put­ers are miss­ing some­thing.

Why not ex­plore it a lit­tle? I have a the­o­ry.

The Theory

Mod­ern com­put­ers are made to run things, old com­put­ers were not.

Get­ting some­one else's soft­ware in­to your com­put­er in 1984 was ab­surd­ly dif­fi­cult.

  1. Get a com­put­er (try do­ing that while liv­ing in Ar­genti­na in 1984)
  2. Now what? There's no In­ter­net
  3. Read the man­u­al and start cod­ing (yes, the man­u­al for the com­put­er ex­plained how)
  4. Fail
  5. Find some­one else who had a com­put­er and had ac­tu­al soft­ware for it
  6. Get copies. That of­ten in­volved copy­ing au­dio tapes. That would take be­tween 10 and 20 min­utes.
  7. Try out the copy on your com­put­er. Load­ing it in­to the com­put­er would al­so take be­tween 10 and 20 min­utes.

And af­ter that you had ... a port of Man­ic Min­er to C64 with crap­py sound.

So, some of us, we stuck a lit­tle to the oth­er side of those re­mark­able ma­chines. That they boot­ed in­to a de­vel­op­ment en­vi­ron­men­t. That you could make them do shit.

And that's what cur­rent com­put­ers don't do. They don't do shit. They don't in­vite you to start do­ing your own shit. Which is per­fect­ly and ag­gres­sive­ly fine, I don't mind. But I do.

The Plan in My Head

What would the evo­lu­tion of an 80s com­put­er look like nowa­days?

  • It should in­vite you to code and do shit
  • It should run on cheap, com­mod­i­ty hard­ware that is cheap and easy to find and buy
  • It should not do much out of the box. It's a box to do shit not to run shit.

There­fore, how about ...

A disk im­age that you can pop in­to a rasp­ber­ry Pi and...

  • Boots to a lim­it­ed en­vi­ron­ment
  • Where you can do shit
  • With fixed APIs and a pro­vid­ed soft­ware suite so that:
    • You can do some graph­ic­s, eas­i­­ly
    • You can do some sound, eas­i­­ly
    • You can ed­it a pro­­gram, eas­i­­ly
    • You can share it some­how, eas­i­­ly

Why the Pi?

  • It's fixed, known, cheap, sup­port­ed hard­ware.
  • You have IO pins to do ex­tra shit
  • It's cheap
  • Al­so, in­ex­pen­sive

What APIs?

  • Di­rec­t-ad­dress text mode (fake)
  • One or two graph­ics modes. 720p and 1080p?
  • Graph­ic prim­i­tives
  • Sprites! (hey, it's not the 80s with­out sprites)
  • Ba­sic mod play­ing
  • Some beep­ing thingie

What language?

Python. Sor­ry. I am play­ing with it, it's not go­ing to be BA­SIC.

Any weird thing?

Oh yes.

  • No im­port. You get the APIs you get.
  • Pro­grams are one file. You can use pack­ages in your big­boy box over there that has chrome in it.
  • No in­ter­net (no web brows­ing at least) just use your phone.
  • In­clud­ed sprite en­di­tor
  • In­clud­ed Mu­sic track­er

Are you really going to write this?

Well, I'm go­ing to give it a try and see if it's fun to do. If it's not I won't.

Are you looking for collaborators?

Nope. I want to do this so­lo at least for the first few month­s. My cod­ing at ear­ly project stages is way too er­rat­ic and would make ev­ery­one hate me.

What's it called.

It's nos­tal­gic. It's 80s. It has snakes in it. It should be Co­bra Kai.

But be­cause copy­right ex­ist­s, it's Co­bra Py. Or maybe Co­bra Pie, be­cause there's al­so oth­er python things called Co­bra.

h/t to Gui­do de Ca­so for fig­ur­ing out the name.

El antiperonismo imaginario

Ayer vi esa ima­gen en un tweet y no es la pri­me­ra vez que veo al­go pa­re­ci­do. La in­ten­ción es­tá bue­na, la idea es mos­trar "el an­ti­pe­ro­nis­mo tie­ne es­ta ga­la­xia des­lum­bran­te de lu­ces de la in­te­lec­tua­li­da­d, mien­tras que el pe­ro­nis­mo só­lo tie­ne pa­ra mos­trar es­ta guir­nal­da na­vi­de­ña com­pra­da en On­ce"

Des­de ya que si bien esa es la in­ten­ción la eje­cu­ción es pro­ble­má­ti­ca.

Em­pe­ce­mos por lo ob­vio, el ex­po­nen­te del an­ti­pe­ro­nis­mo que te­ne­mos más a ma­no, el que hi­zo la ima­gen, no de­be ser tan bri­llan­te si no sa­be es­cri­bir "E­cha­rri". Pe­ro de­jé­mos­lo pa­sar, por­que hay pro­ble­mas un po­co más se­rio­s.

Al­gún an­ti­pe­ro­nis­ta vi­vo no tie­nen?

Bioy mu­rió en 1999, Bor­ges en 1986, Cor­tá­zar en 1984, Pia­z­zo­lla en 1992, Sá­ba­to en 2011. La re­le­van­cia ideo­ló­gi­ca de una opo­si­ción al pe­ro­nis­mo que ig­no­ra el pe­ro­nis­mo des­de Lu­der por­que es­ta­ba vien­do cre­cer las flo­res des­de aba­jo es, al me­no­s, cues­tio­na­ble.

Si uno bus­ca­ra un li­neup vi­vo de an­ti­pe­ro­nis­tas com­pa­ra­ble al de pe­ro­nis­tas que mues­tra se­ría al­go co­mo el co­lo­ra­do Li­ber­man, Vi­via­na Ca­no­sa, Mi­guel del Se­l, Ra­mon Díaz e Ivo Cu­tza­ri­da, que no se ve ta­aaaan ru­ti­lan­te, no?

Ob­via­men­te es fá­cil ele­gir a ma­no y des­pués de­cir "pe­ro mi­rá que zo­que­tes, es­to es lo me­jor que tie­nen" cuan­do el que eli­gió es uno mis­mo, ha­cien­do pa­sar la elec­ción pro­pia por una de­sin­te­re­sa­da e im­par­cial re­fle­xión de la rea­li­da­d, li­bre de de­ba­te.

Pe­ro aún así, hay un pro­ble­ma mu­cho más de fon­do. Que ese su­pues­to an­ti­pe­ro­nis­mo no exis­te.

Bor­ges es­ta­ba tan opues­to al co­mu­nis­mo de Sa­ba­to co­mo al pe­ro­nis­mo, el co­mu­nis­ta Sá­ba­to no de­be ha­ber apro­ba­do que Pia­z­zo­lla di­je­ra "a no­so­tro­s, los ar­gen­ti­no­s, nos fal­tó un per­so­na­je co­mo Pi­no­che­t. Qui­zás a la Ar­gen­ti­na le fal­tó un po­co de fas­cis­mo en un mo­men­to de su his­to­ria" y de he­cho un al­muer­zo con Vi­de­la le cos­tó la amis­tad de Cor­tá­zar que, des­pués de to­do, era bel­ga y de quien Bioy di­jo "No creo que Cor­tá­zar tu­vie­ra una in­te­li­gen­cia muy des­pier­ta y enér­gi­ca, des­de lue­go, sus con­vic­cio­nes po­lí­ti­cas co­rres­pon­den a con­fu­sos im­pul­sos co­mu­ni­ca­dos por un pa­té­ti­co tan­go in­te­lec­tua­l."

Po­dría se­guir así diez pá­gi­na­s, ar­man­do un pe­lo­tón de fu­si­la­mien­to cir­cu­lar don­de ca­da uno de esos nom­bra­dos cri­ti­ca al si­guien­te des­pia­da­da­men­te, con­ven­cién­do­te de que los otros son po­lí­ti­ca­men­te mal­va­do­s, in­com­pe­ten­tes, o sim­ple­men­te una ban­da de idio­ta­s.

Esa fi­la de "an­ti­pe­ro­nis­ta­s" es un re­jun­te de gen­te con ideas to­tal­men­te in­com­pa­ti­bles en­tre sí que la mi­tad de sus vi­das ni se ha­bla­ban en­tre ellos por­que se caían co­mo el cu­lo por po­lí­ti­ca.

Creo que la elec­ción de esas fi­gu­ras pa­ra re­pre­sen­tar a una su­pues­ta "in­te­lec­tua­li­dad an­ti­pe­ro­nis­ta" di­ce más del an­ti­pe­ro­nis­mo que del pe­ro­nis­mo, y no al­go bue­no. Creo que lo que mues­tra es una in­ca­pa­ci­dad pa­ra for­mar una idea, no di­ga­mos ya una ideo­lo­gía, ex­cep­to en opo­si­ción al pe­ro­nis­mo.

To­ma to­do lo que no es pe­ro­nis­mo y le pe­ga ma­za­zos has­ta que lo me­te en una bol­sa de ga­tos y la mues­tra or­gu­llo­so di­cien­do "es­ta bol­sa de ga­tos lla­ma­da an­ti­pe­ro­nis­mo con­tie­ne a Bor­ges, Bio­y, Cor­tá­za­r, Pia­z­zo­lla y Sa­ba­to" cuan­do en rea­li­dad lo que con­tie­ne son los res­tos he­chos bol­sa de esa po­bre gen­te ca­ga­da a gol­pes.

Por eso "la opo­si­ció­n" hoy en día es un re­fle­jo de lo mis­mo. Es Sanz y Ca­rrió y La­rre­ta y Fer­mi­nio y Ma­cri y Pi­ne­do y Vi­dal y Lous­teau y una com­par­sa cu­yo úni­co fac­tor uni­fi­can­te es que no son pe­ro­nis­ta­s, pe­ro que en cual­quier cir­cuns­tan­cia nor­mal se odia­rían en­tre sí y no pue­den ha­cer una pro­pues­ta co­he­ren­te por­que lo úni­co que los une es no ser pe­ro­nis­tas, lo mis­mo que ese re­jun­te de muer­tos fa­mo­so­s.

Eso, se­ño­ría­s, es pa­té­ti­co.

Lanata, el hombre de las 100 millones de bolsas y otros monstruos imaginarios

Ay­er domin­go 26 de julio de 2020 Jorge Lana­ta di­jo es­to, en tele­visión, sin pon­erse col­orado:

Cor­rec­ta­mente Lana­ta in­for­ma que es una com­pra di­rec­ta, y que no es­tá ad­ju­di­ca­da. Lamentable­mente has­ta ahí lle­ga la parte que in­for­ma cor­rec­ta­mente. Salen al­gunos tex­tuales con ex­pli­ca­ciones.

En el renglón 2 pi­den fun­das mor­tuo­rias por cien mil­lones de unidades

No. No pi­den cien mil­lones de unidades. Pi­den co­ti­za­ciones a provee­dores por has­ta cien mil­lones de unidades. Y si uno va y mi­ra el pliego puede ver lo sigu­ien­te:

  • Se ad­mite co­ti­zación par­cial por renglón Po­drán co­ti­zar, un­o, var­ios o to­dos los ren­glones
  • Se po­drá ad­ju­dicar un renglón par­cial­mente.
  • Ad­ju­di­cación por renglón

Es de­cir:

  • Los provee­dores pueden ofre­cer cualquier can­ti­dad de las cosas que quier­an vender has­ta 100 mil­lones de unidades
  • El es­ta­do puede com­prar cualquier can­ti­dad den­tro de lo que el provee­dor ofrece.

Por lo tan­to, ni al­guien va a vender cien mil­lones de nada, ni nadie va a com­prar cien mil­lones de na­da. El número cien mil­lones no sig­nifi­ca na­da.

so­mos 40

No, Jorge, so­mos 44 y pi­co.

Va a haber gente que se muera dos ve­ces

No, Jorge, na­da más es­tás di­cien­do pavadas para provo­car in­dig­nación de gente que to­davía te cree.

El pliego tiene 816 ren­glones

Si, Jorge, y to­dos di­cen cien mil­lones. ¿No te llamó la aten­ción?

Si bi­en la can­ti­dad de cien mil­lones que so­lic­i­tan es un tope máx­i­mo es cu­rioso que se haya elegi­do una cifra tan el­e­va­da.

¿Por qué? ¿Y si sabés que es un tope máx­i­mo, Jorge, por qué hacés co­mo si se es­tu­viera com­pran­do esa can­ti­dad? Ah si, cier­to que vivís de in­dig­nar gente al pe­do.

Hace fal­ta cien mil­lones de todo?

No, por eso no se com­pran cien mil­lones.

Va­mos a ver a quién se la ad­ju­di­can, a ver que ami­go gana.

No es­tá ad­ju­di­cado, lo con­tás de man­era en­gañosa, y enci­ma te hacés el de­tec­tor pre­mon­i­to­rio de cor­rup­tos. ¿No pasó na­da en la se­m­ana, Jorge?

De­bo con­fe­sar peca­dos de ju­ven­tud. Du­rante el men­e­mis­mo, me caía bi­en Lana­ta. ¿Es que con el Car­lo era tan fá­cil ser opos­i­tor, no?

Pero aho­ra, ver­lo ser así de patéti­co, hablar al pe­do de cosas que son la na­da mis­ma, tratar de in­flar un de­talle buro­cráti­co in­signif­i­can­te, ver co­mo se prende tan­to desin­for­ma­do que lo ve por la tele y le cree ...

De­bo con­fe­sar peca­dos pe­o­res, com­pré un li­bro de cuen­tos que es­cribió Lanata, Po­laroids. Has­ta me gustó un poco, tenía una his­to­ria so­bre co­mo se ro­baron el puente col­gante y yo, santafesino de­spués de todo, me sen­tí vis­to, me sen­tí parte de al­go, co­mo podía ser, che, mirá que lo­co to­do.

Nun­ca te voy a per­donar, Jorge. Nun­ca te voy a per­donar que fun­daste el úl­ti­mo di­ario bi­en es­crito de la Ar­genti­na, Críti­ca, y te fu­maste la gui­ta y ca­gaste a los que tra­ba­ja­ban ahí. Nun­ca te voy a per­donar que sa­bi­en­do es­cribir bi­en te hayas ca­ga­do en vos mis­mo y te hayas con­ver­tido en es­to que sos aho­ra.

Nun­ca te voy a per­donar, Jorge, que te faltes el re­speto de es­ta man­er­a. Que te hayas creí­do cuan­do te di­jeron que eras gra­cioso y hayas des­perdi­ci­a­do de es­ta man­era tu tal­en­to.

Que seas aho­ra es­ta car­i­catu­ra de vos mis­mo.

Es im­per­don­able, Jorge Lanata, que pu­di­en­do ser al­go re­al, seas este imag­i­nario hom­bre de las cien mil­lones de bol­sas.


Contents © 2000-2024 Roberto Alsina