August 24, 2019, 07:56:13 PM

Author Topic: Random question about languages  (Read 2254 times)

Offline Xaron

  • Sr. Member
  • ****
  • Posts: 252
Re: Random question about languages
« Reply #15 on: June 25, 2018, 03:38:52 PM »
@col BB3D2  ;)

Offline Phil7

  • Jr. Member
  • **
  • Posts: 2
Re: Random question about languages
« Reply #16 on: June 25, 2018, 03:44:59 PM »
A space between ' and the comment value makes also sense for easier reading. An adult reader seems to recognise a word by looking only at the first letter and some other hints, so anything disturbing there could decrease the speed of perception.

Regarding 'local' I would also prefer to write only variableName:int=10 and an error message if :int is occuring in another place.
Could anyone give an example were this could lead to an ambiguity (using monkey/cerberus)?

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Random question about languages
« Reply #17 on: June 25, 2018, 04:03:35 PM »
Nice :)

Any details on features?
To be is to be perceived.

https://github.com/davecamp

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Random question about languages
« Reply #18 on: June 25, 2018, 09:30:46 PM »
Quote
Could anyone give an example were this could lead to an ambiguity
I've used this approach with a BlitzMax style variant and it works well. I used the colon to be followed by a valid type to mean a variable declaration with an optional initialiser expression.
To be is to be perceived.

https://github.com/davecamp

Offline Kryzon

  • Full Member
  • ***
  • Posts: 132
Re: Random question about languages
« Reply #19 on: June 26, 2018, 03:13:43 AM »
Code: BlitzMax
  1. Type TTest
  2.   Field x:int
  3.  
  4.   Method superduper()
  5.     local x:int = 10
  6.     self.x = 20
  7.     print x + "  " + self.x
  8.   End Method
  9. End Type
  10.  
  11. new TTest.superduper()
  12.  
To me the 'self.x' is what differentiates between the member x and the local x. So the 'local' qualifier is not needed (I know that's how BlitzMax behaves, but it's logically redundant).
self.x = member x
x = x that's not a member of the class.

In Python if you forget the 'self.' suffix you will start creating local variables, even if they have the same name as members.

Offline Xaron

  • Sr. Member
  • ****
  • Posts: 252
Re: Random question about languages
« Reply #20 on: June 26, 2018, 08:19:39 AM »
Nice :)

Any details on features?

Hey col, the plan is as follows:

We (Mike and me) want to create a Basic Language which is easy to use like BB3D.
There will be an interpreter for debugging purposes and fast development plus easy debugging and a transpiler which translates everything to C++ for maximum performance.
There will be the possibility to use C++ together with the libs at all like Tier 2 for AGK.

For the first version we aim for Windows only which already is quite a task. It shall include steam integration and all that stuff plus 2d/3d, sound, physics and networking. If that's done, I'd love to add more targets like Mac, HTML5, Android and iOS but that's very future, so we focus on Windows first.

For the 2d/3d part we still think about what to use as backend. For know I currently check out Irrlicht + IrrlichtBAW, Ogre3d, Urho3d and bgfx. The plan is to use a modern renderer pipeline. Maybe it's an option to use SDL2 for 2d and other stuff for 3d.

At the moment I'm in the process of writing the lexer and parser (C++) and creating the interpreter for just the language itself so it's still a way to go but it's pure fun. :)

The motivation

Ok, some words about why I am (we are) doing this. I grew up with a C64 and Basic was the first language I got in contact with. Shortly after (I was 12 at that point) I started with assembly language and used it for many years, even following by different Amiga computers. I LOVED that 68000 motorola CPU, the Intel compared to that was a nightmare when it comes to assembly language. I even did the GUI stuff and all that in assembly, that was quite funny.

Then I came to PC and somehow stumbled across BlitzBasic and WOW I was in love. Used it for many years, but we all know how the story did end... :/

So I already had the plan to create something by myself a few years ago. But I never really did because there always were good alternatives. Monkey came out and I switched over there, created some ( 8 ) games using it for mobiles and was quite happy using it. Then it died... Monkey 2 came out but for me personally I never got warm with it due to the complexity. Sure, it's a nice language but using C++ day in day out for about two decades now I simply doesn't see the need for another fancy language to learn. So I went to AGK and had the same warm feeling as with BB3D in the beginning. But somehow it just doesn't feel the same. I think it has way too many commands, some things are strange done and unnecessary complex. I even tried out Unity and did a pretty successful game with it but... oh boy, I just hate that tool. So here I am. There is nothing out there atm which creates the same good warm feeling like BB3D did in the past and I want to try to revive that. :)

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Random question about languages
« Reply #21 on: June 26, 2018, 10:25:56 AM »
@Xaron
Sounds interesting. Happy coding ahead :)

