OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:06 pm

All times are UTC - 6 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 37 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: BASIC for OS-Development?
PostPosted: Sat Aug 23, 2003 8:55 pm 
Hello,

I just wondered if there is a way to write an OS in BASIC? Is there a good compiler out there (fast & small binary, elf format, inline asm ...)?

I know C/C++ but I started with BASIC and really love it.

TIA
october

PS: I know lot of people out there think BASIC is crap but I like it ;)


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Sat Aug 23, 2003 11:19 pm 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
Ask yourself the following questions:

* does your BASIC allow you to efficiently handle bits, bitfields etc.?

* does your BASIC allow you to interface Assembler modules?

* does your BASIC allow you to create binaries that run without supporting runtime libraries (i.e., on a system that does not know about BASIC)?

I'd daresay the answer is "no", three times, but I have to admit that I'm not really the authority when it comes to BASIC internals (since, as you put it so eloquently, I think it's a crap language...) ;-)

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Sun Aug 24, 2003 12:00 am 
i asked myself if there is something like C but with the BASIC syntax and with the ability to ...
Quote:
... efficiently handle bits, bitfields etc.?

... interface Assembler modules?

... create binaries that run without supporting runtime libraries (i.e., on a system that does not know about BASIC)?


it should be possible to make it run with loadable libraries. like C does ...


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Sun Aug 24, 2003 3:36 am 
you'd have to write an OS in C and then integrate a BASIC interpreter and then you dould write very high level stuff in BASIC but it would be slow, inefficient and you may as well use C

Pete


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Sun Aug 24, 2003 3:40 pm 
Actually, Therx, BASIC compilers do exist, and it should be possible to implement a BASIC-like language that is suitable for system programming (the primary requisites being those mentioned by Solar earlier).

The real problem is that there is no real standard BASIC (an ANSI standard does exist, but it is universally ignored). For all intents and purposes, each compiler or interpreter has it's own dialect, some so different from each other as to effectively be diferent languages. Furthermore, few if any of the existing BASIC-like languages are designed for systems programming; most are OS specific and require heavy runtime support. Finally, almost any commercial dialect of BASIC (e.g., VB, Powerbuilder) is going to be proprietary, and trying to duplicate it is likely result in legal hassles.

The practical upshot of this is that you'll most likely need to design and implement your own dialect, and because of the requirements of systems programming, you'd be better off simply designing a whole new language from scratch. You may want to check the Free Compiler and Interpreter List, and scan through SourceForge and Savannah for BASIC related projects, but frankly, your probably looking at a major project just to get the language working.

BTW, what dialects of BASIC do you know, and what qualities of ithem do you particularly like or dislike? It may be that there are other languages which are not necessarily BASIC dialects, but which are similar enough to what you want in a language to be of use to you. Currently used dialects include QBASIC, True Basic, KBasic, Visual Basic, and Powerbuilder; older dialects include GW-BASIC, Applesoft BASIC, BBC-Micro Basic, and COMAL.

Also, what other languages are you familiar with? I generally advise fellow programmers that knowing as many languages as possible is a Good Thing; having a broader perspective and range of techniques helps even if you never use those languages to any great degree. I particularly recommend Scheme, Smalltalk, Python, APL, and FORTH, as they are quite different from most of the more common ones and can give some interesting insights (though of these, only FORTH is considered to be for systems programming). It is also a good idea to know at least one Wirth language (e.g., Pascal, Modula-2, Oberon) or one derived form his work (e.g., Ada, Eiffel), but most programmers find them to be too verbose. One older language you might want to look into is BLISS, which is a systems language that was popular around the time C first came out.


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Mon Aug 25, 2003 3:47 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
october wrote:
Hello,

I just wondered if there is a way to write an OS in BASIC? Is there a good compiler out there (fast & small binary, elf format, inline asm ...)?

PS: I know lot of people out there think BASIC is crap but I like it ;)


I started with BASIC aswell, and worked with it for 10 years, but for OSdev ... nah . definitely, you should forget about it.

One of the goodies of basic is that the language includes the library (for instance, Qbasic PSET and PRESET commands to plot pixels). In an OS, you'll have to go with your own abstractions and libraries will usually not offer what you need, or they will offer it assuming an environment you will not have... so you'll be kind stuck :-/

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Mon Aug 25, 2003 12:27 pm 
Oh, just to rattle on about different languages some more: you might want to check out the various programming language chrestomathies[sup]1[/sup] such as:

The "Hello, World!" Page
The Rot13 Page
The "99 Bottles of Beer" page (`Tim Robinson'? You don't suppose...)
The Quine Page

This may help in comparing and understanding different languages more rapidly. You might also want to check out this page of language critiques as well.

[size=-3][[1]] In linguistics, a chrestomathy is a group of passages translated into different languages for the purpose of comparing the languages. Here, I'm following ESR's lead by using it to refer to the practice of writing equivalent programs in multiple programing languages.[/size]


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Mon Aug 25, 2003 3:15 pm 
One final piece of advice: if you do design a systems language, try to concentrate on including the fewest built-in operations, rather than the most. Systems languages have to be lean and mean; even basic I/O should be done as a library call rather than as a built-in part of the language. This, more than anything else, is the reason that C became popular as a systems language - something that was forgotten in C++. This isn't to say that 'advanced' features like exception handling or sophisticated module/namespace control aren't potentially useful in such a language, but one should think twice about adding them, and try to keep them as simple and consistent in both implementation and usage as possible.

Also, it is generally a mistake to try and use one language for all purposes; one of the biggest failures of the past thirty years was that C was regularly applied to large application projects which is it was poorly suited, with the result that there was a percieved need for a a language extension like C++. Had other languages been used for those purposes instead, there would never have been a need for C++.


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Mon Aug 25, 2003 4:05 pm 
Schol-R-LEA wrote:
The "99 Bottles of Beer" page (`Tim Robinson'? You don't suppose...)

