possible issues with class dependencies in Ruby [closed] - ruby

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
After learning power of Rails framework, I have started learning ruby. In Ruby, I learnt that I can add methods to a class at runtime. In Java, we have to define all methods before compilation. I suppose, this advantage in Ruby gives rise to issues with class dependancies. As I am new to Ruby, could anyone please explain in what way do I lose control by adding methods dynamically.

Being able to add methods at runtime doesn't impact the dependencies in any way, or at least not any more than writing any other code would.
The only difference is that you can now have methods "written" as-needed, but you will still have the same dependency issues if you wrote the code yourself. Since ruby is a dynamic language, it's sense of dependencies is rather different from a more "traditional" statically compiled language like C++ or Java, but even in Java you can load arbitrary code at runtime (it's much more difficult, but still possible).

Related

Working with monkey patches [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Is monkey patching possible in Go as in Ruby?
If so, I have a third party library build, which contains one function called encrypt. Now i want to overwrite the behaviour of the function. Is that possible?
Golang is a compiled language, you'll have to edit the code, recompile and deploy all over again. "monkey patching" isn't possible as if you're talking about changing the software after it is already deployed like ruby. (which is an interpreted language).
But if your concerns are beyond an hotfix and involve adding new code at runtime from external source, you might want to have a look at go plugins.
here's a nice medium post about it.
I'm not big on ruby so to make sure we are on the same page: my understanding is that monkey patching allows you to change the underlying behaviours (methods) attached to a given type at runtime.
In go this would be a big fat no no, probably should be in ruby too for the most part :)
Types are concrete in go, everything has to know what it is dealing with at compile time. It's difficult to propose a solution without a clearer understanding of the end goal, can you provide a more concrete example?

Which Ruby implementation is the most widely used? (MRI, Rubinius, JRuby etc.) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
As a novice to Ruby, I am a little bit confused as to which Ruby implementation is the most widely used in the industry.
I personally like to stay on the edge and therefore use MRI, but I get that a lot of people do not like it because of the GIL and prefer to use Rubinius instead, (which is pretty close to MRI), however I also gather that a lot of folks use JRuby (for Swing and such), however JRuby seems to be pretty far behind as far as Ruby development goes, (somewhere on the 1.9 line?).
Which implementation is the most commonly used in the industry?
For most straight forward projects, which don't require multi-threading, need to integrate with specific libraries, or run on certain containers - most people would prefer using the MRI implementation.
The main reason is that most ruby libraries are developed for MRI, and tested on them. You might have certain compatibility problems on other implementations.
Rubinius is preferred if you plan to work on a multi-threaded architecture, like under puma. JRuby also has better support for threads, and also has the rich library portfolio of the Java community. It is also preferred if you want to run on a java-based runtime container.

Is there an entry point in Ruby code execution to be used by a Ruby profiler? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a Java profiler which is a JavaAgent which does BCI on my classes and reports the statistics.
I was trying to create a basic profiler for Ruby as well (just for learning). I was wondering is there a similar mechanism for Ruby as well where I can provide a profiler class to be executed when I start my standalone Ruby program and it starts reporting statistics for the program.
I can search for getting statistics from Ruby however currently my concern is how to invoke the profiler class before execution begins for my code. Note that in case of JavaAgent, no source files needed to be modified as the byte code was directly instrumented instead of source files.
I expect a similar solution for Ruby as well, so that I dont need to modify my source files. In case my approach itself is wrong, is there any guideline or approach that I should follow for creating my basic profiler would be really helpful.
How can I cause my profiler class to be invoked before Ruby begins executing the code being profiled?
http://www.newrelic.com/ruby is really good, and there is a developer mode, you can take a look: https://docs.newrelic.com/docs/ruby/developer-mode

Pitfalls to avoid when writing project specs [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I'm currently trying to write up some software specs for a large-ish project that I'd like to bid out on oDesk (maybe 3k-6k). I have a classical education in computer science, but minimal work experience and I've never worked in a corporate environment.
I've written up 15 pages of project specs for an API that I want to run on Google App Engine. I'm finding the subtleties difficult with issues such as: where to draw the line on what to specify and what not to; how to break the project up into pieces so that if one part goes wrong, other parts can still be used; where and how to set milestones; and how to screen for a candidate who has the skills to properly implement the specs.
I asked a friend what issues I should watch out for and he said:
Make sure specs do not have contradictory information
Make sure specs are not unnecessarily specific because this will turn off more skilled developers
What other pitfalls and common mistakes should I look out for while drawing up project specs?
While it is important to focus on the functionality of what you want to achieve, also keep in mind the non-functional requirements as well. Think about how you want it to perform, security considerations, etc.
One to add to the list
Make sure the specs are unambiguous. (Can only be interpreted one way...Hopefully)
I think these two links will help:
On Reqs And Specs: http://www.pragmaticmarketing.com/publications/topics/02/0204sj
Painless Functional Specifications - Part 2: What's a Spec?: http://www.joelonsoftware.com/articles/fog0000000035.html

how to manage a compiler project? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am a CS student and I have a compiler project this year.
I want to know how to manage my project with my three partners.
I know that the compiler has many level and process, and I want to make use of these features to mange my project.
Thanks for any tips/pointers/resources you can provide for me to start.
You haven't really specified what it is that you are compiling, so it's a little difficult to make specific recommendations.
If you're doing something novel, I wrote a blog post a couple of weeks ago that has some specific things to consider:
http://www.plsadventures.com/2009/09/why-programming-language-design-is-hard.html
If it is a pre-existing language you are compiling, then I would work to generate a decent test corpus, and consider using test-driven development to manage your progress.
As you mentioned, there are some obvious components in most compilers that are relatively discrete. I would consider documenting the interfaces that connect these components. For example, if one person is writing the lexer and another is writing the parser, then ensure that you have a list of tokens written down somewhere. The format for your parse and/or abstract syntax trees should be defined and written down so that anybody working on optimisation or code generation is on the same page.
Above all, tests really help this kind of integration. You should be able to build these components separately and put them together, for the most part.
You should use a DCVS like Git or Mercurial, so each of you can develop individually while it's still easy to merge changes.
Next, you should define test cases to know which features you'll need and how you will know that a feature works.
That should help to figure out different areas of the project which don't overlap too much so each member of the team can work without stepping on each others toes.

Resources