#ruby - 27 January 2018
« Back 1 day Forward 1 day »
[07:52:43] ddwagnz: i know silly question, but cloning from github (master) there is no ./configure or am i missing a step in compiling from github on centos
[12:44:01] untitaker: Hello, I'm relatively new to Ruby but not new to programming in general. I've just submitted my first PR to rubocop, but I think I have a communication problem with the core maintainer that might be due to me still using the wrong terminology for some basic concepts. Does anybody have a clue? https://github.com/bbatsov/rubocop/pull/5513
[15:40:40] mikhael_k33hl: Tried trapping the KILL signal via trap(:KILL) but it's giving me an error `trap': Invalid argument - SIGKILL (Errno::EINVAL)
[15:43:02] bawNg: mikhael_k33hl: you can't trap KILL, it forces a process to terminate immediately without time for any interrupts to be processed
[16:35:58] nchambers: do classes have something like #send except for class variables? I'm dynamically loading certain ruby classes, and I want to test if the class has a certain class variable, and if it exists get the value of it
[17:32:53] alpine: I have question on ssl authenication in ruby, let me know if i should go to a different channel
[18:18:46] hays_: this is a bit OT but im curious if anyone has opinions on a modern language that is in a similar efficiency class as C ? I've been poking around at Rust and maybe D as possibilities
[18:23:49] leitz: hays_, I'm looking at Go. Well, casting glances at it, Ruby is still more fun for me.
[18:26:41] leitz: Agreed. I'm more for Go as I think leaning into it as an almost early adopter will help. I think it has a better chance of displacing Java and .Net than others.
[18:39:55] leitz: WA9ACE, I will probably head to brackets down the road. While not a totally Ruby Newbie I'm only about half a step up. Plan is to work Ruby in 2018 and maybe find a project to join. Would use the project's conventions and most seem to prefer the "do..end".
[18:40:54] leitz: Otherwise near the end of the year I'll either convert to bracets or maybe Go for something new. :)
[18:55:02] leitz: If I collaborate, I agree. If I'm the only coder, and I see to be on my stuff, then I can do what looks best for me.
[18:55:32] leitz: I really dislike multi-levels of "end...end...end...end" and prefer the highlighting vim usually gets right.
[18:58:16] hays_: inasmuch as aesthetics influence design, even in something like a programming language
[18:58:50] hays_: my coding style has changed quite a bit just in the embrace of parenthesis omission
[19:01:16] leitz: Mine changed for the better after spending time with python. i like the whitespace.
[19:10:13] lavamind: hello! I'd like to pass a list of arguments to a rake task, that includes one argument that need to be Nil
[19:10:16] riceandbeans: other than being less likely to accidential interpolation, is there a performance benefit at all to using '' instead of ""?
[19:10:51] WA9ACE: I know back around ruby 1.8 and 1.9 there was definitely a reason to use single quotes over double
[19:11:46] lavamind: the task is set up to read arguments as task :mytask :param1 :param2 do |t, args|, I know how to specify arguments on the command line but how to pass something in :param2 while leaving :param1 nil?
[19:11:53] apeiros: I doubt that. single vs. double is a once-per-compilation difference. and even then the diff is mostly academic.
[19:12:16] riceandbeans: I'll be damned.....https://stackoverflow.com/questions/1836467/is-there-a-performance-gain-in-using-single-quotes-vs-double-quotes-in-ruby
[19:12:55] riceandbeans: I'm still going to use single when no interpolation needed, but I'm somehow surprised by the result
[19:15:48] WA9ACE: at least I found this. It's definitely true https://twitter.com/tenderlove/status/563256768739180544?lang=en
[19:22:25] WA9ACE: This was the string memory post I was misremembering in case anyone wants a good read http://patshaughnessy.net/2012/1/4/never-create-ruby-strings-longer-than-23-characters
[21:06:28] leitz: Two different ways of expressing the same concept; fail if a file doesn't exist. Not sure a better way doesn't exist. Thoughts? https://github.com/makhidkarun/2d6_ogl_chargen/blob/master/lib/character_tools.rb#L146-L179
[21:49:27] apeiros: also methods form an inherent begin/end block, so you can make the code less noisy.
[21:50:40] leitz: apeiros, right now I'm trying this, where MissingFIle < IOError. https://github.com/makhidkarun/2d6_ogl_chargen/blob/robust_file/lib/character_tools.rb#L150
[21:51:15] apeiros: e.g. https://gist.github.com/apeiros/c7d6147c8324c484f001db6e1f287b4d (the rand looks like it should not be part of the return value)
[21:53:03] leitz: The rand is a part of the return, it gives a measure of how much that plot is affecting that individual.
[21:53:25] apeiros: race condition being: 1) File.exist? -> true, 2) something outside your process deletes the file, 3) your try to open it fails despite your check
[21:54:20] apeiros: and you can always perform tests in the rescue to provide better diagnostics for your users
[21:56:24] apeiros: the other is about using begin/rescue over exist? checks because they don't always protect you
[21:57:39] apeiros: yes, I'd prefer the way your second method handles it. though since your second method doesn't actually handle it, I'd just leave the check away entirely.
[21:58:10] leitz: In theory I'm moving towards more expressive error messages and more robust checking.
[21:59:24] apeiros: you have to think about where in your code you are actually able to deal with that problem
[22:00:20] apeiros: as in `array_from_file`, where you don't execute any code to set new_array, which you try to return. ruby might initialize it with nil, or it might consider it an undefined variable…
[22:00:56] leitz: Putting it in these methods seems best since they are called from multiple places. The non-error code generated a nil array which said nothing about the file not being there.
[22:00:57] apeiros: in the former case - can all code calling array_from_file handle a nil return value? is it wise requiring all methods calling array_from_file to be able to handle a nil value?
[22:02:16] apeiros: ok, so your rationale was "then I only have to handle it in a single place", but again, can that single place actually handle it in a way that you can move on? (or abort the program?)
[22:02:51] apeiros: as in: once get_random_line_from_file handled the exception, can the code calling get_random_line_from_file continue?
[22:03:51] leitz: The code should fail if it cannot execute those methods. I had safety nets in before then realized the code was failing and I didn't know because the safety net caught it every time.