<smurfendrek123>
I'm only doing oop, because i have a mandatori uni course where we need to implement a project in a staticly typed and oop language. And crystal seemed like the only language where the developer experience didn't suck
<FromGitter>
<Blacksmoke16> well there you go :p maybe the more you use it, the more you would like it ;)
<smurfendrek123>
But maybe i should also take a look at common lisp with it's Common Lisp Object System (CLOS) or clojure or scala
<smurfendrek123>
Not that i'm switching for the project, but they are interesting languages too
<FromGitter>
<Blacksmoke16> whats the project?
<smurfendrek123>
uni project, we have to basically make a spreadsheet gui without using gui toolkits :p so we can only use a very small library that gives us click events and cursor position
<smurfendrek123>
and keystrokes etc...
<FromGitter>
<Blacksmoke16> ah gotcha
<fullforce>
ok back
<smurfendrek123>
What's crystal's point of existence beside type inference up the wazoo?
<FromGitter>
<Blacksmoke16> its type system is less restrictive than other statically typed langs
<FromGitter>
<Blacksmoke16> as you dont *have* to provide type of like method args
<FromGitter>
<Blacksmoke16> also as you said, easy to use syntax and is quite fast
<FromGitter>
<dscottboggs_gitlab> Yeah, to me it's about striking the right balance between how long it takes to write the code and how long it takes to run the code
<smurfendrek123>
Hmm, but nothing fundamental? I like languages that do something fundamentally different, like rust with memory safety or lisp dialects with code as data etc...
<FromGitter>
<Frederik-Baetens> Also I think that the aliases are weird
<FromGitter>
<Frederik-Baetens> There are both #[] methods and get methods that do the same thing
<FromGitter>
<Frederik-Baetens> right?
<FromGitter>
<dscottboggs_gitlab> no?
<FromGitter>
<Blacksmoke16> :thinking: in some cases yes
<FromGitter>
<Blacksmoke16> but not too many out there
<FromGitter>
<Blacksmoke16> esp compared to ruby
<FromGitter>
<Frederik-Baetens> Ah, i'm thinking of << for example which is an alias for push
<FromGitter>
<dscottboggs_gitlab> well.. there's `fetch` which allows for a default, but that's an explicit goal of the language -- to remove those as much as possible.
<FromGitter>
<dscottboggs_gitlab> see my recently requested feature -- #7497
<FromGitter>
<Blacksmoke16> some aliases are nice, others just add confusion
<FromGitter>
<Blacksmoke16> there was one in ruby i thought they were diff things
<FromGitter>
<Blacksmoke16> but you'd have to use those
<FromGitter>
<Blacksmoke16> since are some cases you would want to generate local vars with a macro
<fullforce>
alright I got it to work
<fullforce>
blacksmoke im really tired turns out splatting did work
<fullforce>
thanks
fullforce has left #crystal-lang [#crystal-lang]
<FromGitter>
<Blacksmoke16> :p np
hightower3 has quit [Ping timeout: 255 seconds]
<FromGitter>
<bajro17> It was so hard to find resource for Crystal
<FromGitter>
<bajro17> even there is so little
<FromGitter>
<bajro17> but still so hard to find it
<FromGitter>
<bajro17> Is development team think to promote alias
<FromGitter>
<bajro17> same like golang (go)
<FromGitter>
<bajro17> maybe crylang
<FromGitter>
<bajro17> or something like that
<FromGitter>
<dscottboggs_gitlab> usually searching for crystal-lang yields better results
<FromGitter>
<dscottboggs_gitlab> but I agree the collision with Crystal Reports and like...rocks... is an issue
<FromGitter>
<Blacksmoke16> :p
<FromGitter>
<whitenoiseoss> I usually search for "crystal lang"
<FromGitter>
<whitenoiseoss> you can also just name your projects after rocks and/or drugs
<FromGitter>
<whitenoiseoss> that's what I'm doing.
Groogy has quit [Ping timeout: 240 seconds]
marmotini_ has joined #crystal-lang
<FromGitter>
<girng> @ammarfaizi2 Hi! Just curious are you a crystal dev?
<FromGitter>
<drum445> For a lot of cases you can just search for the ruby equivalent
hightower3 has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
ashirase has quit [Ping timeout: 268 seconds]
ashirase has joined #crystal-lang
lucasb has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<joshuapinter> Hello All. I'm trying to make a PR for crystal and thus need to get a branch built on macOS for development. When I run `make libcrystal` I get the following errors:
<FromGitter>
<joshuapinter> $ make libcrystal ⏎ Using /usr/local/bin/llvm-config [version=6.0.1] ⏎ cc -fPIC -c -o src/ext/sigfault.o src/ext/sigfault.c ⏎ In file included from src/ext/sigfault.c:1: ⏎ In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk/usr/include/signal.h:61: ... [https://gitter.im/crystal-lang/crystal?at=5c7d2d6f47276019e9b414c5]
<FromGitter>
<r00ster91> what is your architecture?
<FromGitter>
<joshuapinter> @r00ster91 Thanks for the lightning-quick response. Architecture being... OS? If so, macOS 10.14.3, XCode 10 (if that is relevant).
<FromGitter>
<straight-shoota> @joshuapinter From the paths in your error message it looks like you're trying to build for iOS
<FromGitter>
<straight-shoota> At least the header files are used from the iPhone SDK
<FromGitter>
<joshuapinter> I'm on macOS just trying to get the lib and specs running on my branch. If it helps, I'm also getting this error message when trying to link the llvm: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c7d311065ffa019ea86b9f5]
<FromGitter>
<straight-shoota> I don't think that's related. LLVM seems to be already provided.
<FromGitter>
<straight-shoota> You probably need to change your xcode configuration to build for MacOS instead of iOS.
<FromGitter>
<whitenoiseoss> MacOS can make stuff like this difficult. I wrote a Python extension once on Mac and it took me forever to get it to build vs just going over to Linux and doing it.
<FromGitter>
<whitenoiseoss> but I would echo Johannes: `Unsupported architecture` -- it's using iPhone, and the iPhone SDK doesn't support x86_64
<FromGitter>
<joshuapinter> > You probably need to change your xcode configuration to build for MacOS instead of iOS. ⏎ Interesting. That could be it. I do some development for iOS so maybe it's somehow set to that.
ua_ has quit [Ping timeout: 240 seconds]
chemist69 has joined #crystal-lang
ua_ has joined #crystal-lang
ua_ has quit [Read error: Connection reset by peer]
ua has joined #crystal-lang
<chemist69>
Hi, in a class definition, what does the colon in a property definition mean, e.g. `property :source_neuron`? The program also compiles without the colon.
<FromGitter>
<dscottboggs_gitlab> that makes `source_neuron` a symbol, like in ruby
<FromGitter>
<dscottboggs_gitlab> The property macro just uses the text that you provied in that argument field, so it accepts symbols or string literals or just a variable name
<FromGitter>
<bararchy> chemist69 neurons ah? What are you doing? Neural Networks ?
<chemist69>
dscottboggs_gitlab: Ok, please forgive me, if the next question is dumb, I do not come from a Ruby background: what is the advantage of declaring a property a symbol instead of using it as an instance variable?
<FromGitter>
<dscottboggs_gitlab> There isn't one
<FromGitter>
<bararchy> Just looks nicer ;)
<chemist69>
bararchy: just playing with the examples included with the compiler.
<FromGitter>
<bararchy> Oh right, forgot they have a neural net in the examples
<FromGitter>
<dscottboggs_gitlab> TBH I prefer the `property varname : VarType` syntax in most cases
<FromGitter>
<bararchy> But then you cant have multiple in one line
<chemist69>
I have to get used to the symbol concept.
smurfendrek123 has quit [Ping timeout: 268 seconds]
marmotini_ has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<FromGitter>
<joshuapinter> > > You probably need to change your xcode configuration to build for MacOS instead of iOS. ⏎ > Interesting. That could be it. I do some development for iOS so maybe it's somehow set to that. ⏎ ⏎ Hey guys, just a quick update that I went down a bit of a rats nest with `brew` and `llvm` and `readline`. It was a bit of a mess and the only thing that ended up fixing it was installing macOS SDK headers
<FromGitter>
<kinxer> There isn't an XML equivalent to `JSON::Mapping` or `JSON::Serializable`, correct?
<z64>
not in stdlib, no
<FromGitter>
<kinxer> Okay, good to know. Thank you.
<z64>
yw
moei has joined #crystal-lang
<FromGitter>
<TheOnlyArtz> I have an issue JSON::Builder, it resets the IO (File in my case) each program run, how can I fix it? I just want to edit JSON properties in the existing file
<FromGitter>
<kinxer> @TheOnlyArtz I've replied to your forum thread, and I believe @stronny is replying as well.
<FromGitter>
<TheOnlyArtz> But @stronny says it's offtopic, I don't see it being offtopic in any way/
<FromGitter>
<kinxer> I think his point is accurate for that particular forum topic. Also, I'm sorry that my answer wasn't sufficient; I didn't think through what you're trying to accomplish.
<FromGitter>
<kinxer> But it seems to me that now you're asking about how to serialize and deserialize JSON in a way that lets you append to the JSON properly and generally use the JSON as a "database". That's a useful question to ask, but it's not the same question you made the forum post for.
<FromGitter>
<TheOnlyArtz> Well sorry if I wasn't clear enough
<FromGitter>
<TheOnlyArtz> I think I can do it with the logic I would implement to JS and Python
<FromGitter>
<TheOnlyArtz> But for that I need to know how I can turn JSON::Any to so mutable data type
<FromGitter>
<TheOnlyArtz> Any ideas
<FromGitter>
<Blacksmoke16> what does the file look like?
<FromGitter>
<Blacksmoke16> id imagine its in some structured format?
<FromGitter>
<Blacksmoke16> where the keys and types are known already?
<FromGitter>
<Blacksmoke16> @TheOnlyArtz
<FromGitter>
<kinxer> @TheOnlyArtz I would recommend taking a look at https://crystal-lang.org/api/0.27.2/JSON/Serializable.html first, though. And I know that @Blacksmoke16 has made at least one really useful shard for JSON serialization and deserialization.
<FromGitter>
<TheOnlyArtz> The file looks like that ⏎ `{}` ⏎ at first
<FromGitter>
<Blacksmoke16> no i mean since you said you are using it as a "database" what data are you storing in it? is it just random stuff?
<FromGitter>
<TheOnlyArtz> Oh
<FromGitter>
<Blacksmoke16> or is there a defined set of keys/structure to it
<FromGitter>
<dscottboggs_gitlab> even if it's just random stuff, it usually has some sort of structure. Like the above example is a Hash(String, String)
<FromGitter>
<Blacksmoke16> yea pretty much
<FromGitter>
<Blacksmoke16> then you could just do like
<FromGitter>
<Blacksmoke16> or even if you create a hierarchy of structs, where you have a main `DB` one which contains these fields, plus other structs for nested objects
<FromGitter>
<TheOnlyArtz> Didn't know it works like that
<FromGitter>
<TheOnlyArtz> Then I don't have to use any Builder
<FromGitter>
<Blacksmoke16> as at this point you're working with objects, which are all type safe
<FromGitter>
<Blacksmoke16> vs parsing a random json string as `JSON::Any` then trying to cast each value to a type
<FromGitter>
<Blacksmoke16> it still is using a builder, but its handled for you
<FromGitter>
<Blacksmoke16> but imo, unless there is some other requirement, a Sqlite db with an ORM would prob be easier...
<FromGitter>
<TheOnlyArtz> I'm just learning Crystal
<FromGitter>
<TheOnlyArtz> writing a little pastebin-like app
<FromGitter>
<Blacksmoke16> fair enough
<FromGitter>
<dscottboggs_gitlab> The thing you're dealing with is a very common struggle @TheOnlyArtz
<FromGitter>
<TheOnlyArtz> Yes I could imagine
<FromGitter>
<dscottboggs_gitlab> JSON is an inherently dynamic type representation, and interpreting that in strictly-typed languages is very difficult for people coming from dynamic languages. It was my biggest hurdle to learning Go before Crystal
<FromGitter>
<Blacksmoke16> yes, it (crystal/compiler) has to have a way to know the types of each element of JSON
<FromGitter>
<Blacksmoke16> when it doesn't you get the `JSON::Any` problem where its not as easy as ruby where you can just do `json[:key] = "value"` arbitrarily
<FromGitter>
<TheOnlyArtz> Me and statically typed languages are not the best friends
<FromGitter>
<TheOnlyArtz> So I'm trying to adapt :)
<FromGitter>
<dscottboggs_gitlab> You have to learn to see the underlying data structure. Crystal lets you do a lot of crazy stuff, like `alias CrazyHash = Hash(String, Number | String | Hash(String, CrazyHash))`, which makes it easier than other statically typed languages, though. :)
<FromGitter>
<dscottboggs_gitlab> (which would create a data-type that is a Hash of String to a Number OR a String OR a Hash of string to a self-reference)
<FromGitter>
<TheOnlyArtz> Yes, I see how Crystal is powerful
<FromGitter>
<dscottboggs_gitlab> Hey nice you got it working!
<z64>
anyone in the loop with overflow/underflow checking? i'm aware `-Dpreview_overflow` is available, but was there a roadmap/milestone to stabilize this in mind yet?
robacarp has quit [Ping timeout: 272 seconds]
robacarp has joined #crystal-lang
moei has quit [Read error: Connection reset by peer]
moei has joined #crystal-lang
<FromGitter>
<straight-shoota> @drum445 I think this issue has been mentioned a few times. Did you search?
<FromGitter>
<drum445> I did, couldn't find anything related
<FromGitter>
<drum445> Something was in the issues that also mentioned broken pipe
<FromGitter>
<straight-shoota> z64, IIRC the feature was essentially completed with #7206
<FromGitter>
<straight-shoota> now it's about testing existing code bases with the preview opt-in flag.
<FromGitter>
<drum445> Does anybody know how to sanatise ecr data?
<FromGitter>
<drum445> In Ruby you could do <%h %> ?
<FromGitter>
<straight-shoota> I don't expect raise on overflow to become the default in the next release, but the one after might be it.
<FromGitter>
<straight-shoota> @drum445 There is HTML.escape
moei has quit [Quit: Leaving...]
marmotini_ has quit [Remote host closed the connection]
<FromGitter>
<drum445> So do you just use that in every <%= %> block where the input comes from the user?
<FromGitter>
<drum445> I'm used to handlebars which does it auto
<FromGitter>
<vladfaust> `struct On < Validator(T)`
<FromGitter>
<straight-shoota> @drum445 Well, ECR is a very simple general purpose template engine.
<FromGitter>
<straight-shoota> If you want advanced features, you might want to look for a different engine.
<FromGitter>
<straight-shoota> But maybe you'd just be fine by declaring a top level method as alias: ⏎ ⏎ ```def h(string) ⏎ HTML.render(string) ⏎ end``` ⏎ ⏎ Then you can just do `<%= h unsafe_value %>` [https://gitter.im/crystal-lang/crystal?at=5c7db1798a7def0752144eb1]
<FromGitter>
<Blacksmoke16> @PlayLights_twitter yea you need to do `struct On(T) < Validator`
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter>
<Blacksmoke16> well you're using forall so maybe not
<FromGitter>
<Blacksmoke16> whats the error?
<FromGitter>
<PlayLights_twitter> It says that i should define the instance variable type like on a regular class
<FromGitter>
<Blacksmoke16> ah, yea im not sure if you can use forall with an ivar?
<FromGitter>
<Blacksmoke16> i dont know enough about it if you *should* be able to t tho
<FromGitter>
<Blacksmoke16> as a workaround would have to use a generic and pass the type in
<FromGitter>
<PlayLights_twitter> Ok i will try that, thanks (after classes)