Very different result

For other topics related to the FreeBASIC project or its community.
nov79
Posts: 47
Joined: Feb 23, 2020 15:31

Re: Very different result

Postby nov79 » Mar 03, 2020 14:32

Lost Zergling wrote:Hello Nov79. What I like about FB is its versatility in terms of syntax and programming style. You have the possibility of a syntax close to c, directly c, integrate an assembler syntax, prefer an object style, make macros, or try to define your own keywords (an approach that I tried with lzle) . Without elegance and thoroughness, language can never do all that. Often, what may seem "weird" is related to some of the "spirit" of the language: ease, versatility, and creativity. Having been able to keep all of this while offering object or low level possibilities is a feat of the developers involved in the design, documentation, maintenance and development of that tool.

I admit I really feel lost when I come to Free Basic and I want to restrict myself to only a small subset of it.

Your language has so many keywords and so many overlapping functions. There are so many ways to do one thing. And I prefer only one and correct way to do something. It's very powerful but I think if I stop coding in it for a few months when I come back I will just forgot everything.

It's truly a very big language.

p/s: Just my own opinion with my limited knowledge when I first encounter Free Basic.
Last edited by nov79 on Mar 03, 2020 14:59, edited 1 time in total.
nov79
Posts: 47
Joined: Feb 23, 2020 15:31

Re: Very different result

Postby nov79 » Mar 03, 2020 14:37

angros47 wrote:
nov79 wrote:Not needed. I diagnosed the problem.

The problem is in the print to screen part, not the calculating of the sequence.

Free Basic's Print is much slower than crt's printf.


You are not the first to mention this, actually: https://freebasic.net/forum/viewtopic.php?f=3&t=26204

Are you using Linux or Windows?

I'm using Linux. Terminal is XFCE4-Terminal.
fxm
Posts: 9934
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Very different result

Postby fxm » Mar 03, 2020 15:09

Before fbc version 0.90.0, '=>' could only be used in initializing expressions (construction + initialization on a single line) like:
'Dim As Datatype variable => value' (equivalent to 'Dim As Datatype variable = value').

This usage has been extended to pure assignment like:
'variable => value' (equivalent to 'variable = value')
mainly in order to can be used to solve syntax ambiguities of the parser with '=', which sometimes may be interpreted as equality comparison operator while the programmer intended to do an assignment.

Example:

Code: Select all

Function f( ByRef _s As String ) ByRef As String  '' string transits by reference (input/output), no copy will be created.
   Function = _s
End Function

Dim Shared As String s
s = "abcd"
Print s

( f( s ) ) = f( s ) & "efgh"  '' enclosing parentheses are required here on the left-hand side when using '='.
Print s

f( s ) => f( s ) & "ijkl"  '' enclosing parentheses are not required here on the left-hand side when using '=>'.
Print s
nov79
Posts: 47
Joined: Feb 23, 2020 15:31

Re: Very different result

Postby nov79 » Mar 03, 2020 17:11

fxm wrote:Before fbc version 0.90.0, '=>' could only be used in initializing expressions (construction + initialization on a single line) like:
'Dim As Datatype variable => value' (equivalent to 'Dim As Datatype variable = value').

This usage has been extended to pure assignment like:
'variable => value' (equivalent to 'variable = value')
mainly in order to can be used to solve syntax ambiguities of the parser with '=', which sometimes may be interpreted as equality comparison operator while the programmer intended to do an assignment.

Example:

Code: Select all

Function f( ByRef _s As String ) ByRef As String  '' string transits by reference (input/output), no copy will be created.
   Function = _s
End Function

Dim Shared As String s
s = "abcd"
Print s

( f( s ) ) = f( s ) & "efgh"  '' enclosing parentheses are required here on the left-hand side when using '='.
Print s

f( s ) => f( s ) & "ijkl"  '' enclosing parentheses are not required here on the left-hand side when using '=>'.
Print s

I understood. Thank you.
angros47
Posts: 1673
Joined: Jun 21, 2005 19:04

Re: Very different result

Postby angros47 » Mar 03, 2020 17:33

nov79 wrote:I'm using Linux. Terminal is XFCE4-Terminal.


Try running your program from xterm, and see if the speed changes
badidea
Posts: 2148
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Very different result

Postby badidea » Mar 03, 2020 19:34

nov79 wrote:
Lost Zergling wrote:Hello Nov79. What I like about FB is its versatility in terms of syntax and programming style. You have the possibility of a syntax close to c, directly c, integrate an assembler syntax, prefer an object style, make macros, or try to define your own keywords (an approach that I tried with lzle) . Without elegance and thoroughness, language can never do all that. Often, what may seem "weird" is related to some of the "spirit" of the language: ease, versatility, and creativity. Having been able to keep all of this while offering object or low level possibilities is a feat of the developers involved in the design, documentation, maintenance and development of that tool.

I admit I really feel lost when I come to Free Basic and I want to restrict myself to only a small subset of it.

Your language has so many keywords and so many overlapping functions. There are so many ways to do one thing. And I prefer only one and correct way to do something. It's very powerful but I think if I stop coding in it for a few months when I come back I will just forgot everything.

It's truly a very big language.

p/s: Just my own opinion with my limited knowledge when I first encounter Free Basic.

One could say that FreeBASIC (one word) is actually two languages in one. One tries to be compatible with the old BASIC languages, one tries to be a modern language. There is some weird and confusing stuff as a result of this.
I don't thing that there is 'only one and correct way to do something' in any languages. That sounds like pythonic rule. When I write something in python (not too often), I prefer to do it in one of the many 'incorrect' ways to do it.
Lost Zergling
Posts: 333
Joined: Dec 02, 2011 22:51
Location: France

Re: Very different result

Postby Lost Zergling » Mar 04, 2020 10:03

@Nov79 (ps a little philosophy instead coding).
"I admit that I feel really lost when I come to Free Basic and I want to limit myself to a small subset only."
But that's how most people who use FB do!
The important thing is not to learn everything, but to have varied opportunities later when (or if) you are building your own programming style (wich accompany you with time) . It can happen that certain codes are really difficult to grasp (I think for example Paul Doe, Dodicat, Gothon, ..), but it is often due to the fact that the programming level is (very) high and that people have developed their own style, around a shared base.
The best way to do something will always be yours, the one you choose based on your experience, programming level and requirements (wich can target several complexity levels).
In addition, answers are most of the time provided, alternatives proposed. I will not say "a big language" but rather "a rich language".
Welcome.
Tourist Trap
Posts: 2922
Joined: Jun 02, 2015 16:24

Re: Very different result

Postby Tourist Trap » Mar 19, 2020 11:47

fxm wrote:To clearly distinguish the assignment operator (used for setting) from the equality operator (used for testing), some prefer to use the symbol "=>" for the first and the symbol '=' for the second. The opposite ("=>" for equality operator) is not allowed by FreeBASIC.

Yes. As for me, I use => when I initialize a variable at first time, "a = b" (with spaces) when assigning, and "a=b" (no spaces) when truth testing. This way I can debug most common of my coding mistakes.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest