#ruby - 08 April 2017
« Back 1 day Forward 1 day »
[00:07:38] impermanence: okay. so text editors, really. so at the office...people use Atom...not RubyMine or something like that?
[00:09:40] impermanence: wow. and I am looking at a survey of 100 rubyists and 74 of them apparently only use an editor.
[00:11:57] impermanence: rubymine is advertised as a rails IDE. does this mean it's not suitable for ruby dev?
[00:13:45] lupine: the language is really, really hard to parse, so the useful features an IDE can provide over an editor are minimal
[00:14:02] lupine: ISTR using rubymine a while ago, but it was java-heavy and just didn't work in my LTSP environmwnt
[00:26:52] impermanence: Do rubyists use an analog to virtualenv for python or anything like that? just curious.
[00:27:57] impermanence: I thought rvm was just a version manager...can you actually go inside it like virtualenv?
[00:33:27] havenwood: impermanence: RVM is over twenty thousand lines of code. It patches old Rubies to be installable on old systems, manages project-specific gemsets, switches between Rubies, etc. It even ships chruby support. It's more of a superset of virtualenv.
[00:35:08] havenwood: impermanence: ruby-install just builds Ruby from source. you can specify --system for a single Ruby installed to /usr/local or you can install it in a default location or wherever you like.
[00:35:35] havenwood: impermanence: chruby switches between Rubies by setting PATH, GEM_HOME, GEM_PATH etc
[00:37:57] havenwood: impermanence: Often the CRuby reference implementation (YARV) or JRuby (JVM), but there are others.
[00:41:17] havenwood: The CRuby intermediate representation bytecode is different than the JRuby IR bytecode or Rubinius IR bytecode but they each produce one.
[00:42:03] ruby[bot]: allisio: # => [2, [:trace, 256], :label_2, [:trace, 1], [:putobject_OP_INT2FIX_O_1_C_], [:putobject_OP_INT2FIX_O_1 ...check link for more (https://eval.in/770782)
[00:42:59] allisio: And it does those things by vastly simplifying the massive Ruby language down to a relatively small stack-based virtual machine.
[00:43:35] havenwood: it saves time to compile to IR, that's something other implementations have done and the reference implementation might do in Ruby 3
[00:44:14] impermanence: so is there a thing where, like python, I can type "ruby" at the command prompt and like enter an interpreter or something? And just write code on the fly?
[00:44:53] havenwood: allisio: though i prefer the .ruby_binaries dbm from yomikomu's options: https://github.com/ko1/yomikomu#readme
[00:45:06] allisio: impermanence: The REPL that ships with Ruby is called `irb`, but `pry` is loads better.
[00:45:12] ruby[bot]: Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
[00:47:39] havenwood: impermanence: If you're interested in Ruby implementations you should look at truffleruby too: https://github.com/graalvm/truffleruby
[00:49:05] havenwood: impermanence: It's an exciting implementation with a very large team and much promise.
[00:49:40] havenwood: impermanence: It uses dated terminology, but see jruby-dev-truffle-graal performance here (now truffleruby): http://jruby.org/bench9000/
[00:50:48] impermanence: I didn't know there was more than one implementation of python, actually :|
[00:52:27] matthewd: If you just want to write some ruby, you don't need to know there's more than one implementation of ruby either
[00:53:03] havenwood: impermanence: CRuby is the reference implementation and supports C extensions. JRuby is the flagship JVM implementation and supports Java extensions. TruffleRuby runs on the GraalVM and supports C extensions. They're all Ruby. They have different memory and performance characteristics.
[00:53:54] impermanence: havenwood: makes sense. "Supports Java extensions"...like...writing Java in Ruby? Or...what does that mean? java-based Ruby code?
[00:55:01] impermanence: havenwood: okay. so is gem the package installer everyone uses? or is there more than one?
[00:55:48] havenwood: impermanence: one gem can have C extensions for when it's run on CRuby and Java extensions for when it's run on JRuby and pure Ruby fallback, it depends
[00:55:51] matthewd: impermanence: Use gem to install bundler. Then use bundler to manage the dependencies within a project.
[00:56:51] havenwood: impermanence: You can install dependencies from a Gemfile and create a Gemfile.lock with: gem install -g
[00:57:04] havenwood: impermanence: Or a more popular way to do the same is to install the bundler gem, `gem install bundler`, then run: bundle
[00:58:15] havenwood: Bundler resolved dependencies and created a Gemfile.lock before RubyGems supported the same. Bundler still has more features and is a hard-coded dependency of some Ruby software like Rails.
[01:00:40] impermanence: okay. So...regarding CRuby vs JRuby...are those the type of things that like if a Ruby developer goes into a Ruby interview knowing or not knowing the differences might mean getting a job or not? In other words...are the different implementations *that* significant?
[01:00:51] havenwood: impermanence: Most folk use Bundler for resolving gem dependencies. If you're not using Rails you can probably get by just fine with `gem install -g` and `export RUBYGEMS_GEMDEPS=~`.
[01:01:43] impermanence: For example...a Java dev would be expected to know the differences between Java 7 and Java 8 and would definitely be asked questions about Java 8, but it probably would not mean not getting the job if one did not know a ton about Java 8's finer details...
[01:02:51] havenwood: impermanence: if you're making architecture decisions then they'd be significant
[01:15:38] impermanence: wow. so turns out I needed to upgrade bash (I'm on OSX installing rvm. dang...)
[01:18:59] Radar: impermanence: rvm? You might have better luck with chruby + ruby-install: http://ryanbigg.com/2015/06/mac-os-x-ruby-ruby-install-chruby-and-you
[01:37:24] postmodern: appears that both debian (unstable and testing) and ubuntu now have ruby2.3 packages in their official repos. I'm wondering if it's still relevant to use BrightBox's ruby-ng PPA for deploying apps to Ubuntu environments?
[01:44:27] havenwood: impermanence: But yeah, it's stable. 2.4.1 or 2.3.4 are latest stable releases.
[01:45:12] semperfried76: re rspec: having an issue right now where tests complete, but then won't kill db connection, causing a stall. Anyone run into anythin similar?
[01:45:47] impermanence: So the article goes on to install Rails, etc. I plan to learn Ruby. Should I just go ahead and install Rails, too, or does that not matter right now?
[01:46:08] havenwood: impermanence: No need to install Rails 'till you go about creating a Rails app.
[01:52:13] ruby[bot]: impermanence: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
[01:58:54] impermanence: so...what do you all write your Ruby on? Is it just *way* better to use Linux?
[01:59:11] semperfried76: impermanence: you need the xcode tools in order to build native binaries for some gems
[01:59:33] havenwood: impermanence: macOS is fine, just update your build tools and brew update and you should be good to go
[02:01:34] havenwood: impermanence: If you already have command line tools installed, then `xcode-select --install` will tell you to use the software updater to keep them updated.
[02:08:53] impermanence: I'm apparently not the only one that has had this failure regarding softwareupdate --list, --install --all, etc. and there being an update available via the app store.
[02:12:04] impermanence: poor softwareupdate. okay then. anyway it's updating. darn it takes a long time.
[04:18:53] baweaver: Anyways, I didn't notice it when they said it or I'd mention something. Too late now.
[04:20:30] PorcoRex: Yeah, me too. But it seems rather bitter to come to say something like that, stand less than 20 minutes, and just log out. What kind of a grievance is that? I have greater grievances with Ruby that that.
[04:24:21] PorcoRex: baweaver, so, remember when we were discussing a couple of days ago about TCO? And how my friend would like it? Turns out he's a bit disappointed on Ruby for large scale applications. He's seriously considering Scala and/or other functional approaches.
[04:38:34] PorcoRex: I don't want to be controversial or anything, but many people seem to think a functional approach is the way to go, and, as previously discussed, Ruby is not specially apt for that paradigm.
[04:40:41] mzo: production software should ideally be written in Standard ML, or failing that, OCaml or Haskell
[04:42:06] PorcoRex: mzo, that seems an overly opinionated approach. Are there reasons for all production software to be written in those langs?
[04:47:32] baweaver: Ruby is a perfectly valid language for production use, as are several other languages
[04:48:16] baweaver: Ruby has a functional faceplate which allows emulation of some functional techniques, but only scratches the surface. For most this is enough.
[04:48:17] elomatreb: What I meant earlier: You can get some/many benefits of the advantages of FP in Ruby if you appropriate the patterns, but it won't enforce them, so you have to be discplined
[04:49:00] baweaver: There are lessons from FP like immutability, referential transparency, and others which are definitely applicable in Ruby
[04:49:37] baweaver: An example from the other day: someone had a log function that they wanted to test, but the function called Time.new inside it. That's not referentially transparent as it has a hidden input: Time.new
[04:49:58] baweaver: so instead you'd promote that to an argument with a default value of Time.new: def log(message, start = Time.new)
[04:52:18] baweaver: I was referring to the grand sweeping claims earlier from mzo in reference to trolling.
[04:52:32] PorcoRex: I don't see Ruby as a functional friendly language, but I do see it as a very good OOP language. Are there still any takers on that?
[04:53:50] baweaver: though you could almost make it fully functional by using Lambda Calculus and a whole lot of lambdas to rebuild the langauge
[04:54:56] PorcoRex: baweaver, what I mean is, forgetting all functional paradigms and constructs. Do you think that OO/OOP have outrun their lives in a sense?
[04:54:58] baweaver: interesting book, super trippy. Also 'Kestrels, Quirky Birds, and Hopeless Egocentricy' by Raganwald
[04:57:27] baweaver: The best product doesn't always win, remember. Beta was beat by VHS because of marketing. LISP suffered the AI winter and C++/Java took the crown.
[04:57:52] baweaver: Haskell can be the best language in the world, but that'll count for nothing if you can't get good programmers in it.
[04:58:10] PorcoRex: To be completely hones I know nothing about functional programming, but I'm quite comfortable with OOP. It is true that in bit apps maintained by a lot of people disasters happen (and big ones at that).
[04:58:16] baweaver: There's a definite trend towards it, yes, but currently not enough behind it yet.
[04:58:52] baweaver: totimkopf: http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
[05:01:39] baweaver: but it's dense stuff, don't worry if you can't get it the first (second, third, fo...) time
[05:01:57] PorcoRex: I think my friend would like Ruby again if he heard of monads. But, how come, is Ruby becoming a more functional language in the future?
[05:03:42] baweaver: Ruby 3 is doing some interesting things. Last I heard they involved a message concurrency system like Erlang and type annotations as well as some huge performance boosts
[05:03:48] PorcoRex: No, I know (or I think I know but actually don't) but what I mean is... why are we in Ruby instead of in some other IRC channel.
[05:05:14] PorcoRex: So you've overtaken the channel, even though you'd be rather programming in, say, Elixir.
[05:06:57] baweaver: Ruby is the first tool I reach for in anything scripting or operations, every time.
[05:08:27] PorcoRex: And, if I may ask, why did you eventually derive from Ruby to other more functional languages?
[05:11:35] baweaver: Banks? Haskell shows up a fair amount. Ericsson invented Erlang and still uses it. It's already out there
[05:13:36] baweaver: of course chances are I don't entirely agree with myself from two years ago, but that's a different matter.
[05:14:53] PorcoRex: I understand. But programming-wise, is it better/worse or just the same in your opinion?
[05:15:00] totimkopf: baweaver: actually I read it anyway and it actually makes a lot more sense now
[05:16:46] baweaver: See also: The LISP Curse - http://winestockwebdesign.com/Essays/Lisp_Curse.html
[05:18:02] baweaver: they both have some of the same problems, just that one has control of most of the web now because ubiquity is fun
[05:21:10] PorcoRex: beatdown, by the way, I think I asked you before, but say you had to do like a CMS for movies and that it was used (partially or totally) by cinemas all over the country.
[05:22:00] baweaver: TL;DR of everything I've said: If someone knocks on your door selling an ultimate solution, you'd be instantly skeptical. Same with programming. Be skeptical.
[05:22:52] PorcoRex: But if they hired you, and you could assemble the base, what would you choose on that particular example?
[05:23:00] baweaver: I wouldn't have to screw with type signatures, purity, composition, or any of it. I could just be done and let Rails decide the architectural concerns for me.
[05:23:48] baweaver: which is why Twitter started Rails, and when they did make it big, hired people to scale it / switch to Scala
[05:24:14] PorcoRex: I get you. Let's forget about time. (also not specifically talking about Rails, or even Ruby) just your preference.
[05:25:51] PorcoRex: It's hypothetical, but, in any case... Wouldn't FP also sweep languages like Java, Python, etc?
[05:26:59] PorcoRex: I mean like say C. It can't be erased, but, if it can be avoided noone will be pressured to write in it.
[05:27:36] baweaver: A salesman finds a lumberjack cutting redwoods with an axe, and sells him a chainsaw. Comes back after a few days to check on him, and not a single tree is down. Lumberjack hates the chainsaw, calls it worthless. Why do you suppose that is? It's obviously more efficient and better suited for the task.
[05:29:19] baweaver: The salesman asks the lumberjack to show him how he uses the chainsaw, and the lumberjack proceeds to slam it against the tree like his axe. A good tool is worthless in the hands of the untrained, but a familiar tool will always beat it until they learn the good tool.
[05:30:06] baweaver: Remember there's a learning curve to the good tool that may far exceed "swing at tree"
[05:30:28] baweaver: and a lot of people learned on Java and friends, so Haskell is a monster jump to them
[05:31:35] baweaver: I can have a Java programmer effective in Ruby in a week. That won't happen in Haskell, the concepts are too foreign
[05:32:00] PorcoRex: baweaver, no no, I understand that. I think I need a bit of it before I can make the conversation interesting, but actually my discussion was a bit on the "I don't know" side.
[05:32:39] baweaver: There are more factors to choosing than the superior quality of the language / paradigm of programming
[05:33:35] baweaver: Market pool (how many programmers are available), effectiveness (how fast they are, does 1xHaskell == 10xJava?), libraries (how much community support), docs, and a lot more
[05:33:46] PorcoRex: baweaver, I guess my question was, if you had to make a big app, would you choose X language? And what would X be?
[05:37:12] PorcoRex: I must confess, it is only confusing because I don't know these languages well myself, otherwise it would be a matter of making a choice.
[05:38:57] PorcoRex: beatdown, no, I mean, I know some, but just not the ones outside my comfort zone.
[05:52:46] nofxx: PorcoRex, apart from web/js anything is better with ruby! and for JS you can write coffeescript which tries to be ruby!
[05:55:43] nofxx: PorcoRex, can't say... never did anything with ES6. If I got it right it compiles to normal JS but eventually will run w/o compile in modern browsers?
[10:36:51] galtgendo: in Psych, how does init_with method account for yaml anchors ? I'm getting '`*': nil can't be coerced into Fixnum (TypeError)' in such cases with a method that works when no anchors are present
[12:37:39] Verity: I know its not technically the true algorithm, I wanted to change space char also
[12:42:03] Verity: I'll check the doc, I almost noticed I made a mistake. I'll work on improvments now
[12:42:51] matthewd: tr makes it a one-liner, and is the right solution for the problem.. but may not be as helpful for general learning
[13:19:53] jhass: also as long as you have the cookie from creating it you can delete it yourself I think
[13:27:29] canton7: avoid paying for the space required to store millions of gists noone cares about any more?
[13:43:41] Travis-42: Every time I try to use ruby with the watir gem, I get the mac os popup about allowing incoming network connections. Regardless of what I choose, it happens again the next time. It seems like Mac OS is not recognizing the ruby executable each time. Is there any way to fix this?
[15:09:37] lupine: http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-mac-8.7.1-amd64-netinst.iso
[15:36:15] ytti: anyone use VSC to edit ruby files, is there way to make '%' jump between def/class/begin/block and end?
[16:35:48] ruby[bot]: impermanence: Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-do
[16:36:56] impermanence: havenwood: it keeps complaining about zlib. So I updated Xcode like the internets said to, but it did not fix it.
[16:37:29] havenwood: impermanence: Did you entirely remove, and reinstall Ruby after installing the build tools?
[16:38:00] j416: impermanence: use ruby-install + chruby or rvm or something like that; don't mess with the system stuff
[16:38:47] impermanence: so...I need to remove ruby-install and chruby...that's how I uninstall ruby...?
[16:55:29] havenwood: impermanence: for whatever reason they moved it from homebrew/dupes to homebrew/core
[16:56:41] havenwood: impermanence: you could file a dep report with ruby-install - or stop by the #chruby channel any time and I'd be happy to try to debug and PR the fix
[16:57:44] impermanence: havenwood: you Sir are a Sir. I will do that. I can't now because I've already been scripting for like three hours (had to wet the ol' beak despite the gems debacle) and I need to go run some errands.
[16:58:26] impermanence: havenwood: see you over in #chruby on Monday. We'll do this and then maybe I'll write a blog post about it. thanks for the insight!
[17:36:24] siaw23: why am i getting “no block given” error here: https://i.gyazo.com/cfc019fb5b3f026b4f190ce1cda2308b.png
[17:43:20] siaw23: i thought yield will always find the block itself provided the name of the block and method match
[17:44:49] elomatreb: siaw23: `block_given?` returns true if the method was called with a block, nothing more