ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | 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
<FromGitter> <randiaz95> Hi guys! does anyone know a website link to learn scaffold data types in amber crystal framework?
<FromGitter> <randiaz95> like i see string and text in the example but don't know the difference, also I dont know how to make a boolean column
<FromGitter> <randiaz95> colname:bool or colname:boolean?
<FromGitter> <randiaz95> closest thing I can find is: https://docs.amberframework.org/amber/cli/generate#scaffolding but it doesn't go deep into dtyps
<FromGitter> <randiaz95> ^ going to assume that its like rails and going to use rails docs lol.
<FromGitter> <Blacksmoke16> could prob look in the source too
<FromGitter> <randiaz95> for sure
<FromGitter> <randiaz95> i've never used something like rails or amber it definitely feels like the right way to work lol
<FromGitter> <randiaz95> Django you have to write code to migrate database.
<FromGitter> <Blacksmoke16> imo id rather just write the SQL
<FromGitter> <Blacksmoke16> then its not tied to what framework you're using
<FromGitter> <Blacksmoke16> and its usually easier
<FromGitter> <randiaz95> Sure; it feels like i learned alter /create table commands for no raisins.
<FromGitter> <randiaz95> If amber/crystal is a girlfriend, it feels like i would like to marry her
<FromGitter> <randiaz95> Just need to get to know her a little more before i propose.
zorp_ has quit [Ping timeout: 265 seconds]
<FromGitter> <jojokoro> What does `::` means in Crystal? e.g. ⏎ ⏎ ```::File.join({"foo", "bar", "baz"}) ``` [https://gitter.im/crystal-lang/crystal?at=5e9a559f0480c128efc7f646]
<FromGitter> <Blacksmoke16> access the top level namespace of that type
<FromGitter> <jojokoro> Some examples use it. But I guess I could simply call `File.join` directly too, without `::`
<FromGitter> <jojokoro> Not sure if I got it. :/
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9a561ca9ca18620645aaf3]
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8wpw
<FromGitter> <Blacksmoke16> example, works with methods too
<FromGitter> <jojokoro> Oh now it made complete sense tks!
<FromGitter> <Blacksmoke16> np
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Path.html might be helpful as well
<FromGitter> <randiaz95> George! How are you feeling? Anyone you know got the COVID?
<FromGitter> <Blacksmoke16> nope
<FromGitter> <randiaz95> i dont know one case either...
<FromGitter> <randiaz95> Either we over reacted or.... We are doing a good job
<FromGitter> <tenebrousedge> even in the worst case scenario, most people won't know anyone who gets it
<FromGitter> <randiaz95> why?
<FromGitter> <randiaz95> When you get it do you get kidnapped or something?
<FromGitter> <randiaz95> That would make for a fun movie
<FromGitter> <tenebrousedge> just statistics. There are 328 million people in the US, and it's expected that a few million people will get this disease. How many people do you keep in regular contact with?
<FromGitter> <Blacksmoke16> like 2
<FromGitter> <Blacksmoke16> :S
<FromGitter> <tenebrousedge> so if you keep in contact with 2 people, something like 100 million would have to get the disease before it's likely that someone you keep in contact with would have it
ur5us has joined #crystal-lang
<FromGitter> <tenebrousedge> also, part of the reason that this is dangerous is because many people only have mild symptoms and don't know that they have it
zorp_ has joined #crystal-lang
<FromGitter> <randiaz95> Or also possible that all your friends die
<FromGitter> <randiaz95> given we have such few friends
<FromGitter> <Blacksmoke16> my friends are nerds so i doubt they going anywhere either ha
<FromGitter> <randiaz95> but.. under the condition that we code and stay inside often. We most likely won't get it
<FromGitter> <randiaz95> Nerd is a derogative term
<FromGitter> <randiaz95> I like to use Intellectually superior
<FromGitter> <Blacksmoke16> naw they're nerds :D
<FromGitter> <tenebrousedge> I spent like 8 months doing the social isolation thing, but I started being socially active just about when this outbreak started :/ doing it wrong
<FromGitter> <Blacksmoke16> i wish compile time errors in custom macros were more helpful
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9a618fc7dcfc14e2c9b2e4]
<FromGitter> <Blacksmoke16> i.e. point to the actual line its raised
<FromGitter> <randiaz95> Lol Kai
<FromGitter> <randiaz95> I really need to lose the 10 pounds I gained from this
<FromGitter> <randiaz95> Pure cereal and milk lol
<FromGitter> <tenebrousedge> D:
<FromGitter> <tenebrousedge> cooking ftw
<FromGitter> <randiaz95> nah my father in law has been cooking every dinner; but I tend to eat cereal right before he finishes..
<FromGitter> <tenebrousedge> that's silly
<FromGitter> <randiaz95> I grew up feeding myself lol
<FromGitter> <randiaz95> Food anxiety
<FromGitter> <randiaz95> or is it insecurity?
<FromGitter> <tenebrousedge> well you could snack on sausage or some other form of protein
<FromGitter> <tenebrousedge> or snack earlier in the day
<FromGitter> <tenebrousedge> I didn't grow up feeding myself, but I've been cooking for myself for the last howevermany years
<FromGitter> <randiaz95> moisesvasquezca@gmail.com
<FromGitter> <randiaz95> woops
<FromGitter> <randiaz95> I never had such a big family
<FromGitter> <randiaz95> its a good thing now that I am meditating on it
<FromGitter> <randiaz95> all humans are flawed; and we need people that won't give up on you.
<FromGitter> <tenebrousedge> yup
<FromGitter> <randiaz95> https://github.com/amberframework/granite/issues/177 Thanks George
<FromGitter> <randiaz95> You are everywhere lol
<FromGitter> <Blacksmoke16> ha, i try :p
<FromGitter> <watzon> @randiaz95 might be worth looking into Lucky too
<FromGitter> <Blacksmoke16> coughathenacough
<FromGitter> <watzon> Athena is good too, if you're looking for API only
<FromGitter> <Blacksmoke16> it can handle HTML now
<FromGitter> <watzon> Lucky is the most fully featured framework in Crystal as of right now though
<FromGitter> <watzon> Oh that's cool
<FromGitter> <Blacksmoke16> granted i cant say i tested it much tho, but its theoretically doable ha
<FromGitter> <Blacksmoke16> at least the unit tests pass
<FromGitter> <Blacksmoke16> id agree with that
<FromGitter> <randiaz95> Hahah, I kinda am in cli mode; if I change my mind I will go to George's framework; ⏎ ⏎ ( If stripe gets built in api into Athena I will drop everything I am doing and incorporate a business and start building my dream application )
<FromGitter> <randiaz95> I will kidnap my sophmore cousin for forced labor
<FromGitter> <Blacksmoke16> amber for making a cli?
<FromGitter> <randiaz95> amber uses cli commands to make apis
<FromGitter> <randiaz95> like rails
<FromGitter> <watzon> Lucky does as well
<FromGitter> <Blacksmoke16> ah, like generating the files?
<FromGitter> <randiaz95> Yep
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <watzon> Personally I love Lucky because of Avram. It's the sanest ORM I've found so far.
<FromGitter> <watzon> Granite is a close second.
<FromGitter> <Blacksmoke16> granite is only one that supports annotations afaik
<FromGitter> <watzon> The only downside is being locked to Postgres, but since I use it anyway that isn't much of a downside
<FromGitter> <Blacksmoke16> pg ftw
<FromGitter> <randiaz95> postgres <3
<FromGitter> <randiaz95> Omg lol we all like postgres?
<FromGitter> <elorest> Postgres is pretty great.
<FromGitter> <randiaz95> https://pgexercises.com/
<FromGitter> <randiaz95> I've done every exercise on this site
<FromGitter> <randiaz95> my first job was with pgsql
<FromGitter> <tenebrousedge> what's not to like about pg?
<FromGitter> <randiaz95> for geo data
<FromGitter> <watzon> Anyone that disagrees that postgres is the best SQL database can fight me
<FromGitter> <randiaz95> lol
<FromGitter> <watzon> It simply is
<FromGitter> <randiaz95> they will get jumped bro
<FromGitter> <randiaz95> specially in this channel
<FromGitter> <randiaz95> sadly i've been using sqlite for learning amber; due to the fact that I don't know where to put my pgsql link
<FromGitter> <randiaz95> also GUYS OMG
<FromGitter> <watzon> I feel like anyone coming from Ruby probably appreciates Postgres, since it's recommended by Rails
<FromGitter> <randiaz95> use elephantsql.com
<FromGitter> <randiaz95> for free small db
<FromGitter> <randiaz95> 20 mb
<FromGitter> <randiaz95> I made an account for a dashboard I made when I was consulting
<FromGitter> <randiaz95> if it ever passes 20 mb it just deletes the oldest rows
<FromGitter> <randiaz95> in the api I made.
<FromGitter> <elorest> @watzon ⏎ Lucky is a great framework and solves some problems in a different way than Amber. I don't thinks it's objectively true to claim one is more full featured than the other. In both cases the design decisions were deliberate and took a lot of effort. ⏎ ⏎ Both the Amber and Lucky teams are huge fans of crystal in general and are doing their best to draw people to crystal be creating tools that
<FromGitter> ... are easy to use and bring people from Rails, Phoenix, Spring etc. In the case of Amber many decisions were also made in an eat your own dog food sort of way and is used in a few large projects. [https://gitter.im/crystal-lang/crystal?at=5e9a6b8263e7b73a5fe54add]
<FromGitter> <watzon> My main problem with Amber is that they do things more "the Ruby way" than "the Crystal way", and the tooling isn't great when compared with Lucky. It's still a good framework, but I wouldn't put it in the same category.
<FromGitter> <watzon> Lucky also has the backing of Thought Bot
<FromGitter> <elorest> Paul the creator worked for Thoughtbot and created it during innovation time but it wasn't really backed by them. Paul works for github now.
<FromGitter> <Blacksmoke16> i cant imagine the complexity both of those frameworks must have
<FromGitter> <watzon> Fair
<FromGitter> <watzon> They're both very complex
<FromGitter> <watzon> I know of someone getting ready to use Lucky for a very large production project
<FromGitter> <elorest> I know of a least one production project in Lucky and a couple in Amber.
<FromGitter> <elorest> I was an original member of the Amber core team so might be a bit biased, but and I'll admit we intentionally built things as a hybrid between Rails and Phoenix frameworks.
ur5us has quit [Ping timeout: 265 seconds]
<FromGitter> <elorest> Most of us loved haml and then slim-lang in ruby and dru and I have been using rails since 2005 but have a background in C.
<FromGitter> <elorest> Most of the advance functionality works best in slang which we helped to move toward feature completeness with slim.
<FromGitter> <randiaz95> Which has the easiest and safest auth for api services?
<FromGitter> <watzon> I mainly just like how well Lucky uses Crystal to the best of its ability. I like Amber too, but I've gotten very accustomed to Lucky's fresh take on web frameworks. For instance, the way it uses Crystal for building HTML rather than a templating framework that just adds a special syntax on top of HTML.
<FromGitter> <randiaz95> gah.. I am going to learn lucky now lol
<FromGitter> <randiaz95> I just saw that too; I must use slang
<FromGitter> <watzon> @randiaz95 that's a pretty loaded question lol
<FromGitter> <randiaz95> plus the cli autocode doesn't let me automatically send json
<FromGitter> <elorest> When Paul was getting started on Lucky we had multiple discussions to about joining forces but ultimates our goals for DSLs were too different. We both agreed however that finding and preventing errors at compile time was of utmost priority.
<FromGitter> <watzon> Yeah that's the major thing imo
<FromGitter> <watzon> Crystal gives you that ability, why not use it
<FromGitter> <elorest> Exactly.
<FromGitter> <Blacksmoke16> how does lucky handle action arguments?
<FromGitter> <Blacksmoke16> like `/user/:id`
<FromGitter> <tenebrousedge> hmmm. I tend to prefer template languages to DSLs
<FromGitter> <Blacksmoke16> like do you get `id` as a string or?
<FromGitter> <elorest> `get "/users/:user_id" do` @Blacksmoke16
<FromGitter> <watzon> I'm trying to find the answer in the documentation
<FromGitter> <Blacksmoke16> and its a string?
<FromGitter> <watzon> Oh damn, you beat me
<FromGitter> <Blacksmoke16> ha yea, > Here, the string from the request path will be returned by the some_user_id method
<FromGitter> <Blacksmoke16> > Here, the string from the request path will be returned by the some_user_id method
<FromGitter> <elorest> lol
<FromGitter> <Blacksmoke16> so guess its a string
<FromGitter> <watzon> Yeah, I thought there was a way to actually specify the type of the parameter, but maybe not yet
<FromGitter> <Blacksmoke16> is there some abstraction to help keep things try?
<FromGitter> <Blacksmoke16> i.e. if you had multiple routes where you want to resolve the ID to an actual user obj?
<FromGitter> <watzon> I'm not following
<FromGitter> <watzon> Got an example?
<FromGitter> <Blacksmoke16> well i mean like
<FromGitter> <Blacksmoke16> ```get "/users/:id" do ⏎ # Have to do a DB query here? ⏎ User.find id.to_i ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e9a6f0e8e987f3a5e25a437]
<FromGitter> <Blacksmoke16> imagine you could use some method that takes the string id and returns the obj?
<FromGitter> <Blacksmoke16> or does each route have to resolve the id
<FromGitter> <watzon> Ahh I'm sure there is. I'd have to do some digging, because I can't remember right now.
<FromGitter> <Blacksmoke16> ah no worries, just curious how they handled that
<FromGitter> <randiaz95> Wut I love about Athena is you start with ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ And over time it grows into 5 files and 100 lines each. [https://gitter.im/crystal-lang/crystal?at=5e9a6f53c7dcfc14e2c9dfd5]
<FromGitter> <Blacksmoke16> i mean ideally you wouldn't have 1 controller with everything in it
<FromGitter> <randiaz95> I've been using that as a template for each controller
<FromGitter> <Blacksmoke16> they should be grouped by type, `UserController` has CRUD for users etc
<FromGitter> <watzon> Yeah one of the things I like about Lucky is they really take separation of concerns to a new level
<FromGitter> <watzon> It's hard to wrap your brain around at first, but I ended up loving it
<FromGitter> <Blacksmoke16> also depends on what dependencies the controller has
<FromGitter> <Blacksmoke16> deff a diff approach versus lucky ha
<FromGitter> <Blacksmoke16> theres some cool stuff you can do with DI
<FromGitter> <elorest> Architecturally neither is right or wrong and has many design patterns to back it up. It was actually quite a bit of work to pull that off.
<FromGitter> <Blacksmoke16> but basic usages dont require it
<FromGitter> <Blacksmoke16> i could imagine
<FromGitter> <elorest> It works well with the concept of CRUD though.
<FromGitter> <elorest> Kemelyst which was a precursure to Amber also had a single class per action.
<FromGitter> <Blacksmoke16> the main things im most proud about athena is how actions are just methods, and controllers are just classes. makes it super easy to test, document, understand what's going on
<FromGitter> <elorest> Yeah I like that design.
<FromGitter> <Blacksmoke16> esp when paired with DI and use interfaces, to supply dependencies
<FromGitter> <Blacksmoke16> easy to make test implementations of those to use, or to swap out functionality with a 1 or 2 line change
<FromGitter> <randiaz95> So, why do all the big http server libraries in crystal all worry about openssl? I usually deploy with nginx/openssl setup in front of my apis
<FromGitter> <watzon> What do you mean "worry about"?
<FromGitter> <elorest> In amber it's turned off by default but can easily be enabled in the environment specific configuration file. https://docs.amberframework.org/amber/guides/configuration#encrypted-environment-settings
<FromGitter> <elorest> It's handy to have tls sometimes without setting up nginx in front of it on raspberry pi or something. At Nikola Motor we're running on a lot of embedded systems in vehicles and still value encryption, but don't need the overhead or advanced functionality of nginx.
<FromGitter> <watzon> Well this is going to be fun to figure out
<FromGitter> <Blacksmoke16> fun
<FromGitter> <elorest> Obviously all of our cloud instaces are using nginx.
<FromGitter> <watzon> I know more or less what's causing it, just not why it's happening
<FromGitter> <Blacksmoke16> i think its segfaulting
<FromGitter> <watzon> Yeah. This (https://github.com/watzon/cru/blob/master/examples/histogram.cr#L73) is the issue. For some reason, accessing an instance variable causes this every time. Class variables don't cause the problem.
<FromGitter> <Blacksmoke16> ``` def initialize ⏎ super() ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e9a73480480c128efc8554e]
<FromGitter> <Blacksmoke16> pretty sure this is redundant
<FromGitter> <watzon> Well it is right now
<FromGitter> <watzon> I was setting the class variable in there
<FromGitter> <randiaz95> My mind is being blown on this compression response in Athena
<FromGitter> <watzon> That class is extending this (https://github.com/watzon/cru/blob/master/src/cru/area.cr) one, which is doing the voodoo I was talking with @oprypin about earlier
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <Blacksmoke16> @randiaz95 oh?
<FromGitter> <watzon> It seems to be having an issue with the instance variable being accessed from within a proc that's assigned to a class variable being passed into a C closure
<FromGitter> <watzon> So...
<FromGitter> <watzon> Yay me
<FromGitter> <Blacksmoke16> gl
<FromGitter> <watzon> Fml lol
<FromGitter> <randiaz95> @Blacksmoke16 ⏎ ⏎ What does this mean: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9a744fe920022432b35f46]
<FromGitter> <randiaz95> I meant it physically lol it is a little difficult to understand
<FromGitter> <Blacksmoke16> https://athena-framework.github.io/athena/Athena/EventDispatcher/EventListenerInterface.html ⏎ ⏎ > Implementors must also define self.subscribed_events : AED::SubscribedEvents that represents the events that self's methods are listening on. The value of the hash is the priority of the listener. The higher the value the sooner that listener method gets executed.
<FromGitter> <Blacksmoke16> essentially says "this class is listening on the Response event"
<FromGitter> <Blacksmoke16> and its its compression that should happen after all the other response listeners in case they changed the content of the response themselves
<FromGitter> <Blacksmoke16> since its*
<FromGitter> <watzon> I wonder if it's the `h.value.data.as(Area*)` part causing the problem
<FromGitter> <Blacksmoke16> what if you make it as the child type
<FromGitter> <Blacksmoke16> since it would have an extra ivar, thus be bigger, thus not allocate the right memory?
<FromGitter> <watzon> Yeah I think that's the issue
<FromGitter> <watzon> The question is how to fix it
<FromGitter> <Blacksmoke16> define them in`macro inherited` and use `{{@type}}`?
<FromGitter> <watzon> Thought about that
<FromGitter> <watzon> Let's try
<FromGitter> <watzon> Unfortunately no
<FromGitter> <Blacksmoke16> Awe
nowhereFast has joined #crystal-lang
ur5us has joined #crystal-lang
<nowhereFast> I'm using abstract def's in modules which are explict about return types, the compiler warns that we'll have to be explict about return types in the concrete implementation too in future, considering that my use of modules in this manner somewhat resembles an interface, what is the preferred way of specifying return types in Crystal?
<FromGitter> <Blacksmoke16> You just need to specify that type return in the implementation
<FromGitter> <Blacksmoke16> So it matches the abstract defs
<nowhereFast> taking the case of `abstract def foo(x : Thing) : OtherThing`, for reasons of wanting the return type in the contract, I would have to be explict about the return type in the implementation too, but would not have to be explicit about the type of the arg?
<FromGitter> <Blacksmoke16> i.e. being able to do `def foo (x) : OtherThing` in the implementation?
<nowhereFast> that works, but ommiting the return type from the implementation causes the compiler to complain. My question is more from a place of 'what is idiomatic Crystal in this case'.
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9a7cdc5706b414e1d768a0]
<FromGitter> <Blacksmoke16> as the warning says, `add an explicit return type (String or a subtype of it) to this method as well`
<FromGitter> <Blacksmoke16> tl;dr child method should be pretty much the same as the parent
<nowhereFast> I see, so; be explict about return types and args irrespective of what has been specified in the interface.
<FromGitter> <Blacksmoke16> to be clear thats how the abstract def implementation works
<FromGitter> <Blacksmoke16> by making sure the child has the same return type as the interface, hence the error
<FromGitter> <Blacksmoke16> warning*
<FromGitter> <Blacksmoke16> you would still get a compile time warning even if you didnt have the abstract def, but i like them for documentation and such
<FromGitter> <Blacksmoke16> also iirc if the parent method is like `abstract def foo(x : Int32 | String) : Bool`
<FromGitter> <Blacksmoke16> then the child could be one method with a union type arg, or two separate methods restricted to one of the types
<FromGitter> <Blacksmoke16> nvm, thats not a thing
<FromGitter> <tenebrousedge> <__<
<FromGitter> <Blacksmoke16> could of swore that was working for me at some point
<nowhereFast> thanks, I was aiming for being specific in the interface, and letting inference do its thing for the implementation.
<FromGitter> <tenebrousedge> apparently the compiler doesn't like that
<FromGitter> <Blacksmoke16> have the match return type at least
<FromGitter> <tenebrousedge> which presumably means that it's hard for it to figure out
<FromGitter> <Blacksmoke16> but i try to use types where i can, just makes things more clear and improves the generated docs
<nowhereFast> > but i try to use types where i can, just makes things more clear and improves the generated docs
<nowhereFast> ^this is what I was looking for.
* FromGitter * tenebrousedge eats all the types
<FromGitter> <tenebrousedge> fixed it
<FromGitter> <Blacksmoke16> you can also do `def foo(x : _)` i.e. essentially being explicit about this method being able to accept any type
<FromGitter> <Blacksmoke16> same as `def foo(x)`
<FromGitter> <randiaz95> wow its so nice to have front end autorefresh and backend autorefresh set up
<FromGitter> <Blacksmoke16> \o/ i bet
<FromGitter> <randiaz95> For Athena builds
<FromGitter> <Blacksmoke16> :vince:
<FromGitter> <randiaz95> Amber has built in auto-refresh; ( Don't be jelly George )
<FromGitter> <Blacksmoke16> amber has a lot of things lol
<FromGitter> <tenebrousedge> D: VD
<FromGitter> <randiaz95> I smell Jellifer coming
<FromGitter> <Blacksmoke16> not really, be a pita to maintain all that myself
<FromGitter> <Blacksmoke16> xD
<FromGitter> <Blacksmoke16> you using athena for your project @randiaz95 ?
<FromGitter> <randiaz95> Bro I have 30 files in my repo folder
<FromGitter> <Blacksmoke16> or was that suggesting i do that for it? 😉
<FromGitter> <Blacksmoke16> noice
<FromGitter> <randiaz95> lol I am just comparing stuff; weekends are for R&D
<FromGitter> <randiaz95> I am the CEO of my life; lol I can't be using wack shizz during the weejk
<FromGitter> <Blacksmoke16> set your version to latest master commit
<FromGitter> <Blacksmoke16> fixes some bugs and allows streaming responses
<FromGitter> <randiaz95> oo stream ;)
<FromGitter> <randiaz95> my yml doesn't specify
<FromGitter> <Blacksmoke16> that would use the latest release then
<FromGitter> <Blacksmoke16> add a `commit: 634f07487efb61d1020b83a8c0c34db9e1ef1f89`
<FromGitter> <Blacksmoke16> ^ is the changelog
darkstardevx has quit [Ping timeout: 256 seconds]
<FromGitter> <randiaz95> can't i just delete shards.lock and shrds install again?
<FromGitter> <Blacksmoke16> or just add the commit and run an update?
<FromGitter> <Blacksmoke16> same end result tho
<FromGitter> <randiaz95> Newb here lol; I just sent my first PR today
<FromGitter> <randiaz95> hope he accepts it lmao
<FromGitter> <randiaz95> Well, github newb
<FromGitter> <Blacksmoke16> to what repo?
<FromGitter> <randiaz95> sentiment
<FromGitter> <randiaz95> cadmium or something to that sort
<FromGitter> <Blacksmoke16> ah nice, congrats
darkstardevx has joined #crystal-lang
<FromGitter> <randiaz95> I PRed before but first time he rejected it lol
<FromGitter> <randiaz95> i didnt write tests for it
<FromGitter> <randiaz95> This one is likely to be accepted
<FromGitter> <Blacksmoke16> good to hear, we'll find out :p
<FromGitter> <randiaz95> fresh template for new projects on monday
<FromGitter> <randiaz95> ima see if i make something cool today
<FromGitter> <randiaz95> Talk tomorrow!!
<FromGitter> <tenebrousedge> react :/
<FromGitter> <randiaz95> :')
<FromGitter> <randiaz95> I hate compiling my code so dart/typescript is uncomfortable for me
<FromGitter> <randiaz95> plus i invested in learning vanilla JS
<FromGitter> <Blacksmoke16> imma head to bed myself. @randiaz95 any questions/suggestions/issues with Athena let me know. I'd be happy to talk over architecture as well since its a bit diff than other frameworks
<FromGitter> <randiaz95> George I'll let you know
<FromGitter> <Blacksmoke16> > I hate compiling my code ⏎ yet you use crystal :P
<nowhereFast> :-)
<FromGitter> <Blacksmoke16> 👍 sounds good, o/
<FromGitter> <randiaz95> lol
<FromGitter> <randiaz95> hate compiling JS
<FromGitter> <randiaz95> didn't specify what, I love compiling exec files for systemd services
<FromGitter> <tenebrousedge> svelte is nice though
<FromGitter> <tenebrousedge> probably also elm
<FromGitter> <randiaz95> Can't manipulate the DOM through a tertiary language into JS
<FromGitter> <randiaz95> my head hurts just thinking about it
<FromGitter> <tenebrousedge> check out svelte though
<nowhereFast> took a quick look at Svelte earlier in the week, it does look nice
<nowhereFast> I like the direction it's taken, looks like Vue 3 will be doing similar things.
ur5us has quit [Ping timeout: 246 seconds]
ua has quit [Ping timeout: 256 seconds]
ua has joined #crystal-lang
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
<oprypin> watzon, hey i still havent seen the struct wherre you added the data field :p
<oprypin> please publish a repro or just all the code and let's see
renich has joined #crystal-lang
<renich> Good time_of_day to you!
<renich> I was wondering, I have a bunch of jekyll files I want to parse. They have a yaml-like header. It starts with '---' and ends with '---'. I want to match the stuff between these two. With gawk, I could just: `gawk '/---/,/---/{i++}i==1'` and that would work. How do I do this in Crystal?
<renich> sed also works: `sed '/---/,/---/p' somefile`
<oprypin> renich, https://crystal-lang.org/api/master/Enumerable.html#skip_while(&)-instance-method ¯\_(ツ)_/¯
<oprypin> renich, https://crystal-lang.org/api/master/IO.html#each_line(*args,**options)-instance-method ¯\_(ツ)_/¯
<renich> oprypin: OK, I'll try that. Not exactly regex, but it will do, I think.
<FromGitter> <sam0x17> there's also mint lang for frontend -- been meaning to give it a try
alexherbo2 has joined #crystal-lang
Deuns has left #crystal-lang [#crystal-lang]
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo21 is now known as alexherbo2
nowhereFast has quit [Ping timeout: 265 seconds]
darkstardevx has quit [Ping timeout: 260 seconds]
darkstardevx has joined #crystal-lang
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
<FromGitter> <straight-shoota> renich, you could also take a look at https://github.com/straight-shoota/criss/blob/master/src/frontmatter.cr#L41
alexherbo2 has joined #crystal-lang
alexherbo22 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo2 has joined #crystal-lang
alexherbo22 has quit [Ping timeout: 256 seconds]
darkstardevx has quit [Remote host closed the connection]
darkstardevx has joined #crystal-lang
<oprypin> straight-shoota, do you know what makes binaries show up at https://github.com/crystal-lang/crystal/releases ?
<oprypin> i dont mean generally, i mean the actual process to build and put them there
renich has quit [Quit: renich]
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo21 is now known as alexherbo2
darkstardevx has quit [Remote host closed the connection]
darkstardevx has joined #crystal-lang
darkstardevx has quit [Remote host closed the connection]
darkstardevx has joined #crystal-lang
darkstardevx has quit [Remote host closed the connection]
darkstardevx has joined #crystal-lang
ur5us has joined #crystal-lang
DTZUZU has joined #crystal-lang
DTZUZU2 has quit [Ping timeout: 264 seconds]
darkstardevx has quit [Remote host closed the connection]
darkstardevx has joined #crystal-lang
<oprypin> where should i open an issue about crystal's docker image?
zorp_ has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
zorp has joined #crystal-lang
darkstardevx has quit [Remote host closed the connection]
<FromGitter> <straight-shoota> Exactly
ur5us has quit [Quit: Leaving]
<FromGitter> <tenebrousedge> `/(?<=--).*?(?=--)/` maybe
<FromGitter> <straight-shoota> I'm not sure about the exact process, but I suppose the release entry on GitHub is created manually
<FromGitter> <straight-shoota> Release builds are made with in https://github.com/crystal-lang/crystal-dist
hightower2 has joined #crystal-lang
<hightower2> Hey is there an elegant way to make string read only?
<hightower2> actually n/m
<oprypin> hightower2, wat. string are always read only
<FromGitter> <stronny> you mean somehow control write through pointers? I don't think Crystal has it in general
<FromGitter> <stronny> use slices; case in point: as you remember String#to_slice returns r/o slice
<FromGitter> <stronny> if you need it statically analyzed you probably ask too much lol
<oprypin> yea but readonly slice is even easier to bypass than a normal string
<FromGitter> <stronny> not unintentionally though
<oprypin> stronny, even unintentionally
<FromGitter> <stronny> you'll have to take a pointer, and that's intention! =)
<FromGitter> <stronny> or... hm... if I have an r/o slice, will it inherit r/o if I get `slice + n` or `slice[a,b]`?
<oprypin> stronny, im not sure you understand. there is no way to modify a string in Crystal
<FromGitter> <stronny> what did we do to limit strstr? didn't we write \0 directly to a string?
<oprypin> stronny, we had to use to_unsafe, that's intent
<FromGitter> <stronny> so "there is no way to modify a string in Crystal with safe API", right?
<oprypin> ye
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #crystal-lang
alexherbo28 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo28 is now known as alexherbo2
<FromGitter> <ImAHopelessDev_gitlab> good morning
<FromGitter> <ImAHopelessDev_gitlab> @randiaz95 you compile JS?
<FromGitter> <ImAHopelessDev_gitlab> what'd i miss
<FromGitter> <tenebrousedge> typescript, elm, coffeescript, svelte
<FromGitter> <tenebrousedge> and friends
<FromGitter> <tenebrousedge> opal
<FromGitter> <ImAHopelessDev_gitlab> back when i was working with nodejs, i thought of using coffeescript
hightower2 has quit [Remote host closed the connection]
<FromGitter> <faustinoaq> Hi community Can we relay messages between http://crystallang.slack.com/ and https://gitter.im/crystal-lang/crystal?
<FromGitter> <faustinoaq> Like we are already doing with IRC?
<oprypin> i say f* slack
<FromGitter> <faustinoaq> XD
<FromGitter> <faustinoaq> oprypin, Well, that escalated quickly
<oprypin> it sure did! one day, we had a unified chat, next day the community is split, just like that
<FromGitter> <tenebrousedge> some people like threads <_<
<FromGitter> <faustinoaq> Almost every open source community behave like that, forking is like a natural thing XD
<FromGitter> <faustinoaq> Does someone know if rapbian repo is already updated to crystal v0.34.0? http://public.portalier.com/raspbian/
<FromGitter> <faustinoaq> BTW, the rapbian repo is not official yet right?
<FromGitter> <Blacksmoke16> does snap work on there?
<FromGitter> <Blacksmoke16> if so that would deff be updated more quickly, and could use nightly
<FromGitter> <faustinoaq> Oh snap, I forgot it, let me try
<oprypin> i literally download that exe and run it the same way locally and it works
<FromGitter> <tenebrousedge> it wants blood :E
<FromGitter> <stronny> do you need `.\`?
<FromGitter> <ImAHopelessDev_gitlab> wait, there is a slack now?
<FromGitter> <stronny> try running `dir`, maybe it isn't where you think it is
<oprypin> stronny, yea powershell needs it
<FromGitter> <tenebrousedge> @ImAHopelessDev_gitlab that is beyond our borders. You must never go there
<FromGitter> <ImAHopelessDev_gitlab> lol
<oprypin> ImAHopelessDev_gitlab, we cant lose you 😢
<oprypin> ok i just literally copy pasted that whole ENV block and set the same variable values locally
<oprypin> ---------------------------crystal.exe - System Error---------------------------The code execution cannot proceed because LLVM-C.dll was not found. Reinstalling the program may fix this problem. ---------------------------OK ---------------------------
<FromGitter> <ImAHopelessDev_gitlab> "crystal.exe" that's a first
<oprypin> ImAHopelessDev_gitlab, yea get it while it's hot https://github.com/oprypin/crystal/suites/608489308/artifacts/4607317
<FromGitter> <ImAHopelessDev_gitlab> damn, noice
<oprypin> aah i've fooled myself
<oprypin> it's finding C:\Program Files\LLVM\bin\LLVM-C.dll which i forgot i have
<oprypin> the *good* news might be that you can get that exe + crystal repo + LLVM official installer and you can run crystal
<FromGitter> <ImAHopelessDev_gitlab> wow
<FromGitter> <ImAHopelessDev_gitlab> it's happening.gif ?
<FromGitter> <faustinoaq> 🙌
<oprypin> it's happened already
<oprypin> this is crystal master branch, not some fork
<oprypin> *but* most crystal programs won't actually work, of course
<FromGitter> <stronny> is it gonna need some LLVM redist? or maybe link statically if it's possible?
<FromGitter> <stronny> usually I advocate agains static build, but on windows it may actually be a good idea
<oprypin> stronny, yea do you know how to make it static?
<FromGitter> <stronny> no idea
<FromGitter> <stronny> last time I built something for windows was virtual pascal circa 2002
<FromGitter> <faustinoaq> @Blacksmoke16 Looks like crystal snap is not available for armhf :(
<FromGitter> <Blacksmoke16> :(
<FromGitter> <Blacksmoke16> rip
<FromGitter> <Blacksmoke16> is that the same thing as `arm-linux-gnueabihf`?
<FromGitter> <faustinoaq> I think so
<FromGitter> <faustinoaq> I guess I'll keep using crystal 0.33.0 on my IoT project 😅
<FromGitter> <Blacksmoke16> assuming crystal build on it (which its a tier 2 platform, id imagine it would), maybe a PR would be accepted to also build one for that arch in snap
<oprypin> looks like it's this: `cl ***/MT*** /c src\llvm\ext\llvm_ext.cc -I llvm\include /Fosrc\llvm\ext\llvm_ext.o`
<oprypin> (asterisks only for emphasis)
<FromGitter> <faustinoaq> @Blacksmoke16 I think u are right, I can also compile it by myself 😎
<FromGitter> <faustinoaq> I'm using @ysbaddaden rasbian repo because it is super easy to setup
<oprypin> i was wondering, how does one even browse any files under http://public.portalier.com/raspbian/
hightower2 has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> easy, just right click, inspect element. *taps head*
<FromGitter> <tenebrousedge> I was wondering that too oprypin
<oprypin> tenebrousedge, stiill no idea
<hightower2> oprypin, stronny: how did you envision that string-from-string from the other day would actually be used to create two strings sharing the same bytes? Based on your suggestions, I can now manipulate string header to affect the size of string as crystal sees it (this doesn't insert \0), and through a pointer I can also set some byte to 0. But, how to actually create a new String object? All constructors I've found for String do copy
<hightower2> the bytes (i.e. String.new(Bytes) and String.new(Pointer(UInt8)))
<oprypin> hightower2, you cant and shouldnt
<oprypin> you're modifying the old string so whats the point of creating a new object, just use the old one
<oprypin> it can only be one kind of string at a time
<hightower2> yes the whole question arised from the fact that various string search functions do not accept range within which to search (they at best include the starting offset, not the ending one)
<oprypin> you modify the original string, do something with it, then modify it to something else, do something with it
<hightower2> so my wish was to create resized strings using the same bytes, to pass to such functions as argument
<hightower2> and as mentioned I could live with inserting \0 if/when need be
<oprypin> hightower2, i don't understand what's the problem
<oprypin> you have the modified string so just use it, what exactly makes it so you want to create a new String object (which you can't) that you can't do with the old modified one
<hightower2> let's say I want to do a regex search within bytes 1000..1100 of a string (without using a regex rule to skip first 1000 chars, obviously)
<hightower2> how would I do it? (and also without extracting a substring of the original string into the new one by copying the bytes)
<oprypin> modify the header so it has bytesize 1100, then search with regex on that string starting from 1000
<oprypin> or, well, append this to your regex `(?<=.{1000})`
<oprypin> prepend*
<FromGitter> <watzon> @oprypin sorry, what struct with data field?
<oprypin> UI::AreaHandler
<FromGitter> <watzon> Here's the `Area` class
<FromGitter> <watzon> And here's where I was trying to extend it https://github.com/watzon/cru/blob/master/examples/histogram.cr
<FromGitter> <ImAHopelessDev_gitlab> aye, a ui library
<FromGitter> <ImAHopelessDev_gitlab> insta-starred
<FromGitter> <watzon> But it segfaults when trying to access an instance variable
<FromGitter> <watzon> Like `@datapoints`
<oprypin> watzon, thats very nice but UI::AreaHandler
<oprypin> **where is it defined**
<hightower2> oprypin, yeah, wanted to avoid "skipping" explicitly. But OK, should do it, thanks.
<oprypin> hightower2, did you see my non-regex suggestion? like, it just works, what s the problem
<oprypin> ok guess now i just need to try to run it
<FromGitter> <watzon> Yeah you should get a segfault
<FromGitter> <watzon> Something like this https://hasteb.in/otolekaf.css
<oprypin> gtk??
<FromGitter> <watzon> LibUI uses GTK for Linux
<FromGitter> <watzon> It's basically just a cross platform abstraction over existing UI libs
<oprypin> what's the equivalent of `foo $(bar)` in powershell, god
<oprypin> if i run that, it splits by newline, rather than any whitespace
<FromGitter> <watzon> Lol I have no clue
<hightower2> oprypin, sorry which one, strstr? Yes, I already use this to find the offsets of the text in which I want to search. But after that, I need to do a more flexible search within the identified region.
<hightower2> oprypin, btw, so in Crystal's implementation for String the string bytes follow right after the header?
<oprypin> hightower2, yes. `[typeid:4][bytesize:4][charcount:4][c][c][c][c][c][c][c][c][\0]`
<FromGitter> <stronny> @hightower2 I suugested you add a new constructor locally
<oprypin> so you just alter bytesize and use normal operations on it
<FromGitter> <stronny> it would be very unsafe so beware
<hightower2> stronny yes, I was just thinking about this as I opened the source and looked into the implementations
<hightower2> of the existing constructors
<hightower2> but as oprypin confirms, if the bytes follow the header then it's not really possible either way..
<hightower2> other than just playing with the existing one
<hightower2> ok great, thanks
<oprypin> yes i said that before multiple times, just didnt explain why
<FromGitter> <stronny> what's not possible?
<oprypin> have multiple different strings which point to the same data at the same time
<FromGitter> <stronny> why not?
<hightower2> right
<hightower2> because the bytes follow the string header, there is no pointer pointing to the bytes
<hightower2> so it's always the same string/same header
<FromGitter> <stronny> you'll just have to have a larger patch :3
<hightower2> indeed :-)
<oprypin> hightower2, hey technically you can have it if the strings are non-overlapping and have 13 bytes gap between them ;p
<hightower2> but actually ....
<hightower2> I could write a class whose method to_unsafe returns the pointer of the other string's bytes :)
<oprypin> uuuuu
<FromGitter> <stronny> yes, why does it have to be a String?
<hightower2> well, yes.. .maybe convenient though to subclass a String, simply because I do need it to behave as a string really
<hightower2> and do need the string header which I can manipulate, etc.
<FromGitter> <stronny> moreover, if you need some realtime shit with no allocations, Crystal is a wrong tool
<oprypin> anyway got my answer. `foo $(bar)` seems to be the same as `eval "foo $(bar)"` which would be `Invoke-Expression "foo $(bar)"` in powershell
<FromGitter> <stronny> covenient!
<FromGitter> <stronny> you can't subclass String though =(
<oprypin> ^
<hightower2> well... good point... but yeah, looks interesting even if not a subclass of string.. will develop the idea some more... thanks folks
<FromGitter> <stronny> could you share some example code?
<FromGitter> <stronny> what is the problem you are solving, at a high level
<hightower2> At a high level, I have a bunch of text through which I want to scan/search for various things as fast as possible, while being able to set start and end positions for those searches (which can be anything, from String#index to regex matching etc.). So my idea was to use LibC functions since they're much faster and I just need pointers/offsets.
<hightower2> But once I narrow down to specific sections (i.e. have the offsets), then I do need to run some regular finding/matching using regexes
<FromGitter> <stronny> read the bytes into a Bytes, skip String altogether
<oprypin> well this is basically forfeiting stdlib anywaya
<FromGitter> <stronny> you can have regexps with LibPCRE directly
<hightower2> yeah well, didn't want the whole code to look like C, but just wanted to replace those few functions which always run and need to be as fast as possible
<FromGitter> <stronny> well it's up to you to come up with the right tradeoff
<FromGitter> <stronny> low-level but with full control vs. higher level with some limitations
<hightower2> it's a good point though, or future modification... calling LibC from Crystal is still so much nicer than C
<FromGitter> <j8r> giving up with Godot @ImAHopelessDev_gitlab , can't get the C# project compiling under Godot
<oprypin> c++ is nice these days 😂
<FromGitter> <stronny> unity is c# right?
<FromGitter> <j8r> maybe I will write in GDScript, and using C++ in some places where perf is needed
<oprypin> stronny, yes
<FromGitter> <stronny> well there you go
<FromGitter> <j8r> anyone can recommend a game engine (3D)?
<FromGitter> <j8r> "Easy", please :)
<FromGitter> <watzon> Godot?
<FromGitter> <stronny> I guess two most popular right now are unity and unreal
<FromGitter> <watzon> Oh I missed the above
<FromGitter> <watzon> Lol
<FromGitter> <j8r> Open Source also
<FromGitter> <watzon> I'd probably go Unity after Godot, but you're not going to find an open source engine as good as Godot
<FromGitter> <j8r> I can take another shot using GDScript
<oprypin> 😬
<FromGitter> <j8r> Right, there is IDtech with lot of forks. ⏎ I am afraid it will be too much for me 💀
<FromGitter> <stronny> I'm unaware of an opensource engine as common as those two
Xeago has joined #crystal-lang
<FromGitter> <stronny> I guess another option is to make a mod for skyrim lol
<FromGitter> <Blacksmoke16> heres prob a simple question, https://play.crystal-lang.org/#/r/8wsp how do you sort an array with `sort_by`?
<FromGitter> <Blacksmoke16> ideally it should b e, yahoo, google, facebook
<FromGitter> <stronny> so what's the problem? it's soreted
<FromGitter> <Blacksmoke16> i guess i want reverse sort
<FromGitter> <Blacksmoke16> which i suppose i would need `.reverse` would be the easiest solution...
<FromGitter> <stronny> #sort with a block
<FromGitter> <stronny> then `* -1`
<FromGitter> <Blacksmoke16> `.sort_by { |item| -(item[1][:priority] || 0) }` nvm, that seems to do the trick
<FromGitter> <Blacksmoke16> neat
<FromGitter> <stronny> I guess there's room for a `ascending : Bool = true` argument
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b2c6f2ff88975b42e60a8]
<FromGitter> <Blacksmoke16> that and reverse would be helpful
<FromGitter> <stronny> so what's gonna happen if I type `partenr` instead of `partner`?
<FromGitter> <Blacksmoke16> you'd wonder why that one was missing
<FromGitter> <Blacksmoke16> not sure what i could do about that
<FromGitter> <stronny> make it static
<FromGitter> <Blacksmoke16> sec
<FromGitter> <Blacksmoke16> mm would need a way to resolve a constant to its value in macro land
<FromGitter> <Blacksmoke16> er actually
<FromGitter> <stronny> `@[ADI::Register(3, "Yahoo", name: "yahoo", tags: [{name: "partner", priority: 10}])]` I would be bothered by this syntax
<FromGitter> <Blacksmoke16> what would you rather?
<FromGitter> <stronny> I would wish for something much simpler like `@[ADI::Partner(Yahoo: 10)]`
<FromGitter> <Blacksmoke16> sure, but how would you do that :P
<FromGitter> <stronny> hey, that's your job! =)
<FromGitter> <Blacksmoke16> the first two arguments are for the constructor of the `FeedPartner` class
<FromGitter> <Blacksmoke16> `name` is setting the name of the service
<FromGitter> <Blacksmoke16> annotations can only be accessed by name so cant really just define your own type, plus would still need a way to pass the arguments
<FromGitter> <Blacksmoke16> and it cant be `ADI::Tag` since it needs to be specific to a given service, not the class the service is created from
DTZUZU2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> so best you're going to get for now ha
<FromGitter> <Blacksmoke16> you can do this now tho ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b2f3fa9ca18620648bb5c]
<FromGitter> <Blacksmoke16> :shrug:
DTZUZU has quit [Ping timeout: 250 seconds]
<FromGitter> <stronny> Why do you even need this struct?
<FromGitter> <stronny> isn't it just `Array(String)`?
<FromGitter> <stronny> or maybe `Array({Int32, String})` if you need those ids
<FromGitter> <stronny> and wouldn't this data come from configuration rather than be hardcoded into binary?
<FromGitter> <Blacksmoke16> the annotations are used to build out a DI service container
<FromGitter> <Blacksmoke16> the end result of this is like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b30d4e920022432b610b6]
<FromGitter> <Blacksmoke16> idea is that the partner manager could be injected into a controller or something so you could do `GET /partners/2` and resolves to the `facebook` object
<FromGitter> <Blacksmoke16> so to support additional partners you just add another annotation and it all just works
alexherbo21 has joined #crystal-lang
<FromGitter> <stronny> after recompilation and redeployment
<FromGitter> <Blacksmoke16> well yea
<FromGitter> <stronny> instead if you store it in a config file or even database then you have it at runtime
<FromGitter> <Blacksmoke16> that would be one way to do it
<FromGitter> <Blacksmoke16> ofc this is also a simple example, feed partners could have dependencies of their own etc
alexherbo2 has quit [Ping timeout: 250 seconds]
alexherbo21 is now known as alexherbo2
<FromGitter> <stronny> ` private getter google : FeedPartner { FeedPartner.new(1, "Google") }`
<FromGitter> <randiaz95> Doesn't code need to be generated for each new partner?
<FromGitter> <stronny> what if I have
<FromGitter> <stronny> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b322fa9ca18620648c36c]
<FromGitter> <Blacksmoke16> in a real application i would make the names like `myapp_feeds_google` or `myapp_search_google`
alexherbo24 has joined #crystal-lang
<FromGitter> <Blacksmoke16> same idea as namespacing code to prevent conflicts from diff shards
<FromGitter> <stronny> okay.jpg
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo24 is now known as alexherbo2
<FromGitter> <Blacksmoke16> @randiaz95 it would just add another ivar/getter to the contaienr
<FromGitter> <Blacksmoke16> since they're all based on the same class
<FromGitter> <Blacksmoke16> but good call on the constants
<FromGitter> <Blacksmoke16> be easier to document and such as well
<FromGitter> <kingsleyh> hello does anyone know if there is any particular performance hit with converting things into a BigInt e.g. `BigInt.new(some_hex_string, 16)`
<FromGitter> <stronny> I think you should profile yourself
<FromGitter> <kingsleyh> @stronny what's the best way of profiling it
<FromGitter> <kingsleyh> using Benchmark?
<FromGitter> <stronny> that's one way
<FromGitter> <stronny> another is linux's `perf`
<FromGitter> <kingsleyh> thanks
<FromGitter> <Blacksmoke16> fwiw you can also do `"3a060dbf8d1a5ac3e67bc8f18843fc48".to_big_i(16)`
<FromGitter> <Blacksmoke16> does same thing you're doing, but just a bit cleaner
<FromGitter> <kingsleyh> thanks
<FromGitter> <stronny> that's just another syntax, shout be no diff in performance
<FromGitter> <Blacksmoke16> right
<FromGitter> <dscottboggs_gitlab> why is slice.size `Int32` instead of `LibC::SizeT`?????
<FromGitter> <dscottboggs_gitlab> If there's no good reason for this I'm making a PR right now.
<FromGitter> <stronny> Slice is Crystal type
<FromGitter> <dscottboggs_gitlab> I should never have to worry about `Slice(T)#size` being negative, that makes no sense
<FromGitter> <kingsleyh> I'm looking into this https://github.com/q9f/secp256k1.cr for SushiChain - but currently it's like 7000% slower than my openssl bindings
<FromGitter> <stronny> that was already debated
<Stephie> @dscottboggs_gitlab crystal never uses platform-dependent types outside of unsafe code
<FromGitter> <dscottboggs_gitlab> @stronny why does that matter? The size of a pointer is architecture dependent and can never be negative.
<FromGitter> <stronny> afair the argument for Int vs. UInt is you will have problems with math
<FromGitter> <dscottboggs_gitlab> At the very least it should be `UInt32` since crystal doesn't support 16 or fewer-bit architectures
<Stephie> Pointer#address is always UInt64 in crystal
<Stephie> even on 32bit
<Stephie> this is fundamental
<Stephie> types do not change based on platform
<Stephie> unless you are talking to C
<Stephie> it will feel weird to you if you are a C programmer, but crystal is not designed for low-level work
<FromGitter> <dscottboggs_gitlab> > you will have problems with math ⏎ ⏎ only bitwise math, at which point the expectation (with pointer offsets) is that you'll be working with unsigned integers. Using a signed integer is the weird way.
<Stephie> the actual bug is slices not being able to represent more than 4gb of memory, which is a real problem
<FromGitter> <stronny> @dscottboggs_gitlab I would actually support UInt sizes, I'm just remembering devs' arguments
<FromGitter> <dscottboggs_gitlab> > it will feel weird to you if you are a C programmer ⏎ ⏎ I write crystal primarily but jump between languages a *lot*, and having signed sizes for slices is super bizarre
<Stephie> slice size should be UInt64 i think
<Stephie> or at least greater than 32bit
<FromGitter> <dscottboggs_gitlab> @stephie it's currently 31 bits...
<Stephie> yes
<Stephie> it's a problem
<Stephie> array size and string size are unlikely to change
<Stephie> they'll be limited to 2^31 items
<Stephie> slice size probably should change
<Stephie> it's unreasonable to allocate an array that big on the heap anyway
<Stephie> for slices, the situation is different
<FromGitter> <dscottboggs_gitlab> TBH I don't get why crystal has both Slice and Array. Array methods should be implemented on Slice, why not
<Stephie> ...
<Stephie> array is managed and resizable
<Stephie> it's on the heap
<Stephie> it resizes as you use it
<FromGitter> <dscottboggs_gitlab> oh,
<Stephie> slice is a window of memory
<FromGitter> <dscottboggs_gitlab> slice doesn't automatically resize
<Stephie> totally different datastructures
<FromGitter> <stronny> Slice itself is a struct
<Stephie> yes
<FromGitter> <dscottboggs_gitlab> but by default it is on the heap as well
<Stephie> slice is a pointer + size
<Stephie> it's not
<FromGitter> <dscottboggs_gitlab> so is an array
<Stephie> if you use Slice.new it happens to heap allocate
<Stephie> it's easy to create a slice referring to stack memory
<Stephie> but obviously unsafe
<FromGitter> <stronny> @dscottboggs_gitlab a philosophical question: do you think C has arrays?
<FromGitter> <dscottboggs_gitlab> yeah, but by default all of the `.new` methods on it are heap allocated and zero-initialized.
<Stephie> what are you even using this for?
<FromGitter> <watzon> @stronny I'm gonna answer. No.
<Stephie> @dscottboggs_gitlab because they're the only safe constructors
<Stephie> StaticArray exists for the stack
<FromGitter> <stronny> StaticArray has severe size limitations
<Stephie> yeah
<Stephie> keep them small
<FromGitter> <dscottboggs_gitlab> @stronny only static arrays, dynamic arrays are not supported by the C stdlib in a decent way
<FromGitter> <stronny> `a[x]` isn't an array though
<FromGitter> <dscottboggs_gitlab> @stephie yes which is why I was saying that slices are *by default* for heap pointers. Sure you can take a slice of a StaticArray but that's not the *default* usage of a slice
<FromGitter> <stronny> it's literally just "take a pointer a then offset it by `x*sizeof(typeof(a))`
<FromGitter> <dscottboggs_gitlab> so is a static array
<FromGitter> <stronny> it's not!
<FromGitter> <stronny> it's a bare pointer with offsets
<FromGitter> <stronny> arrays have sizes at the least
<FromGitter> <dscottboggs_gitlab> true, there are no bounds checking that way.
<FromGitter> <dscottboggs_gitlab> I like `#unsafe_at` bettere
<Stephie> scary
<Stephie> very scary
<Stephie> please never put your code on the internet
<FromGitter> <stronny> harsh!
<FromGitter> <dscottboggs_gitlab> I meant that I like `#unsafe_at` as an API for accessing without bounds checking rather than that I would use it rather than `.[]` usually
<FromGitter> <dscottboggs_gitlab> sorry to be unclear
<FromGitter> <dscottboggs_gitlab> fuck that was a terribly written message
<FromGitter> <dscottboggs_gitlab> In C, if you write a function that takes a `char[N] x`, where `N` is some sort of defined constant, even if you don't know what `N` is, you can act safely on `x`, just as much as you can on StaticArray, which is what I meant.
<FromGitter> <dscottboggs_gitlab> so only in that rare case @stronny does C have arrays, I didn't mean to be any more controversial than that.
<Stephie> Oh right
<Stephie> Yes, I understand you now
<FromGitter> <stronny> why does this compile? how does it work? https://carc.in/#/r/8wt1
<FromGitter> <dscottboggs_gitlab> `Wat.new` sets @w to 0?
<Stephie> i have no idea how that works @stronny
<FromGitter> <stronny> that's not an interesting part
<Stephie> you'll have to look at the assembly
<Stephie> it's probably luck though
<FromGitter> <stronny> yes, that's my forst question: why does it comile?
<oprypin> why not? pointerof is unsafe
<FromGitter> <dscottboggs_gitlab> ☝️
<FromGitter> <stronny> just declaring something unsafe isn't a get out of jail card
<Stephie> why does it *compile*, of course it should compile
<Stephie> it compiles in C
<Stephie> pointers are unsafe you can do unsafe things
<FromGitter> <stronny> some form of escape analysis would be helpful here
<Stephie> why does it work??
<Stephie> I ave no clue
<Stephie> we're not going to put tooling into making unsafe code safer
<Stephie> rather expanding what is safe
<Stephie> pointers will always be unsafe in crystal
<Stephie> and you will always be able to segfault with them
<FromGitter> <dscottboggs_gitlab> I see what you mean @stronny and have been trying to figure it out for a minute now.... the only thing I can think of is a race condition with `free()`...haha
<FromGitter> <stronny> well there are different levels of unsafe
<Stephie> thats a struct
<oprypin> stronny, https://carc.in/#/r/8wt9
<Stephie> there is no free
<oprypin> w = a_struct is a copy
<FromGitter> <dscottboggs_gitlab> sorry...misspoke
<FromGitter> <stronny> I think taking pointers of Values is especially unsafe
<oprypin> well duh
<FromGitter> <dscottboggs_gitlab> not sure what the word is for struct values getting freed
<Stephie> well they kinda dont
<oprypin> it's not freed, that stack frame gets forgotten about
<FromGitter> <stronny> structs aren't getting freed
<Stephie> but it's just stack deallocation
<Stephie> i guess
<FromGitter> <stronny> because they aren't malloced
<Stephie> is how you'd describe it
alexherbo2 has quit [Ping timeout: 258 seconds]
<FromGitter> <dscottboggs_gitlab> yeah, so like, before that memory gets overwritten, you read from it
<oprypin> yeah
<FromGitter> <dscottboggs_gitlab> but you've already released the reference to it, so who knows what it'll be, it's a race condition with anything else that might overwrite it
<FromGitter> <stronny> that gives me an idea
<FromGitter> <stronny> https://carc.in/#/r/8wtf
<FromGitter> <stronny> what am I missing?
<FromGitter> <dscottboggs_gitlab> omg that URL
<FromGitter> <dscottboggs_gitlab> 😂
<FromGitter> <stronny> wat1 frame should get overwritten, shouldn't it?
<oprypin> stronny, w1 = wat1.value is a copy
<FromGitter> <dscottboggs_gitlab> @oprypin of a pointer
<oprypin> no
<oprypin> stronny, like do u know C
<FromGitter> <dscottboggs_gitlab> oh, you're right
<oprypin> it's like writing Wat1 w1 = *wat1()
alexherbo2 has joined #crystal-lang
<FromGitter> <stronny> sooo how do I do `*Wat1 w() { &new_wat(); }` and later `*w()`?
<FromGitter> <stronny> I don't get where does memory gets copied
<FromGitter> <stronny> ooooh
<FromGitter> <stronny> at `= `
<FromGitter> <dscottboggs_gitlab> @stronny that's not C, that's C++
<FromGitter> <stronny> isn't `&` in C is pointerof?
<oprypin> dscottboggs_gitlab, no it's fine c++, just a mistake `*Wat1` -> `Wat1*` i guess
<FromGitter> <dscottboggs_gitlab> no you're right, I was thinking that was a constructor
<FromGitter> <dscottboggs_gitlab> I'm gonna stop talking now
<oprypin> stronny, well this is how. you're doing it
<oprypin> stronny, this is what will happen then https://carc.in/#/r/8wth
<FromGitter> <stronny> finally! https://carc.in/#/r/8wti
<oprypin> i guess the stack frame of the `.value` call overwrites the memory before u get to that value
<oprypin> you dont need the bump, it's not doing anything noticeable
<FromGitter> <stronny> Initially I wanted to check the member value, because it worked as expected lol
<FromGitter> <stronny> unexpectedly worked as expected or something
<hightower2> Hey oprypin stronny I got a working implementation of that String-like class (well, almost done). I ran some benchmarks just to see whether it even makes sense to develop the idea further:
<FromGitter> <stronny> so basically you have const time with custom sstring
<FromGitter> <stronny> but looks like linear time O(N = slice size) of vanilla String
<FromGitter> <stronny> @hightower2 which is quite normal given that vanilla String copies the memory
<FromGitter> <stronny> `23.04ns` idk about that, doesn't dram have typical latency around 90ns?
<FromGitter> <stronny> maybe you have CPU caches along the way
<hightower2> stronny hm right that's a good observation. If I run the same test with selecting just 1 char at the same starting offsets, then the custom class is still at the same performance while string[] is faster (cca. 70M vs. 40M/s)
<FromGitter> <stronny> because you have to flip the bytes, while String doesn't have to
<FromGitter> <ImAHopelessDev_gitlab> @dscottboggs_gitlab hey
<FromGitter> <dscottboggs_gitlab> yo @ImAHopelessDev_gitlab what's up
<FromGitter> <ImAHopelessDev_gitlab> @dscottboggs_gitlab nm, long time no c
<hightower2> stronny Due to all the complications with it I think I won't use it in the initial implementation, but will rather resort to what oprypin suggested... which was to limit the end with modifying the header, and to modify the start by either specifying start offset or skipping first X chars in regex matches
<FromGitter> <dscottboggs_gitlab> I've been around, just not as active. Busy Boggs, they call me
<oprypin> hightower2, hey u can skip the end with regex matches too
<FromGitter> <watzon> Hey Busy Boggs, how's it going?
<FromGitter> <dscottboggs_gitlab> hahaha
<FromGitter> <ImAHopelessDev_gitlab> Busy Boggs™
<FromGitter> <dscottboggs_gitlab> long week, kinda tired. Gonna play some CS:GO and take a nap today 😛
<FromGitter> <ImAHopelessDev_gitlab> last time i played cs go, i played the prison roleplaying servers
<FromGitter> <ImAHopelessDev_gitlab> so fun
<FromGitter> <stronny> hey I get an idea
<FromGitter> <stronny> who's gonna redo dwarf fortress in crystal?
<hightower2> oprypin, got an example?
<FromGitter> <dscottboggs_gitlab> @ImAHopelessDev_gitlab is the games guy
<oprypin> hightower2, well i showed you a lookbehind construct at the beginning, now you just add a lookahead at the end
<hightower2> yes but I don't know where the end is.. I just know how many chars from the beginning I need to stop at.
<FromGitter> <ImAHopelessDev_gitlab> could do sdl bindings, or crsfml. but iuno just off the top of my head
<FromGitter> <ImAHopelessDev_gitlab> i aint doing it ,that's for sure ;D
<oprypin> hightower2, how can you not know where the end is. do you have infinite RAM?
<FromGitter> <stronny> lookahead takes a constant
<hightower2> yes I can calculate it from total string size - my stop point. But I assumed this would be slow. Will benchmark. Thanks for the idea
<FromGitter> <stronny> but he needs an expression like (strlen - start_offset - search_len)
<hightower2> right
<FromGitter> <stronny> and you probably can't compile this regex
<oprypin> yea
<FromGitter> <stronny> and compiling it each time will be costly
<hightower2> that's true
<hightower2> yeah, right, for that same reason neither look-behind nor look-ahead would be desirable in the regex
<hightower2> good point
<FromGitter> <stronny> what would be cool is AOT regex compilation in crystal heh
<FromGitter> <stronny> like if you have a constant value it gets replaced by the matching code
<FromGitter> <dscottboggs_gitlab> no reason we couldn't do that, but i can't imagine that would be a pre-1.0 priority
<FromGitter> <lbarasti> Hello! What's your favourite implementation of `find_index` in Crystal? I've got ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b50b70480c128efcb8034]
renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Indexable.html#index(offset:Int=0,&)-instance-method
<FromGitter> <Blacksmoke16> that
<FromGitter> <tenebrousedge> yus
<FromGitter> <watzon> Lol always good to check the standard library first
<FromGitter> <tenebrousedge> there's also `bsearch_index`
<FromGitter> <tenebrousedge> apparently o.o
<renich> thank you straight-shoota!
<FromGitter> <lbarasti> Boom, thanks, I didn't see #index - because I didn't look hard enough 😪
<renich> I've managed to pull it off; though, it might mean eternal damnation due to the angering of the programming gods: https://gist.github.com/renich/7954c4fa5e46f31c7eb9d03b0ddd4743
<renich> I know it completely sucks, but I managed to migrate ~300 articles from jekyll to pelican (which supports rst natively).
<renich> I am, though, interested in improvements. I will take a look at the frontmatter.cr file straight-shoota sent me. Any other suggestions are welcome.
<FromGitter> <Blacksmoke16> `#gets` has a `chomp` option which would remove trailing \n
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/IO.html#gets(delimiter:String,chomp=false):String?-instance-method
DTZUZU2 is now known as DTZUZU
<renich> ah! Just noticed that criss is a static site generator! I was looking for one. I hope it ends supporting rst, straight-shoota ;D
<renich> Blacksmoke16: thanks
<renich> I'll use it
<renich> IO::Delimited seems to do the trick then. Interesting.
renich has quit [Quit: renich]
zorp has quit [Ping timeout: 264 seconds]
<oprypin> is there any tool to show me which lines of code never executed?
<oprypin> this is not quite coverage but hm
renich has joined #crystal-lang
<oprypin> no i really need this
<FromGitter> <Blacksmoke16> add a bunch of puts and see which ones dont get printed?
<oprypin> Blacksmoke16, well i cant do that manually!
<FromGitter> <Blacksmoke16> :S fair enough
<oprypin> 1915 liens of code
<oprypin> i have an idea. delete each line of code and see if it fails
<FromGitter> <Blacksmoke16> that works too
<oprypin> still needs implementing
DTZUZU has quit [Ping timeout: 264 seconds]
<FromGitter> <Blacksmoke16> could you use some spec coverage thing?
<FromGitter> <Blacksmoke16> write a spec then that could tell you what lines your spec is missing
DTZUZU has joined #crystal-lang
<oprypin> i just realized that the lines being run isn't even enough. they could be running but still be pointless
<oprypin> the spec is literlaly just "run it"
<oprypin> well ok i should clarify. it's a code generator. as long as it produces the exact same code i dont care
renich has quit [Quit: renich]
<FromGitter> <lodenos> Hello guy's I have a question how u can wait a Fiber 'spawn' ?
<FromGitter> <Blacksmoke16> `Fiber.yield` would give a chance for that other fiber to run
<FromGitter> <Blacksmoke16> other option would be to use `select`
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/blob/master/spec/std/concurrent/select_spec.cr specs are the best docs for it atm tho
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/guides/concurrency.html and if you havent read thru
<FromGitter> <Blacksmoke16> that*
<oprypin> watzon, egh i didnt end up looking at it
<oprypin> lodenos, at the end of the fiber's execution do `channel.send`, and the waiter needs to do `channel.receive`. syncing is done through channels only
<oprypin> which is a separate object to the fiber
<FromGitter> <lodenos> yes but with channel I have a probleme
<FromGitter> <Blacksmoke16> like?
<FromGitter> <lodenos> I go try with .yield
<FromGitter> <Blacksmoke16> got an example of what you're trying to do? https://play.crystal-lang.org/#/cr
<FromGitter> <j8r> https://carc.in/#/r/8wvj
<jhass> channel should be the way to go
<FromGitter> <j8r> you can also have a counter incremented before each spawn
<jhass> Fiber.yield is nothing you should do unless you know exactly why it would fix your issue. It certainly has nothing to do with waiting for a fiber
<jhass> select is for when you want to wait for one of multiple channels or with a timeout
<jhass> so yeah, try to show us a minimal example of what you're trying and then we might be able to point out why it doesn't work :)
<oprypin> Blacksmoke16, why did u recommend yield :s
<FromGitter> <Blacksmoke16> wouldnt that allow for like ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5e9b70c34711086205413fed]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b70e685b01628f05dc911]
<FromGitter> <Blacksmoke16> that was my understanding...
<jhass> it assumes so much
<jhass> it assumes the main fiber does not die, never gets blocked and MT is off
<jhass> then you may need this currently. Often blocking the main fiber on some synchronization channel or just putting it to sleep forever seems the more reasonable chocie though
<FromGitter> <Blacksmoke16> for sure, depends on what his end goal is
<jhass> Fiber.yield is an advanced tool not to be thrown to people still figuring things out, IMO :)
<jhass> it's something we hopefully can make private to stdlib at some point
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <stronny> so I've done that by patching sheduler making it check for fiber.dead? on reschedule and running hooks basically
<FromGitter> <stronny> channels suck big time
postmodern has joined #crystal-lang
<FromGitter> <straight-shoota> jhass, maybe we should rename the method to `Fiber.unsafe_yield`. Or make it nodoc.
<jhass> mmh
<FromGitter> <straight-shoota> (it's not really unsafe, but it would alert people to not use it unless they understand what it does)
<FromGitter> <Blacksmoke16> fwiw its used quite a bit in the docs https://crystal-lang.org/reference/guides/concurrency.html
<FromGitter> <straight-shoota> Yeah, but the examples completely fail with multithreading
<FromGitter> <lodenos> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b78f2c7dcfc14e2cd7495]
<FromGitter> <lodenos> I have something like that
<hightower2> Hey can someone remind me how does a regex refer to a previous match... Like, if I allow the opening quote to be (["']), how to match the same one as closing quote? Is it /(["'])...(\1)/ or something else?
<FromGitter> <straight-shoota> Also, every usage of `Fiber.yield` can just be replaced by `sleep 0.seconds`. Maybe that's not as nice as an API, but it is more explicit about what it does
<FromGitter> <tenebrousedge> hightower, should be
<jhass> lodenos: prepend channel = Channel(Nil).new(data.size), do channel.send nil at the end of each spawn, replace ? with data.size.times { channel.receive }
<hightower2> tenebrousedge great gonna try, thanks
<jhass> maybe pick a better name than channel, stop signal or so
alexherbo2 has quit [Ping timeout: 256 seconds]
<FromGitter> <tenebrousedge> ` %("a 'b'").scan(/(["'])(.*?)(\1)/)`
<postmodern> is there a better way to do a reverse lookup of a value to a key in a Hash than .inverting the Hash?
<FromGitter> <straight-shoota> jhass, @Blacksmoke16 : #9128
<FromGitter> <tenebrousedge> postmodern https://crystal-lang.org/api/0.32.1/Hash.html#key_for?(value)-instance-method
<FromGitter> <lodenos> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b7b3ed65bcf75b5d1d9a2]
DeBot has joined #crystal-lang
<postmodern> tenebrousedge, danke sehr
<FromGitter> <lodenos> Srry the indent it's a bit broken
<FromGitter> <lodenos> @ jhass
<jhass> postmodern: note that's O(n), so if you do it a lot an invert might still be worth it
<FromGitter> <lodenos> the puts "test" start in first but I try/want wait when all fiber has finised the works
<FromGitter> <tenebrousedge> jhass isn't inverting it also O(n)?
<postmodern> jhass, good point
<jhass> yes but only paid once (+ allocation overhead)
<jhass> so if you have many lookups it might be worth
<FromGitter> <tenebrousedge> fair
<jhass> lodenos: yes that pattern doesn't work. if you look on Channel#receive? you have to actually close it on the other end once done. Of course that only works if you share to only one other fiber. Otherwise you need to keep track of how many fibers to wait for you spawned and receive that many times
<jhass> so yeah, looping on receive? only makes sense if you send actual data back from one single other fiber
<jhass> which then can close the channel once its done
<jhass> I guess you could keep an array of channels, one per fiber and loop over that array and .receive? once on them, but I see no benefit
<jhass> also not sure whether that's just the borked paste, the end of the .each loop is missing, but the wait routine should be outside the loop of course
<FromGitter> <lodenos> Thx @jhass I see, I have a logic multi-thread like in C/C++, I would like use the power of Fiber for continue work when a request waiting for receiving...
<jhass> that'll do it :)
<FromGitter> <lodenos> Yes but I search another kind of style of writing more elegant
<FromGitter> <lodenos> like fuild, but actually not really, a bit shit, not really elegsnt I found
<jhass> structred concurrency would do this nicely, but for now that's the best we have :)
<FromGitter> <randiaz95> Hi guys! What do you guys recommend as the best linear algebra library in terms of ease of api syntax?
_ht has quit [Quit: _ht]
<hightower2> Hey I have a LibC function that takes LibC::Char** argument. How can I produce that? Is that Pointer(String).new ?
<hightower2> actually, get an error on Pointer().new... maybe 'reference'
<FromGitter> <randiaz95> I would try using single quote
<FromGitter> <randiaz95> not String but a char
<FromGitter> <randiaz95> Pointer('x').new
<hightower2> Well it requires a class, not instance
<FromGitter> <randiaz95> Did you try the Char class?
<FromGitter> <randiaz95> I mean, I am sure if it asks for LibC::Char maybe you need to require LibC and use LibC::Char
<FromGitter> <Blacksmoke16> isnt `LibC::Char` a `UInt8`?
<FromGitter> <randiaz95> In byte format yet
<FromGitter> <randiaz95> yes*
<FromGitter> <randiaz95> memory size*
<FromGitter> <randiaz95> docs don't say much about that though, https://crystal-lang.org/reference/syntax_and_semantics/c_bindings/type.html
<hightower2> yes, randiaz95 the issue I have is I need to get **ptr so basically allocate just the size of the pointer
<hightower2> but no idea how to do that
<FromGitter> <randiaz95> Idk, maybe test around casting to uint8 like George said and check if it is the right size
<FromGitter> <randiaz95> @Blacksmoke16 , how would you zip two arrays together into an array of tuples?
<FromGitter> <Blacksmoke16> `**` is a pointer of a pointer right?
<FromGitter> <randiaz95> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b888de920022432b71139]
<FromGitter> <Blacksmoke16> tuples are immutable, so would have to join the arrays then do `.map { |item| {item} }`
<FromGitter> <Blacksmoke16> cant just define the two arrays as tuples?
<oprypin> hightower2: usually this is `out pchar`
<FromGitter> <randiaz95> The weights array would probably come from some flat file separate from the input array
<hightower2> oprypin, aaah indeed, I've forgot about 'out'. Thumbs up good man
<oprypin> hightower2: like, a pointer can mean anything. to avoid a copy or to pass an array or to expect output
<oprypin> u see from the docs which it is and act accordingly
<oprypin> if it's a double pointer, it rules out the first of the 3 options
<oprypin> but u maybe got stuck considering that option
<FromGitter> <randiaz95> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b893463e7b73a5fe9180b]
<FromGitter> <randiaz95> potentially can just do (0..inputs.size).each and do that instead.
<oprypin> hightower2: then you'd probably do String.new(pchar)
<oprypin> @randiaz95: looks like `zip` or something
<FromGitter> <randiaz95> Nice I'm learning Crystal/ruby syntax lol ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b8a99a412254f2197ccf9]
<FromGitter> <randiaz95> each does not return the array I think.. and map does return an array; also the three dots is not-inclusive.
<FromGitter> <Blacksmoke16> just use the block version of sum
<FromGitter> <randiaz95> OMFGGG
<FromGitter> <randiaz95> HOLD ON MY WORK COMPUTER IS FINALLY PREDICTING DATA!!
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Enumerable.html#sum(initial,&)-instance-method
<FromGitter> <randiaz95> 32 hours of training LMAO
<FromGitter> <randiaz95> ok, so block version of sum is map and sum combined into one?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Enumerable.html#sum(&)-instance-method this one
<FromGitter> <randiaz95> ok: ⏎ Same output of 35.7 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9b8b3e8e987f3a5e297d85]
<FromGitter> <randiaz95> Perfect I am really learning now lol
<FromGitter> <Blacksmoke16> 💭
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <randiaz95> 58 hour traininng LMAOO
<FromGitter> <randiaz95> The first time I ran it i forgot to force garbage collect the previous feature engineering columns and I had 100 random columns
<FromGitter> <randiaz95> I might rewrite everything in Crystal and pray for speed benefits in the feature engineering step
<FromGitter> <tenebrousedge> Google Foobar Challenge: Completed!! ⏎ Python: Learned
<FromGitter> <randiaz95> took me forever to write concise python like 1.5 years rocking pandas/sqlalchemy/listcomps/dictcomps
<FromGitter> <randiaz95> But even then, it takes time lol
<FromGitter> <tenebrousedge> for this I didn't get pandas or numpy or sqlalchemy
<FromGitter> <randiaz95> Holy guac.
<FromGitter> <galvertez> um. does `Time.now` not work in carc.in?
<FromGitter> <randiaz95> it would've taken months to train this gradient boosting algo if I didn't have numpy
<FromGitter> <dscottboggs_gitlab> Time.now doesn't work anymore
<FromGitter> <galvertez> rip
<FromGitter> <tenebrousedge> but I have a bad habit of writing the most concise code that I can <_<
<FromGitter> <dscottboggs_gitlab> `Time.local` or `Time.utc`
<FromGitter> <galvertez> what do we use instead?
<FromGitter> <galvertez> aha. you know what i think i remember seeing a thread about that a while ago
<FromGitter> <galvertez> thank you sir
<FromGitter> <dscottboggs_gitlab> np
<FromGitter> <galvertez> i haven't been writing crystal much lately :(
<FromGitter> <randiaz95> How dare you
<FromGitter> <randiaz95> Go webscrape something NOW
<FromGitter> <randiaz95> lol
<oprypin> did i really just spend like 2 hours debugging stuff just because i didnt write `extern "C"`
<FromGitter> <dscottboggs_gitlab> :(
<FromGitter> <randiaz95> bruh; why you using c and crystal at the same time?
<FromGitter> <randiaz95> They are like chocolate and spaghetti. ⏎ ⏎ Both good, not good together.
<oprypin> randiaz95, looks pretty good to me https://github.com/oprypin/crsfml-examples#crsfml-examples
<FromGitter> <randiaz95> cool games
<FromGitter> <randiaz95> Wow, I stand corrected; I can eat that chocolate spaghetti
<oprypin> :>
<FromGitter> <dscottboggs_gitlab> > bruh; why you using c and crystal at the same time? ⏎ > They are like chocolate and spaghetti. ⏎ > Both good, not good together. ⏎ ⏎ I respectully disagree [https://gitter.im/crystal-lang/crystal?at=5e9b8e920480c128efcc2111]
<FromGitter> <dscottboggs_gitlab> wrapping C's unsafe nature in crystal's type safety is one of the best things about crystal to me
<FromGitter> <randiaz95> Yep I was wrong lol I just thought I could just use crystal for web/mobile servers and not use it for client side.
<FromGitter> <dscottboggs_gitlab> well, aside from how nice crystal is 😀
<FromGitter> <randiaz95> but yes. If you can ship crystal games I am sure it would perform better than java but with MUCH Better syntax.
<FromGitter> <dscottboggs_gitlab> yeah, unfortunately SFML is super verbose, to make any decent games you'd need a decent native high-level library overtop of that
<FromGitter> <randiaz95> Wouldn't you make that in Crystal though?
<FromGitter> <randiaz95> Thats wut the crsfml is?
<oprypin> dscottboggs_gitlab, srsly
<oprypin> :D
<FromGitter> <dscottboggs_gitlab> > Wouldn't you make that in Crystal though? ⏎ yes ⏎ > Thats wut the crsfml is? ⏎ I'm just going by what I vaguely recall someone else telling me like a year ago so I could be wrong or out of date but I meant something overtop of CRSFML [https://gitter.im/crystal-lang/crystal?at=5e9b908a74bfed5a1b493139]
<FromGitter> <randiaz95> Well graphics is not my expertise; so I wouldn't know :/
<FromGitter> <randiaz95> I'm focusing more on NLP
<FromGitter> <dscottboggs_gitlab> me either, not really too into making games either
<FromGitter> <randiaz95> Text data is so complicated you need a fast language
<FromGitter> <dscottboggs_gitlab> Have you looked at D?
<FromGitter> <randiaz95> Yeah; didn't love the syntax much when I did.
<FromGitter> <randiaz95> I like Crystal cause I like ruby syntax.( Very novel syntax for me and has functional methods I love )
<FromGitter> <dscottboggs_gitlab> D's `std::array` has overloads for mathematical operators that use simd instructions when possible
<FromGitter> <randiaz95> Really?
<FromGitter> <dscottboggs_gitlab> yes
<FromGitter> <dscottboggs_gitlab> instant win for NLP
<FromGitter> <randiaz95> not necesarily; int[char[2]] aa; explicitly. saying data types decreases all types of productivity lol
<FromGitter> <randiaz95> all I need is float and string
<FromGitter> <dscottboggs_gitlab> it has `auto`, or am I misunderstanding?
<FromGitter> <randiaz95> ah..
<FromGitter> <randiaz95> Interesting; it seems a little difficult to do tensor algebra without functional methods; does it have?
<FromGitter> <dscottboggs_gitlab> https://dlang.org/phobos/std_range.html
<FromGitter> <dscottboggs_gitlab> fat arrow syntax for lambdas
<FromGitter> <randiaz95> D is just like another basic statically typed language
<FromGitter> <randiaz95> Omit the auto and I will consider lol
<FromGitter> <randiaz95> I mean the difference between crystal and D probably is marginal versus translating python to crystal which is tremendous.
<FromGitter> <dscottboggs_gitlab> yes, I just think there are a lot of benefits to D specifically for performance-critical and NLP applicatiosns
<FromGitter> <dscottboggs_gitlab> you can drop the `auto` for `const` and `immutable` variables 😀
<FromGitter> <randiaz95> haha, I wonder what simd really means under the hood
<FromGitter> <randiaz95> I understand it increases performance.
<FromGitter> <watzon> Surprisingly Python to Crystal isn't a massive leap
<FromGitter> <dscottboggs_gitlab> it can be
<FromGitter> <watzon> Depends on how dynamic you get with it I guess
<FromGitter> <randiaz95> It has all the NLP shards to build on it.
<FromGitter> <watzon> Same with JS
<FromGitter> <watzon> JS is much more difficult to port in my experience
<FromGitter> <randiaz95> Thing is I am already investing in learning Dart + Crystal
<FromGitter> <dscottboggs_gitlab> yeah it's dynamic-ness is a lot more front and center
<FromGitter> <randiaz95> because dart compiles to everything
<FromGitter> <randiaz95> In theory you can write your server + web app + ios + android in Dart
<FromGitter> <randiaz95> and comes with Great component libraries for UI
<FromGitter> <dscottboggs_gitlab> @watzon in theory you could just create a dynamic language on top of crystal. optional static typing, if you will
<FromGitter> <randiaz95> a new python/ruby
<FromGitter> <dscottboggs_gitlab> I've thought of doing it but I hesitate because it seems like a bad idea
<FromGitter> <randiaz95> The problem is C syntax
<FromGitter> <randiaz95> It does not allow for huge productivity gains
<FromGitter> <randiaz95> If you think in terms of functions instead of algorithms inside of the functions its much more productive.
<FromGitter> <randiaz95> Who cares about for(i=0? i don't care about the index, I care about the element.
<FromGitter> <dscottboggs_gitlab> not sure what you mean @randiaz95
<FromGitter> <dscottboggs_gitlab> oh you just don't like for loops? me either lol
<FromGitter> <watzon> @dscottboggs_gitlab actually thought about that. It would be really useful for configuration files, scripting inside of programs, etc
<FromGitter> <watzon> Basically just a very lightly modified Ruby dialect