# Looking for feedback for my first crystal project

**URL:** <https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112>\
**Category:** Community\
**Created:** [May 14, 2020, 5:31pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112 "2020-05-14T17:31:57Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleandros](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@aleandros](https://forum.crystal-lang.org/u/aleandros)\
**Post date:** [May 14, 2020, 5:31pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/1 "2020-05-14T17:31:57Z")

</div>

Hi everyone! I just created [tdiff](https://github.com/aleandros/tdiff), a cli app for comparing JSON/YAML files.

I would love to read your suggestions regarding organization, idiomatic crystal, general advise, etc. Also I’m scratching my head around how to properly create portable binaries for OSX and Windows, if at all possible, or at the very least a proper installation script for those platforms.

Anyway, thanks in advance for the time, and I’m excited to be part of this great community for such a cool language.

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [May 14, 2020, 5:50pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/2 "2020-05-14T17:50:39Z")

</div>

> [@aleandros](#):
>
> Also I’m scratching my head around how to properly create portable binaries for OSX and Windows, if at all possible, or at the very least a proper installation script for those platforms.

Easiest way for Linux would be to provide a static binary, and maybe a `Snap` package for it. A more robust way would be to, of course, is the provide the package via each OS’s package manager. However , I don’t really have any experience with this, but I imagine it could get painful versus `Snap`/static binary.

Mac would require building from source, or ideally use `Homebrew`.

Windows isn’t really supported ATM, so will just have to wait on that.

---

<div class="post-metadata">

**Author:** ![aleandros](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@aleandros](https://forum.crystal-lang.org/u/aleandros)\
**Post date:** [May 14, 2020, 6:06pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/3 "2020-05-14T18:06:06Z")

</div>

Thanks! a snap package would certainly be more robust. For this project, I created the binary with `shards build --production --release --static --no-debug` but I’m not sure if I should be aware of any potential issue with that running the binary in some random linux machine.

I guess a homebrew package would make a lot of sense. I’ve never tried it but it shouldn’t be that hard.

---

<div class="post-metadata">

**Author:** ![oprypin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/oprypin/32/859_2.png) [@oprypin](https://forum.crystal-lang.org/u/oprypin)\
**Post date:** [May 14, 2020, 8:21pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/4 "2020-05-14T20:21:31Z")

</div>

> [@Blacksmoke16](#):
>
> Windows isn’t really supported ATM, so will just have to wait on that.

Nah, don’t have to wait. It works right now for this particular case 😃

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/1X/99eaab92ebbf20eb539c3c3040a1d57170ed2ee5.png)

> **[Running Crystal natively on Windows, building videogame examples - Blog -...](https://pryp.in/blog/28/running-crystal-natively-on-windows-building-videogame-examples.html)**
>
> Running Crystal natively on Windows, building videogame examples

And actually the resulting executable _is_ fully portable (static), as I understand

---

<div class="post-metadata">

**Author:** ![oprypin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/oprypin/32/859_2.png) [@oprypin](https://forum.crystal-lang.org/u/oprypin)\
**Post date:** [May 14, 2020, 8:30pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/5 "2020-05-14T20:30:49Z")

</div>

> [@aleandros](#):
>
> create portable binaries for OSX and Windows

_also_ (sorry for hijacking this), you can indeed [build for Windows with GitHub Actions](https://github.com/oprypin/install-crystal).  
With _just_ this:

```yaml
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - uses: oprypin/install-crystal@v1
      - run: crystal build src/tdiff.cr
      - run: .\tdiff.exe

```

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [May 14, 2020, 8:30pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/6 "2020-05-14T20:30:58Z")

</div>

Some resources that I found helpful when working on [https://github.com/Blacksmoke16/oq](https://github.com/Blacksmoke16/oq).

## Snap

Can reference the Crystal blog post, and an example `snapcraft` file I use for `oq`.

- [https://crystal-lang.org/2019/06/19/snapcraft-summit-montreal.html#packaging-your-crystal-app-as-a-snap](https://crystal-lang.org/2019/06/19/snapcraft-summit-montreal.html#packaging-your-crystal-app-as-a-snap)
- [https://github.com/Blacksmoke16/oq/blob/master/snap/snapcraft.yaml](https://github.com/Blacksmoke16/oq/blob/master/snap/snapcraft.yaml)

## Linux

I setup a GH action that will build/upload a static binary into the release assets when a release is created. AFAIK this binary should run on any AMD64 architecture UNIX based OS. Probably wont need the `--link-flags` option, as thats for `libxml2`.

- [https://github.com/Blacksmoke16/oq/blob/master/.github/workflows/deployment.yml#L9-L29](https://github.com/Blacksmoke16/oq/blob/master/.github/workflows/deployment.yml#L9-L29)

## HomeBrew

Homebrew is the most painful of the three. Currently I’m handling this by just manually building/uploading the bottle. I suppose I could setup some job within GH actions to automate this, but :shrug:. Ideally, the package would be in homebrew core, which handles bottling for you.

The first link was super helpful is figuring out how to setup the bottle. The second is my cheatsheet so I remember what to do in order to update the bottled version.

- [https://jonathanchang.org/blog/maintain-your-own-homebrew-repository-with-binary-bottles/](https://jonathanchang.org/blog/maintain-your-own-homebrew-repository-with-binary-bottles/)
- [https://github.com/Blacksmoke16/homebrew-tap#bottling](https://github.com/Blacksmoke16/homebrew-tap#bottling)

EDIT:

@oprypin, Is that assuming there aren’t any dependencies? Like wouldn’t `libyaml` need to be installed?

---

<div class="post-metadata">

**Author:** ![oprypin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/oprypin/32/859_2.png) [@oprypin](https://forum.crystal-lang.org/u/oprypin)\
**Post date:** [May 14, 2020, 8:35pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/7 "2020-05-14T20:35:50Z")

</div>

> [@Blacksmoke16](#):
>
> Is that assuming there aren’t any dependencies? Like wouldn’t `libyaml` need to be installed?

Hehe I put the (static) libs to be published as a CI artifact [https://github.com/crystal-lang/crystal/actions/runs/104687833/workflow#L108](https://github.com/crystal-lang/crystal/actions/runs/104687833/workflow#L108) - so they’re there

---

<div class="post-metadata">

**Author:** ![jwoertink](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/jwoertink/32/50_2.png) [@jwoertink](https://forum.crystal-lang.org/u/jwoertink)\
**Post date:** [May 14, 2020, 9:00pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/8 "2020-05-14T21:00:48Z")

</div>

Welcome to Crystal! 🎉

---

<div class="post-metadata">

**Author:** ![jwoertink](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/jwoertink/32/50_2.png) [@jwoertink](https://forum.crystal-lang.org/u/jwoertink)\
**Post date:** [May 14, 2020, 9:01pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/9 "2020-05-14T21:01:03Z")

</div>

That’s awesome! And great news!

---

<div class="post-metadata">

**Author:** ![aleandros](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@aleandros](https://forum.crystal-lang.org/u/aleandros)\
**Post date:** [May 14, 2020, 9:02pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/10 "2020-05-14T21:02:38Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![aleandros](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@aleandros](https://forum.crystal-lang.org/u/aleandros)\
**Post date:** [May 14, 2020, 9:03pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/11 "2020-05-14T21:03:21Z")

</div>

Wow! Thanks for the amazing response! This will be super useful

---

<div class="post-metadata">

**Author:** ![aleandros](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@aleandros](https://forum.crystal-lang.org/u/aleandros)\
**Post date:** [May 14, 2020, 9:03pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/12 "2020-05-14T21:03:59Z")

</div>

Awesome! thanks for the link!

---

<div class="post-metadata">

**Author:** ![oprypin](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/oprypin/32/859_2.png) [@oprypin](https://forum.crystal-lang.org/u/oprypin)\
**Post date:** [May 14, 2020, 9:17pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/13 "2020-05-14T21:17:36Z")

</div>

I confirm that the resulting executable is fully self-contained, because I copied only it and ran through Wine and it works 😃

---

<div class="post-metadata">

**Author:** ![da1nerd](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/da1nerd/32/960_2.png) [@da1nerd](https://forum.crystal-lang.org/u/da1nerd)\
**Post date:** [May 15, 2020, 2:13am UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/14 "2020-05-15T02:13:57Z")

</div>

> [@oprypin](#):
>
> _also_ (sorry for hijacking this), you can indeed [build for Windows with GitHub Actions](https://github.com/oprypin/install-crystal).  
> With _just_ this:
> 
> ```auto
> runs-on: windows-latest
> steps:
> - uses: actions/checkout@v2
> - uses: oprypin/install-crystal@v1
> - run: crystal build src/tdiff.cr
> - run: .\tdiff.exe
> 
> ```

Glad to see this github action! Nice work!

---

<div class="post-metadata">

**Author:** ![ganymedes](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@ganymedes](https://forum.crystal-lang.org/u/ganymedes)\
**Post date:** [May 15, 2020, 5:25pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/15 "2020-05-15T17:25:43Z")

</div>

Who that’s awesome.

@oprypin So what features of Crystal I should not try to use while compiling on Windows?

---

<div class="post-metadata">

**Author:** ![aleandros](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@aleandros](https://forum.crystal-lang.org/u/aleandros)\
**Post date:** [June 2, 2020, 9:40pm UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/16 "2020-06-02T21:40:04Z")

</div>

Just a very late update, but thanks to @Blacksmoke16 I now have available instructions for homebrew (non-bottled) and snap.

And thank you @oprypin, I’m already publishing the windows binaries via gh actions.

---

<div class="post-metadata">

**Author:** ![drhuffman12](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/drhuffman12/32/715_2.png) [@drhuffman12](https://forum.crystal-lang.org/u/drhuffman12)\
**Post date:** [July 1, 2020, 6:08am UTC](https://forum.crystal-lang.org/t/looking-for-feedback-for-my-first-crystal-project/2112/17 "2020-07-01T06:08:43Z")

</div>

I’d love to see some sort of how-to blog[s] for generating self-contained binaries for various platforms; or as part of the official docs. It would probably be great [critical?] for promoting Crystal v 1.0!
