What are you using FB for and what features do you use most?

General discussion for topics related to the FreeBASIC project or its community.
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: What are you using FB for and what features do you use most?

Post by Munair »

caseih wrote:But this is the first time I've heard the claim that one of the most consistent features of C's grammar is a design flaw!
Generally speaking, a language design may be consistent but that doesn't make it necessarily good design. However, in this case I didn't say that the while statement outside of the respective code block is a design flaw but rather a bad choice. IMO, if you have statements inside the block that similarly influence the loop, such as break or continue, then why put others outside of it?
The fact that a <statement> production in the C grammar can be either a single statement or a block of statements was really neat thinking on K&R's part. It simplified the grammar a lot and reduces ambiguities. That's what I consider good design.
I think that it was a logical continuation of ALGOL related languages.
K&R's decisions were also based on the realities of computers at the time. Grammars like FB has today would have made the compiler impossibly slow and memory-intensive back then. They struck an amazing balance between the needs of the programmer and the limited power of the compiler that still serve us well today. Obviously today we have more freedom to design things differently when starting over. So whatever works for Sharp BASIC, good on you.
This is true and it also applies to Pascal and other languages that were developed at the time. In fact, Pascal became hugely popular when it became the first language delivering an all-in-one compiler that parsed and compiled source code in one go on computers that - at the time - were still limited. It was only later on that C became more popular, largely thanks to UNIX.

There have been innumerable attempts of programming language design in the last 50 years, many of which have tried to improve the syntax and paradigms of existing languages. Although I don't particularly like the begin..end implementation of Pascal, I still consider it better than curly braces, which IMO make code difficult to read and I try to avoid those languages as much as possible. But this is probably just as endless a debate as OOP vs non-OOP.

In any case, I think that any attempt of improving syntax with a new language should be encouraged and not seen as criticism or an attack on existing languages.
Last edited by Munair on Jan 16, 2022 19:15, edited 1 time in total.
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: What are you using FB for and what features do you use most?

Post by marcov »

caseih wrote:
marcov wrote:More than design, it simply was entrenched in some (unix) business. Or by that same metric Cobol and Fortran must be the best designed languages ever.
Some (unix) business? Too funny.
Why is that funny? It is its origin and hold out for the first 15-20 years. And it is still especially strong there. (though as said, less so, Gnome partially moved to Vala, GDB/GCC are C++ now etc etc)
While Cobol and Fortran are still in use all these decades later, that is not what I said nor what I meant.
They are both wide in use in their respective strong areas/niches (resp business and numeric calculations). Just like C in kernel/embedded programming.
I was talking about a language that is not only still used, but *widely* used. As in one of the top five most widely-used language A big difference there!
So the log(niche) is a bit bigger. So what? My point is that the exact number of users is mostly not related to language design choices, but staying power within the niche combined with the tooling a big commercial niche provides and the reach that all that provides.

Trust me, as user of a language whose niche (education/engineering) collapsed by the arrival of more specialized applications, I know.
Furthermore
dozens of languages have come and gone in the meantime. Reminds me of the famous quote by Stroustrup (about c++ but it applies to C), "There are only two kinds of languages: the ones people complain about and the ones nobody uses."
Elitist bullsh*t, though with a kernel of truth. People talk more about languages (and other products) they are going to use and experimenting with than about what they are actually using for their production code.
#define begin {
#define end }

Perfectly valid C, now run your editor again.
Oh sure you can deliberately break any editor with macros, including syntax highlighting, but it hardly speaks to the downsides of C's syntax.
Working with macros is nearly mandatory due to the defects of the language. So I did a quick test and my particular netbeans (MP Lab X) based IDE doesn't mind substituting a few { with begin. All code navigation remains working
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: What are you using FB for and what features do you use most?

Post by Munair »

dodicat wrote:A simple break gets your route out, in freebasic a simple nobreak keeps your route in.

Code: Select all

#define nobreak(n)  end select: select case n

Dim As Long n=6
Print "number ";n

Select Case  n
Case 1,3,6:
      Print "1,3,6"
      nobreak(n)
Case 4,5:
      Print "4,5"
      nobreak(n)
Case 1 To 7
      Print "1 to 7"
       nobreak(n)
Case 7
      Print "7"
Case Is < 9
      Print "is < 9"
      nobreak(n)
Case Else
      Print "else"
End Select
Sleep
 
This was also discussed in this 2018 thread. It basically adds a nested select case block each time. Not the best solution IMO. Would it be an idea to have an actual fall-through statement in FB (feature request), perhaps something similar to this "fall" statement?
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: What are you using FB for and what features do you use most?

Post by Munair »