If only... :)


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Mon Aug 25, 2003 4:25 pm 
Gotta say I've always loved some of the more outlandish programming languages. In particular Brainf*ck and Beatnik. I can't program anything in them myself, I just love the idea that someone spent time creating them.

Neat challenge, can you code an OS in Brainf*ck?

Just to add to the links.

Rot13 Page http://www.miranda.org/~jkominek/rot13/


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Mon Aug 25, 2003 4:36 pm 
I like the look of Whitespace. (http://compsoc.dur.ac.uk/whitespace/)

Here's an extract from one of the sample programs:
Code:
            
   
     
 
   


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Mon Aug 25, 2003 8:39 pm 
C is mutateble.

Get Basic UNCOMPILED DIRECT ACCESS LIBS and you can do BASIC in C.

e.g.

#define end return;
void print(char *arg1)
{
//..print function code, yeah, me=lazy :)
}

void main()
{
print("Look, a modC-BASIC kernel!");
end;
}

etc. etc. and ecetra.

You get the point.
1 thing though. Basic strings are allocated. So you need to make a function to allocate space for LARGE strings.
C has a limit
BASIC has no limit (UP till pc memory maybe)


Top
  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Tue Aug 26, 2003 12:19 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
Schol-R-LEA:

Could it be you don't like C++? I mean, agreed, C++ in full flight is one of the most complex languages around, but it sure is also the most powerful...

What language would you suggest for large application projects? (And please don't utter "Java"...)

Tux:
Quote:
#define end return;


Seldom have I seen a more shameless advertising of raping a language. Don't try this. You will be sorry.

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Tue Aug 26, 2003 1:17 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Tux wrote:
C is mutateble.

You get the point.
1 thing though. Basic strings are allocated. So you need to make a function to allocate space for LARGE strings.
C has a limit
BASIC has no limit (UP till pc memory maybe)


Stop! For sure you can rename some stuff, but there are thing you cannot fake with C. For instance you can have
Code:
10 PRINT "1+1= ";1+1

which cannot be faked by C, as the compiler will have no way to tell the printing function that it should print a string then an integer.

Arrays and strings also behave very differently in both language, and iirc, there *is* a limit to the longest basic string (was 256 characters in every version i owned), while there's no such limit to C string (they can be as big as you want provided they end with a '\0' character.

Not even mentionning characters incompatibilities like ":" (in basic, this is an instructions separator, in C, it is a label delimiter or a part of x?y:z operator), ' which is a basic comment and the start of a single character in C, etc.

Btw, do you *really* want to use basic for OS development ? afaik, basic is virtually unable to deal with dynamic structures (i'm thinking of binary trees and linked list) due to the absence of 'variable reference' abstraction ...

There's also nothing like "dynamic memory allocation" in most basics (though i might miss some new stuff in VB)

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:BASIC for OS-Development?
PostPosted: Tue Aug 26, 2003 1:21 am 
Solar wrote:
Could it be you don't like C++?


I must admit, I've no great love of the language; I've come to see it as combining all the worst aspects of C with about 75% of the worst qualities of Ada (fortunately, the C++ language group has yet to embrace anything so absurd as the Ada rendevous mechanism), in a way that cancels out most of the advantages of both. Furthermore, I've become disenchanted with the general procedural and OO/procedural hybrid approach; too many of the advantages of OO are lost in the more static, compiler oriented languages, compared to Smalltalk.

Quote:
I mean, agreed, C++ in full flight is one of the most complex languages around, but it sure is also the most powerful...


That depends on what you consider 'powerful'. There are many areas where Common Lisp or Smalltalk are far more expressive.

Quote:
What language would you suggest for large application projects? (And please don't utter "Java"...)


Well, I'll admit, it's a problem; none of them are really what I'd want them to be. The answer would probably depend on the application in any case. While Java is in many ways a nicer C++, it still has many of the same problems that C++ has. While I generally favor the LISP languages these days, I have to admit that the two major dialects at this time, Common LISP and Scheme, are too unwieldy for many purposes; Scheme is far too minimal, and requires substantial extensions to make it a feasible choice (while such basic extensions as OO support, package control, and structured exception handling, are easy enough to add to the language through libraries and macros, the lack of standard is a serious hinderance), while Common LISP is extremely baroque and overdesigned. Also, like with Smalltalk, they are too tightly woven into their interpreter environments, and often have trouble working in other environments (though that is a facet of the implementations rather than the languages themselves). Modula-2, verbose as it is (a quality which CL also shares), would have been a good choice about fiften years ago; I'm not so sure I would say the same about Oberon. As I said before, however, none of them is quite right to my mind.

All of this is moot; C++ for all it's faults is a good language, and until a suitable replacement arises, it will be around for quite a while. While Java may end up being that replacement, it will need to mature as a system for some time before that happens.
Quote:
Tux:
Quote:
#define end return;


Seldom have I seen a more shameless advertising of raping a language. Don't try this. You will be sorry.


I have to agree here. If nothing else, the semantics of return are quite different from those of BASIC's 'end' statement, and trying to gloss over that difference is likely to lead to serious problems down the road. If nothing else, this sort of masquerade will make it harder to learn and work in C later. The C macro preprocessor is a powerful tool, but it is easily abused, and the resultant bugs are generally hard to nail down.


Top
  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 37 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot] and 66 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group