C code generation

For other topics related to the FreeBASIC project or its community.
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: C code generation

Postby Tourist Trap » Jun 26, 2015 22:26

caseih wrote:In my NSHO, the last thing FB needs is more keywords. I am a strong advocate of removing 90% of the keywords from FB and putting them in the runtime library as callable functions, where they belong. The language should have at most 50 keywords.

Unfortunately, in my very humble opinion, doing so you would take the risk to give this taste of C programing style that makes it so poorly appealing for the beginer. In C even printing "hello" to screen is difficult due to the fact it will require to find the proper library so that you sometimes have more include statements than code! This problem has prevented me from using visual c++, since a lot of code in documentation or example just neglicts to tell you what library is to be linked in order to make something work...
grindstone
Posts: 726
Joined: May 05, 2015 5:35
Location: Germany

Re: C code generation

Postby grindstone » Jun 26, 2015 22:32

@Kot: You speak form the bottom of my heart.

Regards
grindstone
caseih
Posts: 1504
Joined: Feb 26, 2007 5:32

Re: C code generation

Postby caseih » Jun 26, 2015 22:39

EDIT. I concede the point! However if I was a fbc developer, which I am certainly not, I would quickly reject adding CUDA to the FB. Far better to keep platfrom-dependent code in its own module and file. I suspect most CUDA programmers won't have a problem with the nvcc syntax and the resulting object files can link with FB object files and interact just fine.

But I can tell that FB is beloved in its present, imperfect state. And I see a lot of code on the lists doing interesting things with the old DOS-style graphics API. And it still works pretty darn well with good third-party libraries like Gtk, Fltk, etc. I guess the reason why the old cruft of FB is still desired is probably similar to why VB 6 is still looked at fondly by many: it made some complex things very easy, even if it wasn't that portable into future versions of windows.
marcov
Posts: 2969
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: C code generation

Postby marcov » Jun 27, 2015 13:54

caseih wrote: I guess the reason why the old cruft of FB is still desired is probably similar to why VB 6 is still looked at fondly by many: it made some complex things very easy, even if it wasn't that portable into future versions of windows.


It was not technology but MS policy that killed VB6. For a company with Microsoft's resources it would have been peanuts to update it. They just chose not to. Just like they chose to remove and reintroduce the start button.
Emil_halim
Posts: 48
Joined: Feb 19, 2007 21:59
Location: Alex, Egypt
Contact:

Re: C code generation

Postby Emil_halim » Jul 03, 2015 19:07

Hi all,

actually , Inline c , has advantage. sometime users need some c stuff or code while coding in freebasic.

I know there is a model solution , but for lazy users like me inline c is the better.

i have an idea , we can use inline c block with meta keyword. so that the pares will stop at this step and start to strip out that c block,then pares will uses gcc to compile that c block to asm block with -S compiler option , then pares will emit the asm block back to the c block place ofcourse that enclosed with asm - End asm keywords. then pares will continue from this step.

so when pares found a c block will translate it to asm block.
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: C code generation

Postby Tourist Trap » Jul 03, 2015 21:34

Emil_halim wrote:i have an idea , we can use inline c block with meta keyword. so that the pares will stop at this step and start to strip out that c block,then pares will uses gcc to compile that c block to asm block with -S compiler option , then pares will emit the asm block back to the c block place ofcourse that enclosed with asm - End asm keywords. then pares will continue from this step.
so when pares found a c block will translate it to asm block.

Hello,

Good idea in general, but there is 2 things I would notice.

First, you could compile to ASM from a C plateform and import the result to a FB ASM block.

And the second point is a question of language development. I think that C would be a first choice for most programers and wouldn't leave FB grow on its own way. That 's already a fact that ourdays FB is going closer to C (in its new OOP features etc..) than to VB for example. But it is also a well known fact that C, despite its power, is difficult to read and so widespread that if you could just code directly in C , you would quickly have only C code everywhere inside freebasic sources making them unreadable by basic users.

So for those 2 reasons, I dont think a good idea to leave FB invaded too much by C. It is not really necessary, and could really hurt the freebasic from inside. Maybe I'm wrong of course, but if I had to deal too much with C when doing basic, I would probably be unhappy to have to learn a so hard companion language.
BasicCoder2
Posts: 3558
Joined: Jan 01, 2009 7:03
Location: Australia

Re: C code generation

Postby BasicCoder2 » Jul 03, 2015 22:00

Tourist Trap wrote:I would probably be unhappy to have to learn a so hard companion language.

Indeed. Although there is nothing wrong with making a version of FreeBASIC which is C++ with a BASIC syntax for those proficient in C++ it would be different language, it is not BASIC anymore. So we end up with another version of FreeBASIC. The older one for the likes of myself and a newer version for the C++ programmers. In fact not having any particular project to work on at the moment I am relearning C++ using the code::blocks ide but I couldn't take the mental strain of trying to mix it with FreeBASIC. I don't find the C++ syntax difficult to understand it is just more complex than your bog standard BASIC.
.
caseih
Posts: 1504
Joined: Feb 26, 2007 5:32

