RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
<crystal-gh> [crystal] crisward opened pull request #4063: modified bytes to match v0.20.5 of crystal (master...master) https://git.io/vDjER
soveran has quit [Remote host closed the connection]
Guest55967 has quit [Remote host closed the connection]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 240 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
greengriminal has quit [Quit: This computer has gone to sleep]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 255 seconds]
<FromGitter> <jwoertink> Can someone help me understand how this works? On line 8 of Readline https://github.com/crystal-lang/crystal/blob/c2c2276ec667171af5c2347490f49acdbdc4a3ca/src/readline.cr#L8 it takes a UInt8, but on line 44 it takes a string https://github.com/crystal-lang/crystal/blob/c2c2276ec667171af5c2347490f49acdbdc4a3ca/src/readline.cr#L44
<FromGitter> <mverzilli> I tried to follow the code to answer your question, and I think what's happening is that Crystal will call `to_unsafe` on params you pass to lib functions
<FromGitter> <jwoertink> I looked at the C readline docs, and saw this `char *readline (const char *prompt);`
<FromGitter> <mverzilli> String to_unsafe basically returns a pointer to the underlying string bytes (so it's ends up being a pointer to UInt8)
<FromGitter> <jwoertink> I don't know C, but I'm assuming the char is the String
<FromGitter> <jwoertink> ah. that's interesting
<FromGitter> <jwoertink> So when calling `LibReadline.readline("some string")` Crystal will take call `"some string".to_unsafe` which returns a UInt8?
<FromGitter> <jwoertink> or, well, a `Pointer(UInt8)`
<FromGitter> <mverzilli> right
<FromGitter> <mverzilli> again, I went into the compiler's code and try to make sense of it to see if I could answer your question, but I think that's what's happening
<FromGitter> <jwoertink> well, that makes a bit more sense
<FromGitter> <jwoertink> but now the question is, why wouldn't the `fun readline()` be `readline(prompt : Pointer(Uint8))`? Or would they be considered the same to the compiler?
<FromGitter> <mverzilli> yeah, they're synonims
<FromGitter> <jwoertink> cool. That makes more sense now
<FromGitter> <jwoertink> thanks!
<FromGitter> <mverzilli> I mean `UInt8*` and `Pointer(UInt8)` are the same, just as `Union(SomeType, Nil)` is the same as `SomeType?`
<FromGitter> <jwoertink> Right. I guess I should have questioned the asterisk lol.
<FromGitter> <jwoertink> `UInt8` is not the same as `UInt8*` though, right?
<FromGitter> <mverzilli> no
<FromGitter> <mverzilli> I mean, yes, right :P
<FromGitter> <jwoertink> haha cool
<FromGitter> <jwoertink> How would this C code look in a lib? `int bind_key (int key, some_func_t *function);`. I'm curious about the `*function`. Is that like `Pointer(Proc)`?
<FromGitter> <jwoertink> `fun bind_key(key : Int, some_func_t : Pointer(Proc)) : Int` ?
rafadc has joined #crystal-lang
<FromGitter> <jwoertink> Is there anyone not on macOS that can run this code?
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ae6e78de5049082203519e]
<FromGitter> <jwoertink> I get an error when running this with `crystal sample.cr`
<FromGitter> <Sija> @jwoertink I’ve got: ```
<FromGitter> <Sija> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ae6f8e9eb1bd81481dbe5f]
<FromGitter> <jwoertink> ok, so the same thing I get.
<FromGitter> <jwoertink> Is that expected? Or do you think that might be a bug?
<FromGitter> <jwoertink> I get this same error with a few of the readline methods
<FromGitter> <Sija> seems like a bug to me
<FromGitter> <jwoertink> I'll report it then. Thanks!
msg has joined #crystal-lang
msg is now known as Guest24425
Rinkana has joined #crystal-lang
olek_poz has joined #crystal-lang
<FromGitter> <schoening> @Papierkorb, thank you for the tip! I try to asap :D And yes, it's really fun.
<FromGitter> <schoening> I just created my first every github repo :D
<FromGitter> <schoening> Could I get some help for setting it up to be available on crystalshards.xyz ? ^^
snsei has joined #crystal-lang
<FromGitter> <lhz> Just updated crystal to 0.21.0, now trying to update to version 4.1.1 of stumpy_png, which was patched yesterday to work with the changes in crystal. But no matter what I do, I can only get it to fetch the 4.1.0 shard, even though it says 4.1.1 here: https://github.com/l3kn/stumpy_png/blob/master/shard.yml Any ideas?
snsei has quit [Ping timeout: 268 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<Yxhuvud> check your lockfile?
Qchmqs has joined #crystal-lang
<FromGitter> <lhz> I removed it, still no go.
<FromGitter> <lhz> Also tried head or master as version. Anything other than 4.1.0 and it says it can't resolve it.
olek_poz has quit [Ping timeout: 268 seconds]
mark_66 has joined #crystal-lang
<FromGitter> <lhz> I even get 4.1.0 if I just put `github: l3kn/stumpy_png` in my shard.yml without a lock file, even though it says version 4.1.1 in that repo on github. *confused*
<FromGitter> <sdogruyol> why not use version: 4.1.1 in your shard.yml
<FromGitter> <lhz> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ae9f4f21d548df2c4893d7]
<FromGitter> <sdogruyol> shards update?
olek_poz has joined #crystal-lang
<FromGitter> <lhz> If I put `version: 4.1.1` in my deps, I get this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ae9f87de50490822043a2f]
<FromGitter> <lhz> Ok, I found the problem. There is no tag yet for v4.1.1. I forked the repo and set that tag and then it works.
<FromGitter> <schoening> @sdogruyol hey, I updated kemal and now I can't serve static files anymore o_o' did the api change?
olek_poz has quit [Read error: Connection reset by peer]
<FromGitter> <sdogruyol> @schoening no, there's a known issue with Crystal 0.21.0 https://github.com/crystal-lang/crystal/issues/4060
<crystal-gh> [crystal] crisward opened pull request #4068: Fixes #4060 (master...patch-1) https://git.io/vyeJA
<crystal-gh> [crystal] crisward closed pull request #4063: modified bytes to match v0.20.5 of crystal (master...master) https://git.io/vDjER
<FromGitter> <crisward> @sdogruyol Just create a pull request for #4060 - Actually ended up reading about gzip headers to identify the issue. Apparently empty bytes slices are truthy... who would have known? https://github.com/crisward/crystal/commit/fbbb28d591be3e29b27618c91d0c4bb02da050c9
gloscombe has joined #crystal-lang
<FromGitter> <sdogruyol> @crisward great work
<FromGitter> <sdogruyol> thanks a lot
<FromGitter> <sdogruyol> @schoening https://github.com/schoening/pathfinder this is cool
<FromGitter> <sdogruyol> congrats
<FromGitter> <crisward> @sdogruyol thanks... maybe I'll get my first contribute to crystal accepted.
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <sdogruyol> hopefully :pray:
<FromGitter> <schoening> @sdogruyol thank you :) now I need to optimise it. When I run it in my game loop I get gc warnings. Gonna try to create an object pool for the path arrays I am using since I think the problem comes from that
<FromGitter> <lhz> @schoening: cool! have you looked into this? https://en.wikipedia.org/wiki/A*_search_algorithm
<FromGitter> <schoening> I have. But I just can't implement it quite yet. I seem to learn best by trial and error
<crystal-gh> [crystal] asterite closed pull request #4068: Fixes #4060 (master...patch-1) https://git.io/vyeJA
<FromGitter> <schoening> If anyone wants to look at the search function and tell me if my assumption that the allocation of the "todo" and "visited" list causes gc warnings (and eventual crashes in a loop..) that would be neat. I don't know so much about crystal yet.
<FromGitter> <lhz> Implemented a version of A* in C many years ago, it took some effort but was quite satisfying when I got it to work.
<FromGitter> <schoening> Is the c. Garbage collector not super effective? I don't think I would get this problem using js and v8 :smile:
<FromGitter> <schoening> Wow nice! @lhz
<FromGitter> <schoening> Can I pre allocate arrays in crystal? If I know the max size.
<FromGitter> <schoening> Or just loop and push?
<FromGitter> <sdogruyol> @schoening you can preallocate
<crystal-gh> [crystal] asterite reopened pull request #4068: Fixes #4060 (master...patch-1) https://git.io/vyeJA
<FromGitter> <sdogruyol> `Array.new(500, 'a')`
<FromGitter> <schoening> @sdogruyol ohhh. Cheers man. I couldn't find how to do it
<FromGitter> <ezrast> I think you mean `Array(Char).new(500)`
<FromGitter> <ezrast> 0-length array with 500 capacity vs 500-length array
<FromGitter> <schoening> What does the other do? Create 500 'a'?
<FromGitter> <ezrast> yeah
<FromGitter> <schoening> Cool. Now i got two tools
<FromGitter> <schoening> What happens when I try to push beyond the limit in your version ezrast?
<FromGitter> <ezrast> should just start allocating extra memory like normal
<FromGitter> <schoening> Ok. Neato
<FromGitter> <schoening> Thanks both of u :smile:
<FromGitter> <schoening> Does array.swap a, b create any garbage?
soveran has quit [Remote host closed the connection]
Svenskunganka has joined #crystal-lang
Rinkana has quit [Ping timeout: 260 seconds]
rafadc_ has joined #crystal-lang
bjz has joined #crystal-lang
rafadc has quit [Ping timeout: 268 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
akwiatkowski has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
Rinkana has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
<FromGitter> <rishavs> any idea whats wrong here? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58aed5ddde50490822056d04]
<FromGitter> <rishavs> I was restructuring a simple mvc structure when i got this error.
<FromGitter> <rishavs> https://github.com/rishavs/Kamel
<FromGitter> <sdogruyol> seems like a problem with crecto
<FromGitter> <rishavs> i thought so too. but using the last version of crecto made no difference. >.>
mgarciaisaia has joined #crystal-lang
rafadc_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rafadc has joined #crystal-lang
mgarciaisaia has quit [Quit: Leaving.]
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 240 seconds]
<FromGitter> <fridgerator> crystal-db define a private method `drivers` https://github.com/crystal-lang/crystal-db/blob/master/src/db.cr#L94
<FromGitter> <fridgerator> in crecto, I am overriding it here so that its public https://github.com/fridgerator/crecto/blob/master/src/crecto/db.cr
<FromGitter> <fridgerator> I use it to determine which database driver is used
<FromGitter> <fridgerator> This has worked for me, and passes all the tests, so I'm not sure why its not working for you
mgarciaisaia has joined #crystal-lang
<FromGitter> <fridgerator> ah, its because you are requiring "db" after requiring "crecto"
<FromGitter> <fridgerator> `require "pg"`
<FromGitter> <fridgerator> `require "crecto"`
<FromGitter> <fridgerator> This works
<FromGitter> <fridgerator> Explicitly requiring db is not necessary
<FromGitter> <asterite> Maybe open an issue in crystal-db requesting to make the method public and explaining why you need that? Monkey-patching should be done to fix bugs, not to change how things work
<FromGitter> <fridgerator> Will do, that KS
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
rafadc_ has joined #crystal-lang
rafadc has quit [Ping timeout: 255 seconds]
rafadc_ has quit [Client Quit]
rafadc has joined #crystal-lang
rafadc has quit [Client Quit]
rafadc has joined #crystal-lang
rafadc has quit [Client Quit]
rafadc has joined #crystal-lang
rafadc has quit [Client Quit]
rafadc has joined #crystal-lang
rafadc has quit [Client Quit]
Svenskunganka has quit [Ping timeout: 268 seconds]
<FromGitter> <rishavs> hmmm... I removed the require db line but it made no difference....
<FromGitter> <muscar> hey, I'm trying to build crystal from source on macOS Sierra, and the test suite fails
<FromGitter> <muscar> alex:~/A/crystal:master> uname -a ⏎ Darwin Sapiens.48hs.co 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64 ⏎ alex:~/A/crystal:master> crystal -v ⏎ Crystal 0.21.0 (2017-02-21) [https://gitter.im/crystal-lang/crystal?at=58aef5b200c00c3d4f79b932]
<FromGitter> <muscar> system info:
<FromGitter> <muscar> failed test:
<FromGitter> <muscar> gets pointerof constant inside class ⏎ Code gen: debug ⏎ codegens abstract struct (#3578)Assertion failed: (!Filename.empty() && "Unable to create file without name"), function createFilePathPair, file DIBuilder.cpp, line 130. ⏎ make: *** [spec] Abort trap: 6 ⏎ alex:~/A/crystal:master> [https://gitter.im/crystal-lang/crystal?at=58aef5c3e961e53c7f58ba3b]
<FromGitter> <muscar> I looked into it a bit, and it looks like it fails while running the tests for debug info codegen because not all `location`s have a `filename`
<FromGitter> <muscar> alex:~/A/crystal:master> /usr/local/bin/llvm-config-3.6 --version ⏎ ⏎ 1) 6.2
<FromGitter> <muscar> with assertions enabled
<FromGitter> <fridgerator> @rishavs make sure pg is required before crecto for now.
Qchmqs has quit [Ping timeout: 268 seconds]
gewo has quit [Quit: WeeChat 1.0.1]
akwiatkowski has quit [Ping timeout: 260 seconds]
snsei has quit [Remote host closed the connection]
<FromGitter> <muscar> also, after I change the compiler to mitigate the above bug (mind you, not *fix*), the compiler sometimes dies:
<FromGitter> <muscar> alex:/p/t/crystal:pass-filename-in-spec> .build/all_spec -v -e debug --fail-fast ⏎ Code gen: debug ⏎ codegens abstract struct (#3578) ⏎ inlines instance var access through getter in debug mode ⏎ codegens correct debug info for untyped expression (#4007 and #4008) ... [https://gitter.im/crystal-lang/crystal?at=58aefc351465c46a56a3d422]
greengriminal has joined #crystal-lang
<FromGitter> <muscar> it *looks like* this is happening in the finalizer for LLVM context: `LibLLVM.dispose_context(self)`
<FromGitter> <muscar> if I comment this line it doesn't fail at all
greengriminal has quit [Quit: This computer has gone to sleep]
mgarciaisaia has quit [Quit: Leaving.]
Rinkana has quit [Ping timeout: 260 seconds]
greengriminal has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
tatey has quit [Quit: ZNC - http://znc.in]
tatey has joined #crystal-lang
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 268 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
Svenskunganka has joined #crystal-lang
<Papierkorb> *practically
mark_66 has quit [Remote host closed the connection]
<FromGitter> <dreyks> wow. didn't expect it this early
<Yxhuvud> schoening: There are pretty many parts of your pathfinder that can be improved. You may want to look at https://github.com/yxhuvud/advent_of_code_2016/blob/master/linuss-crystal/src/aoc13.cr for inspiration.
soveran has quit [Remote host closed the connection]
<FromGitter> <schoening> Thx @yxhuvud i take a look when I'm home. Right now in removing all the memory allocations in the search
<Yxhuvud> That seems costly if the search space is big.
<Yxhuvud> Using better data structures is simpler :)
<FromGitter> <schoening> Looking forward to reading your code then! Coz right now I can't use my search inside a fast loop :p
<Yxhuvud> how big maps are you searching?
<FromGitter> <schoening> Costly? Memory is cheap now
<FromGitter> <schoening> It crashes if I do 1 search per second on a 10x10 grid. Gc warning, freeze and crash
<FromGitter> <schoening> Pretty bad since I want many searches :smile: but still happy I finally get it
<FromGitter> <schoening> I think I will limit the search to about 20x20. The game won't display more than that
<FromGitter> <schoening> Hey du er jo svensker @yxhuvud . Jeg kan læse den readme haha
<Yxhuvud> There is a lot of easy allocations you can remove, by making Node into a struct and by not using Node#inside?. The latter needlessly allocates a new array, and is also linear instead of constant time.
<Yxhuvud> well it was a podcast I listen to that wrote the readme..
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<FromGitter> <schoening> Linear instead of constant time? What does that mean
<FromGitter> <schoening> Thx!
<FromGitter> <johnjansen> o(n) instead of o(1)
<FromGitter> <schoening> Yeah was about to ask if it was that
<FromGitter> <bcardiff> SugarException.new "Unable to code". https://twitter.com/mariaintidavid/status/834806881973567488 ⏎ 👋
<Yxhuvud> Easier to handle than ENOCOFFE
<FromGitter> <Sija> ```rescue e : SugarException ⏎ e.eat(with: Coffee.new).then { code_some_moar! } ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=58af1475567b0fc8138e7325]
<FromGitter> <schoening> That is something that has been bugging me actually... I an only doing that inside? Search because I don't know how to do key value lookup in crystal since aaa a a aaaaaaaa
<FromGitter> <schoening> Ups
<FromGitter> <schoening> Mobile ftw
<FromGitter> <schoening> Well. Hopefully I can edit that from home lmao!
<Yxhuvud> schoening: well, the method you were looking for is includes?, but you really shouldn't use an Array for that
<FromGitter> <schoening> I didn't find anything like an object in Javascript to store them and check :x
<FromGitter> <schoening> Anyways, I'm home in a moment then I check your code
<Yxhuvud> Arrays is not a good general substitute for Javascript objects. You have to look at the use case and choose the appropriate one
<RX14> yes! finally got jenkins to launch it's own slaves on AWS
<Yxhuvud> \o/
<RX14> aand it broke
<RX14> simple fix i think
<RX14> i.e. mkdir /opt/jenkins/
AckZ has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
early has quit [Quit: Leaving]
early has joined #crystal-lang
Guest24425 has quit [Remote host closed the connection]
Nouv has joined #crystal-lang
<Nouv> Dumb question but I can't figure this out, how do I join two strings together?
<FromGitter> <Sija> @Nouv `str1 + str2` or `”#{str1}#{str2}”` or `[str1, str2].join`
<Nouv> Sija: I get `undefined method '+' for Nil (compile-time type is (String | Nil))` though
<Nouv> I'm trying to do `gets + "\n"`
onec has joined #crystal-lang
<FromGitter> <Sija> gets might return nil so you must either handle this case manually or append `.not_nil!` to make compiler happy
<Nouv> hm
<FromGitter> <Sija> for instance: `(gets || “”) + ‘\n’`
nouv_test2 has joined #crystal-lang
<Nouv> Ah, thank you
nouv_test2 has quit [Remote host closed the connection]
<FromGitter> <Sija> or `gets.not_nil! + ‘\n’` - this will blowup though if `gets` indeed returns `nil`
<Nouv> I went for gets || ""
<FromGitter> <Sija> u could use string interpolation too “#{gets}\n"
<Nouv> So many solutions! :P
<FromGitter> <Sija> this wouldn’t mind `nil` since its `#to_s` returns empty string
<RX14> "#{gets}\n" is the same as gets.to_s + "\n"
<FromGitter> <Sija> yup :)
<RX14> (in behaviour)
<FromGitter> <crisward> Does anyone know the difference between `var |= 1` and `var += 1`?
<FromGitter> <fridgerator> @RX14 i don't know what you're doing, UT running crystal with ec2 container service and docker works well
<FromGitter> <Sija> @crisward same diff as `var = var | 1` vs `var = var + 1` I guess ;)
<RX14> @fridgerator this is for a CI replacement for crystal
<FromGitter> <Sija> depends on how these operators are implemented for given `var` type
<FromGitter> <crisward> For int32 they seem to be interchangeable. Just curious, as I've not come across `|=` before,
<Papierkorb> crisward, binary OR'ing 1 is not the same as adding
<Papierkorb> crisward, try this: `pp 3 | 1, 3 + 1`
<FromGitter> <johnjansen> in practice `var ||= 1` only sets var if its `nil`
<FromGitter> <Sija> @crisward that’s because it's mostly used for `Enum` values
<FromGitter> <Sija> @johnjansen we’re talking about `|` operator, not logical OR `||`
<FromGitter> <crisward> I got the use of || to mean or, it was the single pipe was new. Binary or makes more sense.
<FromGitter> <johnjansen> oops 1 too many `|` sorry about that
<FromGitter> <johnjansen> in that case, `|=` can go truthy but not falsy (except on init)
<FromGitter> <crisward> I naively tested it with `a = 1 a |= 2` which gave me 3.
<Nouv> After doing `crystal init app appname`, where should I do `crystal run` or `crystal build` from?
<FromGitter> <johnjansen> do `a = 1; a |= 2; a |= 6` will give you a clue @crisward
<RX14> Nouv, in the folder it creates
<RX14> Nouv, yes
<Papierkorb> Nouv: `cd appname`, and then run crystal commands
<Nouv> RX14: So `crystal run src/appname.cr`?
<RX14> and you need to specify a source file
<Nouv> Great, cheers
<Nouv> Also what's the best editor for Crystal at the moment? Sublime isn't working out for me
<RX14> vim
<RX14> atom is you want a "normal" editor
<RX14> if*
<Nouv> Atom them, thanks
<Nouv> Does crystal run a `main` method on startup?
<Nouv> How should I initialize the module + class basically
<FromGitter> <sdogruyol> @bcardiff that's awesome :P
<crystal-gh> [crystal] Sija opened pull request #4069: Add File.touch and FileUtils.touch methods (master...file-touch) https://git.io/vyvRA
<FromGitter> <dreyks> still waiting for jetbrains to come up with crystal IDE :/
<FromGitter> <Rinkana> I wont put my money on it for niw
<FromGitter> <Rinkana> now
<FromGitter> <dreyks> there's a uservote issue if someone wants to upvote it https://youtrack.jetbrains.com/issueMobile/RUBY-17225
msg has joined #crystal-lang
msg is now known as Guest5443
gloscombe has quit [Remote host closed the connection]
<FromGitter> <crisward> VSCode has ok crystal support. Sublime was ok until it recently started breaking formatting... not sure why.
<FromGitter> <drosehn> sadly Atom is a problem for me due to the directories it creates in /tmp.
<FromGitter> <Sija> sadly Atom eats sth like 0,5GB or RAM upfront, just because it’s so super awesomely built on top of headless webkit… (oO) ;)
<Papierkorb> Only eats 140MiB here
<Papierkorb> Kate is at 130MiB. Not that big of a difference
<Papierkorb> I don't think that atom-editor is particularly good, mind you. I just don't feel like learning emacs. Neither do I like vim.
<RX14> emacs here, uses 1gb ram
<RX14> actually only after emacs has just updated packages
<RX14> usually it's 250mb ish
mgarciaisaia1 has left #crystal-lang [#crystal-lang]
<RX14> emacs seems to eat ram with ease however
<Papierkorb> spacemacs eats 130MiB residential memory too for me
<Papierkorb> I must say that I'm surprised to see all three this close
<FromGitter> <drosehn> I end up using Xcode for many things, and that's been known to use up a lot of memory too.
<FromGitter> <Sija> i exaggerated a bit, but still it’s couple of times moar than native equivalents, for instance TextMate
<RX14> god damnit
<FromGitter> <Sija> not mentioning vim...
<Papierkorb> Kate is native, as is emacs
<RX14> my aws instance ran out of disk space building llvm...
akwiatkowski has joined #crystal-lang
<Papierkorb> I also seriously dislike the trend of using webkit/electron for "desktop apps" (why is everything an app nowadays?) too, that's why I hope someone steps up in the crystal community and pledges to maintain a robust binding to Gtk or Qt.
<FromGitter> <Sija> and does it shows “Editor not responding” alerts (or similar)? ;)
<Papierkorb> No?
<FromGitter> <Sija> so it’s another “yay" for Atom ;)
<RX14> electron isn't too bad
<Papierkorb> A good GUI toolkit could actually attract many ruby developers, #ruby was full the last weeks of people asking how to create GUIs
<FromGitter> <Sija> actually it’s damn nice in theory, in practice though tends to be bit of a burden when you open couple of ‘em (like Slack + Gitter + Atom)
<Papierkorb> Solution: Don't use Gitter nor Slack
<FromGitter> <Sija> @Papierkorb so true
<RX14> ruby has shoes...
<Papierkorb> IRC is doing just fine, I don't see any value in switching over to the gitter version of this channel
<FromGitter> <Sija> in other words: choose only one Electron to use? :)
<FromGitter> <Sija> btw, do u know any nice IRC gui for macOS?
<Papierkorb> I think we already showed that actually, many editors including atom use about the same memory
akaiiro has joined #crystal-lang
<FromGitter> <Sija> did any1 measured TextMate’s RAM usage?
<Papierkorb> no, why would I want to use a closed-source program?
akaiiro has quit [Read error: Connection reset by peer]
<FromGitter> <Sija> it’s not, see https://github.com/textmate/textmate
<FromGitter> <johnjansen> haha, i was just thinking that … bags not me
<FromGitter> <crisward> I'm waiting for someone suggesting building a text editor in crystal... if nothing it'd be fast.
<Papierkorb> macOS only? don't care
<Papierkorb> crisward, then we can also make it show useless hints like atom does, like "this plugin adds 10ms to the start time"
<FromGitter> <crisward> I don't understand why VSCode is so much quicker than Atom when they're built on the same platform.
<FromGitter> <crisward> I gave up on atom...
soveran has quit [Remote host closed the connection]
<FromGitter> <drosehn> Part of me would love to write a good editor in crystal. The rest of me realizes that I already have 100 other projects that I'd love to do.
<Papierkorb> Programming in a nutshell :)
Guest5443 has quit [Remote host closed the connection]
<FromGitter> <drosehn> Looks like TextMate with one file open takes up about 55-MiB. And I'm pretty sure it's a single process, so the memory-use is not "hidden" by being split up across multiple processes.
<FromGitter> <drosehn> That's "TextMate version 2.0-rc.4", to be precise.
bjz has joined #crystal-lang
<FromGitter> <schoening> I just switched to atom because the sublime crystal package kept deleting any white space I tried to add..
<FromGitter> <crisward> @schoening was it not doing a crystal format for you?
<FromGitter> <schoening> @crisward oh. Is vscode good?
<FromGitter> <schoening> It formatted the indentation really nicely. But I was not allowed to do stuff like this: ⏎ ⏎ ```some_code ⏎ ⏎ some_other_code``` ⏎ ⏎ It would always remove all the empty lines. And that really frustrated me. [https://gitter.im/crystal-lang/crystal?at=58af3e55f1a33b62753ec985]
<FromGitter> <crisward> Good for editors is way too subjective for me to answer that. I often get told vim is good. Vscode is better than you think it's going to be, has lots of nice extensions. Very good for JS. Crystal ok.
<FromGitter> <crisward> sublime wasn't doing that for me. I'm guessing you have an extension doing something.
<FromGitter> <schoening> And it's build on electron too?
<FromGitter> <schoening> Hm yeah alright
<FromGitter> <schoening> I guess so too then.. damn. Now I need to figure out which one it is ;_;
<FromGitter> <dreyks> binary search ftw:)
<FromGitter> <schoening> It only happens when I use crystal syntax tho lol
<FromGitter> <drosehn> I use sublime text on a few of my crystal programs. I have very few plug-ins installed (other than the ones for crystal). I haven't see an issue where it is removing empty lines.
<FromGitter> <ltran> Anyone using crystal-pg? I can add query string params to the database url, but was wondering if configuring the settings through a yml file is built in. I was looking but wondering if i missed something obvious.
<RX14> no, you have to use the URL
msg has joined #crystal-lang
msg is now known as Guest14186
<FromGitter> <schoening> @crisward yep, it was some issue with another package. I did a clean install of sublime text and it lets me have a single empty line now. All is well again.
onec has quit []
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 240 seconds]
<FromGitter> <ltran> Thanks rx14
shawn42 has joined #crystal-lang
<shawn42> While porting some Ruby code to Crystal, I noticed the lack of srand to seed the global rand function. Is there another way to do that or do I need to manage a shared Random instance?
<RX14> there's no way to reseed an existing random instance
<RX14> well, at least not Random::MT19937
<RX14> so you're going to have to maintain a global instance
<RX14> you might want to make an issue for that shawn42, because reseeding the global instance seems useful
<FromGitter> <crisward> @schoening cool.
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
_whitelogger_ has joined #crystal-lang
<Papierkorb> rishavs, for compiler errors, look at the end of the output. The last message is what you're looking for.
<RX14> what could crystal improve?
_whitelogger has quit [Remote host closed the connection]
<RX14> for errors
soveran has joined #crystal-lang
sija has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <rishavs> Thanks @papierkrob, but i think i did define the variable.
<FromGitter> <rishavs> @RX14, i am not sure. I do like elm's errors
<FromGitter> <rishavs> Maybe we can not show the stack by default?
<FromGitter> <rishavs> i thinkit a beginner vs advanced user thing. whom should the language focus more on
<Papierkorb> would that actually change something?
<Papierkorb> People are commonly scared by any error message, to the point of scrolling around like crazy for minutes. I don't know why
<Nouv> How do I only set a varaiable from a regex match if the match contains the group?
<Nouv> variable*
<Nouv> Ah, nvm
<FromGitter> <rishavs> @Papierkorb, can you help me a bit and look into my code? I really cant figure out whats the probem. :worried:
shawn42 has left #crystal-lang [#crystal-lang]
<Papierkorb> rishavs, please gist(.github.com) the template and the get() block (or post or w/e)
<Papierkorb> post-block*
<FromGitter> <rishavs> its in the post_controller.cr
<Papierkorb> From the POV of that line, you're setting a variable somewhere in your program
<FromGitter> <rishavs> i think gitter doesnt handles long gists well. it doesnt shows all the files
<Papierkorb> That somewhere is not in the get block, so doesn't matter as far the block is concerned
<RX14> you're setting dataset in a methodf
<RX14> why would it be available in the template?
<FromGitter> <rishavs> thanks! that must be it
<FromGitter> <rishavs> will edit and check now
<Nouv> Is crystal zero indexed?
<RX14> yes
<Nouv> thanks
<Papierkorb> Has anyone else in here used Qt?
<RX14> damnit, aparrently 7.5gb ram isn't enough to link llvm
<Nouv> How would I go about iterating through an array?
<RX14> use .each on the array
<FromGitter> <johnjansen> `array.each do |i|`
<RX14> with a block
<FromGitter> <johnjansen> ;-)
<Nouv> Thank you!
<Nouv> What's the equivalent of the java `for(int i = 0; i < myArray.size(); i++)`?
<Nouv> I need the index of the elements in the array
<Papierkorb> Nouv: use `each_with_index`
<Papierkorb> Nouv: `foo.each_with_index{|the_element, the_index| ...}`
<Nouv> Thank you!
<Papierkorb> cheers
<FromGitter> <fridgerator> @Papierkorb I have used Qt, only a little
<FromGitter> <fridgerator> I may or may not be of any help. We eventually switched to electron.
<Nouv> Is there any way to define a type? Eg instead of having to write `NamedTuple(english: String, spanish: String, type: String)` every time
<Papierkorb> Ah okay, I'm looking for other fellow (or past) Qt-ers for opinions on crystals docs compared to Qt's really good one
<BlaXpirit> sigh i thought you were gonna say about crystal qt bindings
<Papierkorb> Nouv: `alias Foo = TheType(Blah)`
<Nouv> Papierkorb: Thanks! :)
<FromGitter> <fridgerator> lol
<FromGitter> <fridgerator> I would rather have chromium embedded bindings ;)
<Papierkorb> Nouv: What do you need NamedTuple for? You should rarely need to explicitly use it
<Papierkorb> Qt still has the best look n feel of all
<Papierkorb> no desktop html-wannabe or even gtk comes close
<BlaXpirit> FWIW I did make Crystal Qt bindings - to show an empty window xD
<Papierkorb> BlaXpirit: i think I remember seeing it, though building Qt bindings is not fun
<Nouv> Papierkorb: I have an array of elements that have three parts to them - an english word, a spanish word, and a type (adjective, verb etc)
<Nouv> Papierkorb: Is namedtuple the wrong thing to use for this?
<Papierkorb> It's really good in C++, and I think it really belongs there
<BlaXpirit> Papierkorb, well not in c++11 anymore xD
<Papierkorb> Nouv: You're building a dictionary application. NamedTuple is mainly used for keyword-arguments ("kwargs" for short), its use outside that is limited at least. Consider using a proper type for that (So, a class or struct) instead
<Nouv> Papierkorb: But .. why?
<Papierkorb> Nouv: That'll be easily extendable on the long run, and is more pleasant to use (`word.spanish` instead of `word[:spanish]`)
<Nouv> Papierkorb: Hm
<BlaXpirit> both look crazy to me but whatever
<Nouv> Papierkorb: Thanks, I'll keep that in mind for the future. I'm just building something really quickly right now though, so I think NamedTuple should suffice
<Papierkorb> Or use the `record` macro if you want a immutable struct: `record Word, spanish : String, english : String, type : WordType`
<Nouv> Papierkorb: I'm running through a bunch of different projects to learn Crystal
<Papierkorb> BlaXpirit: Well for a "real" application i'd make it more generic, but for a learning excercise .. eh
<Nouv> Papierkorb: Was that meant for me?
<Papierkorb> Nouv: not directly, I tried to reply to Bla's "both look crazy"
<Nouv> ah
<Nouv> How do I handle stuff like `undefined method '[]' for Nil (compile-time type is (NamedTuple(english: String, spanish: String, type: String) | Nil))`? I already have the call within `if typeof(translated) != Nil`
<FromGitter> <johnjansen> make sure you instantiate one
<Nouv> johnjansen: But why does that matter if I have the if statement?
<FromGitter> <johnjansen> they type is a mixed type already
<FromGitter> <johnjansen> its not about the guard, its about the var type and what it “could” carry
<Nouv> How do I handle that then?
<FromGitter> <johnjansen> you dont get a free pass on typing like you do in ruby
<Nouv> I only want to operate on it when it's not nil
<BlaXpirit> Nouv, uhm I think the condition `typeof(translated) != Nil` is just not somthing the compiler looks at when confirming types inside the if branch
<FromGitter> <johnjansen> use `not_nil!`
<BlaXpirit> preferably use `if translated`
<BlaXpirit> well that's for a different use case but sure
<Nouv> BlaXpirit: That worked, thank you! I was trying stuff along those lines - `if translated != nil`
<BlaXpirit> and i always recommend reading the whole documentation first
<FromGitter> <johnjansen> +1
<Nouv> BlaXpirit: Yeah, will go back over again. Thanks though, that's exactly what I was looking for
<Nouv> What?! `undefined method 'ascii_uppercase' for Char (did you mean 'ascii_uppercase?'?)`
<Nouv> Are they not identical!?
soveran has quit [Remote host closed the connection]
<RX14> Nouv, no
<RX14> one has a ? at the end
<RX14> method names can contain question marks in crystal (and ruby)
<Nouv> Ahh
<Nouv> Thank you!
<RX14> and anything what would typically be isFoo in java would be foo? in ruby
<RX14> s/what/that
<Papierkorb> Nouv: To be more precise, a method can end in ? or !, but not both
<RX14> ^^
<RX14> by convention 9not enforced at all), ? means you're asking a questions and will get a boolean, and ! means "more dangerous"
<Nouv> I like that
<RX14> although "more dangerous" is very loosely defined
<Papierkorb> Nouv: While ? is a "query" method (what RX14 wrote), the ! is a "bang" method: They usually do something "dangerous", like modifying the data itself instead of returning a copy (`#select` vs `#select!`)
<Papierkorb> Nouv: Or in other words, if you use a ! method, your application "may go bang" ;)
<Nouv> I see
<Nouv> Sorry for all of the questions by the way, I have looked through the docs, my recall seems to be lacking though
<Papierkorb> We're here to help :)
<Papierkorb> Nouv: You don't come from a rubyist background, right?
<Nouv> Papierkorb: Nope, I usually work in Go or Java
<Nouv> Have never used Ruby
Svenskunganka has quit [Ping timeout: 255 seconds]
<Papierkorb> Nouv: Would you mind writing each thing you don't understand from the docs, especially those where they assume a ruby background, into a file and share it in some weeks when you're comfortable?
<Nouv> Papierkorb: Sure, I'm not sure if I'll still be using Crystal at that point though
<Papierkorb> Then we could move on to improve it and clear things up. Honestly, I don't see many of those myself, as I too come from Ruby :)
<Nouv> I'm a CS uni student, so just jumping around a bunch of languages at the moment
<Nouv> But yeah if there's anything noticeable I'll point it out
* Papierkorb wonders how many university students we have in here
<Papierkorb> *waves*
<RX14> i'll be one this time next year...
<Papierkorb> Bored in school?
<RX14> not really
<RX14> 6th form is pretty interesting
<Papierkorb> No idea what that is, where are you?
<RX14> in the UK we get 2 years of 6th form where you choose 4 subjects (no mandatory subjects) and do that for 2 years
<RX14> i think it's a great idea because you get to specialize earlier
<Papierkorb> sounds interesting, if you actually can choose among interesting subjects
<RX14> yeah it's really varies
<Papierkorb> wish they'd reform the German school system. few years ago (just before I finished), they shortened school time from 9 to 8 years. Didn't go down so well. Everyone said it's a stupid idea. Everyone still does, and some schools are now allowed to use the old system again "as a test"
<RX14> let me just pick the weirdest classes from my college
<RX14> obviously there's traditional subjects like maths and the sciences and CS
<RX14> but there's engineering courses, government and politics, photography
<RX14> all sorts
<Papierkorb> Our teachers are incapable of doing anything at a computer
<Papierkorb> That degree is meant to prepare people for pursuing an academic degree though
<Papierkorb> After all, university and the like are really cheap over here
<RX14> yeah I heard...
<RX14> at least there's a cap on tuition fees here, so it's not quite as bad as the US
<Papierkorb> I pay 100€ per semester
<RX14> it's £9000 per year here
<Papierkorb> I did pay 500€ at another university, but that also let me use trains all across the state of North Rhine-Westphalia (NRW), so that was awesome in its own right
<Nouv> Papierkorb: Wow, that's amazing
<Nouv> I'm a British citizen but still get screwed on the fees since I don't have home status
<RX14> oh dear
<Nouv> I'm off for the night, cheers for your help all o/
<Papierkorb> cya
Nouv has quit [Quit: Textual IRC Client: www.textualapp.com]
greengriminal has quit [Quit: This computer has gone to sleep]
Guest14186 has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
msg has joined #crystal-lang
msg is now known as Guest41479
soveran has quit [Ping timeout: 260 seconds]
Guest41479 has quit [Ping timeout: 255 seconds]
akwiatkowski has quit [Ping timeout: 240 seconds]