marcov wrote:Curly braces are a fail on so many levels in the current situation. They are characters that need combined keys to make (which any type instructor can say should be avoided), it is quite easily to gloss over them, and training over time (I've been doing embedded C for a significant part of my time for 15 years no) only fixes that when well indented. Misplaced braces are too easily missed.
I agree one 100% with that statement. Even something as seemingly trivial in a language's design as the IF statement should be thoroughly thought-through. Although I must admit that Pascal's begin..end can also really make IF statement look and code messy, especially when IF statements are nested (which also requires some training over time). It was definitely the part of the language I had some difficulty to grasp. I think BASIC has the better design, which made me rethink the whole IF construct, to combine BASIC's simplicity but with mandatory semi-code blocks. Compare SharpBASIC:

Code: Select all

if x == 1 do
  ' ..
else if x == 2 do
  ' ..
else if x == 3 do
  ' ..
else do
  ' ..
end;
with C:

Code: Select all

if (x == 1) {
  ' ..
}
else if(x == 2) {
  ' ..
}
else if (x == 3) {
  ' ..
}
else {
  ' ..
}
The combination of parentheses and braces in C as shown in this example was a reason for me early on to avoid using these kind of languages as much as possible (and to eventually design something new).
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: What are you using FB for and what features do you use most?

Post by paul doe »

This discussion is far gone by now. So stay on topic, gentlemen: what are you using FB for, and what features do you use the most?
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: What are you using FB for and what features do you use most?

Post by jj2007 »

Munair wrote:
jj2007 wrote:See the difference? The lower one is Assembly: no ":", no ";", no "{", no break. In short, no unnecessary crap.
I dare to question that it's Assembly.
Assembly code is code that can be assembled by an assembler, in this case: MASM (and UAsm or AsmC). Sorry that Nasm doesn't have this capacity.

Btw with the same argument you could discard half of all code here in this forum as "not BASIC", because it doesn't look like Dartmouth Basic. No line numbers? Can't be BASIC ;-)
caseih wrote:I know people tire of my c/python/whatever posts and Marcov's pascal posts. But your MASMBASIC macro posts are particularly tiring. That is *not* assembly language, jj, sorry.
The switch example above is not MasmBasic, it's standard Masm32 code. Very, very old code btw, Masm32 switch has been developed around 2005, by a fan of BASIC.
RockTheSchock
Posts: 252
Joined: Mar 12, 2006 16:25

Re: What are you using FB for and what features do you use most?

Post by RockTheSchock »

I started with QBasic with 12 and later switched to QuickBasic. At university I learned Java, C and Scheme. At home I learned to circumvent the deficiencies of QB with libs written in NASM x86. For some years java had been my favourite for any GUI based program.

Then I started working at a small company implementing websites with Typo3 CMS and writing extensions with php. That was 15 years ago.

Since then I learned a bit of python and lua. I like modding. At work I use Vb.net, C# and Powershell and bit of pascal. Mostly for automating tasks, or migrating and syncing data of mssql or firebird databases.

It takes me about an hour to learn or relearn the basics of any standard oop or procedural language and only some days to fluently use the more advanced features of a language. So if there is a nice library for the task I use the language with the best documentation and examples.

But whenever I am prototyping something where theres no library I can use directly, for example reading an obscure file format I will use FB. Sometimes I sketch programs in my brain using FB style of programming and then translating it to another language, especially if I hadn't done programming for a while.
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Re: What are you using FB for and what features do you use most?

Post by oyster »

In one word, FB is only used to remind me of my youth.


TLDR, and it may have words let someone feel be impolited and insulted, but this is not my intention, I just write my thought.

I learned BASIC in my highschool, then I used QBasic and QB 4.5, yes DOS is the mainstream at that time, in my university time, for fun and for class assignment( including some calculation, plotting, animation and simulation) .

Then the graduate period, I learned C course, C seems to be a language good for wrist and keyborad then BASIC. However I can't use C to do some scientifc calculation with matrix/polynimial, and plotting, no I am not willing to write functions/libraries by myself. I found Matlab and used it for a while. However, again, I leaved Matlab because 1) I don't like its way to define a function; 2) I found python.

Then in doctor period and next worklife, I mainly use python. As most of us know, we can do scientifc calculation via numpy/scipy, do plotting via matplotlib. As 2 bonus, 1) we can read and(yes, it s not 'or') write excel's XLS and(yes, it s not 'or') XLSX without COM, and treat data via pandas; 2)it is more efficient to write code dealing with string in python then C/BASIC. I really HATE BASIC's MID$/LEFT$/RIGHT$ which are too clumsy, hard to perform some operations, and hard to write clear chain operation code.
But I have to use BASIC occasionally, or more specified, VBA in MS Word/Excel, because some times VBA is the only sulution, or simpler solution then python
I have used python for many years. There are only 2 small complains from me.
1)array is not native data type for python, so we have to use function to define array, so the python's code is not concise then Matlab's;
2)python code runs slower than C code, but in any case, code runs faster then my manual operation.

