New project, "Code to Code"
linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Wed Dec 17 21:34:05 UTC 2008
Inline reply (sorry, but several good points I'd like to address).
Marc Lanctot wrote:
> Maybe it's easiest to illustrate with an example. I have lots of
> experience with language X and Y, but now because I work for company C I
> have to use language Z. (bummer!)
> So, I coding along happily (or unhappily, as it were) in language Z and
> I find myself not knowing how to pass variables by reference.
> Step 1: I invoke Code-to-Code. First thing I do is lookup "passing
> variables by reference in function calls". I find it, I'm happy. I get
> sent to a page (this concept's profile) called "Passing variables by
> reference to functions". I also see a list of source/target languages.
> Step 2: I notice my target (Z) is there, let's say Z = C++.
> Step 3: I choose my source (X) is there, let's say A = Java.
> Step 4: I click "GO!" and bam, up pops up an example side-by-side. On
> the left we have:
I think this could be done by creating a page, named for the function in
question. In there then could be a list of links to articles with that
function, sorted by 'X to Y'.
This should allow Mediawiki's built in search engine to provide you with
the information you're looking for.
Already people are creating a structure to the articles I hadn't thought
of. I had planned to create 'X to Y' as a single, complete article.
Instead it is evolving as 'X to Y/function|concept|etc' and the 'X to Y'
article becomes a list of links. This may be very useful as it would
allow for what you are talking about.
If I am getting this right, then this page should be inline with what
you are thinking?
> void function(int i, ObjectType o)
> // i is passed by value, therefore changes are local
> i += 4;
> // o is passed by reference.. changes inside persist
> o.somepublicfield = somevalue;
> On the right:
> void function(int i, int & j, int * k, my_type * ptr, my_type & ref)
> // i is passed by value, changes are local
> i += 4;
> // j is passed by reference, changes persist
> j += 4;
> // k's address is passed by value, but you can use it to change
> // the value of the variable it is pointing to in memory
> // changes persist if you do this
> (*k) = 4;
> // but not if you do this. address value in k is local
> k = 0x08fe82a6;
> // changes value of somemember in object pointed to by ptr
> o->somemember = somevalue;
> // same deal except via a reference
> ref.x = 4;
> On the bottom:
> Note1: in Java, all object types are passed by reference whereas all
> primitive data types are passed by value.
> Note2: In C++, all primitive data types are passed by value unless you
> use a reference or pointer. There are two way to pass something "by
> reference": using a pointer or using a reference. Bla bla bla...
Another excellent example that could be a seed article for 'Java to
C++'! Could I ask you to add it, if you have the time? As I mentioned
earlier in this thread, I am more than happy to do it myself, but when
possible I'd like to keep attributions intact in the wiki. :)
>> If you have any ideas you would like to try, by all means please
>> experiment on the project wiki.
>>> There's also the advantage that you can quickly assess whether or not
>>> the concept exists in your collection, and and even better advantage:
>>> you can put a pseudo-code version on the concept's profile.
>> True, I think this would be a very useful feature. Again though, how
>> to implement... ?
> I guess what I'm trying to say is that I would use this as a reference
> and not as a way to learn a new language. IMO, you shouldn't use a tool
> like this to learn a new language, because (as Lennart Sorensen pointed
> out) you'll miss some of the intended ways for the language to be used.
> It should used only as a reference, and as such should be indexed first
> by programming concept and *then* by source/target languages.
I agree. Code to Code is not meant to be a tutorial in any way... There
are already a multitude of great tutorials for every language. It is, as
you suggest, meant to be a reference for programmers interested in
language X, but who have a proficiency in Y.
The notes, which Lennart impressed on me, could well be as important as
any code examples. They will do wonders to help someone write better
code simply because they will come in looking for a function they are
familiar with and find a pointer to what they should do. The associated
code examples will still be important to complete a reference like this
and they could also serve as an example of why 'function foo' is better
approached using concept or function 'bar'.
> Now, if you're using a wiki (without adding any custom code of your own)
> then implementation of this may be problematic. Ideally you'd need to
> build your own database back-end so that you control how the data is
> served. Can you extend a wiki to do this kind of thing? I don't know.
> All I know is if I was using it, I would not want to search all n
> possible source languages (two clicks and two page loads each) to find
> out that what I was looking for wasn't there. In fact, if I had to do
> this I wouldn't use it at all because Googling would be faster.
Anything is possible, but I think with the right collection of "glue"
pages it will not be needed. Simply searching for "Python Array" already
returns the page above as the first result (a page of pointers to 'X to
Y' articles discussing Python's arrays).
All this feedback is already helping a lot in focusing the structure of
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy