haxe annoyances

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

haxe annoyances

slenkar
I think haxe is a great language overall but a couple of things slow me down:

In an IF statement i often use 1 equals sign by accident, if a Bool is being tested, the compiler doesnt complain, which leads to bugs.

Variables are initialized at 'null' or something like that, every integer and float in an object has to set to zero manually,when a new instance is created. Strings have to be set at "".
 If ints and floats were created at zero and strings started off as "" then you serialize big objects a lot faster.
if you left out ints and floats that are zero and empty strings from the serialization it would reduce the size of a serialized string considerably.
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Mark de Bruijn | Dykam
I have never had any problems with `if`, as I never compare to a Bool.

About default values, the default values of a float is 0.0, and of a Int is 0. Strings are null by default in almost any language.
--
Mark


On Sun, Aug 8, 2010 at 8:24 PM, slenkar <[hidden email]> wrote:

I think haxe is a great language overall but a couple of things slow me down:

In an IF statement i often use 1 equals sign by accident, if a Bool is being
tested, the compiler doesnt complain, which leads to bugs.

Variables are initialized at 'null' or something like that, every integer
and float in an object has to set to zero manually,when a new instance is
created. Strings have to be set at "".
 If ints and floats were created at zero and strings started off as "" then
you serialize big objects a lot faster.
if you left out ints and floats that are zero and empty strings from the
serialization it would reduce the size of a serialized string considerably.

--
View this message in context: http://haxe.1354130.n2.nabble.com/haxe-annoyances-tp5386681p5386681.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Heinz Hölzer-2
Yes, you should really get out of that habbit (compare against bool)

for

if (something == true)  or if (something == false)

you should always use

if (something) or if (!something)




Am 08.08.2010 20:28, schrieb Mark de Bruijn | Dykam:
I have never had any problems with `if`, as I never compare to a Bool.

About default values, the default values of a float is 0.0, and of a Int is 0. Strings are null by default in almost any language.
--
Mark


On Sun, Aug 8, 2010 at 8:24 PM, slenkar <[hidden email]> wrote:

I think haxe is a great language overall but a couple of things slow me down:

In an IF statement i often use 1 equals sign by accident, if a Bool is being
tested, the compiler doesnt complain, which leads to bugs.

Variables are initialized at 'null' or something like that, every integer
and float in an object has to set to zero manually,when a new instance is
created. Strings have to be set at "".
 If ints and floats were created at zero and strings started off as "" then
you serialize big objects a lot faster.
if you left out ints and floats that are zero and empty strings from the
serialization it would reduce the size of a serialized string considerably.

--
View this message in context: http://haxe.1354130.n2.nabble.com/haxe-annoyances-tp5386681p5386681.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

MarcWeber
In reply to this post by slenkar
Excerpts from slenkar's message of Sun Aug 08 20:24:26 +0200 2010:
>
> I think haxe is a great language overall but a couple of things slow me down:
>
> In an IF statement i often use 1 equals sign by accident, if a Bool is being
> tested, the compiler doesnt complain, which leads to bugs.

Not sure whether changing the language is an option - but depending on
the editor you're using you can make it highlight a single = ..

If the HaXe -> XML processing chain works you can use that to find those
cases.

> Variables are initialized at 'null' or something like that, every integer
> and float in an object has to set to zero manually,when a new instance is
> created. Strings have to be set at "".
>  If ints and floats were created at zero and strings started off as "" then
> you serialize big objects a lot faster.
> if you left out ints and floats that are zero and empty strings from the
> serialization it would reduce the size of a serialized string considerably.

I fully agree that this is kind of strange:

class FOO {
  var x:Int

  function new(){
    trace(x); // will trace null on PHP backends!
  }

}
 
Marc Weber

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Franco Ponticelli
In reply to this post by slenkar

In an IF statement i often use 1 equals sign by accident, if a Bool is being
tested, the compiler doesnt complain, which leads to bugs.

I can't really see this as a defect, if you have a bool you don't really have to compare it in an if statement and even if you want to for some strange reason you can always reverse the check: if(true == test) ... this way the compiler complains.
 
Variables are initialized at 'null' or something like that, every integer
and float in an object has to set to zero manually,when a new instance is
created.

This is platform dependent ... Flash 9 and above initialize at 0/0.0 fro numbers while it is null for other platforms.
 
Strings have to be set at "".

This is really weird ... string is an object (even if a peculiar one) so it is quite common and desiderable that is initialized at null.
 
 If ints and floats were created at zero and strings started off as "" then
you serialize big objects a lot faster.

Why that? Serializing how?
 
if you left out ints and floats that are zero and empty strings from the
serialization it would reduce the size of a serialized string considerably.

That is not clear too ... whch serialization? Not the haxe one that uses n for nulls and i700 for integers for example

Franco


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Adrian Veith
In reply to this post by slenkar
 I agree - if the result of an expression must be Bool, any single =
should be marked as an error by the compiler. The double == is one of
the biggest drawbacks in any c styled languages (with the fall through
and break in case statements  - which has been gracefully discarded in
haXe). Anybody used to mathematical logic has problems with that. And I
notice that beginners in programming tend to use comparison like
<somthing Bool> = false or <something Bool> = true - and these
expressions are ambiguous even in haXe - the compiler should stop with
an error.

Adrian.


Am 08.08.2010 20:24, schrieb slenkar:

> I think haxe is a great language overall but a couple of things slow me down:
>
> In an IF statement i often use 1 equals sign by accident, if a Bool is being
> tested, the compiler doesnt complain, which leads to bugs.
>
> Variables are initialized at 'null' or something like that, every integer
> and float in an object has to set to zero manually,when a new instance is
> created. Strings have to be set at "".
>  If ints and floats were created at zero and strings started off as "" then
> you serialize big objects a lot faster.
> if you left out ints and floats that are zero and empty strings from the
> serialization it would reduce the size of a serialized string considerably.
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Bernard Visscher
In reply to this post by Franco Ponticelli
Variables are initialized at 'null' or something like that, every integer
and float in an object has to set to zero manually,when a new instance is
created.

This is platform dependent ... Flash 9 and above initialize at 0/0.0 fro numbers while it is null for other platforms.
 
That's not entirely true.. ints do initialize at 0, floats (Number) initialize at NaN.


But I see no problems or annoyances, it's just what you are used to...
like: while(file = getNextFile()){} or something like that...

Bernard


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Franco Ponticelli
 
That's not entirely true.. ints do initialize at 0, floats (Number) initialize at NaN.


You are right, it is just late here ;)

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

