<FromGitter>
<Sevensidedmarble> is there any reason theres no Dir.home to go along with Dir.current?
<FromGitter>
<Sevensidedmarble> it'd be a nice little helper to not have to read from ENV["HOME"]
<FromGitter>
<bew> Dir.current doesn't read the env
<FromGitter>
<Sevensidedmarble> right but it'd still be nice to have dir.home
<FromGitter>
<bew> No need for helpers, and it's more explicit that you want the user's home when you use the ENV, than if you'd use Dir.home
<FromGitter>
<Sevensidedmarble> there are quite a bit of methods in the stdlib I'd probably call a helper however
<FromGitter>
<Sevensidedmarble> ruby even more so
braidn[m] has joined #crystal-lang
kp666[m] has joined #crystal-lang
byteflame has joined #crystal-lang
tybee[m] has joined #crystal-lang
TheGillies has joined #crystal-lang
Renich has joined #crystal-lang
cptaffe has joined #crystal-lang
thelonelyghost has joined #crystal-lang
watzon has joined #crystal-lang
dtcristo has joined #crystal-lang
weston_[m] has joined #crystal-lang
sija[m] has joined #crystal-lang
<FromGitter>
<Sevensidedmarble> is there anyway to compile changes to crystal such that it wont interfere with the version already installed to my /usr/bin?
<FromGitter>
<bew> Huh just compile the crystal sources?
<FromGitter>
<Sevensidedmarble> Where does it put the binary? I just don't wanna overwrite my crystal in /usr
<FromGitter>
<Sevensidedmarble> Sorry if these are stupid questions lol
<bmcginty>
sevensidedmarble: I've got my git crystal in projects/crystal; I link ~/bin/crystal2 to ~/projects/crystal/bin/crystal and just use crystal2 in place of crystal for commands.
<bmcginty>
Sevensidedmarble: For git, I just run `make crystal release=1` whenever I want to update, and git pull before that to fetch changes.
<FromGitter>
<Sevensidedmarble> I'm pretty sure I have all the dependencies
<FromGitter>
<Sevensidedmarble> I have the proper llvm version and the gc, I know that
<bmcginty>
sevensidedmarbel: looking, one sec.
<FromGitter>
<Sevensidedmarble> looks like I messed up the crystal version on my path somehow
<FromGitter>
<Sevensidedmarble> because the crystal command doesnt work at all
<bmcginty>
sevensidedmarbel: You're running out of memory. You Might be able to try make std_spec release=1 (basically, you want to turn off debugging). You may be out of luck building the full specs, dpeending on how muhc ram you have though.
<bmcginty>
sevensidedmarbel: How much ram does your machine have? also, what distribution are you running?
<FromGitter>
<Sevensidedmarble> 4 gigs, but chrome is using most of it lol
<FromGitter>
<Sevensidedmarble> I cloned from github
<FromGitter>
<Sevensidedmarble> I was trying to make some stdlib changes I wanted to suggest
<bmcginty>
Sevensidedmarbel: You should be able to run just some of the spec related to what you're changing. Hav eyou been able to do `make crystal release=1`? IF so, you should be able to do ./bin/crystal to run the newly compiled crystal...
<FromGitter>
<Sevensidedmarble> same thing, cannot allocate memory error
<FromGitter>
<Sevensidedmarble> maybe I need to try it with chrome closed lol
<FromGitter>
<pnloyd> Is there anywhere I can see at an example of compiling llvm IL/BC from `crystal build --emit=llvm-il`?
<FromGitter>
<pnloyd> Iv'e been digging through Crystal's source but I'm having a hard time pin pointing the flags that are used.
<FromGitter>
<pnloyd> llvm-ir*
gcds has joined #crystal-lang
<FromGitter>
<pnloyd> nvm I figured it out.
expeditiousRubyi has joined #crystal-lang
<expeditiousRubyi>
So... why doesn't Array have a to_slice method like String does?
<expeditiousRubyi>
Was playing around with the icr REPL to test out a compute_crc function that operates on a Bytes object. Wanted to make a random test case, so naturally I started with an Array, since UTF-8 strings don't naturally make good ways to test binary data (even if it doesn't care if it's a valid encoding or not)
<expeditiousRubyi>
To get from an array to Bytes, however, required the use of to_unsafe
<expeditiousRubyi>
Given how trivial it was to implement... bytes = Slice.new(ary.to_unsafe, ary.size) ... I'd say a to_slice method should have just been implemented outright on Array
<Guest76467>
does range work? array[2..4]
<expeditiousRubyi>
array[2..4] would just spit out another array, it seems
<Guest76467>
ok, I didnät understand what you want with to_slice
<expeditiousRubyi>
A simple method for converting an Array to a Slice that contains all of its members
Guest76467 is now known as csmrfx
<csmrfx>
expeditiousRubyi: is that like cloning the members into a Slice?
<expeditiousRubyi>
No, it's like making a slice from the Array's buffer
<expeditiousRubyi>
A Slice is a pointer and a length field and nothing else
<expeditiousRubyi>
String has a method called to_slice that'll make a slice from the string's buffer
<expeditiousRubyi>
I'm wondering why Array doesn't have an equivalent method
<csmrfx>
because an array slice is just an array?
<FromGitter>
<codenoid> hi, i use `datanoise/mongo.cr` , but why i cant access multidimentional array, like `data_from_mongocr.each { |v| puts v["parent"]["child_data"] }`
<FromGitter>
<codenoid> `undefined method '[]' for BSON::Code`
<expeditiousRubyi>
csmrfx: despite responding to a number of the same methods, Slice and Array are not the same type, and so if one is using type restrictions, passing one to the other will not work.
<FromGitter>
<codenoid> fixed with `JSON.parse v["parent"].to_s` but i think it's so bad
expeditiousRubyi has quit [Quit: Leaving]
<FromGitter>
<codenoid> is there any alternative solution for that ?, or i will make helper method
balduin has joined #crystal-lang
rohitpaulk has joined #crystal-lang
balduin has left #crystal-lang [#crystal-lang]
lacour has quit [Quit: Leaving]
<FromGitter>
<bew> @codenoid maybe `as_s` so it doesn't do any convertion
<FromGitter>
<bew> > We removed Array#to_slice because it would cause a segfault if you kept a reference to the slice returned from that method and the array was resized.
<FromGitter>
<Rinkana> Morning
txdv has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 268 seconds]
claudiuinberlin has joined #crystal-lang
txdv has joined #crystal-lang
<FromGitter>
<crisward> Is it possible to get the Crystal version in a macro?
<vegai>
simply {{ Crystal::VERSION }} ?
livcd has quit [Read error: Connection reset by peer]
Papierkorb_ has joined #crystal-lang
livcd has joined #crystal-lang
rohitpaulk has joined #crystal-lang
mark_66 has joined #crystal-lang
faustinoaq has joined #crystal-lang
gcds has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gcds has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
faustinoaq has quit [Quit: Konversation terminated!]
<Papierkorb_>
gcds, When you btw get around to PR'ing the changes to bindgen (What did you need to do btw?), you of course have the honor of adding Mac OS X to the platform matrix in the README ;)
<Papierkorb_>
And of course the `Contributors` section in there too if you fancy that.
<gcds>
Papierkorb_ hehe :D I just disabled half of the file and hardcoded paths as I did not had much time to fix it correctly :D
<Papierkorb_>
But only in find_clang.cr, or other things too?
<oprypin>
i dont have anything positive to reply to that thread, so pass :|
<faustinoaq>
opryin What hosting are you using for Critter? DigitalOcean? or something cheaper?
<oprypin>
faustinoaq, Vultr
<FromGitter>
<Rinkana> Hmm for momentum we need more news. Things like more (often) releases can be better for this. Like 0.24.0 is still a pre-release.
<FromGitter>
<Rinkana> More releases gives you the opportunity to post more and also seem more active.
<oprypin>
In my opinion, the only thing missing is people actually working on it but w/e
<FromGitter>
<Rinkana> And things like helping that guy from RedHat. Getting it intergrated into an OS is a huge step
<Papierkorb_>
oprypin: A clear vision of what the language is would also help
<vegai>
thanks for the hand-holding on that PR, everyone :)
<FromGitter>
<Sevensidedmarble> I'm kind of confused how macros really work
<FromGitter>
<Sevensidedmarble> does the code actually get compiled as if you ran `crystal run` ?
<oprypin>
@Sevensidedmarble, crystal run is crystal build into termporary file and run the file
<FromGitter>
<Sevensidedmarble> but is that how macros work?
<oprypin>
I don't see why you're comparing macros to `crystal run`
<oprypin>
so I guess the answer is no, that's not how macros work
<FromGitter>
<Sevensidedmarble> I guess I'm not really understanding them
<oprypin>
definitely
<FromGitter>
<Sevensidedmarble> lol
<FromGitter>
<Sevensidedmarble> I'm trying to build a parser in crystal
<oprypin>
@Sevensidedmarble, have you worked with templating languages like Jinja or somethin
<FromGitter>
<Sevensidedmarble> and yes, I'm familiar with jinja2
<FromGitter>
<Sevensidedmarble> I thought there was more going on for some reason
<oprypin>
@Sevensidedmarble, so imagine macros like macros in jinja2
<Papierkorb_>
Sevensidedmarble, The macro code is interpreted (Macro code isn't Crystal, it just "happens to" look really similar to it), and then parsed into an AST. Then it's rerun until no more macro code is found (basically), and injected into the original place
<oprypin>
and the {% {{ things as templates executed on the source code
<livcd>
i am curious if Crystal reaches 1.0 before Nim :D
<livcd>
sdogruyol: how is your book ? :0
<Papierkorb_>
... Mh I'm actually wondering if you'd be able to generate good C or C++ code out of Crystal
<Papierkorb_>
I mean readable code, not "generated don't look at it" code
<FromGitter>
<sdogruyol> @livcd it's ok
<FromGitter>
<Sevensidedmarble> are you familiar with any other language parsing projects in crystal?
<Papierkorb_>
what do you mean?
<Papierkorb_>
Language implementated in Crystal? Or just parser toolkits?
<FromGitter>
<Sevensidedmarble> well I'm working on a shell and I've gotten to the point where I really need an actual tokenizer/parser I feel, instead of the rudimentary system I have now
<Papierkorb_>
Write a recursive-descent LL(k) parser
<Papierkorb_>
Con: Sucks if you make big-ish changes to your grammar. Pro: Decent debugging capabilities (The stacktraces make sense)
<FromGitter>
<sdogruyol> haven't announced it though
<Papierkorb_>
I mean it's perfectly fine that some people don't like Crystal. It has vastly different paradigms all around. That's fine, we don't need a second Go!
<vegai>
sort of a general one, or one focused on Kemal?
<FromGitter>
<sdogruyol> general
<Papierkorb_>
because if we'd love Go .. we'd just use Go?
<vegai>
all right :)
<FromGitter>
<sdogruyol> @Papierkorb I agree with that
<FromGitter>
<sdogruyol> thanks for your big decimal work @vegai 👍
<FromGitter>
<Sevensidedmarble> In reference to that issue, I like the stdlib being huge
<FromGitter>
<Sevensidedmarble> personally
<FromGitter>
<Sevensidedmarble> but I also like pythons std lib a lot
<FromGitter>
<Sevensidedmarble> which is king of useless modules
<FromGitter>
<sdogruyol> I'm just in the middle...
<FromGitter>
<sdogruyol> I definitely want to have `http` built-in but not sure about `OAuth` e.g
<FromGitter>
<Sevensidedmarble> I like the insurance that the maintainers of the language are 'sanctioning' said package when its in the std lib, it gives the expectation that it will integrate and work better then a seperate tool
<FromGitter>
<Sevensidedmarble> I also don't think OAuth would fit though
<Papierkorb_>
No idea where OAuth even came from
<FromGitter>
<Sevensidedmarble> simply because who's to say it might go the way of tk in ruby I guess
<FromGitter>
<sdogruyol> then there's termios lol
<FromGitter>
<sdogruyol> I don't even know what's that
<FromGitter>
<Sevensidedmarble> yeah but termios isn't going away on linux any time soon
<FromGitter>
<Sevensidedmarble> and I think its still very relevent to people doing raspberry pi stuff
<FromGitter>
<sdogruyol> I'm not sure if it should reside in std
<FromGitter>
<Sevensidedmarble> pretty sure python has a termios module in the library too
<FromGitter>
<Sevensidedmarble> crystal also needs a pty package
<FromGitter>
<Sevensidedmarble> module
<FromGitter>
<bew> should be a shard that linux app/lib uses
<FromGitter>
<sdogruyol> (I don't know any Python)
<FromGitter>
<Sevensidedmarble> or maybe theres pty stuff in another module I didn't see
<Papierkorb_>
There's no PTY stuff for Crystal :(
<FromGitter>
<Sevensidedmarble> someone should really get on that
<FromGitter>
<Sevensidedmarble> its in the ruby std lib, it couldnt be too hard to use that for inspiration
<FromGitter>
<Sevensidedmarble> because I really wanna port some terminal emulator code to crystal
<Papierkorb_>
... I wouldn't use rubys stdlib for inspiration regarding API too much
<Papierkorb_>
E.g., Deviating the Process API made it sooo much better
<FromGitter>
<sdogruyol> ugh, we have a long standing rendering issue
<FromGitter>
<sdogruyol> we need to fix that first
<faustinoaq>
@sdogruyol, I'm using zsh now and crystal works fine, I don't now why bash fails with crystal, maybe because diferent blocking state or something?
<Papierkorb_>
zsh cleans up after returning to it
<Papierkorb_>
Just like it makes sure the prompt is always starting on the first column, and not anywhere else
<FromGitter>
<bew> @faustinoaq zsh has a fail safe when apps (like crystal) doesn't restore IO states correctly when quitting, bash des not
<faustinoaq>
Oh, so zsh is doing something bad or good?
<Papierkorb_>
And that doesn't always work >_>
<Papierkorb_>
zsh is just good
<FromGitter>
<bew> good for the user, bad for finding bugs in apps x)
<FromGitter>
<sdogruyol> we can't rely on zsh, can we?
<faustinoaq>
XD
<Papierkorb_>
it doesn't fix changes to the raw mode though :|
<FromGitter>
<bew> @sdogruyol well it's a crystal issue that will need a fix, we can't expect that everyone use zsh (sadly?)
<FromGitter>
<Sevensidedmarble> doesnt seem to happen for me in fish
<FromGitter>
<bew> Papierkorb row mode is termios related iirc, not io
<FromGitter>
<bew> raw*
<Papierkorb_>
yes, but zsh could still fix it
<FromGitter>
<bew> true
<Papierkorb_>
kinda annoying when a raw-mode process crashes and basically makes the terminal unusable
<Papierkorb_>
"dude I liked this session!"
<FromGitter>
<bew> `$ reset` doesn't fix that?
<Papierkorb_>
never tried that
<FromGitter>
<bew> it resets the termios to terminal's defaults
<faustinoaq>
@bew, no, reset doesn't work
<FromGitter>
<sdogruyol> "dude I liked this session!" LOL
<FromGitter>
<Sevensidedmarble> ` if input.ends_with? ('\')`
<FromGitter>
<Sevensidedmarble> this breaks stuff
<oprypin>
so use \\
<oprypin>
uh use `\\`
rohitpaulk has quit [Ping timeout: 250 seconds]
<FromGitter>
<Sevensidedmarble> without single quotes?
<oprypin>
with
<Papierkorb_>
'\''
<FromGitter>
<Sevensidedmarble> it does work but the weird thing is when I read the string that has it it displays \\
<oprypin>
@Sevensidedmarble, the string is likely just fine but the way you display it is a string representation of the syntax you'd use to produce the string
<FromGitter>
<Sevensidedmarble> that makes sense
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
ryan_ has joined #crystal-lang
<ryan_>
Hi all, not sure if this is expected functionality. When using `dir = File.dirname(__FILE__)` in release code, it appears to be using the `src` instead. I'm trying to get the current working directory of the running program
<ryan_>
I'm writing a wrapper script for some other scripts. The wrapper script may be called at any directory in the system, but the wrapper is in the same directory as the scripts it's calling
<jsn->
Of course it's expected functionality. What you want is probably Dir.current
<ryan_>
Dir.current gets my current working directory and not the directory of the script
<jsn->
i think you're misusing the term; "current working directory" is what .current returns; you probably want File.dirname $0 or something
<oprypin>
__FILE__ is the path to the current source file; PROGRAM_NAME is how the executable was started (so you can get the executable's directory from it); Dir.current is the current working directory; $0 **was** an alias to PROGRAM_NAME
<FromGitter>
<ylluminate> not sure of the details yet, but wanted to give a heads up. apparently @fridgerator working with #amber discovered a problem with websockets and crystal's memory handling. it apparently leads to some serious performance issues and is very frustrating.
<Papierkorb>
Rinkana, an "omnibus" in software is basically the embedded bundling of multiple programs, sometimes into a single one.
<FromGitter>
<Rinkana> Ah i see.
faustinoaq has quit [Quit: Konversation terminated!]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Quit: Konversation terminated!]
rohitpaulk has quit [Ping timeout: 258 seconds]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Quit: Konversation terminated!]
faustinoaq has joined #crystal-lang
faustinoaq has joined #crystal-lang
faustinoaq has quit [Quit: Konversation terminated!]
gcds has quit [Ping timeout: 264 seconds]
<FromGitter>
<marksiemers> Regarding the TechEmpower benchmarks and crystal's relatively slow db benchmarks. I tried creating both prepared statements and functions directly in postgresql (PG Admin actually). ⏎ In that environment, it made no difference - I think the queries are too simple, having the query plan cached doesn't gain anything. ⏎ It is possible that the pgAdmin overhead made the results misleading. Anyone have any
<FromGitter>
... knowledge of that happening?
faustinoaq has quit [Quit: Konversation terminated!]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Client Quit]
faustinoaq has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
faustinoaq has quit [Quit: Konversation terminated!]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Client Quit]
faustinoaq has joined #crystal-lang
faustinoaq has quit [Client Quit]
faustinoaq has joined #crystal-lang
sz0 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
faustinoaq has quit [Quit: Konversation terminated!]
faustinoaq has joined #crystal-lang
<RX14>
@marksiemers we should do what the top frameworks are doing, are they using prepared queries?
<RX14>
I also don't think that crystal-db supports prepared queries
<Papierkorb>
Never understood why prepared statements isn't more popular
<RX14>
because they move the queries away from the code and they take effort and the performance gain is pretty small.
<RX14>
postgres already keeps a cache of query -> plan iirc
<RX14>
all it saves is the bytes overhead
<Papierkorb>
The parsing overhead
<RX14>
and that
<Papierkorb>
And it's by default safe from injection attacks
<RX14>
actually probably not
<RX14>
Papierkorb, uhh we have that anyway
<RX14>
with $1
<Papierkorb>
Yeah no, the driver then escapes the data
<RX14>
nooo
<RX14>
it's all binary
<RX14>
postgres recieves the query with $1 intact
<RX14>
and applies the arguments itself
<Papierkorb>
mh ok
<RX14>
the postgres prepared query syntax literally uses $1, etc
<RX14>
thats why the $1 and ? syntax is different between postgres and mysql Papierkorb
<RX14>
because it's specified by the DB engine
<RX14>
Papierkorb, also postgres could avoid parsing by storing just string -> plan
<FromGitter>
<Sevensidedmarble> can I make macros at runtime by passing strings from something else into them?
<FromGitter>
<Sevensidedmarble> or do they have to be AST node types?
<FromGitter>
<nicck> Hi everyone. Is there analog of 'mail' ruby gem in crystal world? I'm mostly interested in .eml parsing. Can't find anything on crystalshards.xyz or awesome crystal-list. Where else can I check?
<FromGitter>
<Sevensidedmarble> the context of this is I'm trying to come up with a way to include user defined functions in a shell
<FromGitter>
<Sevensidedmarble> but I want the user to be able to write their 'shell scripts' just with valid crystal
<FromGitter>
<Rinkana> But, macro's are compile-time. That would mean custom shell scripts like those would require the user to comple the program again
<FromGitter>
<Sevensidedmarble> if I put them in a separate module though, only that could be compiled to save time though right?
<FromGitter>
<Rinkana> I don't think you can do partial compiles now (at least not yet). But i'm not sure on that one.
<FromGitter>
<Sevensidedmarble> I guess theres no getting around having to recompile everything then
<FromGitter>
<Sevensidedmarble> I suppose its not a huge burden on the user
<Papierkorb>
the following if doesn't do OOB check, and just asks the reader to do something
<RX14>
I dislike Char::Reader overall
<RX14>
it seems weird
<RX14>
a more iterator-line interface with next and nil would be much better I think
<oprypin>
...until you actually try to implement it
<FromGitter>
<Rinkana> @Sevensidedmarble with an language like LUA you can do practically the same. And they can be re-compiled in runtime. It's much easier for the user (and faster). And keeps you in control of what the user can and cannot do. You woulden't want users to embed their own code into the core code. They might break the thing in weird ways. And are huge securtity holes.
<FromGitter>
<marksiemers> Testing in pgAdmin I saw no performance gain, but maybe when connecting from an app it helps...
<FromGitter>
<Rinkana> @Sevensidedmarble yeah but it's kinda hard without re compiling your app. But if you don't mind I'll look at your app tomorrow and if I have an idea I will make an issue for it. But for now it's getting late here.
<FromGitter>
<marksiemers> Even without support in crystal-db, I think you could do `APPDB.exec("PREPARE selectRandomNumber(id INT) ...") ⏎ Then `APPDB.exec("EXECUTE selectRandomNumber(5647);")` - but maybe there wouldn't be a performance gain.
<FromGitter>
<Sevensidedmarble> That'd be awesome @Rinkana
<FromGitter>
<Sevensidedmarble> I'm open to any commits or ideas
<FromGitter>
<Sevensidedmarble> If anyone else had any ideas I'd love to hear them too
<FromGitter>
<Sevensidedmarble> What I have so far is on that gh link
<Papierkorb>
in retrospect, I shouldn't have said anything about this bug publicly. looks like a security vuln to me.
<FromGitter>
<unreadable> One thing that makes fasthttp too is working entirely with byte array oO
<FromGitter>
<unreadable> Wouldn't this be a plus for Crystal too?
<oprypin>
Papierkorb, i dont see any way to do anything wrong with it other than reading a '\u{0}'
<Papierkorb>
oprypin: Ah well, the cats outta the bag, you should see it in the PR
<oprypin>
?
<Papierkorb>
My bad. This is actually kinda bad if you know what you're doing :)