ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.23.1 | Fund Crystal's development: | GH: | Docs: | API: | Gitter:
<FromGitter> <Qwerp-Derp> Hello!
hightower3 has joined #crystal-lang
hightower4 has quit [Ping timeout: 258 seconds]
gokmen has joined #crystal-lang
<FromGitter> <imonmyown> Yo!
<FromGitter> <Sija> @jwaldrip feels like days ahead...
cerulean has left #crystal-lang [#crystal-lang]
rohitpaulk has joined #crystal-lang
txdv has quit [Ping timeout: 240 seconds]
Groogy_ has quit [Ping timeout: 240 seconds]
Yxhuvud has quit [Remote host closed the connection]
Groogy_ has joined #crystal-lang
Yxhuvud has joined #crystal-lang
txdv has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
baweaver has quit [Ping timeout: 255 seconds]
tatey has quit [Ping timeout: 240 seconds]
baweaver has joined #crystal-lang
tatey has joined #crystal-lang
baweaver is now known as Guest33209
greenbigfrog has quit [Ping timeout: 255 seconds]
brycek has quit [Ping timeout: 255 seconds]
brycek has joined #crystal-lang
greenbigfrog has joined #crystal-lang
<FromGitter> <jwaldrip> @Sija many days, or few days?
Groogy2 has joined #crystal-lang
Groogy has quit [Ping timeout: 255 seconds]
andrewzah has quit [Ping timeout: 240 seconds]
andrewzah has joined #crystal-lang
jaitaiwan has quit [Ping timeout: 255 seconds]
<FromGitter> <jasonrobot> Hey got a question that's kinda a "best practices" thing:
<FromGitter> <jasonrobot> I'm making a class that can go to/from JSON and DB, and I'm using the .mapping() macros for both of those, but I'm kinda concerned that they're re-defining a bunch of stuff (initialize methods, getters/setters).
jaitaiwan has joined #crystal-lang
<FromGitter> <jasonrobot> Is that just fine? It seems like a bad thing. The code still seems to work, but I dont know if there might be stuff happening that I'm not aware of in all that macro expansion.
<FromGitter> <fridgerator> I use both together, I haven't had any issues
A124 has quit [Ping timeout: 246 seconds]
<FromGitter> <jasonrobot> Nice. I was thinking of writing my own, but hey if they both work.
A124 has joined #crystal-lang
<FromGitter> <jasonrobot> I'm also trying to figure out how to use "crystal tool expand", but can't quite seem to figure out the arguments to it...
jaitaiwan has quit [Ping timeout: 240 seconds]
jaitaiwan has joined #crystal-lang
zacts has joined #crystal-lang
gokmen has quit [Remote host closed the connection]
gokmen has joined #crystal-lang
snsei has joined #crystal-lang
Philpax has quit [Ping timeout: 246 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <faustinoaq> > @faustinoaq, did you try running hackintosh in a VM? ⏎ ⏎ Hi Papierkorb, not yet. I was a bit busy this week, I will try this weekend. ⏎ ⏎ However, I found this ( interesting way to try macos on Linux using vagrant [0] ... []
<FromGitter> <faustinoaq> > who is working on crystalox? ⏎ >> There have been at least three Crystal OS'es ⏎ ⏎ @monouser7dig yeah, just search for OS, maybe using a custom prelude or `--prelude=empty` Crystal would be capable to do more low level stuff, maybe disabling GC and doing some unsafe things 😉 []
<FromGitter> <faustinoaq> Hey community, I will talk tomorrow about Crystal at my University. I hope I can introduce some classmates this awesome language. 😄
<FromGitter> <ekremkaraca> @faustinoaq good luck!
<FromGitter> <ekremkaraca> And good morning guys
<FromGitter> <ekremkaraca> 🌄🌞
<FromGitter> <faustinoaq> @ekremkaraca Thanks you 👍
<FromGitter> <faustinoaq> And good morning too ☀️
gokmen has quit [Quit: bye.]
<FromGitter> <Rinkana> Morning :)
Groogy_ is now known as Groogy
<Groogy> Morning
<FromGitter> <monouser7dig> @jasonrobot `Usage: crystal tool expand [options] [programfile] [--] [arguments]` which you may have already seen yourself so you should be able to give a filename and just by default gets the file with macro substitutions out?
<FromGitter> <jasonrobot> If I just call "crystal tool expand" it just prints the command's help menu though
<FromGitter> <jasonrobot> call -> run, whichever
<FromGitter> <jasonrobot> I've tried piping in through stdin, using all the different args (none of them are to specify an input file either). Its really got me stumped.
<FromGitter> <monouser7dig> `crystal tool expand -c ./Desktop/ ` thought that would work but it does not 😄
snsei has quit [Remote host closed the connection]
<FromGitter> <monouser7dig> just use `crystal build —emit llvm-ir —prelude=empty` and check if the expansion worked 😄
<FromGitter> <faustinoaq> @monouser7dig you should use `crystal tool expand -c `pwd`/ `pwd`/`
<FromGitter> <faustinoaq> ```code paste, see link``` []
sz0 has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
<FromGitter> <monouser7dig> crystal run, build, tool hierarchy, all work with relative filenames 😄 but indeed you are right
<FromGitter> <monouser7dig> actually this does too
<FromGitter> <faustinoaq> Yeah, you can use relative names too, but ensure to repeat filename at the end of command.
<FromGitter> <monouser7dig> Usage: crystal tool expand [options] [programfile] [--] [arguments] ⏎ could be ⏎ Usage: crystal tool expand [options] [programfile with LNR][programmfile] [--] [arguments] ⏎ (why does It need the programmfile twice at all?) []
mark_66 has joined #crystal-lang
Papierkorb_ has joined #crystal-lang
<Papierkorb_> Morning!
<FromGitter> <jasonrobot> agh, and its complaining about "require 'db'" earlier in the file. I was really hoping it would just show the source file after macro expansion.
<FromGitter> <faustinoaq> @monouser7dig Because the second filename will be different, some projects can use different files, you can use a macro in one file and his definition in other.
undy1ng has quit [Quit: Leaving.]
<FromGitter> <faustinoaq> Papierkorb_ == Papierkorb ? 😅
<FromGitter> <monouser7dig> makes totally sense thanks but should we make an attempt to reflect this in the --help? 😄
<FromGitter> <faustinoaq> Yeah, you are right, a detailed guide about using crystal tools would be very useful. also see
<FromGitter> <jasonrobot> I gotta take off, but thanks for the help everyone!
<FromGitter> <faustinoaq> 👍
rohitpaulk has joined #crystal-lang
<Papierkorb_> faustinoaq, yes when @ work
<Papierkorb_> Too lazy to configure the BNC here :P
snsei has joined #crystal-lang
<FromGitter> <monouser7dig> > Yeah, you are right, a detailed guide about using crystal tools would be very useful. also see ⏎ ⏎ useful yeah! ⏎ is the same possible in sublime? I guess not 😟 😄 []
snsei has quit [Ping timeout: 246 seconds]
rohitpaulk has quit [Ping timeout: 255 seconds]
<FromGitter> <faustinoaq> Maybe sublimetext 3 do support this, but sublime package for crystal will need to implement these features. ⏎ ⏎ 😅 Hey Papierkorb, what pattern do you recommend to write a QT program, I mean some of these patterns 👉
<FromGitter> <faustinoaq> I only used two pattern before, MVC for web development, and the Repo pattern for manage DB using Crecto ( ⏎ ⏎ I'm afraid my crystal+qt code will become in spaghetti code 😅
<Papierkorb_> faustinoaq, I don't think that there's a one-size-fits-all pattern for anything. But if you want to see Qt code, have a look at their vast example section. Here's the section on widgets:
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Papierkorb_> faustinoaq, There are two things: 1) Think in objects 2) Think in signal/slot relations. itself doesn't allow you to add Qt signals to your classes, you can use the "cute" shard for that.
<Papierkorb_> faustinoaq, Really, signal/slot is the biggest factor when starting out with Qt. So focus on that part first. It completely reverses the code flow from "I need to have access to X" to "Someone give me X if wanted". You don't pull information, you push information.
<FromGitter> <faustinoaq> Ok, Thanks you Papierkorb! 👍
<Papierkorb_> faustinoaq, Which is a god send for complex applications (With or without Qt) imho. For applications, I'll use the "architecture" I've been using for a while now, simply because it didn't break yet
rohitpaulk has joined #crystal-lang
<Papierkorb_> faustinoaq, just don't smash everything into MVC. You'll create much more issues for yourself than needed without actual gain.
<Papierkorb_> faustinoaq, start small. Build a some small utility programs, like an image viewer or something. After that thing works, take a look again not at your code, but at the structure, and see what you like and don't like about it.
<Papierkorb_> I wasn't able to get around to working on Qt LibEvent integration yet. So doing e.g. networking won't be fun right now
<Papierkorb_> faustinoaq, if you have a certain question w.r.t. structuring a specific (simple-y) application, I'd use it to write a whole sample/ out of it. You won't be the only one wondering :)
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <monouser7dig> is it considered good style to omit the return keyword at the end of a method? seeing this quite a bit and personally just always type it
<FromGitter> <faustinoaq> Papierkorb, thanks you for your advice 😄 Can I use UiLoader class on ?
<FromGitter> <faustinoaq> I'm trying to load some ui files I did on QtDesigner
<Papierkorb_> 1) You're using the Qt4 docs, you want the Qt5 docs! Don't trust Google to choose Qt5 over Qt4. 2) I didn't try adding it yet
<Papierkorb_> monouser7dig, Yes it's good style to omit it, and most consider it bad style to have needless returns
claudiuinberlin has joined #crystal-lang
Guest33209 is now known as baweaver
baweaver has quit [Changing host]
baweaver has joined #crystal-lang
<FromGitter> <faustinoaq> Papierkorb, yeah, you are right, I mean, Also I just realize you put Qt Designer support in the roadmap. How ui files will be used by, something like PyQt ?
<Papierkorb_> ... How does pyqt use them?
<FromGitter> <faustinoaq> I just downloaded the MacOS iso, next step is trying to create a VM 😅 some hacking stuff here 😎
<Papierkorb_> Are you planning on using Mac OS?
<Papierkorb_> I never used a hackintosh VM not because of durr-legal, but really, because I simply don't care about using Mac OS, and thus can't maintain code for it
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <monouser7dig> making GUI wrapper and being more interested in arch than macOS is a funny combination 😄
claudiuinberlin has joined #crystal-lang
<Papierkorb_> ..?
<Papierkorb_> Me wanting to know what my computer is doing doesn't contradict me wanting to have a fully featured graphical UI
<Papierkorb_> I personally think Mac OS UI is awful
<Papierkorb_> And them not being FOSS is a "No Thanks" already
<FromGitter> <monouser7dig> arch is more the CLI + i3 beginning with how it is installed and configured but no offense, arch is also for those that tune it into a nice custom gui, sure ⏎ ⏎ I'd also use arch for some but Broadcom wifi chips are just sigh, *need* some Mac things
<Papierkorb_> KDE all the way on all machines
rohitpaulk has quit [Ping timeout: 240 seconds]
RickHull has quit [Ping timeout: 260 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <monouser7dig> do you have daily crystal builds for arch? thought I've seem sth. like that in the ci?
<Papierkorb_> No idea, I just use the version from the repository
<FromGitter> <monouser7dig> but arch is prob architecture 😄
<Papierkorb_> Why would I want to have nightlies anyway?
<FromGitter> <monouser7dig> you use arch and get updates before changelogs are written 😄
<Papierkorb_> You can do that on .. any os?
<Papierkorb_> No idea what arch has anything to do with it
<FromGitter> <monouser7dig> compare the update rate of arch main repo with ubuntu ..?
<Papierkorb_> huh?
<FromGitter> <monouser7dig> much more frequent
<Papierkorb_> So?
<Papierkorb_> Arch and Ubuntu are vastly different operating systems
<FromGitter> <monouser7dig> ubuntu uses gcc5.x and arch 7.2 e.g.
<Papierkorb_> Them both sharing most of the same kernel doesn't make them equal
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
<Groogy> monouser7dig that's not really it though
<Groogy> the thing with Arch is there isa community that automates getting bleeding edge versions
<Groogy> which if you want a stable environment to work in is really bad
<Groogy> (note I use Arch)
<Groogy> Ubuntus target audience is people who just want a stable OS that always "just works"
<FromGitter> <monouser7dig> what I said 😄
<Groogy> yeah but Arch doesn't give you nightly or bleeding edge by default
<Groogy> you have to use the AUR manually or install a tool that does it for you, like BB
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <monouser7dig> if you install you get latest kernel and gcc just as a major example, that is cutting edge by default
<Papierkorb_> And enable the testing repository
<Papierkorb_> Truth be told, I can count the outages related to archlinux updates on a single hand on all machines I've been using it for years
<Groogy> that's not true monouser7dig
rohitpaulk has quit [Ping timeout: 248 seconds]
<Papierkorb_> My common windows installation was more prone to error
<Groogy> unless you explicitly tell it to get the bleeding edge
<Groogy> my kernel is 4 versions behind
<FromGitter> <monouser7dig> okay may only be the usage of the arch users I know
<Groogy> them saying how it works doesn't nessecairly mean that is how it works
<Groogy> I am 4.10 while the latest one is 4.14 I think
<FromGitter> <monouser7dig> sure
<Groogy> I think the latest one Arch supports right now is 4.13?
<Groogy> i.e unless you do stuff completley manually
<FromGitter> <monouser7dig> last time I installed one using antergos it was 4.13
<Papierkorb_> antegros isn't arch
<Groogy> yeah and latest one is 4.14, the 4.13 package on the repository is only a few days old
<Groogy> my guess is they probably working on packaging 4.14
<Papierkorb_> Groogy: Have you tried the linux-lts package?
<Papierkorb_> Have been thinking about using it for some time
<Groogy> don't know what it is?
<Groogy> or at least it doesn't ring a bell
<FromGitter> <monouser7dig> antergos is as much arch as shards belong to crystal 😄 seems to depend on the view
<Papierkorb_> the official linux long term support package
<FromGitter> <sdogruyol> @monouser7dig agree
<Papierkorb_> No, antegros *is not* arch
<Papierkorb_> It's like saying Ubuntu is Debian
<FromGitter> <monouser7dig> better not do that in front of a Debian user, advice taken
<FromGitter> <sdogruyol> lol
<Groogy> looked quickly up what it is
<Groogy> It doesn't let oyu install Elemental
<Groogy> definetly not Arch :P
<Groogy> or wait no not Elemental....
<Groogy> what was the merger of Papyros and the other one
<FromGitter> <monouser7dig> sorry for the blaspheme 😈
<Groogy> LIRI!
<Groogy> can't wait for them to finish Liri
<Groogy> looks so nice and is natively Wayland
<Groogy> have it installed at home
<FromGitter> <sdogruyol> I'm waiting for the new Firefox Quantum
<FromGitter> <sdogruyol> had enough with Chromium lol
<FromGitter> <monouser7dig> `OS images and packages are now built automatically by a lightweight Golang program.` is this the new hip?
<Groogy> is that the browser done entirely in rust?
<FromGitter> <monouser7dig> only the ending `servo` seems to be pure rust
<FromGitter> <sdogruyol> guess it'd be really hard and time consuming to a full browser in rust after all
<FromGitter> <sdogruyol> servo is pretty good
<Groogy> didn't some indie guy make rust based game?
<FromGitter> <sdogruyol> haven't seen it
<FromGitter> <sdogruyol> why not?
<Groogy> think I heard someone mention that while prophecising how rust was going to change the entire world
<Papierkorb_> FF is more than "just" the rendering engine
<Groogy> there is obviously also the memory absorption engine (•_•) ( •_•)>⌐■-■ (⌐■_■)
<Groogy> a cruical part of its framework
<Papierkorb_> Porting the whole thing will take years of an dedicated effort that they can't make without not updating the browser in the meantime
Papierkorb_ has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> well the only thing that I hate about FF is there's no easy way of using multiple user profiles as in Chrome
<livcd> oh but i read the idea is not to rewrite everything in FF in Rust but incrementally change what makes sense
<FromGitter> <monouser7dig> that is the idea of rust after all 😄
Papierkorb_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <Rinkana> Ooh, liri looks awesome
<FromGitter> <monouser7dig> Groogy how is Liri supposed to handle existing apps like Thunderbird? they seem rather restrictive in making everything qt and wile I am not sure TB is qt based I bet many things are not and thus it might be quite limiting?
<Groogy> It does I know :D
<Groogy> Eh other things will still work
<Groogy> as long as it can work through wayland
<Groogy> wayland has a x server plugin as well I think for apps that rely on x servers
<livcd> well well ...for me the OS needs to go out of my way
<Papierkorb_> Correct. Something thinks it knows better than me? Into the trash it goes.
<FromGitter> <monouser7dig> livcd use i3 ( 😄
<Groogy> I like liri in how minimalistic and sleek the interface seems to be
<livcd> i am happy with OSX/Windows thanks but thanks :)
claudiuinberlin has joined #crystal-lang
<Groogy> hopefully it stays as that
<Groogy> I've never used window managers like that
<FromGitter> <monouser7dig> if you use tmux on Mac you get at least i3 for cli 😄
<livcd> I use tmux on mac yes :)
<livcd> imho the OS of 2017 and beyond is the browser
<FromGitter> <monouser7dig> for consumers sure, for producers???
<Papierkorb_> "Everything in the cloud!" No thanks.
<livcd> well i wonder how long will it take for Apple to merge osx/ios into one
<FromGitter> <ekremkaraca> Hey guys, I have set a new personal record of building Crystal: 13 min 12sec
<FromGitter> <monouser7dig> if it is not about bigdata in a blockchain hostel by KI in the docker cloud, I'm out 😄
<FromGitter> <ekremkaraca> It was 14 min on my previous trial
<FromGitter> <monouser7dig> crystal compiler or personal project?
<FromGitter> <ekremkaraca> Building Crystal
<FromGitter> <ekremkaraca> Installing by building
<Papierkorb_> Takes less than 5 minutes on my machine
<FromGitter> <ekremkaraca> What do I need to reduce the time
<Papierkorb_> Your machine specs?
<Papierkorb_> With or without full test run?
<FromGitter> <ekremkaraca> 6GB ram
<FromGitter> <ekremkaraca> I suppose full run
<Papierkorb_> That are not the full specs, but 6GiB is not much at all
<livcd> it's interesting how far people are willing to go -> Electron
<FromGitter> <ekremkaraca> Intel i5 core
<Papierkorb_> There are many i5's
<FromGitter> <monouser7dig> crystal takes 1,6gb on my side compiling, cpu quad core or dual will make a difference
<FromGitter> <ekremkaraca> I have older one
<FromGitter> <ekremkaraca> Cpu quad
<Papierkorb_> Invest in RAM. Upgrade to 16GiB and you'll never have any issues with memory anymore (citation needed)
<livcd> unfortunately people build very shitty apps..even the large tech corps are building for "best case scenario"
<FromGitter> <ekremkaraca> I did it with brew
<FromGitter> <monouser7dig> some think they are quad although they are just hyperthread? 😄
<FromGitter> <ekremkaraca> Or Linuxbrew
<livcd> everyone assumes you have the most performant phone / pc and a reasonable internet speed
<Papierkorb_> livcd: Yes and now their crap code doesn't only run on their servers and waste CPU on the consumers devices, but their crap server AND awful UI code runs on my machine. What a time to be alive.
<FromGitter> <ekremkaraca> I want but my family don't :(
<FromGitter> <ekremkaraca> Maybe after army
<livcd> Papierkorb_: sadly
<livcd> it sucks
<livcd> especially if you travel a lot
<Papierkorb_> livcd: It makes me sick when I think how much real-world resources are wasted world-wide because of awful code.
<livcd> i do not care about any of this when I am in Korea with unlimited lte plan
<FromGitter> <sdogruyol> @ekremkaraca good luck
<livcd> but...
<livcd> I guess it's really expensive and requires too much effort to build a proper app that behaves nice even when you are offline / on slow connection
<FromGitter> <monouser7dig> used linuxbrew on pi a bit and was not really bad, the only issue is getting precompiled bottles cause for whatever reason their default install path has the result that you can not use their bottles
<livcd> it's an impossible task like building a reasonably good crossplatform UI kit (or at least reasonably good on OSX/Windows)
<livcd> no wonder electron is that popular
<livcd> sigh
<Papierkorb_> Qt has been around for ages
<Papierkorb_> And is "reasonably good crossplatform" way beyond those two
snsei has joined #crystal-lang
<FromGitter> <ekremkaraca> At least I should make some pressure on my family to buy Mac mini
<livcd> eh most qt applications make me to vomit
<FromGitter> <ekremkaraca> It's harder to find here
<FromGitter> <ekremkaraca> Here I mean, 🇹🇷
<FromGitter> <ekremkaraca> Except Apple store 💲
<FromGitter> <monouser7dig> 8m27s 2,5gb ram usage on a dual core i7, using brew ⏎ if speed is a concern why would you buy a Mac
<FromGitter> <ekremkaraca> It seems that it's about processor
<Papierkorb_> livcd: KDE applications look fine to me
<Papierkorb_> ekremkaraca, if you like the Mac OS and everything about mac, buy a mac. If you're looking for the best bang for the buck, don't buy a mac.
snsei has quit [Ping timeout: 246 seconds]
<livcd> Papierkorb_: they always looked out of place to me
<FromGitter> <ekremkaraca> I should at least get an 87
<livcd> I cant actually name a single QT app that I like or liked to use
<FromGitter> <ekremkaraca> Not 87, i7
<FromGitter> <ekremkaraca> Apologize guys :(
<livcd> Papierkorb_: but i just checked built with QT and the "hiri" mail app looks nice
<Papierkorb_> ekremkaraca, nothing much to do with i5 or i7 by itself. My computer at home has a i5, and is still faster than most mac's you can buy. With Mac, you buy into the experience, you don't "just" by a computer
rohitpaulk has joined #crystal-lang
<FromGitter> <ekremkaraca> Thanks
<FromGitter> <monouser7dig> sitting with a friend wo uses arch, Lenovo dual core i5 and me 13inch mb he always has < 1 load average when idling, I always 1,6 when idle 😄
<Papierkorb_> ekremkaraca, those tiny mac mini and notebooks don't have the capabilities to cool a good processor under full load without the processor running slower. It's a physical restriction. If you want raw power, buy a tower computer.
<FromGitter> <ekremkaraca> Thanks Papierkorb_
<FromGitter> <ekremkaraca> Ah mentioning :(
<Groogy> livcd I kind of like Qt Creator
<Groogy> it's decent enough
<Groogy> though I might switch out for VS Code at work soon
<FromGitter> <sdogruyol> 8m27s to compile Crystal?
<livcd> ok hiri looks nice
<FromGitter> <monouser7dig> yes
<livcd> i wonder if it's all just QT
<FromGitter> <sdogruyol> here I'm complaining of a mere 20 seconds..
<FromGitter> <monouser7dig> the crystal compiler
<Papierkorb_> sdogruyol, with --release?
<FromGitter> <monouser7dig> you either have threadripper or talk about a different project 😄
<FromGitter> <sdogruyol> ah hell no
<FromGitter> <sdogruyol> I won't do --release ever :D
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <sdogruyol> on the compiler :D
<livcd> I hope Crystal will be one day a good alternative to Go :-)
<FromGitter> <monouser7dig> lol
<FromGitter> <sdogruyol> let me check though
<Groogy> already better if you ask me <_<
<Papierkorb_> ^
<FromGitter> <sdogruyol> ^
<FromGitter> <sdogruyol> However it needs more adoption and a 1.0 label
<Papierkorb_> ^
<livcd> well I need windows support
<livcd> so for me it's not there yet
<Papierkorb_> wasn't there this "bash on windows" (sic!) thing?
<FromGitter> <sdogruyol> nope that won't cut it
<Papierkorb_> Most awful name in existence. Can't expect better from MS
<FromGitter> <sdogruyol> bash - windows
<FromGitter> <sdogruyol> that'd better :P
<Papierkorb_> Not for the end-user, but for dev'ing?
<FromGitter> <sdogruyol> just kidding
<livcd> i do not think that's the name of it
<FromGitter> <sdogruyol> Why do you guys compile the compiler in release anyway?
<Papierkorb_> Because it makes me compile with it faster?
<Groogy> Yeah it works
<Groogy> Though it is Windows 10 only which is bit of a problem
<livcd> i think the official thing is Windows Subsystem for Linux
<FromGitter> <sdogruyol> do you use the master branch to compile your Crystal programs all the time?
<Groogy> Linux Subsystem for Windows
<Groogy> :P
<Papierkorb_> sdogruyol, no, never
<Groogy> also it is super simple to setup
<FromGitter> <sdogruyol> then I don't get the reason why you'd do that :P
<Papierkorb_> Groogy: do you still need to be part of that insider program?
claudiuinberlin has joined #crystal-lang
<Groogy> no don't think so
<livcd> go|dfish: windows subsystem for linux :P
<crystal-gh> [crystal] straight-shoota opened pull request #5084: Add custom time formats (
<Groogy> don't remember doing anything like that, though my account might already be hooked up
<livcd> well in any way windows support and parity of features is a must for me
<livcd> to consider Crystal an alternative to GO
<FromGitter> <monouser7dig> I've even seen people running gui through wsl, works without insider program for sure
<Groogy> What do you use Go for?
<livcd> everything :D
<Groogy> what is everything?
<Groogy> i.e what live project do you have running Go?
<FromGitter> <monouser7dig> generics 😄
<FromGitter> <sdogruyol> `make clean crystal release=true 405.74s user 4.97s system 99% cpu 6:52.88 total`
<livcd> ETL, microservices, gui apps on windows (using lxn/walk) etc
<FromGitter> <sdogruyol> ~7 mins not bad
<Groogy> cool
<Papierkorb_> sdogruyol, in any case, 20s for the whole working compiler? And people complain about "those absurd compilation times"?
<livcd> also deploying to Kiosks that mostly run Windows
<FromGitter> <monouser7dig> Kiosks?
<Papierkorb_> Just linking a C compiler would probably take longer
<FromGitter> <sdogruyol> the weird thing is that a simple kemal app takes longer to compiler @Papierkorb
<livcd> yes kiosks
<FromGitter> <sdogruyol> in release mode though
<Papierkorb_> sdogruyol, I noticed that requiring HTTP::Client always dramatically increased build times for me
<FromGitter> <sdogruyol> requiring "http" of any kind
<FromGitter> <sdogruyol> not sure why though
<livcd> never used a kiosk in mcdonalds or on the airport ? :-)
<FromGitter> <sdogruyol> `time crystal build --release src/ ⏎ crystal build --release src/ 34.42s user 0.52s system 100% cpu 34.762 total ⏎ `
<Papierkorb_> livcd: Only that self checkout PoS kiosk at the market. Boy that thing is infuriating. The button "I want to use my own bag" has to be hammered about 100 times, but the other button (and all subsequent interactions) react immediately. What a coincidence.
<FromGitter> <sdogruyol> 1) 42 to compile a barebones kemal app in release mode
<livcd> Papierkorb_: yeah a lot of kiosks are crap
<livcd> but some are good
<Groogy> I know there's a specific file that Clang++ takes like 30 minutes to compile or something if we don't turn off optimizations for that file
<Groogy> Clang likes to optimize
<FromGitter> <sdogruyol> coming from Ruby, It feels like eternity (the compile times)
<FromGitter> <sdogruyol> I can't even imagine using clang lol
<livcd> Papierkorb_: but as i said building a performant and pleasant UI anywhere is apparently a hard task
<livcd> just look at the most infotainments
<livcd> or whatever
<Papierkorb_> livcd: The joke is that only that button takes ages to work. The other button "yeah take my money for another bag" works immediately, just like everything else there.
<livcd> Papierkorb_: strange
<FromGitter> <monouser7dig> coming from ruby one can't even imagine compiling I guess 😄 ⏎ maybe just some strange people write gui because others think they are to knowledgeable to do that but better would
<FromGitter> <monouser7dig> (mind the `some`) please
<Papierkorb_> livcd: Do those advertisment displays at places like the doctor also count as kiosks? If so, they just seem to be 1) horribly underpowered 2) horribly badly progrmmed 3) or both. Laggy slideshow :(
<FromGitter> <sdogruyol> enough about flaming compile times :P
<FromGitter> <sdogruyol> I still remember Rust pre-1.0
<livcd> Papierkorb_: not sure what do you mean but i guess so
<FromGitter> <sdogruyol> taking ages to compile and it's way slower than Crystal at the same stage
<Groogy> I find Crystal being fast enough, though I have noticed Ego taking like a second to compile now which worries me, since there isn't much stuff there yet
<Groogy> though also that is in debug
<livcd> but they are a good example of badly designed user applications
<FromGitter> <krypton97> Does Crystal compile to a standalone binary app without linked files on both mac/linux?
<FromGitter> <monouser7dig> Papierkorb, always think the same when using one of those, like a dead cheap pi could power tens of them
<livcd> 1) if it's slow when it just displays data in a nice way then...really ? wtf is wrong with you people
<livcd> 2) but lots of kiosks do validations when they query remote services
<Papierkorb_> ^
<livcd> so if the network at the airport / mall is slow etc then the user has to suffer
<livcd> but...
<Papierkorb_> livcd: Yeah, my dentist has one of those displays where they have an ad for their services, and show stuff like the weather and "news" from some tabloids. Lags like nothing's ever lagged before. It's basically an overkill power point slideshow?
<FromGitter> <monouser7dig> but they do not need to stream a Netflix show, just get some train arrival bits most of the time ⏎ ⏎ including all deps is still a bit to do I think you can use otool or similar to check @krypton97
<livcd> well you underestimate how "overengineered" these systems are
<livcd> you scan your passport at the kiosk and it goes through so many validations that you want to kill someone
<FromGitter> <monouser7dig> @krypton97 look for sth. like this but I think it will be a dusty road
<FromGitter> <krypton97> I took a look on a linux cr app and it had no deps like rust, just a bin app, but it was a simple print.. I know there's also musl that's a replacement for glibc, but not that fast
<Papierkorb_> The current compiler can link statically
<FromGitter> <krypton97> Even with c bindings?
<Papierkorb_> if you provide the necessary static libs, that has always worked
<FromGitter> <krypton97> I'll take a deeper look when I get home. With go, everything seems to be standalone which makes it very easy to distribute the app
<livcd> so hit me up when Crystal on Windows is ready :D
<FromGitter> <krypton97> Can't say the same with rust, there's a bunch of files damn
<Papierkorb_> krypton97, with Go, it's the same: If you link to shared libs, you'll need to distribute those
<FromGitter> <krypton97> Great!
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
snsei has joined #crystal-lang
ShalokShalom_ has joined #crystal-lang
snsei has quit [Ping timeout: 264 seconds]
ShalokShalom has quit [Ping timeout: 240 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <monouser7dig> @Groogy, I'm looking through some code, can you tell me what ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ what the {{}} are doing in here? []
<FromGitter> <monouser7dig> oh nvm ⏎ totally missed the macro
claudiuinberlin has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <monouser7dig> could you replace sth. like ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I mean I do not intend to bother you if you do not want, but maybe one of us learns something (may as well be me) []
kp666[m] has joined #crystal-lang
<Papierkorb_> `node.value =`
<FromGitter> <monouser7dig> yes ⏎ ⏎ and maybe ? ⏎ ⏎ ```code paste, see link``` ... []
<Papierkorb_> Don't use StaticArray.
<FromGitter> <monouser7dig> just cause it was like this before, and it is only small, don't you think it is faster?
<Papierkorb_> No.
<Papierkorb_> I repeat: Don't use StaticArray.
<FromGitter> <zyriuse75> do you know if there is a way who i can check the OS ?
<Papierkorb_> Its behaviour is *not* that of Array.
<FromGitter> <monouser7dig> cause?
<FromGitter> <zyriuse75> i mean if the script run on (centos or debian or even mac )
<Papierkorb_> monouser7dig, Cause you didn't read the docs nor source.
<Papierkorb_> Using StaticArray just because is equivalent to using struct's just because. Don't.
<FromGitter> <monouser7dig> it's stack what else?
<FromGitter> <monouser7dig> there is actually a ton of static array in there but...
<FromGitter> <monouser7dig> passed by value instead of reference probably if you say like struct
<FromGitter> <zyriuse75> no one have an idea about how i can check the os with crystal ?
<RX14> @zyriuse75 well you can use flag? to get the platform in macros
<Papierkorb_> At compile time ^
<RX14> what do you specifically need the OS for?
<FromGitter> <zyriuse75> i need to check if the script turn on debian or centos
<FromGitter> <zyriuse75> or others os
<RX14> oh ok then flags dont help at all
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14> debian isn't an OS to me, it's a distribution
claudiuinberlin has joined #crystal-lang
<RX14> i'd have told you how to find out if it was on linux, osx or freebsd, etc
<FromGitter> <zyriuse75> its true sorry distribution :)
<RX14> you need something like the lsb_release command to find which distro you're on
<RX14> so just shell out to a couple of those
<Papierkorb_> Debian is an Operating System which is a Distribution of the Linux kernel and the GNU user space
<Papierkorb_> zyriuse75, else read `/etc/lsb-release`. Doesn't have to exist though
<RX14> Papierkorb_, yeah sure but when most people say "check the OS" they mean the kernel
<FromGitter> <monouser7dig> 😄 so still curious what is wrong with the stack papierkorb?
<Groogy> on the StaticArray, most methods of Static array also creates normal arrays
<Groogy> and it is going to screw with your types a lot
<Groogy> just FYI
<Papierkorb_> If it does exist, it's the easiest way to check which exact OS you're running on. Another linux specific thing could be using uname(2) to read the kernel version and name. Not that great though
<Groogy> There's nothing wrong with Static Array or the stack, whats wrong is most likely your reason for using it
<Papierkorb_> ^
<Papierkorb_> And not knowing about all the implications.
<RX14> @monouser7dig because it will perform just the same and act 10x weirder
<FromGitter> <monouser7dig> so you mean static is not faster because it is even slower because it creates a normal array, what do you mean by `screw with the types`?
<Groogy> no I mean
<Groogy> if you do { |val| do_stuff(val) }
<Groogy> what type do you think it produces?
<FromGitter> <monouser7dig> if I have Array(int32) I expect the same back
<Groogy> yeah but static array is not an Array(Int32)
<Groogy> it is a StaticArray(Int32)
<FromGitter> <monouser7dig> yes meant to say that
<Groogy> so yet again what type do you think the map method will produce?
<FromGitter> <monouser7dig> so I expect a StaticArray(Int32) back
<Groogy> because it isn't a StaticArray
<Groogy> what if you do next in the block?
<Groogy> and skip an element
<Groogy> what size would the StaticArray be?
<FromGitter> <monouser7dig> less
<Groogy> if it would create a static array instead
<Groogy> but how would it now it sohuld be less at compile time?
<Groogy> that is a decision made on runtime?
<FromGitter> <monouser7dig> > **<Groogy>** if it would create a static array instead?
<Groogy> Yes but the reason it isn't creating a static array is most probably because of this
<Groogy> because when invoking #map, or any similar method
<Groogy> it can't know the size
<RX14> simply because you can't change the array size means you can't do nice things with it
<FromGitter> <monouser7dig> so does it give back a normal Array(int32) because it otherwise could not cope with the size changes
<Groogy> so you'll get an array instead
<RX14> @monouser7dig being on the stack doesn't inherently make things faster
<FromGitter> <monouser7dig> yes
<RX14> you're trying to use staticarray because you think it'll make your code faster
<Groogy> it won't
<FromGitter> <monouser7dig> so why do you use it nevertheless? 😄
<Papierkorb_> This just in: The Stack is also in memory, just next to the heap
<RX14> if you bastdardized staticarray into working, it STILL wouldn't make a difference to your code
<Papierkorb_> "you"? You tell us
<Groogy> because copy by value does have certain behaviours that might be desirable
<RX14> you make things MUCH harder for NO gain
<Groogy> I use static array in my Matrix and Vector classes
<Groogy> because it gives me the behaviour I want
<FromGitter> <monouser7dig> allright
<RX14> @monouser7dig because we know the situations when it is faster
<RX14> 99% of staticarray use is for an IO buffer for read
<RX14> like thats pretty much all they're practically used for
<FromGitter> <monouser7dig> why is it faster in that case?
<Groogy> you can get performance boost for memory locality, but you get that on Stack or Heap non the less
<RX14> because is much slower than creating a staticarray
<Papierkorb_> And that already touches the more dangerous things about an static array
<Groogy> and with how Crystal is built you can't really optimize for that
<RX14> once you have one the performance difference is minimal
<RX14> you're unlikely to be creating and destroying arrays at a very high rate
<FromGitter> <monouser7dig> yeah sure
<FromGitter> <monouser7dig> thanks
<Groogy> if your objects have a very low lifetime at a point where it is a performance bottleneck then something is definetly wrong
<FromGitter> <monouser7dig> I made a benchmark using Int32 static_a, array, array(size) and malloc, will take a short look
<Groogy> Also keep in mind you can very easily blow the stack
<Groogy> which we've done a bunch of times with Alloca constructs
<FromGitter> <monouser7dig> like how easily? alloca?
<Groogy> As in someone did something wrong once and it would cause the AI to allocate the entire stack in a loop if it looped enough amount of times
<Groogy> alloca is a construct that allows you to dynamically allocate memory on the stack by moving the pointer where oyu are in memory on the stack
<FromGitter> <monouser7dig> ```code paste, see link``` ⏎ ⏎ on 100_000 int32 e.g. []
<Groogy> it is also told by like everyone to not use because you break everything so damned easily
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<Papierkorb_> Please don't use malloc.
<FromGitter> <monouser7dig> yeah
<FromGitter> <monouser7dig> did not want to/ not intend to use it in reality, but wanted to know the speed difference
<Groogy> also without code that says nothing
<Groogy> I am guessing dynamic array is just adding elements one by one?
<Groogy> while normal array is, count)?
<FromGitter> <monouser7dig> always just adding 1...10000 into the respective place
<Groogy> but let's say you have a static array on the stack, with 10k doubles
<Groogy> a weight value for each agent in a simulated strategy game,
<Groogy> setting the static size to 10k wouldn't be that weird
<Groogy> that's already almost 100kb :/
<RX14> well we do have 8MB stacks
<RX14> by default
<RX14> well actually fibers are always 8MiB
<FromGitter> <monouser7dig> yes I remember and 4kb for fibers because they reduce it in the beginning somehow I guess
<Papierkorb_> Copying 100KiB sounds like a great way to disrupt performance. Just by passing it around. Neat
<FromGitter> <monouser7dig> 4mb*
<RX14> no, 8mb max size for fibers
<RX14> 4kb starting size
<RX14> default stack size is controlled by the OS
<Groogy> Papierkorb well luckily we don't have alloca in Crystal
<Papierkorb_> Thanks linux for allocation-on-demand
<Groogy> same thing would have used alloca in our ai code
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Groogy> and we've gotten so many bad to track crashes thanks to it
claudiuinberlin has joined #crystal-lang
<RX14> well staticarray *is* alloca
<Groogy> no alloca let's you at runtime decide what to allocate
<RX14> oh yeah nvm,
<Groogy> static array needs the number at compile time
<Groogy> and that is why I've been campaigning so hard against it
<Groogy> since people started using it at the company as the silver bullet
<Papierkorb_> LLVM's intrinsic is called alloca, which may take a run-time size
<FromGitter> <monouser7dig> if you do pointerof and get a decent array you can have some sort of alloca
<Papierkorb_> 1) No 2) Please don't
claudiuinberlin has quit [Client Quit]
<Groogy> and when you pointed out "we've had so many problems with this" people forget they broke everything yesterday and you just have to scream at them "I JUST FIXED THE MESS YOU MADE"
<FromGitter> <monouser7dig> heard people do that in java to trick garbage collection
<Groogy> the second you put in "trick" that's where something is wrong
<Groogy> if the GC is a problem for you, then you just have to learn how to not trigger it
<Groogy> when it is critical
<Papierkorb_> Writing programs isn't speedrunning. They have tricks. We don't.
claudiuinberlin has joined #crystal-lang
<Groogy> Heap allocation -> Slow -> too many small allocations will most likely tirgger GC -> Find more optimal ways to do these things
<RX14> Groogy, well in java they dont really have an option lol
<Groogy> have only played around in Java so can't say about more high end problems you might end up there
<Papierkorb_> I always heard "Tune the GC"
<Groogy> I just know I hated every second of it because of its design. I don't know why theres just something soul sucking about it
<FromGitter> <monouser7dig> in crystal you can really disable and enable and trigger gc right?
<Papierkorb_> Groogy: Java is just awful.
<Groogy> Yeah but if you need to, don't
<FromGitter> <monouser7dig> 😄
<Groogy> I would like a nice callback to be able to track when the GC is triggered and what it collected
<RX14> i don't mind java
snsei has joined #crystal-lang
<Groogy> so Ican make a tool to debug when I am missusing my objects
<RX14> well java 8
<RX14> its usable
<RX14> its got good tooling
<FromGitter> <sdogruyol> lol
<RX14> but i wouldn't enjoy it
<FromGitter> <sdogruyol> "usable"
<Groogy> only thing I did in Java was metaprogramming by cracking how the JVM worked
<Groogy> but I did that because it was fun
<FromGitter> <sdogruyol> it's like the ten bazillion pounds of 25-year heavy optimizations
<FromGitter> <sdogruyol> calling it just "usable" is a bit understatement :D
<Groogy> I saw JRuby and wondered how they got things to work, talked bunch with people working on it and then expirmented to see how it worked
<RX14> well let me qualify that
<Papierkorb_> sdogruyol, the JVM. Java as language is horrible.
<RX14> java is usable until you start using other people's libraries
<Groogy> oh yeah the JVM is actually quite fun to play with
<FromGitter> <sdogruyol> when someone says Java I always think of JVM
<RX14> well the old ones
<FromGitter> <sdogruyol> and for the last 5 years, Java is more innovative than Ruby
<RX14> the commons helpers are OK since they're just simple libraries
<FromGitter> <sdogruyol> look at Java 8 and Java 9
<RX14> all the frameworks and stuff are horribly overengineered
<Papierkorb_> Just after C++ lul
<FromGitter> <sdogruyol> @RX14 yeah
<Groogy> also does this sound super stupid or would that be fine to add or even possible? Debugging hooks to the debugger?
<FromGitter> <sdogruyol> I strongly agree with that
<Groogy> so you could memory profile usage etc.
<FromGitter> <sdogruyol> They tend to have a high preference of overengineering
<RX14> if i had a company i'd probably use a JVM lang
<FromGitter> <sdogruyol> I never understand why though
<RX14> probably kotlin tbh
<Papierkorb_> Groogy: Check out if boehmgc has a hook for that. Maybe it's just not exposed
<FromGitter> <sdogruyol> same here
<Groogy> yeah I'll do that in the weekend, if I find it I'll make a pull request
<Papierkorb_> Groogy: Though there's `GC.stats` if you just want to know how your program is doing on a 100km above view
<Groogy> yeah true
rohitpaulk has quit [Ping timeout: 240 seconds]
<RX14> you learn a lot of JVM internals from MC modding since everything is a hack
snsei has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <sdogruyol> I'd really like to have built-in toolchain for profiling crystal programs
<FromGitter> <sdogruyol> something like go pprof
<FromGitter> <sdogruyol> makes it dead simple..
<RX14> i think C tools are fine
<Groogy> gprof can profile crystal I think?
<RX14> well
<FromGitter> <sdogruyol> @RX14 it's not so user-friendly..
<RX14> perf and callgrind work just fine in crystal
<RX14> kcachecgrind is fine
<FromGitter> <sdogruyol> crystal tool profile
<RX14> and there's instruments on osx
<RX14> and there's that new profiling GUI for linux
<RX14> which uses perf
<RX14> and makes it user friendly
<FromGitter> <sdogruyol> I dn't know
<RX14> what's really missing is a generic bdwgc profiler
<FromGitter> <sdogruyol> I just think that we have to make it easy to use
<RX14> it is easy to use
<FromGitter> <sdogruyol> no
<RX14> compile with --debug
<RX14> install hotspot
<RX14> open the program inside hotspot
<FromGitter> <sdogruyol> I mean saying "use X" is not enough
<Groogy> Yeah no Papierkorb, the #stats aren't enough, I would like type of what it collected if that information can be hooked in somehow
<RX14> it's THAT easy
<Groogy> dang it I was supposed to start on the GUI this weekend
<RX14> @sdogruyol why not?
<RX14> it's like a few lines of instructions
<FromGitter> <sdogruyol> it prevents us from having a standard metric / tool for profiling Crystla programs
<RX14> why do we want one?
<FromGitter> <sdogruyol> I mean there won't be any ubiquitous results..
<RX14> when all the profiling tools are platform-specific?
<FromGitter> <sdogruyol> why not?
<RX14> the performance is platform specific lol
<Groogy> I am kind of on RX14 side here, better to just hitchhike on tools that get a lot more support
<Groogy> even though a native Crystal profiler would be sweet
<RX14> crystal build --debug <file>; perf record --call-graph dwarf <executable>; hotspot
<RX14> it's so simple
<FromGitter> <sdogruyol> no
<RX14> a memory profiler would be much more useful
<Groogy> ^
<FromGitter> <sdogruyol> you just assume that it's simple because you're so accustomed to it (maybe)
<RX14> have you tried?
<RX14> profiling is so rare
<Papierkorb_> Writing a profiler is no small feat
<FromGitter> <sdogruyol> anyway my idea is to make it more reachable and built-in
<RX14> it's very rare to need profiling
<RX14> 3 commands is already great compared to most languages
<FromGitter> <sdogruyol> not just building form scratch..
<Groogy> RX14 I profile pretty much every sprint :P
<FromGitter> <sdogruyol> same here
<RX14> yeah but in crystal Groogy
<Groogy> oh yeah no I haven't had the need here yet
<FromGitter> <sdogruyol> I don't understand "profiling is very rare" :P
<RX14> it depends a lot on the usecase
<Groogy> though I don't have live projects like sdogruyol
<RX14> for a webapp you're unlikely to find profiling useful
<RX14> well not that kind of profiling
<FromGitter> <sdogruyol> let be a bit more specific
<FromGitter> <sdogruyol> let me be *
<Groogy> this is the GC that crystal uses right?
<RX14> yes Groogy
<RX14> it works really well actually
<FromGitter> <sdogruyol> ```code paste, see link``` []
<Groogy> actually to collect more detailed info on garbage colleciton, I would just need to be able to hook in stuff here right?
<FromGitter> <sdogruyol> @RX14
<RX14> Groogy, you could also create something generic by hooking into GC_* calls and write an external profiler
<RX14> which works on any binary
<FromGitter> <monouser7dig> ( maybe with proper indentation )
<RX14> using something similar to how ltrace does it
<Groogy> hmmm
rohitpaulk has quit [Ping timeout: 260 seconds]
<RX14> i think the hard pert is interpreting it Groogy
<Groogy> Well what I want is the types
<RX14> you can write multiple frontends for collecting the data
<RX14> ok yeah thats a god point
<Groogy> the data is useless without like type of object allocated and deallocated and at what time
<RX14> yeah i forgot about that
<Groogy> also need to think about it, could be a nice thing to add to the standard library but needs to be done right and not leave it open to mess with the GC for unsafe operations
<Groogy> like fucking up the finalize methods of every single class or something
<RX14> lol
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sz0 has quit [Quit: Connection closed for inactivity]
<Groogy> could be nice for users to be able to see "Huh I am doing __tons__ of tmp array allocations it looks like...."
<FromGitter> <sdogruyol> ^
<Groogy> hmmmm so.... seems to be bunch of things that uses malloc alone without providing a type :/ like strings it seem
<Groogy> huh I can't find where objects allocate memory ???
<Groogy> guessing new isn't defined anywhere? :/
Papierkorb_ has quit [Quit: Konversation terminated!]
<FromGitter> <sdogruyol> has anyone seen October yet?
<FromGitter> <sdogruyol> We're above Scala
<FromGitter> <sdogruyol> lol
<Groogy> we're above rust as well
<FromGitter> <sdogruyol> oh boy
<FromGitter> <monouser7dig> and above kotlin, seems like a weird thing 😄
<FromGitter> <fridgerator> isn't that based around web searches?
claudiuinberlin has joined #crystal-lang
<FromGitter> <monouser7dig> Seems part of it
<FromGitter> <monouser7dig> it's like every student googles java and people who do real cpp don't ask stack overflow
<FromGitter> <fridgerator> lol
claudiuinberlin has quit [Client Quit]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
claudiuinberlin has joined #crystal-lang
snsei has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
claudiuinberlin has joined #crystal-lang
<RX14> please ignore the tiobe stuff
<RX14> it's pointless to look at because it's simply wrong by inspection
<RX14> Groogy, there's a `def self.allocate` for each object
<RX14> which calls malloc
<RX14> basically, for each def initialize, there is defined a def with the body `instance = self.allocate; add_finalizer(instance); instance.initialize(*args)`
<RX14> Groogy, you can inspect the type ID from the object header with just a pointer
<RX14> which is also another possibly easyer way to do iot
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
RickHull has joined #crystal-lang
<crystal-gh> [crystal] RX14 pushed 1 new commit to master:
<crystal-gh> crystal/master f0d609c Sijawusz Pur Rahnama: Document ASTNode#symbolize (#5081)
<FromGitter> <georgeu2000> Is there a Crystal linter for Sublime Text?
mark_66 has quit [Remote host closed the connection]
<FromGitter> <fridgerator> "Crystal" plugin for sublime text warns of syntax errors, and runs crystal format on every file save
<Papierkorb> Sublime Text was a native application, right?
<FromGitter> <fridgerator> written in C++ I believe
<FromGitter> <fridgerator> so, yes
<Papierkorb> Not FOSS, but maybe I'll have to try it too.
<FromGitter> <fridgerator> you can use it for free, you just a dialog every x file saves
<Papierkorb> Atom is wrecking my work laptop. No idea why, it's not that bad on my (older) private laptop. But enough is enough.
<Papierkorb> Yeah I know it's WinRAR free
<FromGitter> <fridgerator> yeah
<Papierkorb> VS Code is at least open source
<RX14> Papierkorb, use emacs :)
<Papierkorb> Would have to completely change the keybindings
<Papierkorb> Then, maybe yes
claudiuinberlin has quit [Quit: Textual IRC Client:]
<Papierkorb> Stuff like Ctrl+S and friends. I'm interested in a fully featured text editor, not an ideology
<RX14> well emacs and vim certainly have a quite different interface to modern applications
<RX14> emacs is a lot closer though
snsei has quit [Remote host closed the connection]
<FromGitter> <faultyserver> Sublime is rwitten in Python
<FromGitter> <faultyserver> but yeah, it's all native
<Papierkorb> Too bad Kate isn't up to standards. It served me well for the first years
snsei has joined #crystal-lang
<FromGitter> <georgeu2000> @fridgerator - Thanks
<FromGitter> <georgeu2000> I'll give it a try.
<travis-ci> crystal-lang/crystal#f0d609c (master - Document ASTNode#symbolize (#5081)): The build passed.
<FromGitter> <monouser7dig> just made a request/ issue on the crystal-tools repo or how it is called where they maintain the tooling, atom has nice inspection tooling which does not seem to be available in sublime
<FromGitter> <monouser7dig> Papierkorb, if you choose sublime over atom you choose some speed over some tooling, just depends what you miss/ if you miss any of that
<Papierkorb> I need syntax highlighting. The `initialize` snippet is helpful. Everything else: Couldn't care less.
<FromGitter> <monouser7dig> sublime will in this case probably be good, you can have snippets
<FromGitter> <monouser7dig> init cause one just can't possible type it quickly? 😄
<Papierkorb> it's just so darn convenient for some reason.
<Papierkorb> Any other snippet is more annoying. Can't count how often it extended my `end` to `each_with_index`.
<FromGitter> <monouser7dig> one thing in sublime that got me several times, if you move a file while having it opened, sublime will recreate the file at the old place when you save, I think this is really bad, did not find a setting, but once you know...ok
<FromGitter> <monouser7dig> I've some autocompletion package which just looks at all words in all open documents and chooses completion based on them, it works ok, someday a context aware thing would be cool but...
<Papierkorb> that's what I also have in atom. works well enough most of the time to be honest.
<Papierkorb> It's fast
<Papierkorb> The moment I have to wait on completion I don't use it
<FromGitter> <monouser7dig> I'd like to have that
snsei has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
DTZUZU has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter> <monouser7dig> > Is there a Crystal linter for Sublime Text? ⏎ ⏎ ⏎ they actually started development again and pulled some requests so if something for crystal came up they'd probably merge it rather quickly []
<FromGitter> <georgeu2000> @monouser7dig - Thanks
<FromGitter> <georgeu2000> > if you move a file while having it opened, sublime will recreate the file at the old place when you save ⏎ Yep, this happens to me. I always close before moving.
<Papierkorb> faustinoaq, What exactly do I have to do in VS Code for Peek definition to work?
<Papierkorb> It always tells me that it can't find the def
<FromGitter> <monouser7dig> I think this linter works like, you invoke the crystal compiler and give the linter a regex to extract line number and error message and the linter then displays that inline
ShalokShalom_ is now known as ShalokShalom
claudiuinberlin has joined #crystal-lang
DTZUZO has quit [Ping timeout: 248 seconds]
<FromGitter> <georgeu2000> @monouser7dig - Linter works great.
<FromGitter> <monouser7dig> if I repeat to tell that I had a very dumb issue with a crystal debugging message ⏎ ⏎ `a : Array(Int32) = []; gives the error "expect [] of ElementType"` ⏎ thus I wrote `a : Array(Int32) = [] of ElementType` ⏎ (kind of Like in java: Set<T> l = new HashSet<>(); cause I thought ElementType was some interface or kind of it) ... []
<Papierkorb> I .. don't see the issue
<FromGitter> <monouser7dig> see the debug message led me to write incorrect code still
<Papierkorb> The compilers job is to compile. Yours to think.
<FromGitter> <monouser7dig> either I was just surprisingly stupid or someone else agrees this could be made more expressive
<FromGitter> <monouser7dig> no the compilers job is also to give sensible error messages and help me arrive at the correct conclusion
<FromGitter> <monouser7dig> to you insiders ElementType is obvious of course
<oprypin> monouser7dig, yeah to people who have read the documentation it's pretty obvious
<oprypin> do not expect hints about syntax features that you dodn't bother reading about
<oprypin> uh that camem out a bit too negative
<Papierkorb> "ElementType" is clearly a placeholder.
<Papierkorb> Only "YourElementsTypeHere" would be more obvious.
<oprypin> compilers usually just say invalid syntax anyway
<oprypin> so this is already better than average
<FromGitter> <monouser7dig> nothing about ElementType, just that = [] is wrong, see, I know now it now and it is not hard to memorize just think {{here_goes}} is more obviously showing that here_goes is a Placeholder
<oprypin> nope it's actually worse
<Papierkorb> {{here_goes}}? So `[] of {{String}}`
<crystal-gh> [crystal] Fryguy opened pull request #5085: Short circuit Hash#find_entry for empty Hashes (master...faster_empty_hash_lookup)
<FromGitter> <monouser7dig> and actually a : Array(Int32) = [] giving an error is weird in itself cause why can not crystal know that it is an array of int? at least I told it
<FromGitter> <monouser7dig> okay accept you opinion 😄
<oprypin> you told it the type of the variable, but first it needs to create a value
<FromGitter> <monouser7dig> the value is an empty array of int32
<oprypin> where does it say that?
<FromGitter> <monouser7dig> int : Array(int32) = [] , the first part tells what it is, the second tells it is empty
<oprypin> so you're creating an
<oprypin> so you're creating an "empty"
<FromGitter> <monouser7dig> might be a parsing problem but coming from pure logic, there is no ambiguity
<FromGitter> <monouser7dig> an empty array
<Papierkorb> `getter foos = [] of Foo` should be the only way to do that. Why have two syntaxes for the same thing
<FromGitter> <monouser7dig> the `int :` was nonsense, sorry, should have been some name
<FromGitter> <monouser7dig> yes two syntaxes is bad as well agreed
<oprypin> monouser7dig, you can argue that the programming language should be changed to make your example work ( see also ) but you cannot argue that it makes sense under the current state of the programming language
<FromGitter> <monouser7dig> although I do like the notation arr : Array(Int32) because this is the same Type that I'd put into a function call
<oprypin> the state is that every literal immediately must have a type
<FromGitter> <monouser7dig> of Int32 is different from what I'd put in a function call
<FromGitter> <monouser7dig> oprypin yeah now I see your point, took me some time but actually makes sense currently
<oprypin> when you write an array literal, the compiler must have a way of determining what type it stores. and only then the variable it's being assigned to is being considered
<FromGitter> <monouser7dig> read your proposal as well and especially at the beginning of using crystal strongly I'm not that sure but tend to still agree
<oprypin> yeah the proposal is really easy to agree to but really difficult to implement
<FromGitter> <monouser7dig> 😄
<oprypin> aftettr that's done we can argue for untyped array literals, then your example would work
<FromGitter> <monouser7dig> I'll hopefully will still be around 👍
<FromGitter> <monouser7dig> gee it's too late 😄
<oprypin> another example that might help with understanding:
<oprypin> `a : Array(Int32 | String) = [1, 2, 3]` is invalid
<oprypin> `a : Array(Int32 | String) = [1, 2, 3] of (Int32 | String)` is valid
<oprypin> `a = [1, 2, 3] of (Int32 | String)` is valid
<FromGitter> <monouser7dig> one thing I could argue is that the empty array should be handled as an array with a number, it should both default to Int32 and thus arr : Array(Int32) = [] should work like your first example
DTZUZO has joined #crystal-lang
<oprypin> no comment
<FromGitter> <monouser7dig> nevermind
<FromGitter> <HCLarsen> @sdogruyol we're also above Elixer, and 3 higher than last month.
<FromGitter> <HCLarsen> Hey guys, I'm trying to play around with the "" site, and it gives me an error when I do require "http/client". Is that a limitation in the online interface that you can't require libraries, or is something wrong with that library?
<oprypin> HCLarsen, show proof
<FromGitter> <bew> iirc there are errors when requiring http stuff in crystal play or the online testers
<oprypin> pretty sure it's not about requiring
<oprypin> but about intentionally being prevented from getting a free botnet node
<FromGitter> <HCLarsen> Ok, so it's just the online thing. Got it.
<oprypin> i'm not really sure if you got it
<oprypin> because requiring generally works just fine
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <matrixbot> `` Hey guys! How can I make this work? ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <matrixbot> `` ah, sorry for the bad indentation
<oprypin> Renich, y u do dis
<FromGitter> <matrixbot> `` Well, i have an app that's gonna run in a loop. So, I want to define a Start class that runs all it has to run (logging, config, etc)
<oprypin> please remove matrixbot
<oprypin> you can connect though matrix to irc if you really want
<FromGitter> <matrixbot> `` OK
* FromGitter * matrixbot is looking how to remove it*
Renich has joined #crystal-lang
<oprypin> I strongly believe that objects should represent tangible objects
<oprypin> "Start" is not one of that
<FromGitter> <monouser7dig> def! should do (just working, not saying good or bad)
<Renich> oprypin: how would you go about initializing the app, then?
<oprypin> assign a bunch of variables, i dunno
<oprypin> should it be an App class then?
<Papierkorb> I usually call that facade class `Tool`, which then does the front-end stuff
<oprypin> tool?
<Papierkorb> The tool setting things up for the front-end to do something useful
greenbigfrog has quit [Remote host closed the connection]
<FromGitter> <matrixbot> `` I dunno how to remove the matrix bot, btw, oprypin. I will have to remove it from favorites
<oprypin> well to start with you probably shouldn't be connecting to gitter using matrix
<FromGitter> <monouser7dig> about Foo::bar ⏎ ⏎ says ⏎ Ruby File::exists? becomes crystal File.exists? etc... ⏎ ... []
jnerula has joined #crystal-lang
<FromGitter> <HCLarsen> You were right @bew I tried the same command from my own computer, and it worked.
<jnerula> Hey y'all, is there a way to pass methods on a class as arguments?
<FromGitter> <bew> jnerula what do you mean?
<RickHull> i think he means functional style, passing methods around
<jnerula> Yes, something like
<RickHull> functions-as-args
<jnerula> I want to map strings -> methods and then invoke them
<RickHull> I believe this is more like #send functionality which Crystal explicitly does not support
<FromGitter> <bew> did you read about proc in the docs?
<RickHull> (AFAIK, I'm new)
snsei has quit [Remote host closed the connection]
<jnerula> RickHull: Yeah I was looking at that but thats a little more metaprogrammy
<jnerula> I've got an explicit map of string -> method, but I dunno if crystal supports it or what the syntax is
<oprypin> i don't understand what you're trying to do
<RickHull> obj.send('method_name') is different than passing a method/function as an arg/object itself
<jnerula> Here I'll dpaste some stuff, just a sec
<oprypin> why not bpaste then, which actually supports Crystal
<oprypin> is one of my guesses of what you want
<jnerula> I'm trying to create a class-based view system
<jnerula> The idea being you send 'GET / HTTP 1.1' or whatever, and it calls a 'get' method on a View class
<Papierkorb> `"get" => ->self.get,` etc.
<jnerula> I've just been messing around with Crystal this morning and it seemed kinda fun
<Papierkorb> jnerula: But in your specific case, just use a `case` statement, not a temporary hash
<oprypin> yeah exactly, why store and return methods when you can just call them
<Papierkorb> and just call out to the method from there
<RickHull> yes, my first thought was to reach for `case` -- but there is something nice about declaring your map as data rather than executable code
<Papierkorb> building a map sounds like code to me
<RickHull> you could reference that map from outside
<Papierkorb> if you want to make it harder on yourself, yes
<jnerula> A case here would work great, but I'm trying to put myself through the challenge of more functional style stuff
<Papierkorb> What I already wrote.
<jnerula> btw it's still trying to invoke the methods if I use eg. `"get" => ->self.get,`
<jnerula> wait, nevermind
<oprypin> sigh
snsei has joined #crystal-lang
<FromGitter> <HCLarsen> Hey guys, I can't seem to figure out the to_json method for strings. It's calling for a JSON::Builder argument, but I'm not sure what to put in there.
<Papierkorb> please post code.
<FromGitter> <HCLarsen> I don't have code to post because I don't know what to write yet.
greenbigfrog has joined #crystal-lang
<oprypin> HCLarsen, ok then what are you trying to do?
<oprypin> because calling to_json on a string is not that useful
<RickHull> yeah, typically you call it on a data structure, and it returns a string
<FromGitter> <HCLarsen> The HTTP::Client returns a string, which contains JSON data. I want to parse that into something more meaningful. I figured to_json would be the way to go.
<RickHull> you would want to first extract the JSON string, and then something like JSON.parse(json_str)
<FromGitter> <fridgerator> ah, you want `JSON.parse`
<FromGitter> <HCLarsen> I don't see JSON in the api documentation.
<FromGitter> <fridgerator> its there:
<FromGitter> <HCLarsen> Nevermind, I must have scrolled too quickly.
<jnerula> Okay so methods can be converted into procs with ->, but you still have to specify arguments to them
<jnerula> Thanks
<oprypin> or don't do that
<oprypin> it's types not arguments
<jnerula> Yeah, I meant type annotations
<oprypin> types
<FromGitter> <monouser7dig> if in doubt try ElementType 😄
<jnerula> How are case statements implemented under the hood?
<FromGitter> <HCLarsen> Hey guys, this API documentation leaves a lot to be desired. Is there a way I can contribute to it?
<FromGitter> <monouser7dig> like it scrolls to the top every time you click and search for methods does not work at all? that would be great indeed 😄
<FromGitter> <fridgerator> @HCLarsen yep, create pull requests 👍
<oprypin> but don't make a big pull request cuz those just rot away
<FromGitter> <HCLarsen> @fridgerator Does the API page read from the core library documentation like Ruby does, or is there a separate repo for that?
<oprypin> reads documentation comments
<oprypin> from code
<FromGitter> <HCLarsen> Got it, thanks.
<FromGitter> <HCLarsen> Ok, no idea what's going on here with this error from JSON parsing.
<FromGitter> <HCLarsen> How do I paste code?
gokmen has joined #crystal-lang
<FromGitter> <HCLarsen> What, I paste it into a gist and it shows up here automatically?
<jnerula> yes
<maxpowa> wew
<FromGitter> <HCLarsen> ```code paste, see link``` []
<FromGitter> <HCLarsen> That also works.
<FromGitter> <HCLarsen> Now, despite the output from line 3 saying it's a Hash, the compiler gives me an error on line 4 saying that it's an Array.
<FromGitter> <HCLarsen> ```code paste, see link``` []
<FromGitter> <HCLarsen> That error. Can anyone help me make sense of that?
<jnerula> HCLarsen you might need to do as_h again on ["main"]["temp"]
<jnerula> or on ["main"], rather
Ven has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Ven is now known as Guest1102
<FromGitter> <HCLarsen> Similar error: ⏎ undefined method 'as_h' for Array(JSON::Type)
<jnerula> HCLarsen: Remove the as_h completely
<jnerula> And it'll work as expected
<jnerula> This works for me ^^^
<FromGitter> <HCLarsen> Interesting. The documentation definitely led me to believe that I needed to use as_h.
<FromGitter> <HCLarsen> Thank you for your help.
<FromGitter> <HCLarsen> What's the purpose of the as_h method then?
<FromGitter> <elorest> `as_h` will only work if the underlying structure is a hash.
<oprypin> HCLarsen, at every point in json, everything can be either a string or an array or a hash or etc. the compiler is telling you that. it can't make assumptions
<FromGitter> <HCLarsen> But, it was a hash. That's why I was using it.
<jnerula> the docs seem to imply that only JSON::Any is further traversable, while JSON::Type isn't?
<oprypin> HCLarsen, ok, it's a Hash, but each of its values can be either a string or an array or a hash or etc. the compiler is telling you that. it can't make assumptions
<oprypin> that's why there is a wrapper type JSON::Any that allows you to make these assumptions, up until the very last moment
<FromGitter> <HCLarsen> I wasn't telling it to make assumptions, I was using the as_h method to tell it that it's a hash.
<jnerula> A hash from what to what though? You're only defining the top level type for that object
<oprypin> HCLarsen, OK so you get a `Hash(String, String | Int64 | Float64 | Hash | Array)`
<FromGitter> <HCLarsen> Take this sentence for example: To convert them to String, Int32, etc., use the as_ methods, such as #as_s, #as_i, which perform a type check against the raw underlying value.
<oprypin> geez cant even finish a sentence here :p
<FromGitter> <HCLarsen> I wanted to convert the JSON::Any to Hash so that I could write code that treated it like a hash.
<jnerula> It's a recursive type definition, so it can only go so far without your help:
<oprypin> OK you can do that
<FromGitter> <HCLarsen> jnerula, you lost me on that one.
<oprypin> `value : Hash(String, String | Int64 | Float64 | Hash | Array)`; then `value["main"] : String | Int64 | Float64 | Hash | Array`, then `value["main"]["temp"]` - what if value["main"] ended up being an Int32 you end up calling `["temp"]` on that?
<jnerula> This ^^^
LOLBOW has joined #crystal-lang
<FromGitter> <HCLarsen> That's why I tried calling "as_h" on it before I called ["temp"] on it, and got the same error.
<oprypin> likely not the same. Hash does not have a method `as_h`
<FromGitter> <HCLarsen> But it said that I was trying to call as_h on an Array.
<FromGitter> <asterite> Just remove `as_h` and do `puts value["main"]["temp"].as_f`
<oprypin> that's the intended use, yes, but i was building up to that
nijotz has joined #crystal-lang
<FromGitter> <asterite> With `as_h` you are going from `JSON::Any`, which lets you traverse the data structure infinitely, to a `Hash` that lets you just access one level
<FromGitter> <asterite> So jnerula's answer, basically
<oprypin> welp i cant finish a sentence so whatever
<FromGitter> <asterite> why?
<FromGitter> <HCLarsen> Wait, you mean that as_h prevents me from going any deeper into the nested structure?
<FromGitter> <asterite> Yes, exactly
<FromGitter> <ezrast> @HCLarsen You're misinterpreting that error message - you were calling `[]` on a value that could have been a `String`, `Array(JSON::Type)`, `Hash(String, JSON::Type)`, etc. In order to call a method on a union type, every type in the union has to implement that method. You were getting an error because Array does not implement `[]` with a String argument (neither does String, Int, etc; the compiler just
<FromGitter> ... happened to check Array first)
<FromGitter> <ezrast> The actual value was a Hash, but it's compile-time type is Union, not Hash
<FromGitter> <asterite> `as_h` means: this json thing I have here, which can be any json type, I know it's a hash. From there, if you index it with a string it will be again any json type, but a `JSON::Type`, not a `JSON::Any` anymore
<FromGitter> <asterite> In any case, this is waaaay too confusing
<FromGitter> <asterite> I said many times that `JSON::Any` was a mistake and just having `JSON::Type` would be simpler
<FromGitter> <HCLarsen> I'm gonna be honest, I don't think that structure is a good thing. I would expect an as_h method to convert the entire nested structure to a hash.
<FromGitter> <asterite> That's what it does :-)
<oprypin> but there's no conversion happening T_T
<FromGitter> <asterite> but the elements of that hash can be any type in the JSON world
<FromGitter> <HCLarsen> At the very least, the documentation should be clearer.
<oprypin> oh that's for sure
<FromGitter> <HCLarsen> I hope no one gets offended if I try to clear that up and do a pull request next week.
<FromGitter> <asterite> Please don't, we just need to remove `JSON::Any` from the standard library
<FromGitter> <asterite> With "please don't" I mean that you will waste time because those docs will later disappear
<FromGitter> <HCLarsen> Then how would it work without JSON::Any? What would the JSON.parse method return?
<FromGitter> <asterite> A union of all the JSON types
<FromGitter> <asterite> Maybe you'd like to look at JSON.mapping?
<oprypin> HCLarsen, I'm of the opinion that to explain something, first you need to understand it perfectly, and then also have the ability to put yourself in the shoes of a beginner
<oprypin> which is quite a requirement
<FromGitter> <HCLarsen> I was a technical salesperson for 12 years. Translating expert jargon into beginner jargon was my job.
<oprypin> good, so then you need just the first part, i guess
<FromGitter> <HCLarsen> @asterite , what's a union?
<FromGitter> <HCLarsen> Agreed oprypin.
<oprypin> HCLarsen, it's best to read most of
<oprypin> i used to say read everything but it's grown some non-essential guides
<FromGitter> <HCLarsen> I have read some of that already, but definitely not most.
<oprypin> asterite, I don't see how one would get far without JSON::Any. i'm pretty sure it would be annoying as hell, unless you have some ingenious idea
<FromGitter> <HCLarsen> Thank you. That'll give me some reading tonight.
<FromGitter> <HCLarsen> I assume with union types it's easy to query it to determine which type it is?
<oprypin> yeah
<oprypin> the more involved part is proving to the compiler that you've checked properly
<FromGitter> <HCLarsen> Good then. In the case of JSON.parse, it would be very useful to query it to see which type is it, and then deal with the data appropriately.
<FromGitter> <HCLarsen> Yeah, that's like using optionals in Swift. One hell of a learning curve on those.
<oprypin> you can definitely do that manually at every junction, if you get the union type directly, with JSON.parse_raw
<oprypin> JSON.parse wraps the result in an object that helps traversal
<FromGitter> <asterite> oprypin: JSON.parse(data).as(Hash)["foo"].as(Array)[0].as(Float). A bit longer but super explicit
<oprypin> such nice material for smirks in reddit comments
<FromGitter> <HCLarsen> Readable code is key.
gokmen has quit [Quit: bye.]
<Papierkorb> oprypin: /r/programming attracts mostly unspecialized people living in a funny bubble
<Papierkorb> Who cares what they think
<FromGitter> <HCLarsen> I'm assuming you could also do a case switch on that? Type checking could be useful.
<oprypin> that was just one way of saying "general publicity"
snsei has joined #crystal-lang
gokmen has joined #crystal-lang
<Papierkorb> HCLarsen, if you want to traverse the structure, yes you can use a `case` with a when for each type you care about
<Papierkorb> oprypin: Looking at the current world of *programming*, this "general publicity" person didn't seem to care much about writing stable code in the past years.
<oprypin> look i'm not gonna deny that programming is a special kind of adrenaline chase for me
<oprypin> if i see unnecessary verbosity, i don't like that
<Papierkorb> You can easily write a dig-esque method?
<oprypin> you got me there
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <HCLarsen> I meant that question for @asterite 's theoretical example.
<oprypin> `case (root = JSON.parse data); when Hash; root["foo"]` etc
<oprypin> I'm just thinking about generalizing the idea of turning compile time checks into runtime checks when you really want, like in this case
<FromGitter> <georgeu2000> I have a web request params that comes from the body of an HTTP request: ⏎ `@params = JSON.parse(context.request.body.to_s)` ⏎ How can I add another key/value? The following fails: ⏎ `@params[:foo] = "bar"` []
<FromGitter> <georgeu2000> How can I handle a Hash with arbitrary depth?
<FromGitter> <georgeu2000> Is there any examples or documentation?
<oprypin> a special state you can enter where instead of generating a "no such method" compile error you get a subset of types that support it or a runtime error otherwise
<oprypin> georgeu2000, there's no direct documentation on "handling a Hash with arbitrary depth"
<oprypin> basically it's just applying in a loop
<Papierkorb> Recursion ftw .. Or: Enumerable#reduce ftw
<FromGitter> <georgeu2000> What type would `@params` be?
<oprypin> georgeu2000, but use JSON.parse_raw
<FromGitter> <georgeu2000> So `JSON::Type` is a type?
<FromGitter> <georgeu2000> It's like a Hash? Not a String...?
<Papierkorb> georgeu2000, (Maybe HCLarsen too)
<oprypin> it's a union of types. but unions of types are also types
<FromGitter> <georgeu2000> OK, that makes sense.
<oprypin> Papierkorb, but that will not work with json
<Papierkorb> mh?
<FromGitter> <georgeu2000> Thanks. Also very helpful because I was looking for `dig` as well.
<FromGitter> <georgeu2000> Is there any special reason `dig` is not built into Crystal?
<oprypin> there hasn't been any big push for it. and it doesn't really fit in anywhere i guess?
<Papierkorb> The X.mapping macro demolished almost all use-cases for it
<RX14> i think typing it might be horrendous too
<Papierkorb> If even possible
<oprypin> RX14, what's horrendous?
<oprypin> also typing as in compiler work or finger moving work?
<RX14> getting the return type of dig to be somewhat close to correct
<FromGitter> <HCLarsen> Here come the typing puns.
gokmen has quit [Quit: Be back later ...]
gokmen has joined #crystal-lang
<Papierkorb> HCLarsen, I tried my best at the worst: Two types go into a bar. One comes out in unity.
<jnerula> 6/10
<Yxhuvud> Papierkorb: I fought the SHA, but the SHA1
<oprypin> :'(
* oprypin actually smiles
<Papierkorb> Yxhuvud: I did too, but it was on its birthday.
<RickHull> after the most recent CVE my blood pressure SHA256
<oprypin> :'(
<RickHull> SHA3 don't like it; dropping the bad SHA
claudiuinberlin has quit [Quit: Textual IRC Client:]
Guest1102 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <HCLarsen> I appreciate the joke, but that's not really a pun.
<FromGitter> <HCLarsen> More like, which type did you type?
<FromGitter> <monouser7dig> > **<Papierkorb>** The X.mapping macro demolished almost all use-cases for it ⏎ whats that about?
<oprypin> monouser7dig,
<FromGitter> <monouser7dig> aaah read that but could not infer the context 👍
<FromGitter> <opensas> @Papierkorb @HCLarsen @asterite once I had to parse a json with unknown structure, I started with json.parse and JSON:: Any, but eventually ended up just using json.parse_raw, JSON::Type and a case statement, my code was even more concise and clearer, inside the case I didn't even had to cast the value , in my
<FromGitter> ... case JSON::Any wasn't very useful
<oprypin> good for you, i guess
<Papierkorb> Yup that's how you do it. You shouldn't use a NamedTuple though. At least use a struct instead, the `record` macro comes in handy for this.
<oprypin> you're just mapping a general use case to a general use case, of course a generalistic approach will work better than something made for getting *specific* fields
<FromGitter> <monouser7dig> > **<Papierkorb>** Yup that's how you do it. You shouldn't use a NamedTuple though. At least use a struct instead, the `record` macro comes in handy for this. ⏎ ⏎ at least named tuples are faster than an array afaik? why struct then (had this today already just other way round)
<FromGitter> <opensas> Didn't know about the ´record´ macro, I'll give it a try, thanks! I should be more performant than a NamedTuple, right?
DTZUZO has quit [Ping timeout: 240 seconds]
<Papierkorb> monouser7dig, that's comparing pears with apples
<Papierkorb> opensas, same performance-wise. Just a better choice as data structure. Tuples are not storage data types, they're transfer data types.
<FromGitter> <opensas> good to know, sometimes it's a bit difficult to know which structure is more appropriate for each use case, a cheat sheet would be useful, any docs that might be worth reading about it???
<FromGitter> <monouser7dig> `Tuples are not storage data types` so no real reason other than aesthetic?
<Papierkorb> > they're transfer data types.
<Papierkorb> Logistics aren't aesthetics. Without nothing much would happen in our world.
<FromGitter> <monouser7dig> yeah but whats the catch with that, any implications?
<Papierkorb> "catch with that"?
<FromGitter> <monouser7dig> the downside
<Papierkorb> To what?
<Papierkorb> To doing what?*
<FromGitter> <monouser7dig> the downside of using tuples as storage (instead of struct)
<FromGitter> <opensas> I think @monouser7dig is asking why is it preferable in this case to use a struct instead of a named tuple
<FromGitter> <opensas> me too btw
<FromGitter> <monouser7dig> sure
<oprypin> opensas, in *this* case it's really arguable
<oprypin> i like your usage of namedtuple
<FromGitter> <opensas> when you say transfer data types you mean they are mainly intended to pass parameters between methods?
<Papierkorb> It's totally inconvenient to use. You don't have any control over their behaviour, and can't augment the types with methods. To the programmer, a tuple is a bunch of bytes, a struct brings structure into the chaos. And, writing `foo[:bar]` just sucks compared to ``
<oprypin> opensas, that'
<Papierkorb> opensas, yes
<oprypin> opensas, that's the typical example, but could apply to passing things around in general
<oprypin> which you actually seem to be doing, not really storing in the long term, though i get that the duration is not the point
<Papierkorb> opensas, `def foo(*args)` <- args is a Tuple. You can pass these on (Splatted or not). They're like temporary structures in this regard.
<Papierkorb> Whenever you're storing a tuple, you should take a moment and rethink your approach, if a real type isn't much better suited at this point. A `class` if you can, but even a struct (`record` does exist) is a improvement. It'll make your code much easier to maintain too.
<FromGitter> <monouser7dig> but sometimes yagni (
<Papierkorb> Doesn't mean there may not be a case where storing a tuple is actually a good idea. I haven't come across one yet, but others do other things ;)
<Papierkorb> Maintainability? Yeah, totally YAGNI
<Papierkorb> Who cares
<Papierkorb> You're right, it's a job security thing
<Papierkorb> If no one dares to touch the code but you, your job is safe
<FromGitter> <monouser7dig> it's not like you have to expand every piece of a program 😄 haha
<oprypin> when you care about getting a few pieces of data into one thing, passing it somewhere, then breaking it apart again, that's the use case for tuples
<FromGitter> <monouser7dig> thanks for the advice again though, looking foreword to a prosperous future
<oprypin> and if you need to create them as often as in opensas's case it seems like a nice benefit in addition to seeming like the proper use case to me
<FromGitter> <opensas> I'm using the tuples just to temporary aggregate the json struct to process it after parsing it all, I'll give it a try with a struct to see how the code ends up, thanks for the explanations, I think the docs could benefit from a section comparing the different structures and sue cases available in Crystal, like the one explaining differences between classes and structs
<oprypin> well even old established programming languages don't have that luxury
<oprypin> discussions of tuples happen all the time in #python , and the advice is scattered throughout blogs. "the community" in general has pretty good knowledge about it thought
<oprypin> -t
<FromGitter> <monouser7dig> ```code paste, see link``` []
<FromGitter> <monouser7dig> it literally has --emit as an option but does not parse it?
<FromGitter> <oprypin> someone had a really helpful replacement of -- to —
<oprypin> kind of a big difference between --emit and -—emit
<FromGitter> <monouser7dig> funky, pasted that from a message where I pasted it from a website, look just the same in my term
<oprypin> get a better terminal font then
<FromGitter> <monouser7dig> its completely insane output anyway probably for anything more than x =1
snsei has joined #crystal-lang
<FromGitter> <monouser7dig> so --prelude=empty is required to make it parsable by a human but then I can not use a hash? cause it can not find methods cause it propably leaves a whole lot out
<Papierkorb> Ctrl+F is your friend.
<FromGitter> <monouser7dig> I'll just pretend hash#empty compiles down to exactly the same as hash#size == 0
<FromGitter> <monouser7dig> otherwise faith in llvm would be disrupted anyway
<Papierkorb> The llvm IR isn't optimized
<Papierkorb> Except for trivial platform agnostic things, but that doesn't include method inlining
<Papierkorb> Hence, objdump to the rescue
<FromGitter> <monouser7dig> could be optimized though couldn't it? I mean optimization happens with the IR code and not the binary?
<Papierkorb> The IR is backend agnostic
<Papierkorb> Also, no why should you optimize it? The IR is for human consumption
<FromGitter> <monouser7dig> cause I'd want to see the optimization, otherwise I'd look at the source code for human consumption 😄
<FromGitter> <monouser7dig> LLVM IR Optimizer was what I remembered
snsei has quit [Remote host closed the connection]
<FromGitter> <monouser7dig> so you can actually optimize IR and get back to IR just maybe not with these crystal command which is unfortunate to say the least
<FromGitter> <georgeu2000> I was able to parse, but not sure how to update the params: ⏎ ⏎ ```@params = JSON.parse_raw(context.request.body.to_s) ⏎ @params["foo"] = "bar"``` ⏎ ⏎ I get `no overload matches 'Array(JSON::Type)#[]=' with types String, String` []
snsei has joined #crystal-lang
<FromGitter> <georgeu2000> Not sure why @params is an Array, or how to update it.
<FromGitter> <georgeu2000> Also looking for documentation on what is going on here...
snsei has quit [Remote host closed the connection]
<FromGitter> <georgeu2000> Looks like this might be the answer:
bmcginty has quit [Ping timeout: 252 seconds]
bmcginty has joined #crystal-lang
<FromGitter> <faustinoaq> > @faustinoaq, What exactly do I have to do in VS Code for Peek definition to work? ⏎ ⏎ Papierkorb, Enable implementations on `settings.json` ⏎ ⏎ ```{ ⏎ "crystal-lang.implementations": true, ⏎ }``` []