Re: C code generation

Postby caseih » Jul 04, 2015 2:12

I've used C for years and am quite comfortable in it. However I'm not sure I understand the use case for inline C. Freebasic already has 1:1 equivalents of everything I can think from C.

As for the debate over what is "BASIC," I don't think we can actually say that if such and such was put into FB then it wouldn't be BASIC anymore. FB already barely resembles the BASIC that was invented back in the 60s. We could argue it barely resembles QuickBASIC. Gone are the variable type symbols like $,%,!, etc. I don't think there's anything wrong at look at the new cool features coming in C++14 and C++17, or having a look at Google Go, or Mozilla Rust, and incorporating things that would be useful. And just because C or C++ is unreadable to some doesn't mean that FB will be unreadable with similar features added. Just not having braces makes code instantly more readable in my opinion!
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: C code generation

Postby Tourist Trap » Jul 04, 2015 13:00

@

Hello, from my side I'm not advocating against any new feature whatever it is. Just against style. I'm very affirmative on that, made an exception for people that have learned C academically, most of other people won't understand C. I mean Basic is close as possible to natural language. C , as this letters tends to remind us, is a code. One really may have to decipher programs written in it.

The second thing I'm observing, without judgement, is that FB is influenced by C for its new features , and not by VB.net for example. That also is only today state of art.
Emil_halim
Posts: 48
Joined: Feb 19, 2007 21:59
Location: Alex, Egypt
Contact:

Re: C code generation

Postby Emil_halim » Jul 04, 2015 14:23

okay ,

I see that , implementing inline c with freebasic will add and open new features to the programers.

if you did not like the idea , it is so easy , do not use it in your work. but let others who need that to use it.

actually i have learned c/c++ form BCX which translate the basic code to c/c++ code and ofcourse it allows inline c, so adding this will help users to have some basics of c/c++.

an other idea , we can make it with -gen gcc option , the users uses gcc an back_end can make use of inline c.

what do you think guys ?
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: C code generation

Postby Tourist Trap » Jul 04, 2015 14:34

Emil_halim wrote:I see that , implementing inline c with freebasic will add and open new features to the programers

To "some" programers. I'm just suggesting the fact that this would be of no help for other people, who would be rather confused by the melting. And this would also really eat FB from the inside. I think that a language in development must keep a distance with a fully implemented language, or this last will necessarily eat the first. Ok if C was just a scripting language or a plateform dependant feature, or a tool, but it is fully functional. In conclusion I just wanted to say here that some features may induce side effects, and it's in my opinion necessary to think about future overall development.
MrSwiss
Posts: 3538
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: C code generation

Postby MrSwiss » Jul 04, 2015 14:39

My opinion on the subject are as follows:

x wants C added,
y wants Modula added,
z wants Pascal/Delphi added
...
...

We'll be creating an "endless story" with such additions.
It's NOT the same as inline assembly used for "engine room" stuff.

THIS is why I'm against such things. (it is not an extension of the language IMO)
caseih
Posts: 1504
Joined: Feb 26, 2007 5:32

Re: C code generation

Postby caseih » Jul 04, 2015 15:16

Emil_halim wrote:okay ,

I see that , implementing inline c with freebasic will add and open new features to the programers.

if you did not like the idea , it is so easy , do not use it in your work. but let others who need that to use it.

actually i have learned c/c++ form BCX which translate the basic code to c/c++ code and ofcourse it allows inline c, so adding this will help users to have some basics of c/c++.

an other idea , we can make it with -gen gcc option , the users uses gcc an back_end can make use of inline c.

what do you think guys ?


Again, though what kinds of things would you put in the inline C? What can C do that FB can't? I can't think of any inline C code that couldn't be done with straight FB.
grindstone
Posts: 726
Joined: May 05, 2015 5:35
Location: Germany

Re: C code generation

Postby grindstone » Jul 04, 2015 15:53

What can C do that FB can't?
That's it! Inline C would bring no benefit, other than inline ASM, which can be used in some very special cases to speed up the programme.
Emil_halim
Posts: 48
Joined: Feb 19, 2007 21:59
Location: Alex, Egypt
Contact:

Re: C code generation

Postby Emil_halim » Jul 04, 2015 16:21

but what about makeing it with -gen gcc option , the users uses gcc as back_end can make use of inline c.

no one here comment

edited : i was talking about comment on the next idea

, i think who using gcc back_end will compile the genrated c code with c/c++ compiler , and he have to know about c.

what do you think ?

BTW , the benefit of using inline c is , some times we see post it's titel is how to convert this c code to basic .... , so the user will insert the c code directly with freebasic , saving time of convert , make use of gcc optimized genrated asm code , and learnning c basics.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests