Smart Compiler

For questions and postings not covered by the other forums
User avatar
andy-b
Posts: 24
Joined: Mon Jul 05, 2010 2:00 pm
Location: Dunedin, NZ

Re: Smart Compiler

Postby andy-b » Fri May 20, 2011 9:04 am

One of the best things about this warning system would be for anyone trying to learn Jade. It would improve the coding for any developer and save time i.e. trying to find memory leaks,
Agree that warning messages would be good for new Jade developers. When I first started Jade I didn't realise I had to delete my iterators!
A simple compiler warning that could detect I had declared an iterator but not deleted it would have not only improved my coding efficiency but educated me more about the proper use of Jade.

I come from a Microsoft background so am used to all the various warning messages that you can get bombarded with...no need to go too over the top but I think a few compiler warnings would be helpful where it would make your coding more efficient (i.e. deleting your transients)

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: Smart Compiler

Postby murray » Fri May 20, 2011 10:07 am

"... not setting return values in all execution paths"
I don't understand this point. Can you explain further?
As far as I know the compiler will report an error for a return statement missing a value of the declared type.
Murray (N.Z.)

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: Smart Compiler

Postby BeeJay » Fri May 20, 2011 10:13 am

"... not setting return values in all execution paths"
I don't understand this point. Can you explain further?
As far as I know the compiler will report an error for a return statement missing a value of the declared type.
The following "dummy" code shows an example of what he means. You'll notice that there is no "return" statement in the else code stream, which may or may not be a problem depending on the intention of the method. :)

Code: Select all

someMethod():String; begin if someBoolean then return "Yes, that's true"; else // nothing to do here.. endif; end;

davidmellow
Posts: 42
Joined: Thu Aug 27, 2009 1:27 pm
Location: New Plymouth, New Zealand

Re: Smart Compiler

Postby davidmellow » Fri May 20, 2011 11:22 am

"... not setting return values in all execution paths"
I don't understand this point. Can you explain further?
As far as I know the compiler will report an error for a return statement missing a value of the declared type.
The following "dummy" code shows an example of what he means. You'll notice that there is no "return" statement in the else code stream, which may or may not be a problem depending on the intention of the method. :)

Code: Select all

