www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Moving from 1.0 to D2

reply jicman <cabrera_ _wrc.xerox.com> writes:
Greetings and salutations...

I am corrently trying to get my co. to see the goodness of D.  So, we have a
huge project, which is already live and 5 co-workers are using, which is all
based on D1, if I may call it that.  The project also uses DFL, dbi (v.62) and
juno (v.0.3.5.5), plus other libraries and DLL that I wrote, all based in D1.

12:49:34.90>dmd
Digital Mars D Compiler v1.022
Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/1.0/index.html

17:53:10.15>build
Path and Version : c:\bin\build.exe v3.04(2514)
  built on Mon Oct 16 11:43:04 2006

How much different is D2 vs. D1?

Can the D1 code be easily changed to D2?  We are talking about more than 30K
lines of code.

Any ideas?

thanks,

jose
Mar 09 2009
next sibling parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Mon, 09 Mar 2009 17:55:48 -0400, jicman wrote:

 Greetings and salutations...

 I am corrently trying to get my co. to see the goodness of D.  So, we  
 have a huge project, which is already live and 5 co-workers are using,  
 which is all based on D1, if I may call it that.  The project also uses  
 DFL, dbi (v.62) and juno (v.0.3.5.5), plus other libraries and DLL that  
 I wrote, all based in D1.
Very cool.
 12:49:34.90>dmd
 Digital Mars D Compiler v1.022
 Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
 Documentation: http://www.digitalmars.com/d/1.0/index.html

 17:53:10.15>build
 Path and Version : c:\bin\build.exe v3.04(2514)
   built on Mon Oct 16 11:43:04 2006

 How much different is D2 vs. D1?
Much. Much much much ;) It's almost another language.
 Can the D1 code be easily changed to D2?  We are talking about more than  
 30K lines of code.
I've worked on porting Tango to D2, which I'm thinking is more than 30k lines, but depending on how you have designed your code, it might be really difficult. Tango uses lots of designs that do not port easily to D2, which makes me have to either redesign them, or use casts to get it to work. YMMV. One thing to keep in mind is, D2 is a quickly moving target. You may need fixes that are released in a version of dmd, but design changes in that version may break your code in other ways. It might be best for professional software products to wait until D2 is released before trying to port. Also, I'm not sure if the 3rd party libs you are using are ported yet... -Steve
Mar 09 2009
next sibling parent jicman <cabrera_ _wrc.xerox.com> writes:
Steven Schveighoffer Wrote:

 On Mon, 09 Mar 2009 17:55:48 -0400, jicman wrote:
 
 Greetings and salutations...

 I am corrently trying to get my co. to see the goodness of D.  So, we  
 have a huge project, which is already live and 5 co-workers are using,  
 which is all based on D1, if I may call it that.  The project also uses  
 DFL, dbi (v.62) and juno (v.0.3.5.5), plus other libraries and DLL that  
 I wrote, all based in D1.
Very cool.
 12:49:34.90>dmd
 Digital Mars D Compiler v1.022
 Copyright (c) 1999-2007 by Digital Mars written by Walter Bright
 Documentation: http://www.digitalmars.com/d/1.0/index.html

 17:53:10.15>build
 Path and Version : c:\bin\build.exe v3.04(2514)
   built on Mon Oct 16 11:43:04 2006

 How much different is D2 vs. D1?
Much. Much much much ;) It's almost another language.
 Can the D1 code be easily changed to D2?  We are talking about more than  
 30K lines of code.
I've worked on porting Tango to D2, which I'm thinking is more than 30k lines, but depending on how you have designed your code, it might be really difficult. Tango uses lots of designs that do not port easily to D2, which makes me have to either redesign them, or use casts to get it to work. YMMV. One thing to keep in mind is, D2 is a quickly moving target. You may need fixes that are released in a version of dmd, but design changes in that version may break your code in other ways. It might be best for professional software products to wait until D2 is released before trying to port. Also, I'm not sure if the 3rd party libs you are using are ported yet...
Thanks, Steve. I will stay put, then. :-) jose
Mar 09 2009
prev sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
Steven Schveighoffer wrote:
 On Mon, 09 Mar 2009 17:55:48 -0400, jicman wrote:
 How much different is D2 vs. D1?
