Live data from Hacker News

Building my own Vi text editor in BASIC

leetusman.com

31–40 of 53 posts

Re: Building my own Vi text editor in BASIC

#31
post #23

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

What's interesting about it precisely that despite the equivalence (Turing machines and all that) the difficulty to do one thing is a language versus another is what make it prohibitively hard. If one is "just" translating something that is idiomatic to a language to something that is not in another, it might take 100x for lines for codes in a way that is terribly hard to understand.

I've had the unfortunate exercise of copying an API from pure android java to typescript because "they are similar". It goes against best practices and creates all kinds of weirdness resulting in a finished product which is almost the same but far enough away you could just as well have designed a better API in a few hours from scratch (the real complexity is in the backend of the code, not the interface fortunately). But requirements must be met.

Re: Building my own Vi text editor in BASIC

#32
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.

Re: Building my own Vi text editor in BASIC

#33

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

But you still need to know the language specific constructs.

I can't magically speak German because I know a load of abstract language theory.

And this can work the opposite way. If I know small talk, and then read that C++ can do OO code, I could then think about writing X in C++ and OO being the best model. But I then hit problems when the limitations of OO in C++ become apparent.

In my experience, programming in a language is finding what works in that language, not trying to make the language fit what is in your head.

Re: Building my own Vi text editor in BASIC

#34

Earlier quoted context omitted.

even smart people say dumb things sometimes.

like "goto considered harmful" when all assembly language depends on it

In context though, it was trying to move standards forward.

Look at how acceptable C has changed over the years.

In ye old days it was acceptable to just read in any old text without checking bounds, now that is considered harmful.

There are still use cases for hairier parts of C, but that doesn't mean they should be used all the time. Same with goto.

Re: Building my own Vi text editor in BASIC

#36
post #4

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 le…

Laughing agreement. I’m very sentimental for BASIC. By the standard of getting kids started it’s an amazing and wildly successful language. By any other standard, it is absolutely terrible! It commits every famous programming sin! Stay away! Do not learn from this language! LOL

Classic Basic (line numbers, GOTO) resembles 1960s/1970s FORTRAN before it adopted structured programming. The idea when BASIC was invented in Dartmouth in the 1960s that it would be a good introduction to programming for students who might have to learn FORTRAN. The thing is, when BASIC was at its most popular (1980s home computers) FORTRAN itself had moved on from "spaghetti code".

Re: Building my own Vi text editor in BASIC

#37
post #5
post #4

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 le…

I haven't written BASIC since I was a teenager! The more "modern" basics, without line numbers, were a definite improvement. I went from AppleSoft to AmigaBasic and QuickBasic.

Even with line numbers it's a hell of a lot easier once you get out of the 24 line X 80 character console window and into an editor you can scroll without needing the LIST command.

Re: Building my own Vi text editor in BASIC

#38
post #5
post #4

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 le…

I haven't written BASIC since I was a teenager! The more "modern" basics, without line numbers, were a definite improvement. I went from AppleSoft to AmigaBasic and QuickBasic.

I had a little crisis at 12 when I went from BASIC to Pascal: how was that supposed to work without line numbers? The statements were just floating around without structure!

Re: Building my own Vi text editor in BASIC

#39
post #38
post #5

Earlier quoted context omitted.

I haven't written BASIC since I was a teenager! The more "modern" basics, without line numbers, were a definite improvement. I went from AppleSoft to AmigaBasic and QuickBasic.

I had a little crisis at 12 when I went from BASIC to Pascal: how was that supposed to work without line numbers? The statements were just floating around without structure!

I spent two years on hn just to read this comment. So true!

After all these decades, I finally learned that I wasn't the only one who struggled with line numbers from BASIC to Pascal. Thanks, buddy!

Re: Building my own Vi text editor in BASIC

#40
post #4

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 le…

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

Awww. I downloaded the ECMA-55 standard from 1978 about a year ago and wrote an interpreter in C to be compliant with its "Minimal BASIC". I then had fun typing in code from old computer magazines. So much nostalgic fun.

Post reply on HN