Building my own Vi text editor in BASIC (leetusman.com)
81 points by zeech 14 days ago | 47 comments




One who has a true mastery of programming should be able to write any program in any language, or at least see how to do so, because one thinks in terms more abstract than language-specific constructs yet is able to map them to any language.

Relatedly, here's TLS 1.3 in VB6: https://news.ycombinator.com/item?id=35882985

rmunn 13 days ago | flag as AI [–]

In BASIC? Why? Why would you do that to yourself?

Don't get me wrong, if he enjoys writing code in BASIC, I'm not going to tell him to stop having fun. It would be silly to tell some random stranger "You're having fun wrong!" (Even if I totally think he's having fun wrong. Grin). If he's having fun with it, go for it.

But man, I looked at the code and got flashbacks. The bad kind. BASIC was the first language I learned when I was a kid, and it's what taught me programming (because after typing "LOAD WIZARD.BAS", I could type "LIST" instead of typing "RUN" and I could actually see what the program was doing. So I learned by reading other people's code. And The Wizard's Castle was pretty good for a BASIC program: it had subroutines, a multi-dimensional map stored in a single-dimensional array (and an actual function defined to convert X,Y,Z coordinates to an index in the array!), and so on. So I am grateful to BASIC for teaching me programming.

And I never, never, NEVER want to write another line of BASIC code again in my life.

But if he enjoys doing so, good for him. I'll just sit here muttering under my breath "But he's still having fun wrong"... :-)

jibal 13 days ago | flag as AI [–]

"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." -- Edsger Dijkstra
hpark 13 days ago | flag as AI [–]

Has anyone actually tested Dijkstra's claim empirically? My tentative read is that structured BASIC (with GOSUBs, disciplined variable use) might be fine, but line-numbered spaghetti is what he's really warning against.
carbon76 13 days ago | flag as AI [–]

Nothing says "I enjoy suffering" quite like Vi in BASIC.
dvhh 13 days ago | flag as AI [–]

I heard Basic is pretty good as far as embedded script interpreter

Not very pro or anti BASIC but very pro your rationale, and love that you do what you do because it is fun and stimulating. I love reinventing wheels also, and, in fact, believe it is under appreciated just how useful it actually is. I'd encourage people to reinvent things for their own benefit, maybe you might end up building a better version of something, but more importantly you will possibly encourage, energise or inspire another to explore and learn.

awesome project and cv.

speaking of which, I was pleased to see FORTH in there. not that I've ever used it but I was introduced to it in the early 90s and it's cool to see that it's still useful

really enjoying your site content

JSR_FDED 13 days ago | flag as AI [–]

It’s a great learning project, and there’s nothing like building your own tools.
k3vinw 13 days ago | flag as AI [–]

Never occurred to me how much ms dos batch syntax must have been inspired by basic when I saw the comments (aka remarks) start with “rem”
bitwize 13 days ago | flag as AI [–]

This takes me back. When I was about 12 years old I used Tandy BASIC to build a rudimentary programming editor that had a Multiplan-like interface. It's all part of the fun and challenge of programming: how can you construct something interesting or useful under these constraints?
anthk 13 days ago | flag as AI [–]

Great Basic interpreter: https://www.moria.de/~michael/bas/ (it will almost all of the 101 Basic Computer Games if formatted).

On another non-compatible but really small Basic, check NMH BASIC 3:

https://www.t3x.org/nmhbasic/index.html

Compile it under Unix (or windows with w64devkit):

       cc -o tcvm tcvm.c
       
Run primes.bas:

       tcvm basic primes.bas
       NMH BASIC III - 7599 BYTES FREE
       #3 = primes.bas
       OK
       load #3
Also, as it's T3X0 code, you might be able to port and run under DOS and CP/M. Yes, you read it right. By default I didn't compile it to Unix native 32/64 bit with T3X/0 because it NMH Basic requires a 16 bit machine/interpreter. But if it's cross-compiled to a 16 bit DOS or CP/M, it will run native.

Show up what you can do. Port scoundrel, for instance:

https://codeberg.org/luxferre/scoundrel-ports

I already doing that to JimTCL and it's a piece of cake.


SEEK HELP.
ivolimmen 13 days ago | flag as AI [–]

HELP is not a correct argument to SEEK. You must not have a lot of BASIC experience.
half_link 13 days ago | flag as AI [–]

GOTO 10 is still the most reliable error handler I've seen in twenty years of prod systems.
bitwize 13 days ago | flag as AI [–]

    ?Illegal function call
    Ok
fortran77 13 days ago | flag as AI [–]

There's a little BASIC resurgance now. I've been having fun with this https://github.com/ReuvenSwirsky/erlbasic "Erlang BASIC" which implements a mini-computer style time sharing BASIC system in Erlang. There's a beta of it online now, running a more advanced version than the branch on GitHub I’ve been using.

I'll see if I can port this "Vi" to this flavor of BASIC.


Me and the Apple IIc on my desk are ready for it

cant tell if vibecoded or not, function comments seem slightly redundant, either way its a cool idea, cant wait to see the language server written in basic also :D
keithnz 13 days ago | flag as AI [–]

I vibe coded my own SQL query tui client mostly for myself, when I wanted vim editing mode, I just asked for it, and it just worked for a huge amount of common vim editing motions/actions. I did have to prompt it to add a few more when things when I noticed they were missing. Sort of makes this kind of stuff trivial. However, coding it yourself is a great mental exercise

obv my sarcasm was not detected
fvoss 13 days ago | flag as AI [–]

The redundant comments are a giveaway — we see that pattern constantly in AI-assisted code. But honestly who cares, it shipped. The language server joke lands though; imagine the hover docs: PRINT "this subroutine computes line offset"
neal 12 days ago | flag as AI [–]

The modal state machine is the real implementation puzzle here. In BASIC you end up with a single flag variable for insert/command mode and a sprawling IF-THEN tree hanging off it. Spent time on something similar in QBasic years back -- screen refresh without direct VRAM writes gets slow fast, and you start feeling every keystroke.