Are you changing the original language syntax ( therefore writing a new lexer and parser ) ?
The only reason I ask is because the source is in the public domain on BRLs github and if you ARE keeping things the same then why reinvent the wheel? :P
To be is to be perceived.

https://github.com/davecamp

Offline Xaron

  • Sr. Member
  • ****
  • Posts: 252
Re: Random question about languages
« Reply #22 on: June 26, 2018, 11:31:28 AM »
I do it from scratch, yes. Simply because I like some C++11 features.  ;D

And that makes it much easier for me to fix things when I did it myself.

BTW on topic: I would just not add the keywords goto and gosub because... well. I know, they are part of the Basic language but I don't think they are needed at all, are they?

Online TomToad

  • Sr. Member
  • ****
  • Posts: 408
Re: Random question about languages
« Reply #23 on: June 26, 2018, 01:10:23 PM »
When I was using BlitzMax,I decided to start using Superstrict on all my programs. I was hesitant at first, because it meant losing goto and gosub. After using Superstrict for a while,I found I didn't miss those commands at all. Don't see any use for them at all in a well structured language.
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline Xaron

  • Sr. Member
  • ****
  • Posts: 252
Re: Random question about languages
« Reply #24 on: June 26, 2018, 01:21:52 PM »
I think settings like strict or even superstrict should be enabled by default.

Offline meems

  • Sr. Member
  • ****
  • Posts: 310
Re: Random question about languages
« Reply #25 on: June 26, 2018, 09:32:04 PM »
@tomtoad my understanding is that goto and gosubs are useful when pushing algorithms to their speed limit. they are faster than function and method calls. These days for most coding, speed isn't so crucial as to prefer gosubs over functions. perhaps a compiler can intepret zero parameter functions as gosubs for a minor speed increase.

Offline Xaron

  • Sr. Member
  • ****
  • Posts: 252
Re: Random question about languages
« Reply #26 on: June 27, 2018, 06:26:16 AM »
@tomtoad my understanding is that goto and gosubs are useful when pushing algorithms to their speed limit. they are faster than function and method calls. These days for most coding, speed isn't so crucial as to prefer gosubs over functions. perhaps a compiler can intepret zero parameter functions as gosubs for a minor speed increase.

That was true ages ago but nowadays it's really not an issue anymore, especially with compiler optimization levels beyond our imagination. ;)

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Random question about languages
« Reply #27 on: June 27, 2018, 10:02:22 AM »
My personal 2 pennies...

For BASIC variants I wouldn't entertain versions of 'Strict' - it just creates headaches if you want to expand the language. I'd either have explicit type declaration of a variable, or you don't and you default 'no type declaration' as an integer.
I'd keep the language as strongly typed as possible. I think type inference is just lazy and starts heading towards hidden ambiguities that are silently resolved incorrectly.
The same with type conversion - it should be explicit for clarity: 'Numbers -> string' is ok to be implicitly converted, and 'int -> float/double', 'float/double -> int' should be ok with a warning of possible loss of data, but all other types, including 'string -> number' should be explicitly converted.

I agree with your thoughts on Goto and Gosub.
Whilst they are very powerful ( assembler doesn't have much more than these for moving around inside executable code ) they don't really belong in higher level languages anymore due to compiler optimisations.

For BB3D2 I'd...
Fix the array syntax.
Allow types to have methods for OO but have composition as opposed to inheritance - kind of how B3D is now ( except B3D doesn't support methods of course ).
Fix the Type system to work the same as BlitzMax except there would be no default base 'Object'.
Introduce 'collections' ( structured containers ) which would have a specific type for the instances it holds.
To be is to be perceived.

https://github.com/davecamp

Offline Xaron

  • Sr. Member
  • ****
  • Posts: 252
Re: Random question about languages
« Reply #28 on: June 27, 2018, 10:06:30 AM »
Thanks col, yeah inheritance is probably one of the most misused and misunderstood concepts in OO languages. It's often just evil. In our company I sometimes see hierarchies of 10 derived classes. o_O

Offline col

  • Sr. Member
  • ****
  • Posts: 429
Re: Random question about languages
« Reply #29 on: June 27, 2018, 10:29:11 AM »
Quote
perhaps a compiler can intepret zero parameter functions as gosubs for a minor speed increase.
The major compilers ( Intels icc, GNUs gcc, MSVCs cl ) are really very advanced to yesterday and all are capable of inlining functions regardless of the parameters. Release builds can also be very aggressive when it comes to optimising. Trying to debug the assembly of a release build takes more effort due to optimisations - a lot of variables/parameters can stay in registers across many function boundaries, especially if the function was inlined - code is also moved around and executed 'out of order' to how the code was originally written as long as the result is the same as if it was executed 'in order'.
To be is to be perceived.

https://github.com/davecamp