<FromGitter>
<marksiemers> `self[0]` would probably break on an empty string
<FromGitter>
<marksiemers> If you look at `ends_with?` there is all kinds of `to_unsafe` going on, and checking bytesize. ⏎ It could be that the `each_char` avoids that, but it does look very strange.
<woodruffw>
ah, yeah, `self[0]` breaks with `""`. adding `return false if empty?` covers that, though...
<FromGitter>
<marksiemers> It has an early return - so in a non-empty string, that block only gets executed once
<FromGitter>
<marksiemers> and if it is empty, the the default `false` return is at the bottom.
<FromGitter>
<marksiemers> It would be helpful for readability if there were `first_char` and `last_char` methods, even if private.
<FromGitter>
<marksiemers> The `last_char` one might be tricky to implement without O(n)
<woodruffw>
i see, thanks
<FromGitter>
<marksiemers> Releasing the newest version of crystal in time for shards to update before new year's would be great.
<FromGitter>
<marksiemers> I'm fairly certain the amber team will work toward that between christmas and new year's if the 0.24.1 is release with a few days to spare
happycoder2 has quit [Ping timeout: 248 seconds]
ylluminate has quit [Ping timeout: 248 seconds]
ashirase has quit [Ping timeout: 240 seconds]
ashirase has joined #crystal-lang
happycoder has joined #crystal-lang
happycoder has quit [Ping timeout: 248 seconds]
happycoder has joined #crystal-lang
happycoder has quit [Ping timeout: 272 seconds]
ashirase has quit [Ping timeout: 264 seconds]
ashirase has joined #crystal-lang
<crystal-gh>
[crystal] woodruffw opened pull request #5442: INI: Rewrite parser to avoid regular expressions (master...ini-parser-without-re) https://git.io/vbHSj
sz0 has joined #crystal-lang
codenoid has quit [Remote host closed the connection]
happycoder has joined #crystal-lang
happycoder has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
happycoder has joined #crystal-lang
happycoder has quit [Ping timeout: 248 seconds]
happycoder has joined #crystal-lang
alex`` has quit [Ping timeout: 272 seconds]
happycoder has quit [Ping timeout: 248 seconds]
rohitpaulk has quit [Ping timeout: 265 seconds]
alex`` has joined #crystal-lang
alex`` has quit [Client Quit]
happycoder has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
rohitpaulk has joined #crystal-lang
happycoder has quit [Ping timeout: 264 seconds]
alex`` has joined #crystal-lang
happycoder has joined #crystal-lang
happycoder has quit [Read error: Connection reset by peer]
happycoder has joined #crystal-lang
happycoder has quit [Read error: Connection reset by peer]
happycoder2 has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.0]
happycoder has joined #crystal-lang
happycoder2 has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
<oprypin>
marksiemers, funnily enough, last_char is easily O(1) but there's no implementation of it
sz0 has joined #crystal-lang
<oprypin>
e.g. string[-1] will scan from the very start of the string when really all it could do is start from the back and find the first byte < 128 and go from there
<oprypin>
woodruffw, howd you create the git,io link?
<oprypin>
but indeed ends_with is very optimal, even beyond what a `last_char` could provide
happycoder2 has joined #crystal-lang
happycoder has quit [Ping timeout: 248 seconds]
p0p0pr37 has quit [Quit: Going offline, see ya! (www.adiirc.com)]
happycoder2 has quit [Ping timeout: 248 seconds]
afraeim has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
<afraeim>
hi brothers
happycoder has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
happycoder has quit [Ping timeout: 252 seconds]
afraeim has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
<FromGitter>
<bew> Hi
<RX14>
oprypin: its even worse than that because I'm certain we have the ability to read utf8 backwards
<oprypin>
not sure what you mean by "its even worse"
<RX14>
As in utf8 is designed so you can look at any byte and find the character its part of
<RX14>
And we have code to do that
<RX14>
We just don't use it
<RX14>
So it's even worse in that its so easy to optimize
<oprypin>
i describe how it's easy to optimize then you say "it's even worse in that its so easy to optimize"
<oprypin>
mkay
<RX14>
No its even worse in that its easier to optimize than you think because the code is already written
<RX14>
And also that you don't need to go back to the last ascii char because utf8 is a far more useful encoding than that
happycoder has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
happycoder has quit [Ping timeout: 248 seconds]
<Yxhuvud>
Yeah, you need at the most 4 byte, right?
bmcginty has quit [Ping timeout: 256 seconds]
hightower3 has joined #crystal-lang
happycoder has joined #crystal-lang
hightower2 has quit [Ping timeout: 248 seconds]
happycoder has quit [Ping timeout: 252 seconds]
<RX14>
Yxhuvud, it's simple: if the byte starts with 10 then it's a multibyte sequence
<RX14>
you just count back in bytes until you stop seeing 10
<FromGitter>
<Jens0512> Uh, may i ask how to deal with this?: `Unable to create directory '/private/etc/to': Permission denied` 😅 If not i can probably find out somehow
<FromGitter>
<Jens0512> Should i change to a process?
<oprypin>
Jens0512, can you go to a shell and run `mkdir /private/etc/to`
<RX14>
@Jens0512 looks like a permissions error to me
<oprypin>
you probably actually don't have permissions, cuz why would you?
<FromGitter>
<Jens0512> Wouldn't a shell throw the same permission error?
<RX14>
Path.relative_to is so useful
<RX14>
@Jens0512 yes
<oprypin>
that's the point
<FromGitter>
<Jens0512> Would something like `sudo mkdir -p /private/etc/to`work?
<FromGitter>
<Jens0512> (This is a cli I'm making)
<oprypin>
probably but you also probably should stop and think what you're doing, and describe the actual problem you're trying to solve
<RX14>
you probably want to chmod or chown the path
<FromGitter>
<Jens0512> Im just trying to create a file at `/private/etc/to/where.json`for now
<oprypin>
why tho
<FromGitter>
<Jens0512> Thanks for the help, i'll figure out the rest for myself ^^
<RX14>
I think there should only be one Path honestly
<oprypin>
yeah that's fine
ruby_ has joined #crystal-lang
<oprypin>
abstract class Path::Pure class Path::Posix < Path::Pure class Path::Windows < Path::Pure {% if flag?(:win32) %}class Path < Path::Windows
<FromGitter>
<ArtLinkov> can anyone tell me why im getting nil here? (I wanna sum each value with same index of all the arrays in an array) ⏎ https://play.crystal-lang.org/#/r/3a7c
<oprypin>
ArtLinkov, each has no return value
<RX14>
oprypin, too many classes
<oprypin>
RX14, that's the bare minimum
<FromGitter>
<ArtLinkov> ah... obliged :)
<RX14>
no it's not
<RX14>
one is the minimum
<oprypin>
Pure needs to store data on it so it's a class
<RX14>
why do we need a pure?
<oprypin>
you do want to manipulate Posix paths on Windows, without stupid hacks
<RX14>
yes
<RX14>
make it a ivar
<RX14>
which changes a few method's implementations
<RX14>
@windows : Bool
<RX14>
removed half the classes
<oprypin>
that's bad
<RX14>
and just remove the pure split
<oprypin>
not extensible
<RX14>
look at java's implementation then
<oprypin>
in fact, having just Path is bad for the same reason
<RX14>
they have a filesystem class
ruby_ is now known as rubyanderson
<RX14>
which gets delegated all of the platform specifics
<rubyanderson>
is possible to change current POSIX with windows env variabele ?
<oprypin>
rubyanderson, sorry what?
<rubyanderson>
i want make current POSIX data which currently not defined in win32api, with current posix subsystem
<FromGitter>
<straight-shoota> @oprypin is there any difference between posix and windows path besides how they handle separators and absolute paths?
<oprypin>
\\ c:\
<oprypin>
case sens
<rubyanderson>
yes, i want to porting POSIX env to Win32 API, which is currently not available on crystal:master
<rubyanderson>
i got little trouble in win32 api, as your know, windows API always different
<FromGitter>
<straight-shoota> okay, but this could be well flagged with an ivar
<oprypin>
RX14, i'm also wondering what people would say about creating a class for every file/path operation
<oprypin>
creating an object rather
<FromGitter>
<straight-shoota> there are no substantial differences in the API or something
<oprypin>
only to throw it away immediately
<rubyanderson>
no, it's bad @oprypin
<rubyanderson>
it could be IMIX Gargabe Compiler
<Papierkorb>
Windows has supported forward slash for over a decade at this point
<rubyanderson>
are you sure windows will available in 2018
<oprypin>
Papierkorb, it has extremely many corner cases
<FromGitter>
<straight-shoota> no object, struct should do
<RX14>
oprypin, yeah path can be a struct
<RX14>
so its fine
<RX14>
its immutable anyway
<rubyanderson>
struct has nothing to do with Gargabe Collector,
<Papierkorb>
I'd actually prefer writing `Path("foo").copy(to: "bar")` over `File.cp("foo, "bar")`
<oprypin>
except it's Path.new ...
<Papierkorb>
small detail.
<FromGitter>
<straight-shoota> `Path{"foo"}` should work
<oprypin>
funnily enough, in Python pathlib doesn't do that
<oprypin>
has no copy method
<rubyanderson>
currentlu i work in small project
<rubyanderson>
writing GO interpreter in crystal
<Papierkorb>
straight-shoota, good point. aliasing Path.[] would also be fine to mirror Dir[]
<Papierkorb>
The parser can't know if the user intended to write an integer or really meant a float. JSON only knows of a numeric type
<Papierkorb>
union types are ordered by name, so that A | B == B | A, and that order is also the order in which types are tried to be parsed. The Float can parse `2`.
<Papierkorb>
If you want to enforce a special, custom rule, you can use a converter to make such a deduction
afraeim has quit [Remote host closed the connection]
<RX14>
pcre links fine until you use too much of it then you get pcre.lib(pcre_compile.obj) : error LNK2019: unresolved external symbol __imp_strncmp referenced in function check_posix_name
<RX14>
and somehow none of the existing windows porting effort has hit this
<Yxhuvud>
can you reach out to them for help? perhaps one of them have an idea of what it could be?
happycoder has quit [Ping timeout: 260 seconds]
happycoder has joined #crystal-lang
<RX14>
i'm literally grepping through every symbol in every library on windows
<crystal-gh>
[crystal] marksiemers opened pull request #5444: Change Hash#key to Hash#key_for (master...fix/change-key-to-key_for) https://git.io/vbQsx
ylluminate has joined #crystal-lang
<Papierkorb>
> abstract `def Enumerable(T)#each(&block)` must be implemented by Dir
<Papierkorb>
Completely unrelated to the code I wrote (the heck compiler?), but Dir indeed doesn't have a yielding #each
<Papierkorb>
Adding one really does fix the compiler error ... which is still unrelated to my code. I do a `Dir[..]` somewhere, but that gives me a Array(String) so .. whatever
<RX14>
how on earth does grisu3 break on windows
<RX14>
is the ABI broke somehow??
<Yxhuvud>
not having a yielded each manages to make the lack of iterator each-es in certain other places look like a small problem.
<Papierkorb>
Yxhuvud: It literally breaks my code without me even using an instance of Dir
<Papierkorb>
Which is an interesting error by itself
<Papierkorb>
Didn't even know that Dir could be instantiated. Never needed it.
<Yxhuvud>
that is amazing. are you monkeypatching a module?
<Papierkorb>
No
<Yxhuvud>
if you implement one that raises, do you get an error when running your code? Perhaps Dir[] make use of the instances?
<Papierkorb>
Nope when I implement it it works
<Papierkorb>
And I searched my code, I do use Dir[] exactly once, and that returns an array of string
<Papierkorb>
I even restrict the return type of that method to array of string
<FromGitter>
<jwaldrip> Permissions in S3 perhaps?
<Papierkorb>
> Qt 5.10.0, linked to 5.10.0 / Crystal 0.24.1
<Papierkorb>
Finally
<FromGitter>
<jwaldrip> RX14, docker image?
<RX14>
wait Papierkorb
<RX14>
thats probabblt normal
<RX14>
the apt not having a release file is not
<RX14>
well
<RX14>
nice
<RX14>
apt broken, docker old, release has major bugs
<RX14>
and everyone's on holiday for christmas
<Papierkorb>
Ah well, travis will note once the Dir fix is in, as my still-broken check will "break" :3
A124 has quit [Quit: '']
<FromGitter>
<sam0x17> is anyone else working on making Chromium Embedded Framework (CEF) available as a crystal shard? (in other words, Electron for crystal)? Would love to join forces if I'm not the only one
<Papierkorb>
Electron *shudder*
<FromGitter>
<sam0x17> yeah yeah
<RX14>
whyy
<RX14>
just use Qt
<RX14>
seriously
<FromGitter>
<sam0x17> QT isn't free for commercial purposes, and in my experience it's a real pain in the ass
<Papierkorb>
Qt isn't free for commercial?
<Papierkorb>
It is
<FromGitter>
<sam0x17> last I checked that was the case, is that no longer true?
<Papierkorb>
As long you don't statically link, sure, but with electron, you have even more files flying around
<Papierkorb>
Hasn't been for over a decade
<FromGitter>
<sam0x17> ah ok
<FromGitter>
<sam0x17> but yeah, would really like a few of the startups I work with to be doing their native desktop apps in crystal rather than in javascript eventually (realistically at least a year from now)
<Papierkorb>
The LGPL allows you to link dynamically, and distribute such (closed) programs along the DLLs (or shared libs or what your OS uses)
<FromGitter>
<sam0x17> that's good to know
<Papierkorb>
The LGPL was literally developed for that purpose for Qt
<FromGitter>
<sam0x17> that's cool
<FromGitter>
<sam0x17> but yeah, still going to work on bringing CEF to crystal -- I totally get your perspective and the bad rap electron has -- a lot of that has to do with crazy bloaty decisions the electron project itself has made (thanks to influence from the atom team) and the fact that linux support doesn't get much love, but I want to be very different from them. I want this to be lightweight as possible, with linux + osx +
<FromGitter>
... windows treated equally support wise (once windows support is available).
<Papierkorb>
It can't be lightweight. It got a whole fucking browser.
<Papierkorb>
That's nowadays the polar opposite of lightweight
<FromGitter>
<sam0x17> *as possible*
<Papierkorb>
The JBoss ("Wildfly") guys are pissed, they want that anti-title back
<FromGitter>
<sam0x17> lol, will have to look that one up
<Papierkorb>
Application server for Java. If you want to know what the opposite of "lighweight" is defined as, it's JBoss.
<FromGitter>
<sam0x17> hahaha gotcha
<RX14>
enterprise bad java is so bad
<RX14>
how do they manage to generate more XML config than it actually takes to write the functionality sanely
<RX14>
and then 10x the xml config in code and useless interfaces and "ImplBuilderFactory" classes
<FromGitter>
<sam0x17> yeah, similar experience if you ever try to write an android app
<FromGitter>
<sam0x17> it's funny because nothing about Java forces you to be that way, other than an extremely verbose type system I suppose, but nothing about Java screams XML
<RX14>
nothing like the good old InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState class
<FromGitter>
<sam0x17> so true
<Papierkorb>
RX14: Beans. Like .. Oh my god. Words don't describe my experience while working at a JEE shop.
<RX14>
I love that thats a real class
<RX14>
that someone wrote and thought
<RX14>
thats OK
<RX14>
lets review and merge thins
<RX14>
lets review and merge this
<RX14>
i've never had the unpleasantry to actually work with bad java Papierkorb
<Papierkorb>
Ever wondered why I'm so adamant on architecture design? not even mad about that, but that's why.
<RX14>
what do you mean by "architecture design"?
<FromGitter>
<sam0x17> the art of not being like JEE
<Papierkorb>
application/library/system/... design. as in, design that will be maintainable and extensible tomorrow and the day beyond. (Not saying I get it right in all ways lul).
<RX14>
it's genuinely amazing how hard it actually is to do anything in such systems
<RX14>
there was a maven resolver library I used once
<RX14>
and it was just utterly impenetrable
<Papierkorb>
maven aaaaaaaaahh
<RX14>
maven is alright as a repository format
<Papierkorb>
On how to make it complicated again to do dependency things
<RX14>
and it's ok for small projects
<Papierkorb>
at least gradle is easy to use
<RX14>
Papierkorb, this was literally the repo format
<RX14>
not maven the tool
<RX14>
but yes gradle's pretty cool
<RX14>
so I just realised that cmake FOO=bar is silently ignored
<RX14>
and you need to use cmake -DFOO=bar
<Papierkorb>
yup just like cc
<RX14>
yeahhh
<RX14>
i copied faulty instructions from txe
<RX14>
and that was most of my day wasted
<RX14>
i mean i'm still stumped
<Papierkorb>
with WSL, can I just install crystal from the ubuntu mirror (or some targz), and then do stuff?
<RX14>
because the grisu3 algorithm seems to have broken
<RX14>
on windows only
<RX14>
and that makes no sense and i dont get the algorithm either way
<Papierkorb>
Dunno if I have enough space left in the VM, as Win10 by itself aleady ate 20GiBs for nothing. I mean, it installed clickbait games I didn't want..
<FromGitter>
<sam0x17> if I had to convince a co-worker that javascript "callback hell" and "promises" can be largely or completely avoided in crystal.. would my argument basically be "blocks are extremely powerful" or is there something else I'm forgetting. In my own experience, I would have to say those are problems I only run into in js and not ruby or crystal, but I can't put my finger on why exactly... thoughts?
<RX14>
it's not about blocks
<RX14>
it's about fibers
<RX14>
JS has one callstack
<RX14>
and so to do concucrrency it needs to trace multiple threads of execution over one callstack
<RX14>
crystal solves that problem super super simply:
<RX14>
have multiple callstacks
<FromGitter>
<sam0x17> that's awesome, I didn't realize crystal did fibers differently
<Papierkorb>
Crystal borrowed blocks from Ruby. One of the large benefits is that Blocks allow you to think more in a pipeline, so you only look at one item at a time, and don't have to do the boring stuff.
<RX14>
fibers are the differently
<RX14>
nodejs doesn't have fibers
<FromGitter>
<bew> they are starting to have them
<FromGitter>
<bew> not the same
<RX14>
@sam0x17 async/await is just a shitty way to create the illusion of fibers over promises
<FromGitter>
<sam0x17> ah, hence my confusion, because I know I first heard of fibers in a js context
<RX14>
the better solution is just to have fibers
<RX14>
but nodejs already dug itself into a corner
<RX14>
tell them it's the same way go does concurrency
<RX14>
because it is
<Papierkorb>
Blocks, once used by your own code, are insanely powerful, and insanely boring at the same time. They're nothing else than anonymous functions. The point is, the look&feel that they give in your code makes it great for writing clean and expressive code.
<RX14>
indeed
<FromGitter>
<drosehn> Well, let me try to change the topic to something mundane and probably stupid on my part...
<FromGitter>
<drosehn> I'm trying to figure out how to get Process.run() to work the way I'd like to use it for monitoring the output of some other program.
<FromGitter>
<sam0x17> thanks guys
<FromGitter>
<drosehn> What I have above works kinda-okay, but seems pretty lame.
<FromGitter>
<drosehn> I have to put the `hproc.output.read_line` inside a `rescue`, because I don't know how to tell when I've read out of lines to read. Also, what I'd really like to do is be monitoring both STDOUT and STDERR streams, in real-time.
<FromGitter>
<drosehn> At one point the `&& ! hproc.terminated?` seemed like a good idea, but it turns out that there can still be data to read when`hproc.terminated?` turns true. So that wasn't the right idea.
alex`` has quit [Quit: WeeChat 2.0]
<FromGitter>
<drosehn> Seems to me there should be some method I could call to tell if there is anything to read from an `IO::FileDescriptor`. So I could be looping around doing something like ```cr
<RX14>
looks like the APT repository is being fixes
<RX14>
fixed*
<FromGitter>
<drosehn> So what am I missing? I was hoping for something as simple to use as `IO.popen()` in ruby, but so far I haven't made much progress. And while the above works, it looks about 100 times uglier than using `IO.popen()`. for the kinds of things I want to do.
<FromGitter>
<bew> I would suggest to use fibers, one the read stdout, one to read stderr of the running process
<RX14>
@drosehn i'm not quite sure from the code what you actually want to do
<RX14>
but if you want to monitor things in realtime, yes you want fibers
<FromGitter>
<drosehn> ok
<FromGitter>
<bew> and maybe another fiber to monitor the state of the process, and when it's terminated, send a message to a channel to notify who needs to know the process exited
<RX14>
not too many fibers
<RX14>
the one monitoring the process should be the one that spawned it ideally
<RX14>
@Val, Papierkorb, @faultyserver APT should be fixed now
<Papierkorb>
with 0.24.1?
<RX14>
yep
<FromGitter>
<drosehn> Well, I use this in a number of different programs, and what-I-want-to-do is different in different programs. here I was trying to write an example program which would show how to use all the flexibility which `Process.run()` seems to provide.
<RX14>
i've never used popen
<RX14>
but it surely has some way of handling stdout and stderr
<FromGitter>
<drosehn> But basically I want to read lines which the program-being-run writes to stdout and stderr, parse them a line at a time, and make decisions based on what the program is writing.
<RX14>
well you have 2 streams of information
<RX14>
so you need concurrency
<RX14>
so you need 2 fibers
<RX14>
it's super variable how any of this works depending on the usecase
<RX14>
whether you want to process out and err as seperate streams
<RX14>
or to think of lines from each of them
<RX14>
or if you even want to process them as a terminal does - as a single stream with both of them merged
<RX14>
if youw ant that you might want to open an IO.pipe
<FromGitter>
<drosehn> It's a very easy to use for stdout, and in some cases you can handle stderr by cheating and redirecting stderr to stdout. There's a number of nice use cases, but it is more limited than `Process.run`. And sometimes those limits are fine.
<RX14>
and then use the same pipe filedescriptor for both stdout and stderr
<FromGitter>
<jwaldrip> RX14: anything I can do to fix the socket build. If so... should I try to fix the Dockerfile in master? Or is the one is the distribution script the one that is being used to build the image on socket hub too?
<RX14>
"socket build"?
<RX14>
@jwaldrip well honestly we're all burned out from trying to release 0.24.1
<RX14>
and i'm burned out from windows
<RX14>
so it's not going to happen from the core team before the other side of christmas
<FromGitter>
<jwaldrip> I know. I was offering to see if I could at least get it fixed in my fork.
<FromGitter>
<jwaldrip> If that would help the core team. I’ve given up on getting an official 0.24.1 docket image before Xmas. But if I can help the effort before they come back, then I will.
<RX14>
Papierkorb, guess what's more annoying than a segfault in pure logic code that only happens on windows?