Hello I am pursuing my Masters in Computer Science and I have to do my Masters thesis on Ruby 1.9.1 to make a new compiler. I have downloaded the source code from Ruby Homepage. I saw many *.c files in the source code folder.Can any one tell me how to combine two files and start running a fraction of the code.(As I need only the Garbage collector part for my thesis.) Eagerly waiting for a reply at your earliest. Regards...Thank You Tridib Bandopadhyay
on 2010-09-01 18:26
on 2010-09-01 18:55
On Wed, Sep 1, 2010 at 11:26 AM, Tridib Bandopadhyay <tridib04@gmail.com>wrote: > > I really don't intend to come off as disparaging in my following statements, just surprised at the ambiguous wording from a "computer science" fellow. First off, the GC is not likely to compile separate from the rest of ruby. I am unsure as to what you mean by "combining two files and start running a fraction of the code." Your first step really aught to be to simply get a handle of the build system that is used to compile ruby. Once you have that under control, it would be wise to compare notes between MRI ruby ( what you downloaded) and Ruby enterprise edition. The ent build of ruby has implemented copy on write. IIRC they made a few changes to how GC works in that build. http://www.rubyenterpriseedition.com/download.html Also note that there are significant differences between the 1.8.x series and 1.9.x. Enterprise ruby is a 1.8 ruby. Since you mentioned that you are writing a compiler, I might suggest: http://www.rubyspec.org/ http://ruby-std.netlab.jp/ In regards to compiler theory, you may already be aware of this book ( the ambiguous-ness in your question challenges this assumption) http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886 http://dragonbook.stanford.edu/ Also here are some additional Ruby GC resources: http://timetobleed.com/garbage-collection-slides-from-la-ruby-conference/ http://timetobleed.com/plugging-ruby-memory-leaks-heapstack-dump-patches-to-help-take-out-the-trash/ http://timetobleed.com/string-together-global-offset-tables-to-build-a-ruby-memory-profiler/ I hope this shot gun fire of resources get's somewhere closer to an answer, or at least a better refinement of the question. Respectfully, Andrew McElroy http://TryRuby.org
on 2010-09-01 19:06
On Wed, Sep 1, 2010 at 11:55 AM, andrew mcelroy <sophrinix@gmail.com> wrote: > > I saw many *.c files in the source code folder.Can any one tell me how > > to combine two files and start running a fraction of the code.(As I need > > only the Garbage collector part for my thesis.) > You could literally do. ./configure && make then look for the vm.o file, but I don't think this will be of much value -- I could be wrong. If you can restate your question, I would at least have a better idea at what you are trying to accomplish. Are you trying to write/ swap out the GC for ruby? If so, fantastic! However, your question is still very ambiguous to me. Respectfully, Andrew McElroy http://TryRuby.org
on 2010-09-01 19:18
Thank You for Your reply.... I don't know how to resent my question to You...I think It will be better if I Present my Thesis plan I am thinking of Making a programming language which has Garbage collector in it And also will allow Direct Memory Access with no mis-use of memory. So I thought of going with Ruby. So I need the Garbage Collector code of Ruby and then I will write my code of own to let the user access the memory with some desired rules.The Compiler will be a short one just to see whether it works or not. Can you tell me what will be the first step to go with? Regards Tridib Bandopadhyay
on 2010-09-01 19:32
Tridib Bandopadhyay wrote:
> Can you tell me what will be the first step to go with?
Learn to program in C ?
on 2010-09-01 19:44
Brian Candler wrote: > Tridib Bandopadhyay wrote: >> Can you tell me what will be the first step to go with? > > Learn to program in C ? I know C programming...But I need the Ruby Compiler to work with...So I need to run some files of Ruby not all the files...How to run some desired files.. For e.g- I need to run gc and Hash file How to make only those two file run?
on 2010-09-01 21:24
On Wed, Sep 1, 2010 at 12:18 PM, Tridib Bandopadhyay <tridib04@gmail.com>wrote: > Thank You for Your reply.... > > I don't know how to resent my question to You...I think It will be > better if I Present my Thesis plan > > I am thinking of Making a programming language which has Garbage > collector in it And also will allow Direct Memory Access with no mis-use > of memory. > I am curious as to how you plan to do this. > > So I thought of going with Ruby. So I need the Garbage Collector code of > Ruby and then I will write my code of own to let the user access the > memory with some desired rules.The Compiler will be a short one just to > see whether it works or not. > Honestly, Ruby is a great language, but the GC in Ruby isn't exactly the 8th wonder of the world, if you catch my drift. The upside to studying Ruby's GC is that it is a GC used in the real world. The down side is that there is a lot of room for improvement in this space. Maybe someone who has worked on the GC can speak more to this? So you intend to write a VM which allows the user to specify where in memory they want to place objects? Will this VM be writing it's memory allocation pools to random access memory? Which operating system are you planning to make this work on? This will be an incredible feat if you are able to pull this off on anything outside of a highly modified Linux kernel. What do you mean by the compiler will be a short one? Ruby is a dynamic language. Due to this, the compilation process works a little different than in a static language such as c. I would highly recommend that dragon book I linked to earlier. Most decent university libraries should have a copy of this book. If you don't mind me asking, I am assuming that you are a student at a university in India? Is this correct? I ask this only because it is an assumption that keeps coming up in my mind. If I am wrong, please let me know. You certainly have your work cut of for you. Respectfully, Andrew McElroy http://TryRuby.org
on 2010-09-01 21:24
On Wed, Sep 1, 2010 at 2:15 PM, andrew mcelroy <sophrinix@gmail.com> wrote: > > > If you don't mind me asking, I am assuming that you are a student at a > university in India? > Is this correct? > I ask this only because it is an assumption that keeps coming up in my > mind. > If I am wrong, please let me know. > > Again, I don't mean to ask this in a disparaging manner, but your proposed premise and methods for a masters thesis is... different. > You certainly have your work cut of for you. > Meant to say: You certainly have your work cut out for you.
on 2010-09-01 22:29
Tridib Bandopadhyay wrote: > I know C programming... ... > But I need the Ruby Compiler to work with...So I > need to run some files of Ruby not all the files...How to run some > desired files.. I don't want to be disparaging, but you clearly don't know C programming, or at least, not how to build large programs in C - or you would understand that you can't "run" an object file. So you need to learn the difference between "object files" and "executables". Learn about C "compilation units". Learn about "linking". Learn about how functions and variables can be private to one compilation unit (static), or shared with other compilation units (external). Learn about "static libraries" and "shared (dynamically linked) libraries". Learn how "makefiles" can automate the process of compiling and linking. It's easy to start the whole process, because it's all been done for you: to build the full ruby interpreter, you just need to do ./configure && make && sudo make install But if you want to build a different program which incorporates parts of ruby - such as its garbage collector - then it's up to you to (a) extract the bits of code you want, (b) work out how to call them, and (c) build the object files and link them with your own code in a meaningful way. Even if the ruby GC had been written as a standalone library - which it hasn't - you still wouldn't be able to "run" it. You would need to link it with your own program, and invoke it via its API entry points. (Aside: the whole ruby interpreter *is* available as a standalone library. You can use it to embed Ruby scripts in your C programs, by starting the interpreter and giving it code to eval. See http://ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html That doesn't mean that *fragments* of the ruby interpreter are available as standalone libraries) > For e.g- I need to run gc and Hash file > > How to make only those two file run? I'm afraid the question is meaningless, and I'm not sure this is the right forum to try to explain why. Very briefly: hash.c is a C source file. It defines functions and variables. It doesn't "run"; however, your main program could call external [i.e. externally visible] functions defined in that source file. However, I'm afraid that just linking your own main.c with hash.c is unlikely to be of much use, because the functions defined in hash.c may in turn make calls to other functions defined in other compilation units to do their work, and if they are missing, building your program will fail at link time with "undefined function" errors. If you're trying to reduce ruby to a set of compilation units which includes hash.c and a minimal set of other compilation units sufficient to make it link, and for the functions defined in those compilation units to do something useful when you call them, you're going to find that's a lot more work than you expect.
on 2010-09-01 22:35
> you're going to find > that's a lot more work than you expect. ... but actually, it would be a pretty good way to learn your way around the internals of the Ruby interpreter, so by all means go for it. I'm afraid there is no quick-fix solution we can offer you.
on 2010-09-02 00:20
@Andrew Mcelroy Yes I am an Indian Student completed my Bachelor in Computer Science from India and now pursuing my Masters in Computer Science from U.S.A The project which I am planning is a programming language which will allow users mainly to access the memory without any misuse also it will have garbage collector.The plan behind is that there will be a garbage collector which will be called by the compiler to clean the memory which is not in use by the user.And for certain variable (e.g- var,char)..Which i will create it in the compiler for those variables the garbage collector will ask the compiler whether it is being used by the user or it will be used by the user at later time.If yes then The garbage collector will ask for the time to come and clean it. Regarding the small compiler, I will just make a compiler to allow Direct Memory Access and Garbage Collector work together without misuse of Memory.Since its a Masters Project and the time span is very short. Therefor it will be my own compiler only the Garbage Collector part I will take it from Ruby.And will just add that code with my code. I am trying for working in Windows Platform.If not possible will switch to Linux Will this VM be writing it's memory allocation pools to random access memory? Yes thats my idea..But without any misuse of Memory. And I am following the Red-Dragon book. I need some start point in the sense..what the Garbage Collector code is using so that it comes clear to me. Am I able to present my doubts to You? Also One more question...Can Ruby be run in Windows Platform. Regards Tridib
on 2010-09-02 00:24
@Brian Candler I only want is that, Since Ruby is a OOP Language so I just want to develop a small compiler based on Ruby to show that Direct Memory Access is possible without Memory mis-use. The compiler will just be a model of my Idea where I can improvise it. So The coding of Ruby GC will be there and I will code to allow the user to access the memory directly. Am I able to clear my question? Regards Tridib
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.