ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
<FromGitter> <faustinoaq> ^ lol my Projects folder is filled up by XML files XD
sz0 has quit [Quit: Connection closed for inactivity]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
vikaton has joined #crystal-lang
Yxhuvud has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
faustinoaq has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
rohitpaulk has joined #crystal-lang
Yxhuvud has quit [Client Quit]
Yxhuvud has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 265 seconds]
Creatornator has quit [Ping timeout: 245 seconds]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
<FromGitter> <girng> xD
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
snsei has joined #crystal-lang
blackchalk has joined #crystal-lang
blackchalk has quit [Changing host]
blackchalk has joined #crystal-lang
blackchalk has quit [Client Quit]
blackchalk has joined #crystal-lang
blackchalk has joined #crystal-lang
blackchalk has quit [Changing host]
snsei has quit [Remote host closed the connection]
blackchalk has quit [Quit: quitting]
faustinoaq has quit [Ping timeout: 240 seconds]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
mooe has quit [Quit: Connection closed for inactivity]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <bararchy> @fridgerator can you show your c source and crystal binding ? We might be able to help
Yxhuvud has joined #crystal-lang
<FromGitter> <fridgerator>  lib binding is here : https://github.com/fridgerator/netcdfcr/blob/master/src/lib_netcdf.cr
<FromGitter> <fridgerator> trying to currently figure out the `nc_get_vara` function
<FromGitter> <fridgerator> the node cpp version builds a `size_t` based on the number of arguments (dimensions) passed: https://github.com/swillner/netcdf4-js/blob/master/src/Variable.cpp#L275
<FromGitter> <fridgerator> then passes those as the parameters for `startp` and `countp`
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <bararchy> @fridgerator this ``` EXTERNL int ⏎ nc_get_vara(int ncid, int varid, const size_t *startp, ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5acc3f4192f5d62057b04254]
<FromGitter> <fridgerator> yes
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <fridgerator> I just made a new binding for `nc_get_vara_double` and it worked
<FromGitter> <fridgerator> this c library is weird
<FromGitter> <fridgerator> there is `nc_get_vara` for getting any type (i guess?), and then get_vara functions specific to each type
<FromGitter> <fridgerator> so I think i'll just have to use the methods that are specific to the variable type, instead of the generic ones
qard has joined #crystal-lang
qard has quit [Client Quit]
qard has joined #crystal-lang
<FromGitter> <fridgerator> `LibNetcdf4.nc_get_vara_double(@parent_id, @id, pos, size, out val)`
<FromGitter> <fridgerator> that works
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 264 seconds]
DTZUZO has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
qard has quit [Quit: qard]
Jenz has joined #crystal-lang
Jenz has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
crystal-lang630 has joined #crystal-lang
flaviodesousa has joined #crystal-lang
Jenz has joined #crystal-lang
Jenz has quit [Ping timeout: 256 seconds]
ua_ has joined #crystal-lang
ua__ has quit [Ping timeout: 268 seconds]
crystal-lang630 has quit [Ping timeout: 260 seconds]
<jokke> hey
<jokke> is it somehow easily possible to parse command line params that come from somewhere else than from command line? :D Basically i want to be able to send strings to a webapp which will be parsed like command line params (including esacaping and quoting for including whitespace etc)
<FromGitter> <alehander42> https://nim-lang.org/docs/parseopt.html
<FromGitter> <alehander42> uh https://nim-lang.org/docs/parseopt2.html *
<FromGitter> <alehander42> ( I guess? guys why do we still have two parseopt)
<FromGitter> <alehander42> you can optionally pass cmdline to initOptParser
<jokke> umm
<FromGitter> <alehander42> oh God
<jokke> that's not crystal
<FromGitter> <alehander42> I am in the wrong chat
<jokke> :D
<FromGitter> <alehander42> sorry
<jokke> haha
<FromGitter> <alehander42> totally confused
<FromGitter> <alehander42> oh man hahah sorry
<jokke> makes two of us
<jokke> no problem
<FromGitter> <alehander42> but still afaik
<FromGitter> <alehander42> you should be able to optionally pass args
<FromGitter> <alehander42> .parse(args, &block) : self
<jokke> yeah but that's already an array
<jokke> not a string
<jokke> i need something to do the splitting for me
<jokke> which isn't so trivial
<jokke> because of the quoting and escaping possibilities
<jokke> also OptionParser just parses options
<FromGitter> <Sjoerrdd> Hello
<FromGitter> <Sjoerrdd> I doubt about a Crystal framework
<FromGitter> <Sjoerrdd> which is great for building an API with Windows?
<jokke> rest api?
<FromGitter> <alehander42> @jokke well either there is such a parser lib already, or you have to write a simple parser function or to wrap existing solution I guess
<FromGitter> <alehander42> but I am not sure, I hope other people know better
<jokke> could be that there's no such parser lib because ARGV is being set by the operating system
<FromGitter> <Sjoerrdd> @jokke It's for a SPA & an app
<FromGitter> <Sjoerrdd> So a rest api with websocket stuff
<jokke> ok
<jokke> have you looked into amber?
<jokke> it's very rails-like
<FromGitter> <Sjoerrdd> Yes, I'm using Amber right now
<jokke> ok
<FromGitter> <Sjoerrdd> but I thought maybe there is an framework pure for API's
<jokke> yeah i was hoping there would be such a thing aswell
<FromGitter> <Sjoerrdd> Since Amber is a bit hard with returning relationships
<jokke> haven't found one though
<FromGitter> <Sjoerrdd> Lucky is a nice framework, but it doesn't work on my windows machine
<jokke> oh ok
<jokke> get a linux machine! :D
<FromGitter> <Sjoerrdd> I need windows for school :/
<FromGitter> <Sjoerrdd> otherwise I had a macbook
<FromGitter> <bararchy> @Sjoerrdd what about Kemal ?
<FromGitter> <Sjoerrdd> I'll try it
<FromGitter> <bararchy> @Sjoerrdd I found this https://github.com/blocknotes/kemal-rest-api ⏎ Also, offical example: http://kemalcr.com/cookbook/json_api/
<FromGitter> <Sjoerrdd> Thanks
<oprypin> jokke, there's no splitting, because Bash does that part
<crystal-gh> [crystal] Daniel-Worrall opened pull request #5935: Include type restriction on getters in JSON/mapping (master...json-type) https://git.io/vxd7G
Nik736 has joined #crystal-lang
Nik736 has quit [Client Quit]
<jokke> oprypin: i just hacked something together myself
shalmezad has joined #crystal-lang
<FromGitter> <straight-shoota> If someone want's to install crystal nightly, I have written an installer script: https://gist.github.com/straight-shoota/a2f4b29203936c04c578d6f6a1ad5f9b
<FromGitter> <straight-shoota> Unfortunately, it's relatively complicated to retrieve the appropriate download URLS from circle CI's API
<FromGitter> <straight-shoota> jokke, it's better to use `Char::Reader` instead of allocating and looping over an array of characters
pbodev1 has joined #crystal-lang
<jokke> thanks for the tip
<oprypin> jokke, nice specs
<oprypin> straight-shoota, does this mean that circle publishes binaries?
<jokke> yeah that's what i mean with "hacked something together"
shalmezad has quit [Ping timeout: 256 seconds]
Jenz has joined #crystal-lang
<FromGitter> <straight-shoota> oprypin
<FromGitter> <straight-shoota> yes
<FromGitter> <straight-shoota> but they are difficult to get to
<FromGitter> <straight-shoota> and are not guaranteed to be available foreever
<FromGitter> <straight-shoota> best way would be to publish them to a dedicated storage and after each run and make them available on crystal-lang.org
bcardiff has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
duane has joined #crystal-lang
<FromGitter> <girng> hello my friends!!!
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vxFtE
<crystal-gh> crystal/master e4f637c TSUYUSATO Kitsune: Add IDNA support and integrate with DNS lookup (#2543)...
hightower2 has joined #crystal-lang
<lhz> e
duane_ has joined #crystal-lang
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vxFt5
<crystal-gh> crystal/master 27697cf TSUYUSATO Kitsune: Parse slash after open-paren as regex delimiter (#5453)...
duane has quit [Ping timeout: 255 seconds]
hightower3 has quit [Ping timeout: 268 seconds]
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vxFqa
<crystal-gh> crystal/master f91af5f William Woodruff: init: Turn fork URL into a Markdown link (#5644)
<jokke> are there any template engines for crystal that compile the templates at runtime?
<FromGitter> <Sjoerrdd> Slang?
<FromGitter> <Sjoerrdd> https://github.com/jeromegn/slang
<jokke> i need something like ecr
<FromGitter> <Sjoerrdd> I'm not sure if it renders at runtime
<jokke> i don't want to render html
<jokke> mh i see that's not trivial
<jokke> since the templates contain crystal code
<jokke> and would have to be compiled during runtime
<jokke> i can't believe i'm saying this but something like jinja2 would be what i'm looking for
<jokke> i need some filters i could apply to arguments in the template
<jokke> like urlencode or so
<z64> https://github.com/straight-shoota/crinja ? (unfamiliar with jinja, just remembered this)
aarongodin has quit [Quit: ~]
aarongodin has joined #crystal-lang
<jokke> oh wow!~
hmans has quit [Quit: ~]
hmans has joined #crystal-lang
<z64> :)
mroth has quit [Quit: ~]
mroth has joined #crystal-lang
<jokke> straight-shoota: kudos
ilovezfs_ has quit [Quit: ~]
ilovezfs_ has joined #crystal-lang
thi_ has quit [Quit: ~]
thi_ has joined #crystal-lang
jetpack_joe has quit [Quit: ~]
jetpack_joe has joined #crystal-lang
jwaldrip has quit [Quit: ~]
jwaldrip has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e4f637c (master - Add IDNA support and integrate with DNS lookup (#2543)): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/364621803
<DeBot> https://github.com/crystal-lang/crystal/pull/2543 (Add IDNA support and integrate with DNS lookup)
<travis-ci> crystal-lang/crystal#27697cf (master - Parse slash after open-paren as regex delimiter (#5453)): The build is still failing. https://travis-ci.org/crystal-lang/crystal/builds/364623060
<DeBot> https://github.com/crystal-lang/crystal/pull/5453 (Parse slash after open-paren as regex delimiter)
rohitpaulk has joined #crystal-lang
Jenz has quit [Ping timeout: 240 seconds]
<travis-ci> crystal-lang/crystal#f91af5f (master - init: Turn fork URL into a Markdown link (#5644)): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/364624727
<DeBot> https://github.com/crystal-lang/crystal/pull/5644 (init: Turn fork URL into a Markdown link)
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
qard has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
swav has quit [Quit: ZNC - http://znc.in]
<FromGitter> <straight-shoota> yeah, that should work for you
<FromGitter> <straight-shoota> it's only lightly battle tested, so let me know if you find something that needs improvement
shalmezad has joined #crystal-lang
Jenz has joined #crystal-lang
Jenz has quit [Ping timeout: 245 seconds]
shalmezad has quit [Quit: Leaving]
Jenz has joined #crystal-lang
Jenz has quit [Ping timeout: 240 seconds]
<jokke> it works like a charm so far
Jenz has joined #crystal-lang
<jokke> i use it for a bot which can be taught responses to certain keywords. i can pass arguments to the calls now and they get interpolated in the templates at runtime. very nice
Jenz has quit [Ping timeout: 264 seconds]
hightower2 has quit [Ping timeout: 264 seconds]
<FromGitter> <straight-shoota> 👍
<FromGitter> <girng> 👍
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
ua__ has joined #crystal-lang
alex`` has joined #crystal-lang
snapcase has quit [Remote host closed the connection]
ua_ has quit [Ping timeout: 240 seconds]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
<FromGitter> <r00ster91> is a Tuple in any way modifyable? I can do this: ⏎ ⏎ ```tuple = {a: 1, b: 2} ⏎ tuple[0] = 2 ⏎ # or: ⏎ tuple = {1, 2} ⏎ tuple[0] = 2``` [https://gitter.im/crystal-lang/crystal?at=5acce9f692f5d62057b3a743]
<FromGitter> <straight-shoota> `NamedTuple` has merge: `{a: 1, b: 2}.merge({a: 3}) # => {a: 3, b: 2}`
<FromGitter> <straight-shoota> I don't know of anything similar for `Tuple`
<FromGitter> <straight-shoota> you can deconstruct it and create a new tuple
<FromGitter> <straight-shoota> ```_, b = {1, 2} ⏎ {2, b}``` [https://gitter.im/crystal-lang/crystal?at=5acceb336bbe1d2739d0cba4]
havenwood has left #crystal-lang ["Textual IRC Client: www.textualapp.com"]
<FromGitter> <r00ster91> ah ok i will try that thanks
greengriminal has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
<FromGitter> <girng> https://play.crystal-lang.org/#/r/3utx can anyone help me with this. im checking the docs and i see to_json can be used but not sure if i'm using it correctly
bcardiff has joined #crystal-lang
<z64> girng: you need to require the json library, https://play.crystal-lang.org/#/r/3uty
<FromGitter> <girng> oh wow lol
<FromGitter> <girng> thank you
<z64> np
ua_ has joined #crystal-lang
ua_ has quit [Max SendQ exceeded]
ua__ has quit [Ping timeout: 256 seconds]
aemadrid has quit [Quit: Connection closed for inactivity]
<FromGitter> <girng> this may be a dumb question but...
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <girng> nvm answered it with Int32 | Int16
qard has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
bcardiff has quit [Quit: bcardiff]
duane_ has quit [Ping timeout: 260 seconds]
ua has joined #crystal-lang
bcardiff has joined #crystal-lang
alex`` has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
flaviodesousa has quit [Ping timeout: 264 seconds]
That_Guy_Anon has joined #crystal-lang
<FromGitter> <girng> man. the | operator for types is a life savior.. LOVE IT1
<FromGitter> <bararchy> XD
<FromGitter> <ryankshah> How can I read into a `JSON` object from a file?
<FromGitter> <ryankshah> that is specified by the user*
bcardiff has joined #crystal-lang
moei has quit [Quit: Leaving...]
Jenz has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
hightower2 has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
bcardiff has quit [Quit: bcardiff]
greengriminal has joined #crystal-lang
bcardiff has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
<FromGitter> <straight-shoota> JSON.parse
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <straight-shoota> @ryankshah ^^
bcardiff has quit [Quit: bcardiff]
<FromGitter> <girng> same exact syntax in Godot too, which is cool :D
greengriminal has joined #crystal-lang
<travis-ci> crystal-lang/crystal#7cdb1f4 (ci/docs - WIP sync master docs to s3): The build failed. https://travis-ci.org/crystal-lang/crystal/builds/364773013
<FromGitter> <ryankshah> I know the JSON method to use, but how can I read the file into the string parameter for `JSON.parse` 😆
<FromGitter> <straight-shoota> You don't need a string, `JSON.parse`can read from File/IO directly
<FromGitter> <straight-shoota> ```File.open(path) do |file| ⏎ JSON.parse(file) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5acd184a2b9dfdbc3a78138e]
<FromGitter> <straight-shoota> this example should probably be added to the API docs
<FromGitter> <ryankshah> Thanks! Also, if I have a module (which contains a struct and classes), can i extend self to create utility methods? I.e module is called `MyModule` and method is called `func_x`
<FromGitter> <ryankshah> @straight-shoota would be useful to have in the docs :)
<FromGitter> <straight-shoota> sure
<FromGitter> <straight-shoota> you should be able to use `extend` and sub-namespaces without intereference
<FromGitter> <ryankshah> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5acd19146bbe1d2739d1bb1d]
<FromGitter> <ryankshah> would this be valid to do then?
<FromGitter> <ryankshah> or would it be better to raise an exception at the end of the `File.open ...` statement?
ua has quit [Ping timeout: 268 seconds]
Jenz has quit [Quit: leaving]
rohitpaulk has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
ua has joined #crystal-lang
<FromGitter> <straight-shoota> Why would you do that? You don't need `return nil` because it will never be reached, the method already has a return statement before that
<FromGitter> <ryankshah> @straight-shoota What if the file at the path specified isn't found?
<FromGitter> <straight-shoota> and you can skip `return` in the block either because the result from JSON.parse will implicitly be returned
<FromGitter> <straight-shoota> `File.open` raises an exception
<FromGitter> <ryankshah> ^^ Alrighty thanks
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <ryankshah> @straight-shoota say I've got a folder called `files` in my spec dir, how can i get the path of a file in here? I tried using `"./files/file.json"`
<OvermindDL1> Ooo, that's an idea, I wonder how embeddable crystal is, it could be quite an interesting scripting language for Godot now that Godot supports arbitrary languages via a set of C bindings...
* OvermindDL1 wonders if it would work in Godot's threading model even though crystal itself is not parallel..
<OvermindDL1> Single-core wouldn't be any worse than GDScript though at least, hmm
<OvermindDL1> How well does crystal support sandboxing code?
<FromGitter> <straight-shoota> @ryankshah paths need to be relative to the project root, so it should probably be `./spec/files/file.json`
<RX14> OvermindDL1, not at all
<OvermindDL1> No way to replace built-in calls to sandboxed proxy calls?
<OvermindDL1> That's the usual way to sandbox native code
<RX14> no?
<OvermindDL1> Might be an interesting feature in time
greengriminal has joined #crystal-lang
<RX14> "sandboxed native code" doesn't really make sense
<RX14> to me
<FromGitter> <ryankshah> @straight-shoota is it possible to use `./spec/files/*`?
<OvermindDL1> Eh regardless, Godot doesn't need sandboxing in general
<OvermindDL1> It actually has quite some uses, a combination of speed and safety
<RX14> like you can just write arbitrary instructions to memory
<OvermindDL1> NaCL was quite a good model of it for example
<RX14> and jump to it
<RX14> and you're done
<OvermindDL1> RX14: The language should prevent that
<RX14> why?
<RX14> we have an asm literal
<OvermindDL1> In a sandbox'd mode*
<RX14> how do you suppose we prevent it?
<RX14> prevent all casts, remove pointers?
<RX14> remove the asm embedding?
<OvermindDL1> Eh, same way that C/C++ can be sandboxed, disallow `__asm` calls, have bound memory and pointer access, etc...
<OvermindDL1> Does asm embedding even work well if you compile for a different arch or does crystal use LLVM assembly or invent a multi-platform assembly of it's own?
<RX14> sounds like a feature for the far far future
<RX14> OvermindDL1, no it's just like C
<RX14> you get platform asm
<RX14> which is good
<crystal-gh> [crystal] straight-shoota opened pull request #5936: Docs: Add examples for parse(IO) to JSON, YAML (master...jm/docs/json-yaml-read-file) https://git.io/vxbLA
<OvermindDL1> Platform being... x86 and arm only, or others?
<RX14> it's exactly the same syntax as __asm
<OvermindDL1> Does crystal support arm speaking of which?
<RX14> OvermindDL1, whatever the host is
<OvermindDL1> arm32 and arm64 both or just one or the other?
<RX14> whatever ASM you would write in C
<RX14> OvermindDL1, both
<RX14> on glibc
<RX14> aarch64 on musl
<OvermindDL1> Cool, what arch's does it support, does it have an official list?
<RX14> those ones
<travis-ci> crystal-lang/crystal#1fed53c (ci/docs - WIP sync master docs to s3): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/364787737
<OvermindDL1> Ah only x86's and arm's
<OvermindDL1> Should make a webassembly backend. ;-)
<FromGitter> <straight-shoota> @ryankshah as an argument to `File.open`?
<RX14> OvermindDL1, not plausible really
<FromGitter> <straight-shoota> but there's an issue for that
* OvermindDL1 really had hope for NaCL, but webassembly is close enough and still native compilation...
<RX14> it would be possible if you disabled the stdlib
<RX14> but wasm has no way to walk the stack for GC
<OvermindDL1> Oh Crystal doesn't have platform specific standard stuff in a 'core'-like library and generic things in a standard-like library?
<RX14> and no way to do arbitrary jumps for fibers
moei has joined #crystal-lang
<OvermindDL1> Correct, need CSP for wasm
<OvermindDL1> And GC works if root nodes are recorded
<OvermindDL1> But not the current crystal bohem collector
<RX14> "need CSP for wasm" you mean wasm needs to support csp?
<RX14> OvermindDL1, no we're not that organised
<RX14> everything's in 1 stdlib
<OvermindDL1> Eh you can still split up function compilation to make everything tail called with function context passing
<RX14> and it all depends on each other
<FromGitter> <ryankshah> @straight-shoota no for the require
<RX14> as in you can't require "string" without pulling in platform specifics
<FromGitter> <straight-shoota> yes
<FromGitter> <ryankshah> @straight-shoota so I can require the `files` directory and just call `file.json`?
<OvermindDL1> Does string pull 'in' platform specifics or does it embed platform specifics, I.E. can you just write new platform specifics that it will use on a specified platform?
<RX14> OvermindDL1, crystal's stdlib is really ugly in terms of modularity and portability
<FromGitter> <straight-shoota> @ryankshah no, `require` loads a crystal file, it doesn't change path lookups
<FromGitter> <ryankshah> That doesn't work
<FromGitter> <ryankshah> ^^
<RX14> it's a struggle to sort that out
<FromGitter> <ryankshah> So ill just load it in the path straight then
<OvermindDL1> RX14: Heh, Rust is in the process of ripping theirs into 2 parts currently, it is quite an ordeal, but they've already got wasm building native now
<RX14> OvermindDL1, in addition crystal's stdlib and compiler have a really really badly defined interface
<OvermindDL1> Ahh, ick
<RX14> the compiler makes numerous random generated calls to method it assumes exist in the stdlib
<RX14> OvermindDL1, exactly
<RX14> it's super ugly
<OvermindDL1> Uh, the compiler generates stdlib calls? o.O
<OvermindDL1> That's odd...
<RX14> for example:
<RX14> .as() case
<RX14> cast*
<RX14> can raise exceptions
<RX14> it generates the string for which to raise the exception using calls to String.build with a block argument
<RX14> and then passes that string to the raise method
<RX14> the raise method being in the stdlib is acceptable
<OvermindDL1> It doesn't embed constant strings into the data segment?
<RX14> the String.build invocation is not
<RX14> OvermindDL1, it generates the string dynamically to display what the class was it failed to cast
<RX14> for example failed to cast Foo to String
<OvermindDL1> Ah yeah that could use a proper interface layer then
<RX14> we really should permute the strings
<RX14> and put them in as literals
<RX14> and that would solve that
<RX14> it's just... ugly because the compiler and stdlib were never designed to be seperated
<RX14> it can be fixed
<RX14> behind the scenes
<OvermindDL1> Oh it doesn't dynamically generate it based on some data passed in? Yeah if it can be constant it definitely should
<RX14> but it needs someone to care about the issue
<OvermindDL1> There's not constant folding in the compiler? Or is it only for primitive integral types or so?
<OvermindDL1> no*
<RX14> OvermindDL1, LLVM does constant folding
<RX14> crystal compiler does absolutely 0 execution optimizations
<OvermindDL1> Yes, but no pass for type-knowledgeable folding, for things like strings?
<RX14> no
<RX14> you can override String#+ if you want
<OvermindDL1> Ah, LLVM has a fantastic pluggable optimization system, pretty easy to define your own passes. :-)
<RX14> the only optimization crystal ever does is turn Reference | Nil into Reference and representing nil as a null pointer
<RX14> and thats it
<OvermindDL1> Hmm, is nil a zero type in Crystal? Or does Crystal even have a zero type?
<RX14> zero type?
<OvermindDL1> A 'default type' for something not otherwise defined, like `null` for pointers in C++ or `nil` (yick) in ruby
<RX14> you mean how Java treats null?
<OvermindDL1> That too
<RX14> no lol
<RX14> otherwise we couldn't call ourselves type safe with a straight face
<OvermindDL1> Heh, so all uses of it have to be explicitly typed? Good. ^.^
<OvermindDL1> Indeed
<RX14> no null pointer exceptions at all
<OvermindDL1> It's considered one of the 2 major design faults for older languages that most modern languages don't have anymore because of the major design issues around it.
<RX14> you'll never get an exception from a method call itself
<RX14> only inside the method you call
<OvermindDL1> Though some newer languages (*cough*go*cough*) are still broken like that, so I have to ask...
<RX14> OvermindDL1, yeah crystal's type system is based on unions
<FromGitter> <straight-shoota> OvermindDL1 and Crystal has a very sweet solution
<OvermindDL1> Purely unions, or is it HM typed?
<RX14> you can define a variable as any arbitrary union of types
<OvermindDL1> Hmm, what is Crystal's typing system?
<RX14> and you can call any method shared by all the types in the union
<OvermindDL1> Is it full HM (with the unnamed sum types extension) or something else?
<RX14> so (String | Nil) you *can* call to_s because it's defined by both string and nil, but not for example []
<RX14> OvermindDL1, no it's informal
<OvermindDL1> Yeah, that's the Unmamed Sum Types extension to HM
<OvermindDL1> Unnamed*
<OvermindDL1> Oh, it has no inference?
<RX14> it's an entirely homegrown type inference system
<RX14> basically you just start at the literal types
<RX14> and grow the types outwards
<OvermindDL1> Are generic sum types representable? Or higher types?
<RX14> probably not
<RX14> sum types as in algebraic datatypes?
<RX14> no sum types because it doesn't make sense in OO
<OvermindDL1> In general though generic sum types are able to encode unknown types within heads rather than just being able to encode types at the type level as algebraic sum types do
<RX14> you can replicate sum types kinda by creating a union of different classes
<OvermindDL1> Algebraic Sum Types work quite well with OO, a closed single-level hierarchy from a singular interface is such an Algebraic Sum Type
<RX14> OvermindDL1, i know what some of those words mean
<OvermindDL1> Heh, sorry... ^.^;
<RX14> OvermindDL1, we don't really have interfaces
<OvermindDL1> By `interface` I mean any base level of a hierarchical tree, not an interface as in Java for example
<RX14> sure
<RX14> you can totally just make an abstract class with entirely abstract methods
<RX14> and boom interface
<OvermindDL1> That would indeed be one yep!
<RX14> but yeah
<RX14> no explicit ADTs
<RX14> because you can really do them various other ways
<OvermindDL1> Does crystal have a method for closing the children of a given class?
<RX14> either with classes as you said
rohitpaulk has quit [Ping timeout: 260 seconds]
<RX14> or with a alias of a union of records
<RX14> which is shorter and neater
<OvermindDL1> In OOP children are ADT's, you just have a hierarchy of ADT's
<RX14> OvermindDL1, what do you mean by "closing the children"
<OvermindDL1> By Closing I mean restricting the children, so only a given library can define the children for an 'interface' and no other library is allowed to subclass it (I.E. no surprises)
<RX14> no
<OvermindDL1> Like take Scala, it has that ability
<RX14> you can monkeypatch and reopen arbitrary classes and methods in any part of the stdlib
<RX14> just like ruby
<OvermindDL1> o.O Ogod that is horrifying...
<RX14> As I said
* OvermindDL1 hates hates *HATES* monkey patching...
<RX14> you can go make 1 + 1 == INT32::Max
<RX14> right now
<OvermindDL1> Once a function is defined it should never change ever again... >.>
<OvermindDL1> Why would someone want to add that capability to a language though?!
<OvermindDL1> Not even lisp allows for that and it has Generic Macros... >.>
<RX14> it's fun
<OvermindDL1> Dwarf Fortress definition of 'Fun'? ;-)
<RX14> just override any method
<Groogy> I do it all the time
<FromGitter> <straight-shoota> :D
<Groogy> With CrystalClear
<RX14> you even have a nice previous_def
<RX14> to call the previous definition
<Groogy> I've automated modifinyg defined methods ;D
<Groogy> modifying*
<OvermindDL1> Overriding functions by name is fine, but replacing a previous definition that other things compiled 'before' you get changed as well is horrifying...
<Groogy> it's fine
<RX14> OvermindDL1, our philosophy is "if it hurts don't do it"
<RX14> programmers can take care of themselves
<FromGitter> <straight-shoota> OvermindDL1, "compiled"?
<Groogy> heck I use it to hijack how memory is allocated in Crystal and deallocated
<Groogy> so I can track object lifetime
<OvermindDL1> straight-shoota: Eh, prior scope
<RX14> exactly
<OvermindDL1> Like say in OCaml `let a () = 1 in let b () = a () in let a () = 2 in a(), b()` will return `2, 1`, that mmakes sense
<RX14> bug in the stdlib?
<RX14> just fix it in your application
<OvermindDL1> Having it return `2, 2` is utter crazy...
<RX14> lol
<Groogy> I horribly violate Crystal with these two :3
<Groogy> and it's great
<RX14> it's difficult to accidentally monkey-patch something OvermindDL1
<FromGitter> <girng> @groogy i thought crystal has a garbage collector built in how are you managing memory??
<OvermindDL1> RX14: Problem is that people have a tendency to monkey-patch when they really shouldn't
<RX14> so just don't do it and trust the libraries you use not to do it
<OvermindDL1> I cannot think of a single good reason why monkey-patching would ever be good, especially as it changes the linearity of a program...
<RX14> OvermindDL1, our protection against monkey patching is flaming anyone who does it unneccisarily
<OvermindDL1> Like in Python, monkey patching is easy, no one does it though, compared to Ruby where it is OGodWhyAreTheyOverridingThis...
<RX14> OvermindDL1, Groogy just gave you a fantastic reason
<RX14> overriding the memory allocation routines for profiling
<RX14> OvermindDL1, yeah we plan to be like python
<RX14> it's possible but nobody does it
<RX14> not like ruby, it's possible and everyone abuses it
<OvermindDL1> If no one does it, why add it?
<RX14> because "nobody" isn't nobody
<Groogy> "noone" as in very select few
<RX14> because I just gave a good reason
<Groogy> this is essentially the monkey-patch code I guess: https://github.com/Groogy/trashman/blob/master/src/trashman/hooks.cr
<OvermindDL1> `crystal-clear` certainly doesn't need monkey patching, just language level macros, and trashman should just be hooks to the allocator as I'm guessing it will miss occasions where memory is allocated via, say, a C library or so
<FromGitter> <straight-shoota> it's certainly more healthy to monkey patch in a small feature missing from stdlib or a library than setting up a fork which adds it
<Groogy> If it becomes way too much & unreadable you probably doing something wrong
<Groogy> and also it should always be "opt-in"
<Groogy> we talked about that a lot ages ago
<OvermindDL1> straight-shoota: or better yet, make a library? ;-)
<Groogy> OvermindDL1 it is monkeypatching though, I am rewriting every single method in a class
<FromGitter> <girng> what's the difference between trashman and using crystal's built in GC (boehm's GC)?
<OvermindDL1> Groogy: Uh... why?
<Groogy> girng trashman just tracks what the GC does
<OvermindDL1> girng: trashman just looks like a statistical recorder
<OvermindDL1> Or counter, I'm unsure of what information it returns
<Groogy> OvermindDL1 because it gives a nice language to work with when defining the contracts
<Groogy> there's no other way to do it
<Groogy> unless you want to force the user to manually hook in everything
<OvermindDL1> Groogy: Well take Elixir, you can have, quite literally, identical syntax with it's macro system as to what your readme shows
<OvermindDL1> And it's a pre-compilation language, no monkeypatching
<FromGitter> <girng> but why do i want to know what the GC does if it's a garbage collector?isn't the point of a GC is so the developer doesn't have to worry about memory?
<Groogy> Well that is monkeypatching...
<OvermindDL1> girng: Because allocation can be slow
<Groogy> if you are opening up and changing what's defined
<OvermindDL1> Macro's are not monkeypatching
<Groogy> then you are monkeypatching aren't you?
<OvermindDL1> Elixir does not do that
<Groogy> So where do you draw the line?
<OvermindDL1> Nothing opens or changes what is defined
<OvermindDL1> In Elixir once something is defined, it cannot be changed, at all
<Groogy> Well monkeypatching is also done before the code is generated in Crystal
<Groogy> so it would in spirit be the same?
<RX14> OvermindDL1, so what's the practical difference to those macros and monkey patching?
<OvermindDL1> Except in Elixir all macro's are scoped, just because you change the AST of one module, does not mean any others are changed
<Groogy> after the binary been generated, nothing can be changed
<RX14> not being able to change it outside the module?
<OvermindDL1> And that module has to explicitly activate the macro's as well
<Groogy> Well it's the same here
<Groogy> The monkeypatching code is only aware of the things it's included into
<Groogy> it's scoped within that class/struct/module
<OvermindDL1> Groogy: So say I write a class and don't require anything in it, I don't have to worry about someone else's code elsewhere futzing with it?
<oprypin> hold on... why aren't we all using Elixir right now?
<RX14> Groogy, OvermindDL1 means that you can't just decide to modify a method on String with elixir macros
<Groogy> OvermindDL1 nope
<OvermindDL1> opypin: Because it's very problem-specific
<OvermindDL1> What RX14 said yes, like take the standard library (kernel), you can't change *anything* on it, at all
<Groogy> You can do it in Crystal, but when I started the libraries we talked a lot about it and the proper way to do it is to hook everything by an active choice by the user
<OvermindDL1> oprypin* Elixir runs on the BEAM, which is a VM designed for massive and safe IO handling, it's bad at everything else
<RX14> i mean
<OvermindDL1> Groogy: So as a user I have to specifically activate monkey patching? It won't "just happen" because a dep of a dep got brought in or so?
<RX14> crystal's pretty bad at anything else
<RX14> lol
<Groogy> OvermindDL1 you can use a library that doesn't follow that dogma
<Groogy> but then just don't use that library
<OvermindDL1> You can't always know, until maybe your application does wtf things in production a month later. ;-)
<RX14> OvermindDL1, no it can just happen because of a dep of a dep
<OvermindDL1> Almost no one goes over their dep's with a fine-toothed comb
<OvermindDL1> RX14: Yeah that is what is horrifying...
<RX14> ruby programmers live with it
<Groogy> I do, I make sure to understand how things work and read pretty much all documentation available
<OvermindDL1> I don't want code that I *know* is working to suddenly be changed because some library author got a weird itch
pbodev1 has quit [Quit: ChatZilla 0.9.93 [Firefox 56.0/20170903140023]]
<RX14> and by *cough* educating the community you can stop it
<OvermindDL1> RX14: I don't use Ruby for a couple big reasons, one is monkey patching. ;-)
<RX14> has it ever actually bitten you?
<OvermindDL1> I think you also assume too highly of most programmers. ^.^;
<RX14> instead of just the fear of it?
<Groogy> Well of course not RX14, he doesn't use it :P
<OvermindDL1> RX14: Yes, I have been bit by it, in both python and ruby (python was not always as anti-monkey patching as it is now, this was way back in the early python1/2 days)
<RX14> OvermindDL1, if we stop assuming hugly of programmers we get go
<RX14> highly*
<Groogy> Let programmers burn themselves
<Groogy> mistakes is the biggest learning tool
<OvermindDL1> OCaml is better, Go assumes their programmer wants to burn things
<OvermindDL1> Mistakes in production are not though
<oprypin> i dont get the fad for require * btw, if it were me, i'd ban it
<OvermindDL1> There's a reason I teach OCaml here (I'm a programmer and teacher at a college)
<oprypin> require spec_helper which requires * - that kills me every time
<RX14> oprypin, what do you mean?
<RX14> you mean requiting everything in a folder?
<oprypin> i mean any `require` statement followed by `*` in any form
<RX14> require "../src/**" is more fun
<oprypin> y tho
<OvermindDL1> I'm really thinking of pushing Rust in though, it is fantastic at yelling at someone if they code something stupid. :-)
<OvermindDL1> What does `require *` do?
<RX14> thats not valid syntax
<RX14> oprypin was talking about globs in requires
<OvermindDL1> Cool
<OvermindDL1> Ah
faustinoaq has joined #crystal-lang
<FromGitter> <straight-shoota> how can monkeypatching (or any other potential issue with a dep of a dep) crash production if all code is extensively specced? ;)
<RX14> i honestly wou;dn't be opposed to making monkeypatching opt-in somehow
<RX14> copying ruby's refinements
<RX14> but... later
<faustinoaq> "Consider interfaces, generics, macros and interactions between all of them. Remove inessential or redundant language features." What does that mean?
<RX14> @straight-shoota because nobody ever gets 100% branch coverage
<oprypin> what do you mean by "branch" and by "nobody" ?
<RX14> by nobody I mean almost nobody
<FromGitter> <straight-shoota> RX14, did you miss the smiley?
<RX14> and branch coverage is whatever kcov spits out
<RX14> @straight-shoota yes
<OvermindDL1> straight-shoota: Because the 'types' may work, but the 'logic' may not be what you expect
<OvermindDL1> And tests are not always covering
<OvermindDL1> Like ever, even with fuzzers, unless they are really simple programs
<FromGitter> <straight-shoota> OvermindDL1, I was not entirely serious
<OvermindDL1> I know, just saying. ;-)
<FromGitter> <girng> https://play.crystal-lang.org/#/r/3uvg oyrpyin helped me yesterday with sorting an array of namedtuples but im trying to do with an array of hashes
<FromGitter> <girng> im not sure what im doing wrong
<FromGitter> <straight-shoota> but logic can change as well without monkeypatching, for example with subclasses
<Groogy> There's always be bad code and bad practices. No matter what limitations you setup
<Groogy> There's always a better idiot
<oprypin> girng, you're using Hash here, that's what you're doing wrong
<FromGitter> <straight-shoota> still, I like that the Crystal community has a strong emphasis on speccing
<OvermindDL1> straight-shoota: I also abhor subclassing, so that argument I entirely agree with. ;-)
<oprypin> straight-shoota, does it really?
<Groogy> he wasn't making an argument Overmind
* OvermindDL1 exceptionally hates OOP, as a long-time teacher and programmer both it is nothing but garbage
<FromGitter> <girng> so what's it's NOW ILLEGAL to use a hash of arrays??
<FromGitter> <straight-shoota> oprypin, in my experience, yes
<oprypin> girng, no, it's just bad form and gives you annoying errors like this. experienced people can work around them but experienced people don't run into them in the first place
<FromGitter> <ryankshah> @straight-shoota im getting this error for the code we talked about earlier: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5acd2875080a3850531aca03]
<OvermindDL1> girng: It's looking like from the error that it's not propagating a type union properly?
<FromGitter> <straight-shoota> but depends on what you're comparing with
<OvermindDL1> At least in HM systems an unnamed sum type does not implicitly type well and explicit typing is almost always needed, and yes I know this isn't HM, but close enough for that
<FromGitter> <straight-shoota> @ryankshah looks like your JSON is invalid
<RX14> OvermindDL1, i'm ashamed that my uni has a really bad OOP teacher
<Groogy> my favorite quote: `Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.`
<RX14> the imperative and functional teachers were super
<RX14> the OO teacher is terrible
<Groogy> OOP theory is also insanley boring
<OvermindDL1> RX14: Heh, seems to be a recurring pattern, most OOP teachers (mostly python and java) are not programmers but are instead math teachers
<OvermindDL1> For whatever sense that makes
<RX14> the coursework is implementing 1 class inside an application
<FromGitter> <ryankshah> @straight-shoota how is this invalid? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5acd28fa7c3a01610dcb999e]
<OvermindDL1> That's... taking advantage of OOP sure... >.>
<RX14> and the whole application is set up so there's exactly one way to write that class
<RX14> so
<RX14> it completely avoids any advantage of OO
<OvermindDL1> ryankshah: You are missing comma's
<OvermindDL1> In the `"values:"` array
<RX14> because the class is entirely non-replacable
<Groogy> Book Object-Oriented Analysis and Design with Applications is the hardest book I've ever had to read... because it's so damned exhausting
<FromGitter> <ryankshah> @OvermindDL1 thanks x_x
<FromGitter> <straight-shoota> @ryankshah missing ',' in line 11 and 12
<RX14> oh and also the application is far far far more complex than it needs to be
<Yxhuvud> also teachers tend to overuse inheritance
<OvermindDL1> RX14: Yeah that's useless. OOP *IS* useful at times, but it's almost always used in the wrong places
<faustinoaq> @girng Check this: https://play.crystal-lang.org/#/r/3uvp
<RX14> it's just annoyed me to no end
<FromGitter> <ryankshah> Sublime didn't throw a syntax violation oh well
<oprypin> girng, this looks like borderline a bug. but here are the lengths you need to go to to fix this up https://play.crystal-lang.org/#/r/3uvr
<OvermindDL1> Like 99% of the time where I see inheritance being used, instead a sum type or composition should be used
<oprypin> faustinoaq, that's simpler, nice :)
<oprypin> but just dont use Hash for this, mkay?
<RX14> OvermindDL1, this OO teacher is definitely a programmer
<oprypin> faustinoaq, no, you know what? that .to_i is a mistake
<RX14> they're just an enterprise programmer
<oprypin> why would you want strings to sometimes slip through
<RX14> born in the depths of enterprise bad programmer hell
<RX14> and raised on design patterns
<FromGitter> <girng> i LIKE to use HASHES
<RX14> @girng no you don't, you just don't realise it yet
<FromGitter> <girng> :(
<RX14> OvermindDL1, pretty much
<oprypin> girng, see ruby
<OvermindDL1> https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition/ is such a perfect train wreck, it is OOP to an extreme for a problem that shouldn't be. ;-)
<RX14> OvermindDL1, we were implementing a board game, and we had to deal with observer pattern and callbacks everywhere
<oprypin> or python, for that matter, though they also wouldn't condone this
<RX14> the application logic was split over all together too many classes
<OvermindDL1> RX14: ...if the observer pattern is used, OOP should *NOT* be used... callbacks, eh, it depends
<FromGitter> <girng> thank you @oprypin and @faustinoaq your playground link worked
<OvermindDL1> girng: personally I'd have used, oh, named tuples there or so
<OvermindDL1> I don't know why but I smile at that name. ^.^
<RX14> OvermindDL1, no like you needed UML diagrams to work out tne entirely unintuitive ordering observers had to be called
<OvermindDL1> Named Tuples...
<OvermindDL1> RX14: Ogod...
<RX14> the observed events are entirely made up
<RX14> and arbitrarily ordered
rohitpaulk has joined #crystal-lang
<FromGitter> <girng> i did named tuples before but i have to DEFINE all the keys. i like hash more because it's not as strict
<RX14> such that the class can only be implemented one way
<OvermindDL1> girng: Strict is Good
<OvermindDL1> RX14: Yeah I see... >.>
<oprypin> girng, use struct, as you've been told
<RX14> oh, and everything has to be an interface with an implementation
<RX14> because OO
<RX14> thats what annoys me the most
<RX14> making EVERY class an interface
<oprypin> girng, yes, namedtuples are annoying if used for the wrong purpose. Hash will be even more annoying if used for the wrong purpose
<OvermindDL1> Why are there both Named Tuples and structs anyway? Why not just a struct with a short tuple-like form like rust has?
<RX14> it's awful
<OvermindDL1> RX14: And fantastic for speed! Yay thousand papercuts
<RX14> OvermindDL1, because structs can be mutable
<RX14> named tuples cannot
<RX14> and like
<OvermindDL1> You can't make a constant struct?
<RX14> structs can have methods
<RX14> structs are just classes without the pointers
<oprypin> OvermindDL1, you can
<FromGitter> <girng> btw, this is not fair at all because: https://play.crystal-lang.org/#/r/3uvu if you look at this error. HOW AM I as the programmer supposed to know that I need to do `e["last_joined_channel_time"].as(Int32)` for a fix? the error says nothing about casting it as an Int32. i am so confused and depressed about this
<oprypin> girng, yes that's pretty bad.
<oprypin> compilers, how do they work?
<OvermindDL1> ...I'm not a crystal program at this time but that error makes sense to me? >.> It could definitely point at a better place though
<FromGitter> <girng> i really appreciate gitter but i feel like if i continue to post errors all the time, you guys will become mad at me
<FromGitter> <girng> i am trying i promise
<oprypin> girng, if you were trying, you'd really follow advice, rather than the hacky fixes we reluctantly give
<oprypin> this is a job for a struct or a class
<FromGitter> <girng> if i use a class or struct there is a new object that gets created each time its called. that makes me scared of memory leak
<FromGitter> <girng> so i use inline namedtutple or hash
<oprypin> girng, struct is exactly the same as namedtuple memory-wise
<FromGitter> <omerxx> Hi, Having a problem I'm bashing my head at - Trying to run a GET request with the HTTP client. When compiling a binary, it runs on the crystallang/crystal container. But on any other (alpine / ubuntu) it just won't. I'm getting a weird "No address found for api.example.com:443 over TCP (Socket::Error)" ⏎ Can't figure what I'm doing wrong. ⏎ Tried adding ca-certificates and even copying the entire ssl dir to
<FromGitter> ... my container. No luck... ⏎ Help anyone? [https://gitter.im/crystal-lang/crystal?at=5acd2b246bbe1d2739d210ce]
<oprypin> girng, Hash is heavier than a class
<oprypin> omerxx, show code
<oprypin> also hopefully you dont specify the hostname as "api.example.com:443"
<FromGitter> <girng> ok i try struct
<FromGitter> <omerxx> @oprypin Just throw it here or can we talk privately without others getting the noise?
<oprypin> omerxx, you go to http://bpaste.net/ and post a link
<FromGitter> <omerxx> And of course not, its a working service (the code works, also compiled) just on other platforms it won't
<FromGitter> <omerxx> @oprypin https://bpaste.net/show/59a503519cc3 ⏎ Thanks!
<faustinoaq> OvermindDL1 I should learn OCalm, would be a nice educational experience :)
<OvermindDL1> You really should. It is one of those languages, like Lisp, that makes you a better coder everywhere else too
<OvermindDL1> But it is fantastic in it's own right, the power of Haskell, sometimes shorter sometimes longer, *much* faster
<OvermindDL1> And it has easily one of the most *beautiful* compiler source codes out
<OvermindDL1> It compiles to near optimized C speed, but it compiles in a fraction of the time, one of the *fastest* optimizing compilers out
<OvermindDL1> And yet still beautiful
<oprypin> hold on... why aren't we all using OCaml right now?
<faustinoaq> OvermindDL1 I know crystal is full OOP (comparison here: https://pragtob.wordpress.com/2018/01/27/slides-where-do-rubyists-go/ ) , but Can I use other paradigms in Crystal? By example using just def and avoid using classes?
<OvermindDL1> It's a good language, but it's still a fringe language
<OvermindDL1> And it's currently only single-core like Crystal currently (though that is about to be fixed in the next Major update in whatever-N years)
<OvermindDL1> faustinoaq: If you can create a globally accessible static function in a language, then you don't need to use the OOP parts of it
<Groogy> Isn't OCaml literally the OOP version of caml?
<oprypin> omerxx, looks good to me. you say on ubuntu it just won't work? wut
<oprypin> tried on another host? tried without tls? what is it exactly that makes it fail?
<OvermindDL1> Groogy: Eh... kind of...
<OvermindDL1> It has 'Objects' yes, but they are not OOP-like objects
<OvermindDL1> They are actually row-typed records
<Groogy> looking on their website it looks pretty similar
<OvermindDL1> So they are both more and less powerful (in different ways) than OOP objects
<Groogy> you have mutables and you have methods attached
<Groogy> you have polymorphism
<OvermindDL1> OCaml has mutable cells regardless, and you can put functions in records
<OvermindDL1> The polymorphism is only single level though
<OvermindDL1> That is one big difference
<Groogy> you have inheritance
<OvermindDL1> And the interfaces are more... hmm, rust-like than OOP
<Groogy> what do you mean only single level?
<OvermindDL1> You cannot easily extend an object
<FromGitter> <omerxx> @oprypin Yeah! As simple as that! Tried multiple platforms. I gotta use 443 because that's how this API works. I run the code on my own machine, and the compiled version, and even the compiled version from "crystallang/crystal" (when that's the platform running), but moving this binary somewhere else just prints this weird problem. ⏎ If I'd get a platform exception it would be understood.. but it aint!!
<Groogy> eh you mean it is just like C++?
<OvermindDL1> It's best not to think of it as an OOP object (because it really is not), and think of it more as HM Row-Typed records
<FromGitter> <omerxx> @oprypin Should I report this on GitHub or something?
<OvermindDL1> No, C++'s OOP is stupidly powerful, if not verbose at times
<OvermindDL1> The prime-bits of OOP aren't even the objects
<Groogy> I mean from what I can see I can pretty much use it as if it was C++ though?
<OvermindDL1> They are almost never used, row-typing is not always useful, only specific occasions
vikaton has joined #crystal-lang
<Groogy> horrible lexically but it's OOP nonetheless
<OvermindDL1> prime-bits of OCaml*
<OvermindDL1> Rather the prime-bits of OCaml is the module system
<Groogy> I mean for being the main addition it's adding to the Caml language
<Groogy> I mean why not simply use Caml? :P
<OvermindDL1> They are missing a lot of features, you *will* notice difference if you try
<OvermindDL1> The OCaml module system
<OvermindDL1> It is the only ML language (that I've come across) that is fully HPT
<OvermindDL1> So it has a First-class, efficient, compile-time, HPT, module system
<Groogy> Ocaml isn't compile-time, it's bytecode and vm?
<OvermindDL1> No
<Groogy> OCaml's toolset includes an interactive top-level interpreter, a bytecode compiler
<OvermindDL1> OCaml has pluggable backends (and front-ends, you can define other language on it if you want) (and middle)
<Groogy> from wiki at least
<OvermindDL1> By default it comes with a bytecode compiler and interpreter, and a machine code compiler
<OvermindDL1> I'm always speaking of the native-code compiler if otherwise unspecified
<OvermindDL1> There are other backends as well, can compile to C (though that's old, I think unmaintained), javascript (2 of those!), and more
<OvermindDL1> You can literally plug in to the OCaml compiler at any point for any reason you want
<OvermindDL1> You can define new languages that use it
<OvermindDL1> Or make new backends
<OvermindDL1> Or new constructs inbetween
<oprypin> omerxx, whether to get help or report it somewhere, you'll need a reproducible example
<oprypin> that runs
<Groogy> also I have no idea what you mean with HPT
<Groogy> they don't mention anything of it on their website either
<FromGitter> <omerxx> @oprypin Of course, the code on GH is reproducible and I manage to do it right now right here..
<Groogy> also one of the first things they talk about in their tutorial seems to be polymorphism and mutating types
<faustinoaq> OvermindDL1, I had the crazy idea of a VM for crystal, after seeing OCalm approach, maybe is not that crazy: https://github.com/charly-lang/charly/issues/168
<Groogy> seems like polymorphism of a type is a big thing in ocaml from what I can read scimming through their documentation
<Groogy> Chaoter 3, objects, chapter 4 labels, chapter 5 polymorphism, chapter 6 advanced examples with classes
<Groogy> that's part 1
<Groogy> "an introduction to ocaml"
<Groogy> part 2 is "the ocaml language"
<FromGitter> <omerxx> Posted it ^
<Groogy> You might say that the focus of the language is not it's OO capabiliteis
<Groogy> but the devs sure seem to put focus on it
<Groogy> capabilities*
<Groogy> also from what I can read on ocamlopt is that it is not 100% supported it seems
rohitpaulk has quit [Ping timeout: 265 seconds]
<OvermindDL1> faustinoaq: Teeeechnically you could make a crystal->OCaml transpiler. ;-)
<Groogy> anyway bed time, night
<OvermindDL1> Sans any asm calls of course
<OvermindDL1> Groogy: ocamlopt is the primary use method now, back in OCaml3 it was not as supported as it was new, but in ocaml4 (like 6 years old now) and newer everything uses ocamlopt
<Groogy> yeah documetnation I am reading is from 5 months ago, and it says specifically there that ocamlopt is not supported on all supported platforms
rohitpaulk has joined #crystal-lang
<FromGitter> <girng> for example this code: https://play.crystal-lang.org/#/r/3uwe gets called everytime a user logs in. is crystal creating a new "NamedTuple" each time, or re-using it just once?
<oprypin> girng, a NamedTuple isn't even a thing to be created, it just starts writing memory on top of the stack
<crystal-gh> [crystal] straight-shoota opened pull request #5937: Add Tempfile.tempname accepting block (master...jm/feature/tempfile-yield) https://git.io/vxbWC
<FromGitter> <girng> ok thank you just checking if memory leak
<oprypin> girng, you probably should stop worrying about performance, especially when your worries are based purely on guessing.
<FromGitter> <girng> @oprypin if you look here: https://www.reddit.com/r/crystal_programming/comments/8ar12s/how_to_get_data_from_a_dbquery_one_into_a_hash_key/ ⏎ ⏎ there is a new `#<DB_Character:0x1921ea0>` that gets created each time the query is called. and it has a different memory address associated to it. that means, it's creating something "NEW" each time. which worries me
<FromGitter> <girng> when it shouldn't be creating more memory address space because i'm just getting a result from db. possible memory leak?
<oprypin> girng, is a Class, so sure
<oprypin> and when you say "memory leak" that's totally not what it means
<FromGitter> <girng> but where does the other class addresses go?
<FromGitter> <girng> i don't use em again
<oprypin> "memory leak" is normally used when memory usage grows unbounded
<oprypin> but you're scared of bounded memory growth
<oprypin> for whatever reason
<oprypin> the class gets deleted then, and the memory can be reused
<FromGitter> <girng> oh, so that is when boehm's gc comes into play?
<FromGitter> <girng> on older classes that are not referenced?
<oprypin> yes
<FromGitter> <girng> okay got it that makes sense then
<oprypin> a few more people like you and maybe one day i will finish https://pryp.in/blog/24/abandoned-post-modern-memory-management-what-are-structs-in-crystal.html -_-
davic has quit [Ping timeout: 256 seconds]
<FromGitter> <girng> that's cool. i think a memory FAQ about how classes work with crystalwould be beneficial
<FromGitter> <girng> since structs are accessed on the stack they aref aster than classes?
<oprypin> structs are slightly faster to create and dispose but they only way to pass them around is copying, which is costly and can greatly outweigh other advantages, depending on the size
<oprypin> they -> the
<FromGitter> <girng> so in my example: https://play.crystal-lang.org/#/r/3uwe if i had my character info in a struct, technically it would be faster to access than the named tuple?
<OvermindDL1> Can't get a reference to a struct that is owned elsewhere?
<FromGitter> <girng> can you create an array of structs?
<oprypin> I think I said previously that namedtuple is the same memory-wise as a struct
<oprypin> struct exposes more language features
rohitpaulk has quit [Ping timeout: 256 seconds]
<oprypin> OvermindDL1, there is no ownership in the language. you can get an unsafe pointer to the struct.
<OvermindDL1> Well unsafe is no fun, the GC should make that safe. ;-)
<oprypin> yeah good luck telling GC to keep alive memory managed by the stack
<FromGitter> <girng> ok i was reading about namedtuple `A named tuple is a fixed-size, immutable, stack-allocated mapping of a fixed set of keys to values.` so it's on the stack
<FromGitter> <girng> but a class is on the heap
<oprypin> but a struct is on the stack
<oprypin> also FYI a Hash is on the heap
<FromGitter> <girng> ohh that's bad
<FromGitter> <girng> i don't want that
<FromGitter> <girng> not for method just to send char info at least
<FromGitter> <girng> i rather use the stack for that
<OvermindDL1> oprypin: Segmented moveable stacks. ;-)
<oprypin> that's called a heap
<RX14> OvermindDL1, pointer in crystal == unsafe
<RX14> we might put in explicit unsafe blocks ala rust
<RX14> but no ownership
<OvermindDL1> Heh, I'm personally a fan of segmented stacks, so few languages use them...
<RX14> just pointers are *always* unsafe
<OvermindDL1> What about making pointers have to be tested first, ala an Option type
<FromGitter> <girng> why would sum1 want to use pointers in crystal when it has a garbage collector built in?
<OvermindDL1> Assuming an active reference can be kept somewhere
<oprypin> Overm..., the pointer could already have a different value at the same address
<oprypin> it's not sound
<FromGitter> <girng> the think i like about hashes is not all ym keys are strict. some keys i don't want to be sent, but sometimes i do want a key to be sent
<FromGitter> <girng> if i do namedtuples... i have to send all those keys and explicit type them in {}'s. not fair
<oprypin> premature optimization at its best
<oprypin> the overhead of json trumps all of this by far
<oprypin> protobuf would solve all problems tho :p
<oprypin> anyway... if you really want to skip some keys, you should arrange it at the protocol level
<FromGitter> <girng> if i want to skip keys, i'm using a damn hash and not specfying them
<oprypin> or, you know, just forget about it until you have something actually working
<oprypin> girng, if i see you using a Hash for this, I swear I'll stop replying to you
<FromGitter> <girng> well in my .send method i use a namedtuple, but some methods return data as a hash and it then i do .to_json on it
<oprypin> don't. use JSON.mapping
<oprypin> i mean don't use Hash, instead use JSON.mapping
<FromGitter> <girng> @oprypin u have to remember im coming from php/js/gdscript. mostly dynamic languages i dun't like messing around with types all the times. although, it feels good when i do but it gets kinda depressing after a while
<FromGitter> <girng> o really? i can use json.mapping instead of a hash?
<oprypin> i went through the brain damage of php myself. got out in time, took only a few years to recover
<FromGitter> <girng> LOL
<oprypin> like, what sane person would ask this question https://stackoverflow.com/q/6571476
<oprypin> my comments on the answers are the best part tho
<FromGitter> <girng> dat karma :D
<FromGitter> <girng> reputation *
bcardiff has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
bcardiff has quit [Client Quit]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
<FromGitter> <straight-shoota> did anyone try my install script for nightly builds? https://gist.github.com/straight-shoota/a2f4b29203936c04c578d6f6a1ad5f9b
<FromGitter> <girng> > You've earned the "Suffrage" badge (Use 30 votes in a day). ⏎ lmaooo
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
qard has joined #crystal-lang
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: Leaving]