Much. Much much much ;) It's almost another language.
But most of the differences aren't breaking changes. You'll encounter some problems with string literals because of the new const features, but much of the rest should "just work."
 One thing to keep in mind is, D2 is a quickly moving target.  You may 
 need fixes that are released in a version of dmd, but design changes in 
 that version may break your code in other ways.  It might be best for 
 professional software products to wait until D2 is released before 
 trying to port.
I expect the features already in D2 to stay largely as-is, so I wouldn't be terribly concerned about targeting D2 from that perspective.
 Also, I'm not sure if the 3rd party libs you are using are ported yet...
This is by far the biggest issue in my mind.
Mar 10 2009
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 10 Mar 2009 11:15:36 -0400, Sean Kelly <sean invisibleduck.org>  
wrote:

 Steven Schveighoffer wrote:
 On Mon, 09 Mar 2009 17:55:48 -0400, jicman wrote:
 How much different is D2 vs. D1?
Much. Much much much ;) It's almost another language.
But most of the differences aren't breaking changes. You'll encounter some problems with string literals because of the new const features, but much of the rest should "just work."
Couple of breaking changes I've encountered that weren't const related when porting Tango (so far): had to change singletons named 'shared' this in structs is now a reference, not a pointer. And there are several blocking bugs that are preventing completion of the port. For instance 1645 and 2442.
 One thing to keep in mind is, D2 is a quickly moving target.  You may  
 need fixes that are released in a version of dmd, but design changes in  
 that version may break your code in other ways.  It might be best for  
 professional software products to wait until D2 is released before  
 trying to port.
I expect the features already in D2 to stay largely as-is, so I wouldn't be terribly concerned about targeting D2 from that perspective.
Yes, if you target D2 as is, the resulting release will be close to that. But if you get to a point where you cannot go any further because of design deficiencies or bugs, then you have to wait for Walter to fix those, or design around them. On one hand, you want to do the porting to help solve the bugs. Phobos is not even close when it comes to stressing the compiler's features, so building stuff that has different valid design ideas is critical to make sure D2 is as good as possible. On the other hand, as a business you want to be able to plan when your projects will be complete. Bottom line is, yes you can port your code, but only if you are willing to accept that your code may not work until several versions after D2 is released :) As a business decision, I think that's a no-brainer to wait. Other people may look at it differently. Now, starting a project using D2 may not be a bad idea, because you may be able to work with the quirks of the language, or design around the language, but you still run the risk of hitting blocker bugs. -Steve
Mar 10 2009
prev sibling next sibling parent Trass3r <mrmocool gmx.de> writes:
jicman schrieb:
 Can the D1 code be easily changed to D2?  We are talking about more than 30K
lines of code.
 
The most important change is constness. I personally use the following compatibility "layer"; though it's aim is to provide compatibility with both D1 and D2 compilers and not completely porting to D2 it might be an inspiration for you. The hard part is to determine which one you need; mutable, const or immutable. package { // define string types for compatibility with both D1 and D2 version (D_Version2) { pragma(msg, "D2 detected. Taking care of constness."); // we need a mixin cause the code is syntactically illegal under D1 mixin(` alias const(char) cchar; /// const char type alias invariant(char) ichar; /// invariant char type alias char[] mstring; /// mutable string type alias const(char)[] cstring; /// const string type alias invariant(char)[] istring; /// invariant string type alias wchar[] mwstring; alias const(wchar)[] cwstring; alias invariant(wchar)[] iwstring; alias dchar[] mdstring; alias const(dchar)[] cdstring; alias invariant(dchar)[] idstring;`); } else { pragma(msg, "D1 detected. All strings are mutable."); alias char cchar; alias char ichar; alias char[] mstring; alias char[] cstring; alias char[] istring; alias wchar[] mwstring; alias wchar[] cwstring; alias wchar[] iwstring; alias dchar[] mdstring; alias dchar[] cdstring; alias dchar[] idstring; } }
Mar 10 2009
prev sibling parent reply Robert Fraser <fraserofthenight gmail.com> writes:
jicman wrote:
 12:49:34.90>dmd
 Digital Mars D Compiler v1.022
I'd recommend upgrading to 1.041 first ;-P (especially considering all the bug fixes & performance improvements in it).
Mar 12 2009
parent jicman <cabrera_ _wrc.xerox.com> writes:
Robert Fraser Wrote:

 jicman wrote:
 12:49:34.90>dmd
 Digital Mars D Compiler v1.022
I'd recommend upgrading to 1.041 first ;-P (especially considering all the bug fixes & performance improvements in it).
true. .-)
Mar 12 2009