D language as a basis for a Basic
D language as a basis for a Basic
Some of the D language is really badly though out. Like array views being total incompatible increasing array length. And some of it is overly complex or simply too much. However guy who designed it probably has an IQ of 150.
Nevertheless a subset of the D language seems like it would map to a Basic very well. Maybe there is only a fairly simple set of text transformations needed. Also you would have to use some sort of graphics library as well.
I can't use FreeBasic so easily now, it is getting a bit out of date. On the latest version of Linux I have the FB graphics are broken.
Nevertheless a subset of the D language seems like it would map to a Basic very well. Maybe there is only a fairly simple set of text transformations needed. Also you would have to use some sort of graphics library as well.
I can't use FreeBasic so easily now, it is getting a bit out of date. On the latest version of Linux I have the FB graphics are broken.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: D language as a basis for a Basic
I have no problems with FreeBASIC on different Linux boxes.sean_vn wrote:I can't use FreeBasic so easily now, it is getting a bit out of date.
On the latest version of Linux I have the FB graphics are broken.
What is the problem, can you describe it with more details ?
Joshy
Re: D language as a basis for a Basic
I'm not understanding what you mean about D's arrays. I took a quick look at the D language docs and it's arrays seem rather normal to me, with the powerful addition of slicing. From what little I know of D, having followed it a bit over the years, D seems rather well-though out to me. I'm not sure it will ever replace C++, as C++ is so mature and entrenched. I dunno.sean_vn wrote:Some of the D language is really badly though out. Like array views being total incompatible increasing array length. And some of it is overly complex or simply too much. However guy who designed it probably has an IQ of 150.
Nevertheless a subset of the D language seems like it would map to a Basic very well. Maybe there is only a fairly simple set of text transformations needed. Also you would have to use some sort of graphics library as well.
Like Joshy says, what version of Linux? I had thought FB uses SDL, but actually I think it uses X directly. So as long as you have xcb libraries installed, and if you're using Wayland, if you have the X server compatibility thing working, it should work. Linux is moving away from X.org, so some time FB's runtime will need to support Wayland. But in the meantime, and for the foreseeable future, X apps should continue to run under Wayland desktops.I can't use FreeBasic so easily now, it is getting a bit out of date. On the latest version of Linux I have the FB graphics are broken.
Re: D language as a basis for a Basic
The problem with FB on Xenial Linux is that the graphics are always displayed in full screen mode.
The problem with array slices in D is they become invalid if you increase the length of the underlying array in a very messy way.
I think you can map everything in FB to D in a straight forward way, including assembly language facilities.
I'm definitely not interested in writing a full parser to map a Basic language to D, however if there is a set of simple text transformations that will work instead I might even try that.
The problem with array slices in D is they become invalid if you increase the length of the underlying array in a very messy way.
I think you can map everything in FB to D in a straight forward way, including assembly language facilities.
I'm definitely not interested in writing a full parser to map a Basic language to D, however if there is a set of simple text transformations that will work instead I might even try that.
Re: D language as a basis for a Basic
Do you mean Ubuntu 16.04?
If I understand you correctly, yes that's completely understandable and expected behaviour on D's part, much like how an iterator becomes invalid when the underlying list is changed. I'm sure in both instances the language could dynamically regenerate the view or iterator every time you accessed it, but that would be fantastically slow, especially in a looping situation. Sorry, but in this case, D does the right thing. Coming from FB, which doesn't have slicing or view, I'm a little uncertain why you find this feature problematic. If you liked everything else about D, couldn't you just not use array slicing?
If I understand you correctly, yes that's completely understandable and expected behaviour on D's part, much like how an iterator becomes invalid when the underlying list is changed. I'm sure in both instances the language could dynamically regenerate the view or iterator every time you accessed it, but that would be fantastically slow, especially in a looping situation. Sorry, but in this case, D does the right thing. Coming from FB, which doesn't have slicing or view, I'm a little uncertain why you find this feature problematic. If you liked everything else about D, couldn't you just not use array slicing?
Re: D language as a basis for a Basic
D's slices seem nicer than C++'s pairs of iterators. I didn't get very far with learning D, but it definitely seems to be a big improvement over C++98. Not sure how it's evolved since.
(If I had time, I'd still like to finish that translator, for fun)
Right, it uses X directly, and doesn't use SDL at all, except for the emscripten and OSX ports of fbgfx, which use (emscripten's emulation of) SDL 1.2 and SDL 2 respectively. Neither of which has been merged.caseih wrote:I had thought FB uses SDL, but actually I think it uses X directly.
I had the same idea, for FB to C++ translation. I wrote a PEG-based translator, but only got it half finished. Turns out that you really can translate a very large part of FB directly to C++ using a very simple PEG parser (which is basically a regexp matcher) which directly outputs the replacement text, but it's inevitable that you need to do much more to correctly translate expressions 100% of the time: to do that you need to know the type of each variable, so you have to parse all variable and argument declarations, and also type declarations, the return types of functions, and if you're parsing instead of doing direct replacements you also need to implement the preprocessor...sean_vn wrote:I'm definitely not interested in writing a full parser to map a Basic language to D, however if there is a set of simple text transformations that will work instead I might even try that.
(If I had time, I'd still like to finish that translator, for fun)
Re: D language as a basis for a Basic
D seems to have remained a niche language, despite it's continued development and nice features. In the meantime C++ seems to have started to move again, and recent versions support a lot of nice features, including automatic variable typing, lambda expressions, and new types of smart pointers. I think C++'s resurgence has kind of damped D's growth. And in the meantime other languages that promote security and safety, such as Rust, have gained traction.
The problem with automatic translation into other languages like C++ is that idioms of the target language end up bleeding through into development process. Even FB's current close relationship with C can lead to programming in C style with FB syntax. Not that that's a bad thing necessarily. It's just that at a certain point, why not just C or C++ (or D)?
The problem with automatic translation into other languages like C++ is that idioms of the target language end up bleeding through into development process. Even FB's current close relationship with C can lead to programming in C style with FB syntax. Not that that's a bad thing necessarily. It's just that at a certain point, why not just C or C++ (or D)?
Re: D language as a basis for a Basic
Maybe because:caseih wrote:... why not just C or C++ ?
- we like FB syntax (and, can't/won't cope, with C/C++ syntax)
- we might dislike curly braces
- we might dislike 'endless' break statements (in switch)
- we might dislike semi-colons (at every line end)
...
Re: D language as a basis for a Basic
What is the advantage to have hundreds of programming languages all similar like C++ or D? Who wants D can use it. BASIC should stay BASIC. Like it once was (from my viewpoint, i started with CBM BASIC V 3.5). Yes, there can be enhancements, but they should match the original style. Otherwise we end with hundreds of C++ clones.
Re: D language as a basis for a Basic
I agree, for the most part. Although trying to identify what is BASIC style is a bit challenging to pin down.
Definitely I don't understand the obsession with braces and semi-colons. I guess the only thing going for braces is that it's easy to type and multi-purpose. Pascal's BEGIN...END blocks drove me nuts. Besides all the extra typing, I was never quite sure how to format them. FB's multiple END statements is okay, since you don't have to specify BEGIN all the time. Oddly enough, Python's white-space syntax feels super natural to me.
As for semicolons, a lot of languages these days with C-inspired syntax make the semicolon optional, and use it much like FB uses the colon. In this instance, I prefer semicolons to colons as from a natural language point of view a colon implies that what follows is related; whereas a semicolon indicates a new though.
Definitely I don't understand the obsession with braces and semi-colons. I guess the only thing going for braces is that it's easy to type and multi-purpose. Pascal's BEGIN...END blocks drove me nuts. Besides all the extra typing, I was never quite sure how to format them. FB's multiple END statements is okay, since you don't have to specify BEGIN all the time. Oddly enough, Python's white-space syntax feels super natural to me.
As for semicolons, a lot of languages these days with C-inspired syntax make the semicolon optional, and use it much like FB uses the colon. In this instance, I prefer semicolons to colons as from a natural language point of view a colon implies that what follows is related; whereas a semicolon indicates a new though.
Re: D language as a basis for a Basic
That was a idea from Kernighan and Rtchie and since then nobody changed it. I programmed a while in C, but never really liked the syntax.caseih wrote:Definitely I don't understand the obsession with braces and semi-colons.
Funny to think the first languange i came in contact was already the best. Like somet are thinking the first idea is the best. Naturally it was not my invention but from Commodore. They developed their CBM BASIC V 3.5 (used on "Commodore +4" 1986). It had a similar set of commands like FB today. There where even some more like sound and vol. And it was fast! Because it was in ROM it was immediately ready after switching on.
Now we have higher resolutions and a HD, but many things are still the same in FB.
If sean_vn wants something taken in FB he should explain exactly what. But because there are no developers, afaik, it most likely will not be implemented.
Re: D language as a basis for a Basic
I think both C and Pascal got it wrong. Blocks should simply always be multiple lines (e.g. require an end block keyword, like } or "end"). So no more variant for one statement, just one for multiple statements.caseih wrote:
Definitely I don't understand the obsession with braces and semi-colons. I guess the only thing going for braces is that it's easy to type and multi-purpose. Pascal's BEGIN...END blocks drove me nuts. Besides all the extra typing, I was never quite sure how to format them. FB's multiple END statements is okay, since you don't have to specify BEGIN all the time. Oddly enough, Python's white-space syntax feels super natural to me.
Then (1) one doesn't need begin block token to differentiate between the two and (2) because then always an END (or whatever the end block keyword is) follows, IDEs can easier autocomplete it. (since any IF has an END etc).
That said, IDEs have gotten pretty good in completing blocks with extra keysome extra hinting, so it should not be exaggerated. Personally I prefer begin..end of course, with braces it is IMHO harder to see the block structure. Python is even worse, even with my relative modest work done in it. I hate it with a passion.
If I ever design a language, it would have this Modula2 feature, and I make the BASIC option of having the type of block (end if, end <x> in general) optional. If you supply it, it has to match, but you can omit it, except at the end of a routine (sub,function,procedure)
(Modula2 had end "name of sub" but that was a hassle to keep in sync. It is mainly important if you allow nested subs)
And then of course there is the discussion of the semicolon is a terminator or a separator (the difference between Pascal and C's ;) :-)As for semicolons, a lot of languages these days with C-inspired syntax make the semicolon optional, and use it much like FB uses the colon. In this instance, I prefer semicolons to colons as from a natural language point of view a colon implies that what follows is related; whereas a semicolon indicates a new though.
Re: D language as a basis for a Basic
Yeah there's definitely no syntactic need for anything other than "end" (or something similar) to end a block. The only problem with end is similar to the problem with braces in that it adds a bit of cognitive burden on the human if the formatting isn't perfect or if the code block is very long. I would suspect you'd find a whole bunch of comments in the code like:
Especially for longer code snippets that scroll off the screen. Never mind that a function should never be longer than a screen full making such comments unnecessary.
It's really humorous to me what strong feelings Python engenders in people who don't use it much. There are very very few people who after working with Python for a period of time, dislike the syntax. Most find it very natural. That was a surprise to me. I certainly didn't like what I saw when I first was exposed to Python. But having developed in it for some time, I now strongly prefer it; problems with whitespace indent levels have only caused me trouble on a couple of occasion when trying to refactor soemthing. There's something very appealing about executable pseudocode. ESR's experience with Python is actually the common case. I'm sure most non-python programmers feel we're zealous nutcases. But Python really has changed my life! :)
Code: Select all
if ...
if ...
for ...
...
end 'for
end 'if
end 'if
It's really humorous to me what strong feelings Python engenders in people who don't use it much. There are very very few people who after working with Python for a period of time, dislike the syntax. Most find it very natural. That was a surprise to me. I certainly didn't like what I saw when I first was exposed to Python. But having developed in it for some time, I now strongly prefer it; problems with whitespace indent levels have only caused me trouble on a couple of occasion when trying to refactor soemthing. There's something very appealing about executable pseudocode. ESR's experience with Python is actually the common case. I'm sure most non-python programmers feel we're zealous nutcases. But Python really has changed my life! :)
Re: D language as a basis for a Basic
caseih: agreed with you wrt to Python. I write a lot of Python, and find the indentation pleasant because it means shorter code and less typing, even though on some occasions I've managed to get confused while refactoring.
And FB resembles C not because it has a GCC backend, which is irrelevant. (However, it is most certainly heavily influenced by design and limitations of the assembler-linker toolchain which FB inherits from C. Even QB was linkable with C.)
I don't see why you would write FB any differently if using the GCC backend or some new FB-to-C++ transpiler rather than the traditional assembly backend, aside from not using varargs because the GCC backend doesn't support those, and some other inline assembly edge cases. (If that's your point - that compatibility is not actually 100%, so it's a leaky abstraction, then you're certainly correct.)caseih wrote:The problem with automatic translation into other languages like C++ is that idioms of the target language end up bleeding through into development process. Even FB's current close relationship with C can lead to programming in C style with FB syntax.
And FB resembles C not because it has a GCC backend, which is irrelevant. (However, it is most certainly heavily influenced by design and limitations of the assembler-linker toolchain which FB inherits from C. Even QB was linkable with C.)
Re: D language as a basis for a Basic
Not that bad actually. But having a block structure at all, allows automated reformatting in complex edit scenarios, while with indent-only languages that is more complicated.caseih wrote:Yeah there's definitely no syntactic need for anything other than "end" (or something similar) to end a block. The only problem with end is similar to the problem with braces in that it adds a bit of cognitive burden on the human if the formatting isn't perfect or if the code block is very long.
More advanced IDEs have highlighting that you can trust. (go to a token, and it highlights the matching token)
Such comments are workarounds for IDE deficiencies.
I don't recognize that sentiment. I hear all the time that people don't like the whitespace identing. It is not that undisputed, even under Python users.It's really humorous to me what strong feelings Python engenders in people who don't use it much. There are very very few people who after working with Python for a period of time, dislike the syntax.
I had to use Python on some colloborative project, and hate every minute of it. Might have had something to do with the habit of using plain texteditors instead of proper IDEs though.
Mine also! Just not for the better.There's something very appealing about executable pseudocode. ESR's experience with Python is actually the common case. I'm sure most non-python programmers feel we're zealous nutcases. But Python really has changed my life! :)
But I recognize the zealous nutcases aspect. That describes the people I had to work with perfectly. Personally I was seriously underwhelmed, and didn't understand what the fuzz was all about. Yes there are a million packages, but quality is fairly low.
Last edited by marcov on Mar 18, 2018 15:04, edited 1 time in total.