Wish "New" Keyword

LWGShane

Well-Known Member
Licensed User
Longtime User
Would love to see the upcoming rewrite of the IDE come with the "New" keyword. Would make creating objects much more faster.

Old Way
B4X:
Dim Pikmin As Map
Pikmin.Initialize

With "New" Keyword.
B4X:
Dim Pikmin As New Map

If any methods have parameters that need to be included with the Initialization:
B4X:
'Old Way
Dim Pikmin As Method
Pikmin.Initialize("parameter 1", null)

'With "New" Keyboard
Dim Pikmin As New Method("parameter 1", null)
 

Troberg

Well-Known Member
Licensed User
Longtime User
I like it. It would take us one step closer to a "real" constructor.

If one just started to always use New instead of Dim & Initialize, one would also get compiler errors (instead of runtime errors) if one forgot to initialize with required parameters.

B4X:
Dim MyObj as cMyObject
MyObj.Initialize("Monday", "Pig", "Aircraft") 'Forget this line and the compiler will not say anything about it
 
Dim MyObj as New cMyObject("Monday", "Pig", "Aircraft") 'Correct form
Dim MyObj as New cMyObject 'Forget the arguments and the compiler will scream at you
 

Peter Simpson

Expert
Licensed User
Longtime User
A big +1 from me :)
 

LWGShane

Well-Known Member
Licensed User
Longtime User
This would also help:

- Existing VB.NET developers will have a faster time adjusting.
- Porting existing VB.NET code will be easier.

There could also be this option of coding:
B4X:
'Instead of
Dim Pikmin As New Method("parameter 1", null)

'This way would make B4X much closer to VB.NET, which is a good thing ;)
Dim Pikmin As New Method
Pikmin.Parameter1 = "The Property"
Pikmin.Setting1 = Null.
 

Peter Simpson

Expert
Licensed User
Longtime User
@WhiteholeSoft in theory why would you really want to change one line into 3 lines?
You're suggestion is just way too much work as programming should be made shorter, not longer if possible ;)

The suggestion in the original post is way better than your suggestion, why would you suggest doing that?

The current way takes 2 lines of code, @WhiteholeSoft suggestion turns 2 lines of code into 1 line of code :), but you want to turn 1 line of code into 3 lines of code :rolleyes: which is one line longer than how it's currently done. The main problem is that your suggestion (3 lines) is longer and does the exact same thing as the 1 line suggestion.

I'm definitely :confused:
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
@WhiteholeSoft in theory why would you really want to change one line into 3 lines?
You're suggestion is just way too much work as programming should be made shorter, not longer if possible ;)

The suggestion in the original post is way better than your suggestion, why would you suggest doing that?

The current way takes 2 lines of code, @WhiteholeSoft suggestion turns 2 lines of code into 1 line of code :), but you want to turn 1 line of code into 3 lines of code :rolleyes: which is one line longer than how it's currently done. The main problem is that your suggestion (3 lines) is longer and does the exact same thing as the 1 line suggestion.

I'm definitely :confused:

To be fair, the IDE could have two coding options: B4X Mode (the way it is now) and VB.NET Mode. (The closer the language gets to VB.NET, the more likely VB.NET devs will use the product ;))

Also, as an example to open a OpenFileDialog in VB.NET:

B4X:
'Rough example of a OpenFileDialog.

Dim TheDialog As New OpenFileDialog 'creates a new instance of the OpenFileDialog class
TheDialog.Title = "Select a File!" 'sets the title
TheDialog.Show() 'shows the dialog
 

Peter Simpson

Expert
Licensed User
Longtime User
@WhiteholeSoft we will have have to agree to disagree.
The closer the language gets to VB.NET, the more likely VB.NET devs will use the product)[/Code]
I disagree with the above statement. I for one personally use Visual Studio (VB) every single day of the week, B4x working slightly differently should not really be a problem for any competent(or even half competent) VB developer. Making a product more like visual studio is not really the way to go imo. @Erel has a nice plan which is working absolutely great so far. I'm sure that using some bad techniques from Microsoft isn't on Erels agenda lol ;)
 

Troberg

Well-Known Member
Licensed User
Longtime User
I don't think there's much to be gained from making it more similar to VB.net. The one thing I'd like to see more of is a more developed object orientation (interfaces in particular, but inheritance (preferably multiple) would also be nice, no need for operator overloading), but that's quite possible to build on the current VB6-like framework.
 
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
As a paid VB.NET programmer in my day job I prefer B4X. It's just dead simple and easy to read. That's why I use it.
 
Top