someMethod():String; begin if someBoolean then return "Yes, that's true"; else // nothing to do here.. endif; end;
When I was looking at this thread yesterday, the VS "Not all code paths return a value" type error (can't remember exact wording) immediately sprung to my mind as one of the most useful.

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: Smart Compiler

Postby murray » Fri May 20, 2011 11:48 am

@torrie": "... not setting return values in all execution paths"

I don't understand this point. Can you explain further?
As far as I know the compiler will report an error for a return statement missing a value of the declared type.
The following "dummy" code shows an example of what he means. You'll notice that there is no "return" statement in the else code stream, which may or may not be a problem depending on the intention of the method. :)

Code: Select all

someMethod():String; begin if someBoolean then return "Yes, that's true"; else // nothing to do here.. endif; end;
When I was looking at this thread yesterday, the VS "Not all code paths return a value" type error (can't remember exact wording) immediately sprung to my mind as one of the most useful.
In Jade all paths always return a value. I guess the question becomes whether it is the intended value.
Murray (N.Z.)

Stokes
Posts: 66
Joined: Wed Oct 13, 2010 2:06 pm
Location: QLD, Australia

Re: Smart Compiler

Postby Stokes » Fri May 20, 2011 3:16 pm

It could be designed so you can pick what warnings you would like shown. Something for the preferences section.

Rich Cassell
Posts: 77
Joined: Mon Aug 24, 2009 11:22 pm
Location: Nottinghamshire, UK

Re: Smart Compiler

Postby Rich Cassell » Fri May 20, 2011 11:20 pm

I'm happy to put my vote in the "Do it please JADE!" box.

I'm with andy-b with this, i came to this job having never heard of JADE before and a lot of the coding i now do i learned from just playing around. There is only one other developer here and he came through Linc to JADE, so is unconfident when it comes to object orientation and also modern programming such as TCPConnections and web services. This meant that i have had to learn this stuff by myself, meaning that, undoubtedly, i often wrote inefficient code and also had situations where all execution paths hadn't been considered, as discussed here. Over the past couple of years, now i am getting more experienced with JADE, i have been able to revisit the code in various places and improve it to how i now believe it should be. I have only been able to do this from the experience though, if the development environment warned me of these inefficiencies when i coded them in the first place then i am confident that i'd have learnt JADE much quicker, and potentially be a better programmer for it.

Aside from that, i am still learning, as we all are. And i am sure that some of my coding i do now could be made better still if written by some others using this forum, so i think the "smart compiler" would still give me a lot of benefits.

As Stokes said, i think add the functions in for those who want them, and make the options selectable in preferences. That would be great! :D

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: Smart Compiler

Postby allistar » Tue Jun 14, 2011 9:50 am

Sorry for chipping into this thread so late, the forum stopped showing my new posts.

A couple of years ago I developed (for a client) a full JADE metadata analyser which includes a JADE source code parser. This can parse any Jade code it's given (from a single method to a whole schema) into an abstract syntax tree (AST) of objects. It uses a shift-reduce parser to parse expressions (which is the trickiest part of the whole thing) and is developed in JADE as a separate schema which exports interface and a package. Once you have the AST for a method you can easily walk the tree and do all sorts of checks on it. It has been used for many things, include automated peer review (to automate mundane tasks) - it checks development standards such as:

- transient leaks, including iterator leaks, even taking into account iterators created inside nested while loops.
- poorly named variables (e.g. Booleans must start with a verb, collections with "all").
- consistent variable definitions (we don't like one line per variable definition, rather they should have more than one on a line to make the lengh of a method less).
- access modes set correctly (believe it or not there are still developers who don't see the point of "protected"!!) :-)
- no illegal commands (like beginTransaction, we have our own version of that).
- we can detect certain contention issues, such as a foreach on a large persistent collection.
- poor use of literals in code (to prevent "magic" numbers from creeping in).
- ensuring that methods are too deep or too long (we consider that to be poor programming style).
- etc.

It can also be used to do bulk automated modifications to the code (and structure) or a schema. We can modify the AST for a method then extract that as an scm file and reimport it into the database. This makes bulk changes (which would otherwise take months of effort) a lot easier to deploy. It can do the kinds of checks mentioned in this forum thread. I had considered using it to extend the JADE language by adding those things that we all want (operator overloading, ++ and -- operators etc). It could fairly easily take such "advanced" code and convert it back to normal JADE. The issue is developing another mini-IDE to support this.

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: Smart Compiler

Postby BeeJay » Tue Jun 14, 2011 10:57 am

- consistent variable definitions (we don't like one line per variable definition, rather they should have more than one on a line to make the lengh of a method less).
Is this really an issue anymore given that you can just fold up the vars section?
I had considered using it to extend the JADE language by adding those things that we all want (operator overloading, ++ and -- operators etc).
Truth be told, I've never wanted to do operator overloading in JADE. ;)

You didn't mention anything about one of my other pet hates, people making parameters io when they really should have made them input in response to:

"6084 - cannot assign to constant" - when trying to set a property on a parameter or
"6094 - Updating method called for a constant parameter" - when trying to add an object to a collection parameter

Cheers,
BeeJay.

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: Smart Compiler

Postby allistar » Tue Jun 14, 2011 11:10 am

- consistent variable definitions (we don't like one line per variable definition, rather they should have more than one on a line to make the lengh of a method less).
Is this really an issue anymore given that you can just fold up the vars section?
I never use code folding in the IDE. The point of some of the standards is consistency across the whole product for all developers, including third party developers.
I had considered using it to extend the JADE language by adding those things that we all want (operator overloading, ++ and -- operators etc).
Truth be told, I've never wanted to do operator overloading in JADE. ;)
I have, so I don't have to use ParamListType (which I consider to be a bit of a hack). I don't use them often, but when I do I cringe.
You didn't mention anything about one of my other pet hates, people making parameters io when they really should have made them input in response to:

"6084 - cannot assign to constant" - when trying to set a property on a parameter or
"6094 - Updating method called for a constant parameter" - when trying to add an object to a collection parameter
Yeah, it can pick up things like that.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 25 guests