slenkar
well i learnt a few things like that bool trick, so good discussion guys
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Lyndon Howie
In reply to this post by Adrian Veith
Affecting all bool expressions could have the drawback of making chained assignments not possible eg. a = b = false; (the compiler wouldn't know if you actually means a = b == false;
I don't know about making it mandatory, but how often DO people find themselves needing to do an assignment inside an if/while statement?
I think some C/C++ compilers have the ability to warn about assignment in if/while statements.
Perhaps a warning, or a compiler option to make assignment in if/while an error might be a useful feature to add?

--- On Mon, 9/8/10, Adrian Veith <[hidden email]> wrote:

> From: Adrian Veith <[hidden email]>
> Subject: Re: [haXe] haxe annoyances
> To: "The haXe compiler list" <[hidden email]>
> Received: Monday, 9 August, 2010, 5:21 AM
>  I agree - if the result of an
> expression must be Bool, any single =
> should be marked as an error by the compiler. The double ==
> is one of
> the biggest drawbacks in any c styled languages (with the
> fall through
> and break in case statements  - which has been
> gracefully discarded in
> haXe). Anybody used to mathematical logic has problems with
> that. And I
> notice that beginners in programming tend to use comparison
> like
> <somthing Bool> = false or <something Bool> =
> true - and these
> expressions are ambiguous even in haXe - the compiler
> should stop with
> an error.
>
> Adrian.
>
>
> Am 08.08.2010 20:24, schrieb slenkar:
> > I think haxe is a great language overall but a couple
> of things slow me down:
> >
> > In an IF statement i often use 1 equals sign by
> accident, if a Bool is being
> > tested, the compiler doesnt complain, which leads to
> bugs.
> >
> > Variables are initialized at 'null' or something like
> that, every integer
> > and float in an object has to set to zero
> manually,when a new instance is
> > created. Strings have to be set at "".
> >  If ints and floats were created at zero and
> strings started off as "" then
> > you serialize big objects a lot faster.
> > if you left out ints and floats that are zero and
> empty strings from the
> > serialization it would reduce the size of a serialized
> string considerably.
> >
>
> --
> haXe - an open source web programming language
> http://haxe.org
>




--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Matthew Spencer-2
I don't know about making it mandatory, but how often DO people find themselves needing to do an assignment inside an if/while statement?
I find myself doing assignments in while/if statements quite frequently.

Perhaps a warning, or a compiler option to make assignment in if/while an error might be a useful feature to add?
HaXe pretty much already does this for anything except bools (which shouldn't need == anyways)

var item:Node;
while( item = stack.pop( ) )               //Error: Node should be Bool



On Sun, Aug 8, 2010 at 10:47 PM, Lyndon Howie <[hidden email]> wrote:
Affecting all bool expressions could have the drawback of making chained assignments not possible eg. a = b = false; (the compiler wouldn't know if you actually means a = b == false;
I don't know about making it mandatory, but how often DO people find themselves needing to do an assignment inside an if/while statement?
I think some C/C++ compilers have the ability to warn about assignment in if/while statements.
Perhaps a warning, or a compiler option to make assignment in if/while an error might be a useful feature to add?

--- On Mon, 9/8/10, Adrian Veith <[hidden email]> wrote:

> From: Adrian Veith <[hidden email]>
> Subject: Re: [haXe] haxe annoyances
> To: "The haXe compiler list" <[hidden email]>
> Received: Monday, 9 August, 2010, 5:21 AM
>  I agree - if the result of an
> expression must be Bool, any single =
> should be marked as an error by the compiler. The double ==
> is one of
> the biggest drawbacks in any c styled languages (with the
> fall through
> and break in case statements  - which has been
> gracefully discarded in
> haXe). Anybody used to mathematical logic has problems with
> that. And I
> notice that beginners in programming tend to use comparison
> like
> <somthing Bool> = false or <something Bool> =
> true - and these
> expressions are ambiguous even in haXe - the compiler
> should stop with
> an error.
>
> Adrian.
>
>
> Am 08.08.2010 20:24, schrieb slenkar:
> > I think haxe is a great language overall but a couple
> of things slow me down:
> >
> > In an IF statement i often use 1 equals sign by
> accident, if a Bool is being
> > tested, the compiler doesnt complain, which leads to
> bugs.
> >
> > Variables are initialized at 'null' or something like
> that, every integer
> > and float in an object has to set to zero
> manually,when a new instance is
> > created. Strings have to be set at "".
> >  If ints and floats were created at zero and
> strings started off as "" then
> > you serialize big objects a lot faster.
> > if you left out ints and floats that are zero and
> empty strings from the
> > serialization it would reduce the size of a serialized
> string considerably.
> >
>
> --
> haXe - an open source web programming language
> http://haxe.org
>




--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Lyndon Howie

Except for comparing two bools:

var a = true;

var b = false;

if (a == b) { /* stuff */ }


--- On Mon, 9/8/10, Matthew Spencer <[hidden email]> wrote:

From: Matthew Spencer <[hidden email]>
Subject: Re: [haXe] haxe annoyances
To: "The haXe compiler list" <[hidden email]>
Received: Monday, 9 August, 2010, 1:10 PM

I don't know about making it mandatory, but how often DO people find themselves needing to do an assignment inside an if/while statement?
I find myself doing assignments in while/if statements quite frequently.

Perhaps a warning, or a compiler option to make assignment in if/while an error might be a useful feature to add?
HaXe pretty much already does this for anything except bools (which shouldn't need == anyways)

var item:Node;
while( item = stack.pop( ) )               //Error: Node should be Bool



On Sun, Aug 8, 2010 at 10:47 PM, Lyndon Howie <lyndon.howie@...> wrote:
Affecting all bool expressions could have the drawback of making chained assignments not possible eg. a = b = false; (the compiler wouldn't know if you actually means a = b == false;
I don't know about making it mandatory, but how often DO people find themselves needing to do an assignment inside an if/while statement?
I think some C/C++ compilers have the ability to warn about assignment in if/while statements.
Perhaps a warning, or a compiler option to make assignment in if/while an error might be a useful feature to add?

--- On Mon, 9/8/10, Adrian Veith <adrian@...> wrote:

> From: Adrian Veith <adrian@...>
> Subject: Re: [haXe] haxe annoyances
> To: "The haXe compiler list" <haxe@...>
> Received: Monday, 9 August, 2010, 5:21 AM
>  I agree - if the result of an
> expression must be Bool, any single =
> should be marked as an error by the compiler. The double ==
> is one of
> the biggest drawbacks in any c styled languages (with the
> fall through
> and break in case statements  - which has been
> gracefully discarded in
> haXe). Anybody used to mathematical logic has problems with
> that. And I
> notice that beginners in programming tend to use comparison
> like
> <somthing Bool> = false or <something Bool> =
> true - and these
> expressions are ambiguous even in haXe - the compiler
> should stop with
> an error.
>
> Adrian.
>
>
> Am 08.08.2010 20:24, schrieb slenkar:
> > I think haxe is a great language overall but a couple
> of things slow me down:
> >
> > In an IF statement i often use 1 equals sign by
> accident, if a Bool is being
> > tested, the compiler doesnt complain, which leads to
> bugs.
> >
> > Variables are initialized at 'null' or something like
> that, every integer
> > and float in an object has to set to zero
> manually,when a new instance is
> > created. Strings have to be set at "".
> >  If ints and floats were created at zero and
> strings started off as "" then
> > you serialize big objects a lot faster.
> > if you left out ints and floats that are zero and
> empty strings from the
> > serialization it would reduce the size of a serialized
> string considerably.
> >
>
> --
> haXe - an open source web programming language
> http://haxe.org
>




--
haXe - an open source web programming language
http://haxe.org


-----Inline Attachment Follows-----

--
haXe - an open source web programming language
http://haxe.org

 
--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Cauê W.
this should be at most a concern for the ide, not haXe itself

2010/8/9 Lyndon Howie <[hidden email]>

Except for comparing two bools:

var a = true;

var b = false;

if (a == b) { /* stuff */ }


--- On Mon, 9/8/10, Matthew Spencer <[hidden email]> wrote:

From: Matthew Spencer <[hidden email]>

Subject: Re: [haXe] haxe annoyances
To: "The haXe compiler list" <[hidden email]>
Received: Monday, 9 August, 2010, 1:10 PM


I don't know about making it mandatory, but how often DO people find themselves needing to do an assignment inside an if/while statement?
I find myself doing assignments in while/if statements quite frequently.

Perhaps a warning, or a compiler option to make assignment in if/while an error might be a useful feature to add?
HaXe pretty much already does this for anything except bools (which shouldn't need == anyways)

var item:Node;
while( item = stack.pop( ) )               //Error: Node should be Bool



On Sun, Aug 8, 2010 at 10:47 PM, Lyndon Howie <lyndon.howie@...> wrote:
Affecting all bool expressions could have the drawback of making chained assignments not possible eg. a = b = false; (the compiler wouldn't know if you actually means a = b == false;
I don't know about making it mandatory, but how often DO people find themselves needing to do an assignment inside an if/while statement?
I think some C/C++ compilers have the ability to warn about assignment in if/while statements.
Perhaps a warning, or a compiler option to make assignment in if/while an error might be a useful feature to add?

--- On Mon, 9/8/10, Adrian Veith <adrian@...> wrote:

> From: Adrian Veith <adrian@...>
> Subject: Re: [haXe] haxe annoyances
> To: "The haXe compiler list" <haxe@...>
> Received: Monday, 9 August, 2010, 5:21 AM
>  I agree - if the result of an
> expression must be Bool, any single =
> should be marked as an error by the compiler. The double ==
> is one of
> the biggest drawbacks in any c styled languages (with the
> fall through
> and break in case statements  - which has been
> gracefully discarded in
> haXe). Anybody used to mathematical logic has problems with
> that. And I
> notice that beginners in programming tend to use comparison
> like
> <somthing Bool> = false or <something Bool> =
> true - and these
> expressions are ambiguous even in haXe - the compiler
> should stop with
> an error.
>
> Adrian.
>
>
> Am 08.08.2010 20:24, schrieb slenkar:
> > I think haxe is a great language overall but a couple
> of things slow me down:
> >
> > In an IF statement i often use 1 equals sign by
> accident, if a Bool is being
> > tested, the compiler doesnt complain, which leads to
> bugs.
> >
> > Variables are initialized at 'null' or something like
> that, every integer
> > and float in an object has to set to zero
> manually,when a new instance is
> > created. Strings have to be set at "".
> >  If ints and floats were created at zero and
> strings started off as "" then
> > you serialize big objects a lot faster.
> > if you left out ints and floats that are zero and
> empty strings from the
> > serialization it would reduce the size of a serialized
> string considerably.
> >
>
> --
> haXe - an open source web programming language
> http://haxe.org
>




--
haXe - an open source web programming language
http://haxe.org


-----Inline Attachment Follows-----

--
haXe - an open source web programming language
http://haxe.org

 
--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

jlm@justinfront.net
this should be at most a concern for the ide, not haXe itself

But everyone uses a different IDE on a different platform, so it is better if haXe can protect users from common typos. 

I find myself doing assignments in while/if statements quite frequently.

could the compiler check if there is only a single = within an if bracket statement and state as much? - If statement on line 100 contains single '=', please revise.


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Jan_Flanders
The AS3 compiler gives a warning:

Warning: 1100: Assignment within conditional.  Did you mean == instead of =?

Those warnings are often an annoyance (though you can disable them).

Jan

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Yanis Benson
In reply to this post by slenkar
  On 08/09/2010 05:50 AM, slenkar wrote:
> well i learnt a few things like that bool trick, so good discussion guys
Just so you know, this trick is million year old, and became a part of
many coding standards for C.

Talking about others of your 'annoyances' I suggest you to dive a bit
deeper into programming, because 'fixing' them will reduce speed and
cause much more real annoyances for everyone else.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Matthew Spencer-2
But everyone uses a different IDE on a different platform, so it is better if haXe can protect users from common typos. 
Typos are the programmers responsibility. I don't want to see tons of warnings for "assignment within conditional" every time I compile one of my projects.

When you declare a float array you might accidentally type a comma instead of a period! The keys are right next to eachother, and when using a small font look very similar. Does this mean we should remove the ability to declare arrays with floats? No, it's a typo. The programmer needs to notice, and fix it.

Talking about others of your 'annoyances' I suggest you to dive a bit deeper into programming, because 'fixing' them will reduce speed and cause much more real annoyances for everyone else.
Agreed. 

On Mon, Aug 9, 2010 at 7:03 AM, Yanis Benson <[hidden email]> wrote:
 On 08/09/2010 05:50 AM, slenkar wrote:
well i learnt a few things like that bool trick, so good discussion guys
Just so you know, this trick is million year old, and became a part of many coding standards for C.

Talking about others of your 'annoyances' I suggest you to dive a bit deeper into programming, because 'fixing' them will reduce speed and cause much more real annoyances for everyone else.


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: haxe annoyances

Benjamin Dasnois
It's not because you don't do a thing that other people don't do it. I use assignments inside if quite often.
An if statement doesn't particularly take a test, it takes an expression. That's the philosophy behind haXe, everything has/is a value.

On Mon, Aug 9, 2010 at 4:26 PM, Matthew Spencer <[hidden email]> wrote:
But everyone uses a different IDE on a different platform, so it is better if haXe can protect users from common typos. 
Typos are the programmers responsibility. I don't want to see tons of warnings for "assignment within conditional" every time I compile one of my projects.

When you declare a float array you might accidentally type a comma instead of a period! The keys are right next to eachother, and when using a small font look very similar. Does this mean we should remove the ability to declare arrays with floats? No, it's a typo. The programmer needs to notice, and fix it.

Talking about others of your 'annoyances' I suggest you to dive a bit deeper into programming, because 'fixing' them will reduce speed and cause much more real annoyances for everyone else.
Agreed. 

On Mon, Aug 9, 2010 at 7:03 AM, Yanis Benson <[hidden email]> wrote:
 On 08/09/2010 05:50 AM, slenkar wrote:
well i learnt a few things like that bool trick, so good discussion guys
Just so you know, this trick is million year old, and became a part of many coding standards for C.

Talking about others of your 'annoyances' I suggest you to dive a bit deeper into programming, because 'fixing' them will reduce speed and cause much more real annoyances for everyone else.


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org



--
DASNOIS Benjamin
http://www.benjamindasnois.com

--
haXe - an open source web programming language
http://haxe.org