I also use C/Arduino/micropython for MCU these years.

Years ago, nimlang came into my life. To me, it has a python-like syntax, Uniform Function Call Syntax, powerful DSL(ok, I don't know how to call it correctly, since I am not a professional programmer, on the other hand, I am a user who uses computer language to solve problem in my daily duty.) I really like to coin GUI via https://github.com/khchen/wNim 's DSL.

I almost met freebasic and python at the same time, although I am not very sure. At the very begining, I was excited because I can pick my old QB experience but produce binary for DOS/Windows. But qucikly I realise that, in FB, I can't write concise code to do scientifc calculation, dataframe/string manipulation, I can't read/write XLS/XLSX. So I thought BASIC runs away from my job in a very different direction. So I only come here to recall the old friend, I mean BASIC. It is hard to admit, but it is the fact that even good friend from childrenhood can turn into stranger when they can't share more between each other.
Last edited by oyster on Feb 23, 2022 9:27, edited 1 time in total.
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: What are you using FB for and what features do you use most?

Post by Munair »

oyster wrote: Feb 23, 2022 6:56 I really HATE BASIC's MID$/LEFT$/RIGHT$ which are too clumsy, hard to perform some operations
Pascal has a similar function Copy(). With the definitions of strings and how they are represented by variables in these languages, how do you propose string manipulation should be done?
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: What are you using FB for and what features do you use most?

Post by fxm »

Remember that you can always add your own keywords by defining them with '#define', or your own functions.
aurelVZAB
Posts: 666
Joined: Jul 02, 2008 14:55
Contact:

Re: What are you using FB for and what features do you use most?

Post by aurelVZAB »

is more efficient to write code dealing with string in python then C/BASIC
hmm in which universe ...in all python sucks..
1.it is interpreter which depend on external libs totaly
2.not perform well on Windows
3.have ugly syntax and freakin white_space

and so on...and on...
aurelVZAB
Posts: 666
Joined: Jul 02, 2008 14:55
Contact:

Re: What are you using FB for and what features do you use most?

Post by aurelVZAB »

back to topic

i have simple explanation why i use BASIC( so this include Free Basic too)

because is best programming language ever made ..YES.
:)
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Re: What are you using FB for and what features do you use most?

Post by oyster »

Munair wrote: Feb 23, 2022 7:06
oyster wrote: Feb 23, 2022 6:56 I really HATE BASIC's MID$/LEFT$/RIGHT$ which are too clumsy, hard to perform some operations
Pascal has a similar function Copy(). With the definitions of strings and how they are represented by variables in these languages, how do you propose string manipulation should be done?
There is a saying in my culture, "My honey is other's arsenic". My suggestion will let orthodox BASIC user roar "go away, you are breaking the purity of BASIC" like people did on https://github.com/WaynePhillipsEA/twinbasic/issues/132

p.s.
since python is an OOP language, we can write

Code: Select all

print('hello'.upper().lower())
which can be rewritten in a BASIC way as

Code: Select all

import string
print(string.lower(string.upper('hello')))
further more, due to "Uniform Function Call Syntax" feature in nim, all the following lines are valid

Code: Select all

import strUtils

echo toLower(toUpper("hello"))

echo "hello".toUpper().toLower()

echo toLower("hello".toUpper())

echo "hello".toUpper.toLower  # remember  BASIC langauge?
there is no langauge which is suitable for all users/cases. Because I do not have the ability to implement my language, I'd better choose the easy-written one for specified case. Just my conclusion.

Regards
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: What are you using FB for and what features do you use most?

Post by badidea »

oyster wrote: Feb 23, 2022 10:34 since python is an OOP language, we can write

Code: Select all

print('hello'.upper().lower())
which can be rewritten in a BASIC way as

Code: Select all

import string
print(string.lower(string.upper('hello')))
What is wrong with:

Code: Select all

print lcase(ucase("Hello"))
String slicing is nice in python (due to its compact notation), but also cryptic if you are not familiar with it.
From the example on this twinbasic page, who here can guess whats this prints?

Code: Select all

print("Python"[::3])
aurelVZAB
Posts: 666
Joined: Jul 02, 2008 14:55
Contact:

Re: What are you using FB for and what features do you use most?

Post by aurelVZAB »

What is wrong with :
CODE: SELECT ALL

print lcase(ucase("Hello"))


-yes what is wrong ..ouuh is not OOP..what OOP it is just UDT style

and something is wrong with this :

import string

so poor python user before want to use simple string functions he must
include string library ...oh come on :o
Post Reply