Garb0 has quit [Read error: Connection reset by peer]
Garb0 has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<sagax>
hi all!
<sagax>
rubyzip so slowly
<sagax>
we have speed alternative then rubyzip? to stream files as zip archive
drincruz has quit [Ping timeout: 260 seconds]
Rakko has quit [Quit: Leaving]
cnsvc has joined #ruby
SuperLag has quit [Ping timeout: 264 seconds]
cnsvc has quit [Ping timeout: 240 seconds]
gix has quit [Ping timeout: 264 seconds]
Rakko has joined #ruby
SuperLag has joined #ruby
Rakko has quit [Remote host closed the connection]
drincruz has joined #ruby
drincruz has quit [Ping timeout: 258 seconds]
xco has joined #ruby
xco has quit [Client Quit]
lightstalker has quit [Ping timeout: 256 seconds]
lightstalker has joined #ruby
burgestrand has joined #ruby
burgestrand has quit [Client Quit]
Emmanuel_Chanel has quit [Ping timeout: 264 seconds]
drincruz has joined #ruby
drincruz has quit [Ping timeout: 272 seconds]
Garb0 has quit [Remote host closed the connection]
Emmanuel_Chanel has joined #ruby
johnny56 has quit [Ping timeout: 240 seconds]
johnny56_ has joined #ruby
gavlee has quit []
deathwishdave has joined #ruby
ChmEarl has quit [Quit: Leaving]
Arkantos has joined #ruby
hassox has quit [Read error: Connection reset by peer]
Arkantos has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
inanepenguin has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
inanepenguin has quit [Quit: inanepenguin]
drincruz has joined #ruby
drincruz has quit [Ping timeout: 272 seconds]
pwnd_nsfw has joined #ruby
pwnd_nsfw has left #ruby ["Leaving"]
pwnd_nsfw has joined #ruby
pwnd_nsfw has quit [Remote host closed the connection]
plutes has joined #ruby
NightMonkey has quit [Ping timeout: 260 seconds]
gavlee has joined #ruby
wymillerlinux has quit [Ping timeout: 260 seconds]
NightMonkey has joined #ruby
imode has quit [Ping timeout: 260 seconds]
xco has joined #ruby
xco has quit [Client Quit]
zacts has joined #ruby
lxsameer has quit [Ping timeout: 260 seconds]
blackmesa has joined #ruby
lxsameer has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
pwnd_nsfw has joined #ruby
blackmesa has quit [Ping timeout: 272 seconds]
<matti>
sagax: rubyzip is pure-Ruby, perhaps there exist something that uses C bindings to some libraries, that might be faster. But, what do you mean by "slow"?
blackmesa has joined #ruby
blackmesa1 has joined #ruby
blackmesa has quit [Ping timeout: 260 seconds]
blackmesa1 has quit [Ping timeout: 256 seconds]
burgestrand has joined #ruby
drincruz has joined #ruby
chouhoulis has quit [Remote host closed the connection]
drincruz has quit [Ping timeout: 246 seconds]
conta has joined #ruby
pwnd_nsfw has quit [Quit: Leaving]
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
howdoi has quit [Quit: Connection closed for inactivity]
imode has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
blackmesa1 has joined #ruby
burgestrand has quit [Quit: burgestrand]
blackmesa1 has quit [Ping timeout: 260 seconds]
blackmesa1 has joined #ruby
burgestrand has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
chalkmonster has joined #ruby
lesihctej has joined #ruby
jetchisel has quit [Read error: Connection reset by peer]
<yoones>
Hi, I need help with define_method and value persistance (I'm not sure how to phrase my question but the code sample is pretty explicit) => https://pastebin.com/Pdt97N1t Any help appreciated!
<havenwood>
yoones: There's no 42 in your example.
<jhass>
yoones: https://carc.in/#/r/91ok but beware https://carc.in/#/r/91ol Generally define_singleton_method on an object instance is quite a smell, there's probably a better way to design your program
<havenwood>
Oh.
<havenwood>
Line 11.
<jhass>
lucianp: add the m flag, /../m
<jhass>
or wait, isn't that default?
<jhass>
hah, it matches \n but not \r\n
<lucianp>
m flag makes . match newline
<jhass>
can you just gsub("\r\n", "\n") before?
<jhass>
or possibly even .delete("\r")
<jhass>
looks like Ruby offers \R to match linebreaks generally but that won't match end of string then I guess
<lucianp>
Sure. There are a number ways around this, but I don't want to redo a bunch of regex and duplicate that workaround in numerous places. I was hoping ruby's regex engine had a way to configure $ to match end-of-line like pcre's compile-time option or run-time option. :)
<jhass>
I don't see anything in there unfortunately
<lucianp>
seems a bit of an oversight, no? \r\n is common in networking and windows
<havenwood>
lucianp: common in networking?
giorgian has joined #ruby
<havenwood>
I think regexp can be forgiven not focusing on carriage returns in networking.
<jhass>
:D +1 to that
<lucianp>
yea, it's sometimes used in telnet (depending on options)
<lucianp>
and nearly always used in windows
<jhass>
maybe on windows it matches?
<jhass>
not sure anybody has a windows machine here to try :D
<lucianp>
anyhow, my point being that a pcre that works to match end-of-line (e.g. in a windows env) would have the above issue if used without adjustment in ruby. I'm not sure how compatible ruby's regexes intend to be to pcre though.
<jhass>
well, they'll have their reasons for building their own RE engine (and rebuilding it a couple of years ago) over just including libpcre I guess
<havenwood>
lucianp: Ruby uses Onigmo, which has a --enable-crnl-as-line-terminator, but I've never tried to enable it.
<lucianp>
yea, that'd be what I was looking for. Thanks. Interesting that it's not enabled by default in ruby, while it is in libpcre.
TCZ has joined #ruby
drincruz has joined #ruby
rubydoc has quit [Ping timeout: 260 seconds]
drincruz has quit [Ping timeout: 246 seconds]
ur5us has quit [Ping timeout: 260 seconds]
conta has quit [Quit: conta]
infinityfye has joined #ruby
blackmesa has quit [Ping timeout: 256 seconds]
burgestrand has joined #ruby
burgestrand has quit [Client Quit]
vondruch has quit [Ping timeout: 240 seconds]
Benett has quit [Remote host closed the connection]
Benett has joined #ruby
yoones has quit [Quit: Leaving]
TomyLobo has joined #ruby
lesihctej has quit [Ping timeout: 240 seconds]
Garb0 has joined #ruby
jeromelanteri has joined #ruby
vondruch has joined #ruby
<lucianp>
def method_missing(m, *args, **kw, &block) if @thing.respond_to? m then @thing.public_send(m, *args, **kw, &block) end end What's the appropriate way to pass on all args prior to 2.7 where there exists (...)? With this approach, I get errors like "Exception: wrong number of arguments (given 3, expected 2)" with obj[5] = "apple".
<lucianp>
It looks like https://bugs.ruby-lang.org/issues/12022 was supposed to have fixed this, but it isn't clear to me which versions received the fix and which are still affected.
<lucianp>
That above exception was in 2.5.7
chalkmonster has joined #ruby
cnsvc has joined #ruby
conta has joined #ruby
drincruz has joined #ruby
Arkantos has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
conta has quit [Quit: conta]
pwnd_nsfw has joined #ruby
plutes has quit [Quit: If you judge me now, you have judge me prematurely.]
pwnd_nsfw has quit [Client Quit]
pwnd_nsfw has joined #ruby
blackmesa has joined #ruby
infinityfye has quit [Remote host closed the connection]
Xiti` has joined #ruby
drincruz has quit [Ping timeout: 264 seconds]
Xiti has quit [Ping timeout: 240 seconds]
TomyLobo has quit [Read error: Connection reset by peer]
fercell has joined #ruby
Arkantos has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drincruz has joined #ruby
gigetoo has quit [Ping timeout: 260 seconds]
infinityfye has joined #ruby
<jhass>
did you try without **kw?
Arkantos has joined #ruby
conta has joined #ruby
jetchisel has joined #ruby
gigetoo has joined #ruby
<lucianp>
hmm.. that works. Though, I'm confused as to why **kw seems to be passed as a single positional argument.
<jhass>
ruby didn't have keyword arguments historically, but always allowed to leave the braces off of a hash literal when passing it as the last argument to a method. so foo(a, :key => 1). Then it introduced the symbol hashes and thus foo(a, key: 1) became valid. Now a lot of code was written expecting hashes there. When introducing keyword arguments the syntax could be reused if a caller not expecting
<jhass>
keyword arguments would receive a hash of them instead
<jhass>
that kind of conversion/adaption behavior has a couple of edge cases, hence the deprecation of the hash passing style in 2.7
Arkantos has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gigetoo has quit [Ping timeout: 256 seconds]
gigetoo has joined #ruby
caterfxo has quit [Quit: leaving]
Arkantos has joined #ruby
gigetoo has quit [Ping timeout: 256 seconds]
blackmesa has quit [Ping timeout: 272 seconds]
fercell has quit [Quit: WeeChat 2.8]
fercell has joined #ruby
fercell has quit [Client Quit]
ellcs has joined #ruby
fercell has joined #ruby
wymillerlinux has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
TCZ has quit [Quit: Leaving]
dviola has joined #ruby
Xiti` has quit [Quit: Leaving]
leitz has joined #ruby
Garb0 has quit [Read error: Connection reset by peer]
zacts has quit [Read error: Connection reset by peer]
TCZ has joined #ruby
hassox has joined #ruby
hassox has quit [Ping timeout: 260 seconds]
chalkmonster has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
Xiti has joined #ruby
chalkmonster has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 256 seconds]
blackmesa has joined #ruby
blackmesa has quit [Ping timeout: 240 seconds]
goepsilongo has quit [Quit: Konversation terminated!]
Rakko has joined #ruby
MrCrackPot has joined #ruby
MrCrackPot has quit [Remote host closed the connection]
gigetoo has joined #ruby
kristian_on_linu has joined #ruby
gigetoo has quit [Ping timeout: 256 seconds]
<axsuul>
Anyone know off the top of their head which is more performant? Set[1, 2, 3] - Set[1, 2] vs. Array[1, 2, 3] - Array[1, 2]
gigetoo has joined #ruby
Emmanuel_Chanel has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
conta has quit [Quit: conta]
kinduff has joined #ruby
<pwnd_nsfw>
axsuul, Ruby comes with a super easy way to benchmark these things
<jhass>
it does some common pitfalls for you like cache warmup, calculating the standard variance
<axsuul>
Cool! so I tested it, it seems the array method is more performant
<jhass>
now try what happens with a thousand entries ;)
<jhass>
and then 10k
<jhass>
also make sure you don't actually allocate those inside the benchmark function
<jhass>
you want to compare Set#- and Array#- after all, right? Not Set::[] and Array::[]
nowhere_man has quit [Remote host closed the connection]
nowhere_man has joined #ruby
burgestrand has joined #ruby
caterfxo has joined #ruby
fercell has quit [Quit: WeeChat 2.8]
akem has quit [Remote host closed the connection]
gigetoo has quit [Remote host closed the connection]
gigetoo has joined #ruby
<pwnd_nsfw>
Thanks for the supplementation jhass!
<jhass>
gladly. Not that I think that microbenchmarks are worth anybody's time outside things like standard library development
<jhass>
but hey, no judging what brings you joy
gigetoo has quit [Remote host closed the connection]
gigetoo has joined #ruby
<pwnd_nsfw>
I mean, it's good to know what tools are available.
ua has quit [Ping timeout: 240 seconds]
mikecmpbll has quit [Ping timeout: 256 seconds]
mikecmpbll has joined #ruby
burgestrand has quit [Quit: burgestrand]
unreal_ has quit [Ping timeout: 258 seconds]
akem has joined #ruby
akem_ has joined #ruby
pwnd_nsfw has quit [Remote host closed the connection]
ua has joined #ruby
dviola has quit [Ping timeout: 264 seconds]
akem has quit [Ping timeout: 272 seconds]
inanepenguin has joined #ruby
memcorrupt has joined #ruby
<memcorrupt>
hello, why there isn't a "Hash#clear!" but a "Hash#clear" ?
gemini315 has joined #ruby
<leah2>
because there is no non-destructive way to clear
<leah2>
resp it's called {} ;)
d3bug has joined #ruby
<gemini315>
test
gemini315 has quit [Quit: Light travels faster then sound, which is why some people appear bright, until you hear them speak]
burgestrand has joined #ruby
imode has joined #ruby
burgestrand has quit [Client Quit]
orbyt_ has joined #ruby
gigetoo has quit [Ping timeout: 272 seconds]
gigetoo has joined #ruby
howdoi has joined #ruby
<memcorrupt>
leah2, yeah, it's destructive and affects in place, so... why it doesn't tail with ! mark?
<leah2>
x! usually only exists if x exists too
dionysus69 has quit [Ping timeout: 264 seconds]
akem_ is now known as akem
<memcorrupt>
leah2, I don't see why...
<apotheon>
Basically, if the effects of the method are *obviously* and *only* destructive in some sense, it's assumed you don't need a warning, I think.
dviola has joined #ruby
<apotheon>
The ! doesn't seem intended as some universal statement that you're causing side effects, but rather as an indication that, of two variations on a method implementation, this is the variation that has more sigificant effects you might want to be wary of unknowingly triggering.
gigetoo has quit [Remote host closed the connection]
ChmEarl has joined #ruby
memcorrupt has quit [Ping timeout: 272 seconds]
memcorrupt has joined #ruby
<memcorrupt>
apotheon, it's okay for a human as a reader, but not a machine/bot/tool
<jhass>
in stdlib the rule simply is "oh it would be nice to provide a self-modifying variant of this! Let's add one with the same name and add !". If either a self-modifying or a copy returning variant of the method makes no sense, you won't get any !. In other words you will find no ! method without a non-bang counterpart
<jhass>
but the reverse is obviously not true
<memcorrupt>
how it wouldn't make sense?
<memcorrupt>
it might not*
conta has joined #ruby
<apotheon>
memcorrupt: I think Ruby's designed for humans.
<memcorrupt>
yet we need static analyzer tools :)
<memcorrupt>
and automation
<apotheon>
memcorrupt: An example of something that doesn't make sense to have both method types is any case where what you're talking about doing is only and solely about the modification, and not about returning a value (e.g. an "increment_in_place" method), or something that just requests a value from a public, non-writable API.
<apotheon>
. . . so if a self-modifying variant of a method makes no sense because it's effectively impossible to implement or conceptually nonsensical, or a non-self-modifying variant is similarly nonsensical, then we end up with no bang method.
<apotheon>
Consider puts. How does it make sense for that to have a self-modifying variant?
<memcorrupt>
we were talking about Hash#clear ...
<apotheon>
As for Hash#clear, it doesn't make sense to have a non-self-modifying variant, because the implementation would basically just be something like `def clear; Hash.new; end`.
<apotheon>
If that's all you want, just use Hash.new instead.
<memcorrupt>
and my point is... Hash#clear! must exist and Hash#clear should be removed (after 3.0 or so...)
<apotheon>
There's no reason for a non-self-modifying variant of Hash#clear, in other words.
<apotheon>
memcorrupt: You asked jhass "how it wouldn't make sense". I was answering that.
<apotheon>
That was after jhass said "If either a self-modifying or a copy returning variant of the method makes no sense, you won't get any !."
<memcorrupt>
yeah, right, topic got a bit complicated...
<apotheon>
Again, the bang doesn't mean "self-modifying method" or "dangerous method" or "side-effect method" in the Ruby stdlib. It means "more side-effecty variant of another way to implement a method like this".
<memcorrupt>
oh
<apotheon>
(to address your initial question)
<memcorrupt>
right... OO after all
hassox has joined #ruby
<jhass>
actually in stdlib it does mean "self-modifying variant of the bangless version"
<apotheon>
It's just a way to differentiate, not a signifier of a particular behavior pattern.
<jhass>
there's no bang method in ruby stdlib that's not that
<jhass>
just again the reverse implication is not valid, if it has no bang it does not mean it's not self-modifying
<apotheon>
I feel like your description is conflating two issues.
<memcorrupt>
so... is there any reason that a x! shouldn't exist if x doesn't exist?
<jhass>
(talking explicitly exclusively about stdlib, the wider community sees it differently)
<memcorrupt>
I was about to open an issue, but my friend said it's better to ask the community so I came here
<apotheon>
One is whether its purpose is to indicate a particular behavioral pattern, and the other is whether its purpose is to differentiate two variants. I see it as the latter, with the specific case of this difference conforming to the former. Thus, while the former is an unreliable way to judge whether there should be a bang method, the latter is *very* reliable -- exactly as reliable as combining
<jhass>
the reason is that stdlib is very consistent of that being the case
<apotheon>
the two criteria together.
<apotheon>
. . . so it can be minimized in coplexity by only using the latter criteria to explain it, thus eliminating the tendency of people to still think that something should be a bang method despite lack of a non-bang method due to confusion over the complexity of the description of the criteria for bang methods.
<apotheon>
s/coplexity/complexity/
rippa has joined #ruby
<apotheon>
memcorrupt: The reason is that bang methods are for variants, not sole implementations, only differentiating between multiple extant implementations.
<apotheon>
It's a disambiguator, not Hungarian notation.
hassox has quit [Ping timeout: 272 seconds]
<jhass>
mmh, in stdlib the behaviour pattern is very straight forward though. there's no rails style .save / .save!. It's all about self-modification
<jhass>
I feel like understanding this simple behaviour pattern may actually guide to why having two variants sometimes is useful and sometimes not
TCZ has quit [Quit: Leaving]
<memcorrupt>
I think it's better to allow sole ! too...
<jhass>
you won't undo 25 years of history now :)
impermanence has joined #ruby
<havenwood>
memcorrupt: The Ruby convention is to only have a bang version if a less dangerous non-bang version exists.
<memcorrupt>
another question: how would it *harm* to have the former criteria? (having x! even if x doesn't exist)
<havenwood>
memcorrupt: It's not enforced. The VM lets you define a bang method without a non-bang one, but it violates a convention as old as Ruby.
<havenwood>
memcorrupt: You should only define a #foo! method if a #foo method exists, to be clear.
<havenwood>
memcorrupt: A bang doesn't necessarily mean the receiver is modified. It means it's more dangerous, nebulously.
<memcorrupt>
I'm talking out of standards, I'm trying to find out if this standard is limiting for no good or there is or at least can be a reason
<memcorrupt>
like will having x! without x result in *any* harm? either readability, dependent conventions or etc...
tomg_ has joined #ruby
<havenwood>
memcorrupt: The bang (!) does not mean "destructive" nor lack of it mean non destructive either. The bang sign means "the bang version is more dangerous than its non bang counterpart; handle with care". - Matz
<memcorrupt>
okay then... problem solved, thanks
tomg has quit [Ping timeout: 256 seconds]
TCZ has joined #ruby
TCZ has quit [Quit: Leaving]
memcorrupt has quit [Ping timeout: 260 seconds]
memcorrupt has joined #ruby
alexherbo23 has joined #ruby
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo23 is now known as alexherbo2
memcorrupt has quit [Quit: -a- ...]
infinityfye has quit [Read error: Connection reset by peer]
<lucianp>
http://dpaste.com/2QQM630 Why is 'rank' treated as a local var without 'self.' in thumbs_up, but not in popular? Is ruby's name binding spelled out somewhere that explains the distinction between the two cases?
Dalboz has joined #ruby
crankharder has joined #ruby
crankharder has quit [Client Quit]
sauvin has quit [Read error: Connection reset by peer]
nowhere_man has quit [Read error: Connection reset by peer]
tomg_ is now known as tomg
tty1 has joined #ruby
<tty1>
Hi, am I crazy or does ruby handle variables differently based on their capitalization
CrazyEddy has quit [Ping timeout: 256 seconds]
<tty1>
I notice if i assign something to a capitalized variable name it behaves entirely different as to when I assign something to an uncapitalized variable name
<adam12>
tty1: They're case senitive.
<tty1>
adam12: well obviously their case sensative but thats not what i meant
<adam12>
tty1: Variables starting with a capital are technically a constant. That changes their lexical scope.
<pokui>
tty1: constants begin with a capital letter if that's what you mean.
<tty1>
it seems to be more than just a scope thing
<tty1>
the behavior is entierly different it seems
<adam12>
tty1: Example?
<pokui>
well you get a warning if you try to change the value of a constant
<phaul>
"You can give a class a name by assigning the class object to a constant."
<jhass>
lucianp: if we canonicalize rank += 1, it's rank = rank.+(1), assignment is not a method call, it creates a local variable at parse stage already.
<leftylink>
whatever that means for what is created
<phaul>
it's just a normal class, an instance of Class in other words
<tty1>
phaul: well it doesnt appear to be an instance of an ordinary class, only of an Eigenclass because it has "new" ..
<tty1>
so I guess Class itself is an Eigenclass that can create other Eigenclasses, or perhaps just treated as a special keyword
<jhass>
tty1: What's an eigenclass for you? Note the term is eradicated from Ruby API and docs as far as I'm aware. There's singleton classes that historically sometimes were called eigenclasses in Ruby
<leftylink>
it would be easier for me if there were a statement of the form `class C1; ... end; C2 = Class.new { ... }` "we can do this with C1 but we can't with C2" (or vice versa)
<leftylink>
I thought there wouldn't be any difference between what we can do with C1 and C2.
<lucianp>
jhass: thanks. Reading that now leaves me paranoid wondering how many times I've left out an explicit self in an assignment
<jhass>
I'm not aware of any either. Except referring to them by a constant or getting their name if you don't assign the latter, I guess?
<jhass>
lucianp: yes, it's a common gotcha :)
<tty1>
jhass: then perhaps its a bad term now.. I just knew that when you create a class of something "class X ... end" that X is considered an Eigenclass. Which meant taht X was an instance of a class that existed as a singleton and capable of creating "children" classes that were instances and not singleton via new...
<tty1>
jhass: but what I really meant was that Class.new creates "something" which iself has a new method able to create instances
<jhass>
so how about the above question? Can you name a functional difference between class X; end; and X = Class.new?
<tty1>
So "Class" acts very differently than other "class objects" it seems
<tty1>
jhass: no but there are functional differences between X in that context and Class in that context
<tty1>
in other words "Class" is not the same sort of "thing" as X is
<jhass>
not so much! X.new is actually Class#new
<jhass>
it's the instance method new on the class Class
rapha has joined #ruby
<rapha>
hi all!
<tty1>
jhass: but Class.new.new is valid.. but X.new.new is not
<jhass>
but it's true, you cannot really recreate your own Class
<tty1>
so the new methods do act different in those two cases it seems
<leftylink>
of course Class.new.new is valid. Class.new is of type Class, so you can do Class.new.new. X.new is of type X, so you cannot do X.new.new.
<tty1>
yea thats kind of my point, though more generally.. class is some sort of special thing that X (and other class objects) are not.
<jhass>
class X; def new; y = allocate; y.initialize; y; end; end
<jhass>
wait, that allocate needs a receiver I guess
<tty1>
well yea, but my point remains.. 'Class' is not really just a class object like X would be, its something special entierly.. not that thats all that revolutionary..
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<tty1>
I guess this explains why they did away with the phrase Eigenclass.. sounds like it really doesnt work that way anymore
<tty1>
phaul: related to what im trying to understand now?
Xiti` has quit [Remote host closed the connection]
<jhass>
the singleton class is a class that's a parent of just a particular object.
<phaul>
it's about explaining the ruby object model, and singetonclasses
<tty1>
phaul: awesome thanks
<jhass>
you can do x = X.new; def x.foo; end; and only x but not all Xes will respond to foo
<ericm>
phaul, I've watched that video so many times over the years! Love it!
<jhass>
this foo is defined on x'es singleton class
pwnd_nsfw has joined #ruby
<jhass>
you can imagine the singleton class as an implicit child class for each instance of any object, so the object is actually an instance of that singleton class that has the actual class as its parent class
<jhass>
This is how "static methods" work, def self.foo inside a class defines a method on the singleton class of that classes (self) Class instance
Xiti has joined #ruby
<tty1>
jhass good point, you can extend instances just like you can class objects
<jhass>
because there's no real difference!
<tty1>
Ruby is funny.. depending on what angle i look at it from it is either overly complicated to the point of confusion... or very astronomically simple
<rubydoc>
I will remember that objectmodel is This lecture by Dave Thomas is about the Ruby object model, and singleton classes....
leitz has quit [Quit: Leaving]
conta has quit [Quit: conta]
<apotheon>
Ruby is great when one is willing to think in Ruby.
<apotheon>
Thinking in Algol makes it murderously difficult to happily use.
<apotheon>
I think most people's experiences of Ruby are effectively either "thinks in Ruby while writing Ruby" or "thinks in something wildly incompatible with thinking in Ruby".
rubydoc has quit [Remote host closed the connection]
<apotheon>
. . . which would likely be why so many people seem utterly flabbergasted to learn I like and enjoy both C and Ruby: I think in C when I write C, and I think in Ruby when I write Ruby.
rubydoc has joined #ruby
<d3bug>
i think in asm :o
<apotheon>
I don't even think most C programmers really think in C, though.
<apotheon>
C books and instructors sure don't really seem to show any evidence of thinking in C.
<apotheon>
d3bug: . . . while writing Ruby? That must be miserable.
<jhass>
I'm curious, do you have a simple example for both, thinking in C and thinking in Ruby? maybe even for the same problem statement?
howdoi has quit [Quit: Connection closed for inactivity]
<apotheon>
Thinking in Ruby involves stuff like thinking in terms of all things being objects or methods (or, in rare cases, keywords), with a consistent object model and rich support for some built-in functional programming techniques, where one realizes that thinking in terms of "functions" one would in Algol leaves one with the impression that Ruby is much like PHP's giant bag of core functions only
<apotheon>
worse instead of the impression that it is a duck-typed human-friendly set of predefined entities on which one can build.
<apotheon>
That's why, for instance, some Python people just scoff at Ruby saying it has "too many functions" to be particularly usable, I think.
seaef has joined #ruby
<apotheon>
Thinking in Ruby potentially leads one, by contrast, to think Python is the incoherent mess, given the way things are semi-haphazardly divided up into functions and methods.
<jhass>
I learned python before ruby and I still think this :D Maybe it's too similar for me really letting go of Ruby
<apotheon>
As for thinking in C, it basically comes down to recognizing that C is a pointer-oriented language, and all this shit about "avoiding" pointers in favor of arrays is just self-delusion that will get you in trouble, and also deprives one of the simple elegance of a language almost as intrinsically pointer-oriented as Ruby is object/message-oriented.
leitz has joined #ruby
<apotheon>
s/deprives one/deprives you/
<apotheon>
clearer to maintain the same pronoun
<jhass>
does it change how you approach problems? Like what aspects/properties of a solution are important to you? In other words, would you focus on different trade-offs writing a solution to the same problem in Ruby vs in C?
chalkmonster has quit [Quit: WeeChat 2.8]
<apotheon>
I always use dynamically allocated pointer arrays instead of stack array[]s if I don't have a specific need to use the latter, for instance, and even for those I tend to use pointer arithmetic notation such as *(foo + 1) instead of bracket notation such as foo[1] for clarifying iteration limits and so on. The bracketing is misleading, and I think contributes to some degree to the likelihood of
<apotheon>
off-by-one errors.
* leitz
thinks he's missed part of an interesting conversation.
<apotheon>
jhass: Do you mind if I stuff some of the preceding (including your comments) in a paste for leitz to see?
<phaul>
can I chip in? Even though I wasn't asked, I think the main difference to me is how well one can guess the assembly resuting from a C code. This is all related to micro optimisation of time sensitive code, like driving hardware. If the code you express tranlates into some internal YARV instruction set that later results in many C calls, you really can't say much about run time apart from vague time
<phaul>
complexities. Then if you look at stuff like stockfish chess engine code, they align their stuff on the stack for cache line
* leitz
goes to read.
<leftylink>
I could run pisg and make the stats, but it doesn't seem right because I am not an authorised statistician of the channel
<phaul>
which would only work in a language like C
<apotheon>
phaul: My take on that approach is largely informed by the old saw that "premature optimization is the root of all evil".
<jhass>
!fact alias factoids facts
<ruby[bot]>
jhass: I will remember that factoids is also called facts.
<apotheon>
Given Ruby's design and the purpose Matz stated for creating and developing it, I'm happy to treat it as a tool for making code *maintainable* first and foremost, and *performant* only as needed.
<apotheon>
jhass: cool alias
elcuervo has joined #ruby
<phaul>
yeah, depends on what you do. If you want to beat the other chess engines, you might need to do stuff that is bad for design and maintainability
<apotheon>
Right. That's not "premature" optimization, then.
<apotheon>
. . . but using Ruby for such a chess engine seems like a bad idea.
<jhass>
phaul: I believe rust strives to give the same level of access
<apotheon>
Rust is kind of a C++ replacement, as far as I can tell at this point.
<jhass>
yeah, steve even says as much in the talk
<apotheon>
It's weird portability conditions kinda exclude it as a full replacement for C.
<apotheon>
s/It's/Its/
<apotheon>
damn
<apotheon>
I don't know that I'll get to that video today.
<jhass>
So this is all interesting to me because I'm a Crystal contributor and the talk above made me realize I'm still not sure where I want Crystal to be on that scale
<jhass>
or spectrum or whatever
schne1der has joined #ruby
<leitz>
Go and Rust look to be C++ replacements. Yet I'm not sure that looking at the same problem with C and Ruby is the right question. It seems like they are much more suited to different problems.
<apotheon>
jhass: I'd like Crystal to have a better license.
<jhass>
I didn't mean so much a concrete problem but the abstract thing of what a problem is and what a solution is :)
<apotheon>
leitz: I feel like Go is more of a Java replacement, really.
<apotheon>
jhass: . . . but, ignoring my near-non-sequitur, I can see how you'd come to that point of indecision.
<jhass>
apotheon: tbf our license file seems to be the mandatory be file preamble, so it's essentially unlicensed I guess :D
<jhass>
*per file
<apotheon>
Shit. Really?
<apotheon>
That's kind of worse.
<jhass>
I can't fix it, Manas has to
<apotheon>
I had a discussion about the licensing with some Crystal people years ago, and it didn't go well, so I've just moved on.
<apotheon>
It became one of those languages I'll ignore unless/until professional needs require it, as long as the licensing is suboptimal.
<apotheon>
(as opposed to PHP, which I'd actively avoid as much as reasonably possible regardless of license)
<apotheon>
In some respects, I guess I should be thankful for Crystal's licensing, because it helped encourage me to dive deeper into C with the time freed up by not caring about Crystal any longer.
gitter1234 has joined #ruby
<jhass>
I'm just not ideological about it. Most people in OSS (excluding FOSS) don't really understand what they're doing with the license anyways so I just interpret the fact that it's there as a message of "we won't bother you about it". Especially if the people behind seem generally relaxed and reasonable, which I can definitely say for everything Manas.
<apotheon>
err
<apotheon>
OSS (excluding FOSS)
<apotheon>
What does that mean, exactly?
<jhass>
and I really don't want to go into a deep discussion, so simple question and hopefully oneline answer I won't question: What license would you make use Crystal?
<apotheon>
I'd go with a copyfree license, such as those favored by the Ruby community (Simplified BSD License, MIT License, et cetera).
<jhass>
OSS for me is open source defined by roughly the MIT spirit and FOSS is more the FSF/GNU/Stallmann area of things
<apotheon>
Oh, you mean general OSS vs. copyleft, then.
<apotheon>
Anyway, Crystal uses AL2, which has some restrictive issues.
<apotheon>
(notably including license incompatibilities and weird requirements for stuff outside of the license itself, like bookkeeping about changes to the source).
<apotheon>
s/.$//
<leitz>
The Ruby/C/Rust/Go/Algol conversation is hitting me at an odd time. I've given myself a break from Ruby, because I have to get some writing done and there's only so many non-work hours in the day.
<leitz>
It's the first time in a few years where I haven't been trying to learn some programming language or another, and I feel sort of lost.
howdoi has joined #ruby
<leitz>
Which is a bad feeling when an eye to the not too distant future says a job change may be needed.
<leitz>
Unless I want to commit myself to Perl. =8{
<apotheon>
eek, Perl
<apotheon>
DON'T DO IT!
<apotheon>
I mean, if your choices are Perl and PHP, sure, go for Perl.
seaef has quit [Quit: I am functioning within established parameters.]
<apotheon>
leitz: What languages do you think might get you a job, that you could lear well enough in time, given your situation?
<apotheon>
s/lear/learn/
<apotheon>
I'd probably say that Algol won't help you much for career development at this point.
<apotheon>
Ruby has some strong presence in startups. C is foundational for a lot of stuff. Rust and Go both have continuously developing niches.
<leitz>
Yeah. Python seems the most "Job friendly", though I've done C, PHP, lots of shell, and a little Go.
<apotheon>
I don't see anything wrong with pursuing any of those, though I think if you know C *and* Rust you're probably more likely to get a Rust job, and if you *just* know C and have no notable experience with C it might be difficult to get a C job just based on that.
tomaw has quit [Read error: Connection reset by peer]
<apotheon>
The thing about Python is that it seems to be a widely-valued "also" skill, rather than primary job skill.
tomaw has joined #ruby
<leitz>
I've given thought to pitching a sub-entity in my company, where we use Ruby to do rapid proof of concept, in the order of days. Then if hired work in an environment appropriate language.
<apotheon>
"data science, also Python"; "Go, also Python"; "JavaScript, also Python"; "DevOps, also Python"; et cetera
<leitz>
I've seen a lot of primary Python jobs.
tau has joined #ruby
<apotheon>
I haven't.
<leitz>
Though some want C/Java/C++ and a scripting language like Python.
<apotheon>
I've seen jobs *advertised* as Python jobs that turned out to be secondarily Python.
<apotheon>
Yeah, see, that's what I'm talking about.
<tau>
hi. just wondering how to install https://github.com/rsense/rsense correctly. the last time i used that it has been like four years lol
<apotheon>
Those are really Java jobs (for instance) with Python also needed.
<apotheon>
(or at least strongly desired)
Arkantos has joined #ruby
<apotheon>
Many of those jobs might bend on the Python part and not on (for instance) C++, figuring you can learn Python on the job if they don't find a unicorn job candidate.
<tau>
i'm having difficult due to having different ruby versions.
<apotheon>
To be fair, the Ruby jobs I've seen are almost invariably Rails jobs, specifically, and not general Ruby jobs.
<tau>
no idea how to handle that.
<rapha>
leitz: you'd be surprise how many things Ruby can be "appropriate" if the person who's writing the Ruby know what they're doing. Incidentally, the same goes for a lot of languages.
<apotheon>
tau: Would a Ruby version manager like chruby or rbenv solve your problem?
<tau>
also i dont know which version of ruby to install for that.
<tau>
apotheon hmm probably rbenv. i'll look it up.
Dalboz has quit [Quit: But only if I'm threatened will the tables turn.]
mikecmpbll has quit [Ping timeout: 256 seconds]
<apotheon>
tau: I don't know anything of substance about rsense, so that's the best suggestion I have at the moment.
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
mikecmpbll has joined #ruby
<leitz>
rapha, agreed. That's why I think Ruby would make a great Proof of Concept language; you can quickly mock up, and begin to see the hidden domain issues quickly.
<leitz>
Which is not to say *I'm* that good, yet. :)
<apotheon>
. . . and just stick with Ruby if there turns out to be no reason to reimplement.
<tau>
however it would be nice if i managd to get rsense straight.
<tau>
leitz can i do that regardless of the ruby version?
<leitz>
"Can you", likely. Most older code can run under newer Ruby. Unless it's like pre Ruby 1.9, you should get something.
<jhass>
worst case it'll fail running or installing
<jhass>
no harm in trying
<leitz>
Yup.
<tau>
i'll try.
crankharder has quit [Ping timeout: 246 seconds]
chouhoulis has quit [Ping timeout: 260 seconds]
<rapha>
leitz: what apotheon said :) ... i just wanted to caution that someone who's really well-versed in Python won't become faster at prototyping if they switch to Ruby. sure, Ruby /might/ end up feeling more natural to them, or it /might/ end up holding that person back. at my current work I'm lucky enough that the policy is "use what works best for you". that only works, though, because it's all about non-GUI
<rapha>
scripts that take some plain text as input and produce some other plain text as output.
<rapha>
(and i'm still wishing for Ruby to get as awesome graphing as Python has)
<jhass>
apotheon: was that license discussion public by the way? Do you remember where it happend?
<apotheon>
rapha: Chad Fowler semi-famously organized a business around software architecture that allows "use what works best for you" by ensuring all components of the system are small enough that it's as easy to replace one wholesale when changing functionality as it is to modify it in place.
<apotheon>
I met him at the same Rocky Mountain Ruby conf where he presented about that.
<rapha>
oh, i didn't know about that, cool!
<apotheon>
jhass: I think it was in IRC.
<rapha>
but enjoyed everything i ever read by him, so, not surprised :)
<jhass>
ah, too bad
<apotheon>
rapha: Yeah, he's pretty cool.
<apotheon>
rapha: He and I were about the only people in the place who, when handed a lanyard with nametag for the conf, only wrote our first names.
<rapha>
just googled him again and found out he's also a musician
<leitz>
rapha, it's more my lack of confidence. I've been shell programming for years, but it feels like I have 1 year of expeience 20+ times, than 20 years of programming experience.
<rapha>
apotheon: so, you're also semi-famous? :)
<apotheon>
rapha: . . . and we saw each other's tag and said "Nice name!" because I was "The Other Chad".
<gitter1234>
lmao
<rapha>
lol! :-D
<apotheon>
I was semi-famous at various times, I suppose, but I don't think I was ever famous in Ruby circles.
<rapha>
apotheon: turns out Chad now lives a mere 200km from me.
<gitter1234>
leitz: yes i! :D
<apotheon>
ugh
<apotheon>
I'm not a huge fan of contemporary uses of the name Chad.
<rapha>
(TIL: Microsoft have offices in Berlin, d'oh)
<rapha>
Contemporary uses?
<apotheon>
I moved to Florida for a few years in 2003, and within the first couple weeks someone, upon learning my name, said "We don't like that name here."
<apotheon>
I refrained from saying "Fuck you too, pal."
<gitter1234>
what?!
<apotheon>
. . . but it was an internal struggle.
<rapha>
Ur?
<apotheon>
"hanging chads" and so on
<leitz>
Chad is also the small circles made from puched tape.
<apotheon>
Yes, "chad" means "computer confetti".
<leitz>
And voting ballots.
<pwnd_nsfw>
deb ships with older version of ruby
<rapha>
apotheon: perhaps because English is my 2nd language, but I don't even get those.
<apotheon>
. . . but most people associate it with ballots, in particular.
<pwnd_nsfw>
GET WITH IT
<rapha>
pwnd_nsfw: or stop using Debilian.
<gitter1234>
Chad is prolly the coolest name since scotch bonnet
<pwnd_nsfw>
ayyyy
<gitter1234>
get widdit!
<apotheon>
leitz: Voting ballots that produce chads are that way because they're read by automated systems, so it's still computer confetti.
<leitz>
rapha, "chad" is created when you punch holes in computer paper tape. It was also created in some ballots for a US election, and supposedly votes were counted wrong becuase the "chad" didn't completely clear the holding paper.
<apotheon>
rapha: What don't you get -- the comments about hanging chads, or the stupid jokes about "Chad" as some trolls' Platonic form of a class of person, or what?
<rapha>
leitz: i wrote my first line of Ruby in 2003. and until today, each time i want to write to a file i'm googling "ruby way to write file" and go to the same stackexchange answer /again/. programming is a lot about psychology.
<rapha>
ways*
<leitz>
rapha, I think languages fit our brains, and different languages fit different people's brains. Ruby fits mine, of the half a dozen or so I've tried.
<leitz>
In the job market, though, Ruby without Rails has almost no market share.
<rapha>
same here. still, the "20 times 1 year instead of 20 years" thing can feel overpowering at times and it's important to be aware that it's only real within limits.
<apotheon>
20:52 < rapha> leitz: i wrote my first line of Ruby in 2003.
<apotheon>
Mine too!
<apotheon>
20:54 < leitz> In the job market, though, Ruby without Rails has almost no market share.
* leitz
used to laugh at Ruby, the Why book seemed pretty childish.
<apotheon>
That's my experience.
<gitter1234>
word!
<leitz>
Then I had to learn Puppet, which used Ruby.
<gitter1234>
i wrote my first line when i saw this other dude write his first line
<apotheon>
Puppet's Ruby is a bit . . . weird.
<gitter1234>
was *inspirational*
<rapha>
apotheon: it's a little shameful to admit, but 3 years later, i landed a Rails job. thank god i quickly abandoned it again, but Ruby stuck.
<rapha>
oh yeah, the Why way of teaching never worked for my brain
<apotheon>
rapha: What's shameful about that?
<apotheon>
I liked Why's book, but not exactly for how much I learned from it.
<apotheon>
(I learned more elsewhere.)
<apotheon>
(I just enjoyed reading it, for entertainment value.)
<rapha>
apotheon: dunno ... Rails has a very "oh lord, beware of the hipsters" ring to it now.
<apotheon>
har
<apotheon>
I have run into hipster Rails devs, and they don't make me happy.
<rapha>
still learning new things from the pickaxe even after all that time
<rapha>
so you do understand my use of the word shameful :L)
<apotheon>
I'd be happy with a Rails job, even now, though.
<rapha>
also if anyone ever speaks about "rockstar developers" around me i might forget myself
<apotheon>
. . . as long as the place did some good stuff with process and let me do good work.
<apotheon>
rapha: Ah, yeah, the mythical 10x programmer.
<apotheon>
I'm more interested in programmers who won't create extra work down the line, after they moved on.
<rapha>
as much as a love ruby, i'd prefer something with Matlab and data cleanup blah blah graphing blah over anything web-whatever nowadays
<apotheon>
"I can stand up a whole MVP for this revolutionary new business model in two days." Can anyone maintain it? If not, that's not what I want.
<apotheon>
I don't want MatLab, thanks.
<apotheon>
. . . but I'd rather write plumbing code than user-facing GUI-ish stuff, including web dev.
<rapha>
gf had to use it for her Master's thesis. now i know stuff about it. still trying to convince myself there's sadder things ^^
<apotheon>
ouch
<rapha>
plumbing code in a lot of ways is nice. let's you be by yourself. create something that you can know the ins and outs of.
<apotheon>
I sometimes toy with the idea of just learning my way into an irrelevant niche, then making it relevant by rebuilding the entire world using those niche tools, but then I'd run the risk of turning into Terry A. Davis Mk2.
<apotheon>
I enjoyed some plumbing code in JavaScript at times, but it always turned into torture when I had to start working on the front end.
<rapha>
hmm there's more to becoming TAD than that
<rapha>
ouch
<apotheon>
TAD?
<leitz>
My programming claim to fame was saving the company tens of thousands of dollars with some infrastructure shell code to do a warm failover.
<apotheon>
nice
<leitz>
Since it was the world's largest (at the time) paid subscriber website, I felt pretty cool.
<apotheon>
I'm not sure I have any fame for *programming*, per se.
<apotheon>
I did have some internet fame for programming-adjacent things, such as writing fourteen articles per month for TechRepublic for a while, in the topic areas of security, open source software, and programming.
<apotheon>
. . . but nobody cares about my code.
<apotheon>
I once even implemented a "sudo" and "su" system for a Rails application where my implementation involved a net reduction in code, but within a week nobody gave a shit or, for the most part, even remembered.
<pwnd_nsfw>
koans is great to pair with learning emacs as well
<pwnd_nsfw>
I'M LEARNING SO MUCH
<pwnd_nsfw>
I also primarily use Windows, and I'm on Debian as well. Full switcharoo
blackmesa has quit [Quit: WeeChat 2.8]
ellcs has quit [Ping timeout: 260 seconds]
Unlimiter has joined #ruby
<Unlimiter>
Why can't I define a global function?
<leitz>
Unlimiter, like, what?
<Unlimiter>
`def $f ... end`
<leitz>
Methods defined in the main scope exist, but I'm not sure if or how they would be referenced by objects that were called.
<Unlimiter>
It's because I can access nothing global when required
chouhoulis has joined #ruby
<jhass>
module Kernel; def f; "I'm callable anywhere. But you shouldn't do this"; end; end;
<Unlimiter>
then what should I?
<jhass>
Why do you need a global method? Why don't you have a place for it to live? Worst case a utils module that uses module_function or plain def self. definitions
<Unlimiter>
I want to define a function accessible anywhere in my rails app
<apotheon>
leitz: You seem to know shell stuff pretty well. Maybe you can answer a question for me.
<jhass>
are you really sure about anywhere? what does the method do? who needs to call it currently?
<apotheon>
leitz: What's the difference between :- and - in brace-contained variable substitution?
<Unlimiter>
I want it to be called by all controllers in all views
<Unlimiter>
no no, i want it to be called by one controller
kristian_on_linu has quit [Remote host closed the connection]
<apotheon>
(or anyone else who knows
<apotheon>
)
<Unlimiter>
You can just search for <your shell here> variable substitutions
<apotheon>
Unlimiter: That's not easy when my shell is sh.
<apotheon>
I get shit like a Bash page explaining :- but not -.
<Unlimiter>
why do you use sh?
<apotheon>
portability
<apotheon>
using better languages when things get complicated enough that sh itself isn't sufficient, rather than switching to a more complicated and less portable shell
<Unlimiter>
aren't other shells portable?
<apotheon>
not *as* portable
<Unlimiter>
are you talking about the dependencies?
<apotheon>
FreeBSD's default shell is (t)csh. OpenBSD's default shell is ksh. Some Linux distributions use Zsh by default. Many Linux distributions use Bash.
<apotheon>
All of them have something roughly just "sh".
<apotheon>
"all"
<apotheon>
Are we done nitpicking my shell choice, now?
<apotheon>
So . . . I like the way the "endless" method syntax looks so much like SML function definition by simply assigning a lambda expression to a label.
<apotheon>
The thing that bothers me about it is that it's not very consistent with Ruby in general.
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drincruz has quit [Ping timeout: 240 seconds]
<apotheon>
(especially considering that's *not* the syntax for a lambda in Ruby)
<apotheon>
It feels inconsistent in Ruby, and seeing it in the middle of Ruby code might actually make me feel less good about the rest of the code.
<apotheon>
I'm sad now.
elcuervo has quit [Read error: Connection reset by peer]
elcuervo has joined #ruby
hiroaki_ has joined #ruby
BH23 has quit [Ping timeout: 240 seconds]
<apotheon>
Actually, on the subject of Ruby lambdas . . .
<apotheon>
I've always been a bit confused about why these work:
<apotheon>
->(arg) { puts arg }
BH23 has joined #ruby
<apotheon>
lambda {|arg| puts arg }
<apotheon>
. . . but these don't work:
<apotheon>
-> {|arg| puts arg }
<apotheon>
lambda(arg) { puts arg }
<apotheon>
What's up with that? It seems . . . very odd.
phI||Ip has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
drincruz has joined #ruby
hiroaki_ has quit [Ping timeout: 260 seconds]
gitter1234 has quit [Quit: Connection closed for inactivity]
`Alison has quit [Quit: ZNC 1.7.4+deb4 - https://znc.in]
`Alison has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
howdoi has quit [Ping timeout: 244 seconds]
gajus has quit [Ping timeout: 244 seconds]
howdoi has joined #ruby
gajus has joined #ruby
drincruz has quit [Ping timeout: 264 seconds]
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]