As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 13 years ago.
Matz said :
I designed Ruby to minimize my surprise. I wanted to minimize my frustration during programming, so I want to minimize my effort in programming.
But sometime we get (bad) surprise in ruby practice.
As beginner in ruby, I found some example :
Exception Thread do not produce any immediate traces by default, we must do Thread.abort_on_exception = true or don't forget to join all thread.
socket search dns name for any accept, do BasicSocket.do_not_reverse_lookup = true for do not be surprise by long delay
split(regexp) don't split empty field in the end of string, do split(regexp,-1) for splitting all string
string.trim is unknown, use sting.strip in place (for old tcl dev...)
Have you other case for improve my ruby practice ?
thank you.
The design of Ruby the language is different from the design of Ruby libraries (which mostly seem to be what you use as examples). Matz designed the language around the principle of least surprise, but not every library (even modules in the Ruby standard library) were designed that way. (Keep in mind that Matz didn't write every Ruby library, or even the entire Ruby standard library, himself.)
A gentle note, I think you are over-extending the idea of least surprise. To me you are extending Matz's idea of least surprise from his idea of least surprise to include your idea of least surprise. Remember that what surprises you may not surprise another and may in fact surprise them if it worked the way that you think it should. All that said, it's good to voice your opinions about how you think it should work because we can all learn from it but to say that "we get (bad) surprise" is extending your idea of surprise onto others.
As for me, all of these examples have the feel that you want these to work better for your preference (or app) than the general case.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
This may be the weirdest question ever made here...
But its for a programming class animation project where we are learning about the differences about paradigms.
The project is based on the "Hi I'm a Mac, Hi I'm a PC" advertising, but instead of being about OS, we must show in an animation the differences between four different languages with four different paradigms...
My idea... romantic and artistic as i think i am... is that the 4 would compete for a girl to whom they want to declare their love by giving her a letter.
Chessy, right?
The "cool" part is that the girl looks like this concept art and the letter would just say: "Hello, World." :)
So...
if you still don't think this is the stupidest thing in the world, and this is allowed here, this is my question:
**
Which are JAVA'S, C'S, VISUAL BASICS'S, RUBY'S or PHP'S "personalities"?
**
For example:
Java (object-oriented) - gives her lots of gifts
Visual Basic (event-driven) - dates, events, parties
And that's it...
Do This languages would work? I'm still not sure how different they are?
Should i get other languages so it would be easier to understand the differences between paradigms? Any opinions about the animation? Should World stay single?
any help of ANY kind would be amazing, thanks :D
Here's some info which might help:
VB is stodgy, corporate, square-headed & crufty -- like Dilbert.
Ruby is like a web designer -- flashy & quick but probably crunky behind the scenes.
Java is like an expensively-suited contractor, integrating to mainframes.
C is like.. a hairy-bearded engineer, with a big wrench & some bare iron?
PHP is like.. some Unixy guy, more a VI/ text processing guy rather than the C guy?
Fill in the ways they express these personalities, yourself. Java guy can have a flash car & work on airline reservation systems (hence travel). Web designers are pretty easy to characterize. You do the rest.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I've been programming for the last 6 years. I just recently started my first degree in computer science. My work seems to be constantly marked down for different reasons, amongst many of them:
Uncommented code
Writing too long identifier names and methods
Writing too many methods
After working as a programmer for six years for numerous startup companies, and absorbing best practices which include the requirement to write "self explanatory code" I find it very difficult to go back to bad practices.
What can I do?
Self documented code is not synonymous with comments.
I've argued with many senior devs around this point. Code can go a long way in communicating intent but there are some things which simply cannot (and should not) be documented through code.
For example if you have a highly optimised function/method or chunk of code which is heavily coupled to the underlying problem domain and requires very specific knowledge of the business or solution. Comments are needed in these scenarios.
Yes, yes, comments come with there fair share of problems but this doesn't mean they aren't helpful (or mandatory in certain cases).
I can't tell you how many times I've read a colleagues line of code and thought "what the hell?!?" only for them to explain that they needed to do that due to some quirk of some library or browser we were targeting etc.
Comments are a mechanism for a developer to justify a design decision.
As for your other problems, they are subjective. How long is too long? How many is too many?
Point them at Microsoft's guidelines if you are on the MS stack or there will be countless articles for whichever language you're using...
Hope that helps.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I've always thought defensive programming was evil (and I still do), because typically defensive programming in my experience has always involved some sort of unreasonable sacrifices based on unpredictable outcomes. For example, I've seen a lot of people try to code defensively against their own co-workers. They'll do things "just in case" the code changes in some way later on. They end up sacrificing performance in some way, or they'll resort to some silver bullet for all circumstances.
This specific coding practice, does it count as defensive programming? If not, what would this practice be called?
Wikipedia defines defensive programming as a guard for unpredictable usage of the software, but does not indicate defensive programming strategies for code integrity against other programmers, so I'm not sure if it applies, nor what this is called.
Basically I want to be able to argue with the people that do this and tell them what they are doing is wrong, in a professional way. I want to be able to objectively argue against this because it does more harm than good.
"Overengineering" is wrong.
"Defensive Programming" is Good.
It takes wisdom, experience ... and maybe a standing policy of frequent code reviews ... to tell the difference.
It all depends on the specifics. If you're developing software for other programmers to reuse, it makes sense to do at least a little defensive programming. For instance, you can document requirements about input all you want, but sometimes you need to test that the input actually conforms to the requirements to avoid disastrous behavior (e.g., destroying a data base). This usually involves a (trivial) performance hit.
On the other hand, defensiveness can be way overdone. Perhaps that is what's informing your view. A specific example or two would help distinguish what's going on.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I will be teaching only one lecture on basic Prolog to students with little to no experience in programming. I'd like them to see that programming and Prolog can be used in the real world, perhaps even to do cool things.
I have looked at this and this threads, but I cannot find anything that is visually appealing that I can show them when we wrap up the lecture.
Do you have any suggestions for cool applications that use Prolog? I'm especially looking for something that can be shown as a video or slideshow.
If what you want is to highlight the uses of prolog and use audio-visual media merely for presentation purposes, combining the following 2 links might do it:
Natural language processing with prolog in the IBM Watson system
IBM's Watson supercomputer destroys all humans in Jeopardy
Dynalearn is implemented in Prolog and has animations.
See:
http://personnel.univ-reunion.fr/fred/Enseignement/Prolog/index.html
under "La librairie clpfd", there are links to 3 finite domain constraint animations (N-Queens, Sudoku, Knight Tour) that are used in this class.
InFlow is written in Prolog. You may browse through the examples and / or contact the author for details. VisiRule might also help.
Disclaimer: I have not used either InFlow or VisiRule, but I do use WIN-Prolog which is the environment used for both programs.
+1 for Visirule. It is, as far as I can tell (and I've researched this topic quite a lot) a unique visual programming tool (I don't know of any other visual tool that is easily reduced to a turing-complete language). I have implemented a trouble-shooting website with it along with various other solutions. Highly recommended- version 5 coming out soon too.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I have recently started learning Ruby, as my first programming language. I feel comfortable with the syntax, and I've done numerous tutorials that just teach the same basics. I have written a few small programs (including my own method for sorting an array that I thought was pretty smart until someone told me to Google 'Bubble Sort'), but I feel I need to attempt something bigger and harder to understand more about Ruby. Any ideas as to how I can do this?
Ruby Resources
http://www.rubyist.net/~slagell/ruby/
http://web.njit.edu/all_topics/Prog_Lang_Docs/html/ruby/syntax.html
http://www.ruby-doc.org/core-1.8.7/index.html
http://en.wikipedia.org/wiki/Ruby_(programming_language)
http://pleac.sourceforge.net/pleac_ruby.html
http://www.zenspider.com/Languages/Ruby/QuickRef.html
http://www.ruby-doc.org/docs/ProgrammingRuby/
The "advanced" Ruby book is The Ruby Way by Hal Fulton. It wouldn't hurt to read some real Ruby code - most gem's will do for this.
Finally, you need a project. You could take a program you have already written and redo it in Ruby, or you could think of something new to write.
Rubylearning Blog is hosting a fortnightly contest. The first contest went live - http://rubylearning.com/blog/2009/09/24/rpcfn-shift-subtitle-1/
That should be a start :)
A few years back I worked through Dave Thomas' Code Kata as part of a similar exercise. Fairly simple, self-contained pieces that let me explore the language at my own speed.
The kata idea seems to be moderately popular with developers, particularly at the Agile end - Googling "code kata" with and without "ruby" ought to throw up some more ideas.
fellow newbie. :) I too have just recently started learning ruby.
Right now, I'm reading The Ruby Way. Although I'm not required to code at work, I try to find practical applications of ruby -- no matter how mundane. For instance, I prepared scripts when I needed to test something that required several files with 0 file size and when i needed to generate an xml file based on another xml file; and since there was a tennis meet at work, i tried to create a script for random pairing or grouping. (Little baby steps, i know)
My colleague has written a post listing out the resources that a Ruby newbie would find useful. It was primarily intended for members of our local Ruby User Group, but it should be useful to you too.
More importantly, a lot has changed in the last couple of years and this post is pretty up-to-date (as of September 2012).
Here's the link: http://www.jasimabasheer.com/posts/meta_introduction_to_ruby.html