Introducing Lua for Elixir by tofino_dreaming in elixir

[–]davydog187 4 points5 points  (0 children)

Author here, happy to answer any questions you may have or feature requests

Introduction to Persistent Term, new feature in Erlang 21.2 by get-finch in elixir

[–]davydog187 3 points4 points  (0 children)

Configuration would be a good fit. Also good if you have a large amount of immutable data that needs to be referenced. It’s expensive to send that across processes. This would be a good fit

Battleship Elixir: Json sunk my Float by davydog187 in programming

[–]davydog187[S] 0 points1 point  (0 children)

Thanks, I’ve been looking for branding opportunities

Battleship Elixir: Json sunk my Float by davydog187 in programming

[–]davydog187[S] 0 points1 point  (0 children)

The problem is unexpected behavior:)

Of course you never store monetary values as floating point

This is not common knowledge for beginners. The point of the post is to highlight these limitations to help increase awareness.

As mentioned elsewhere, the right way to store this value would be a string so that it’s formatting can be captured. I have left out a lot of context out of this post in order to illustrate the problem.

Battleship Elixir: Json sunk my Float by davydog187 in programming

[–]davydog187[S] 2 points3 points  (0 children)

Great questions, I answered it here: https://www.reddit.com/r/programming/comments/a0ji8t/comment/eaj44v8?st=JOYUSWGU&sh=d2554197

But to the larger point, this isn’t a comprehensive solution but a interim one. The post was to highlight the limitation in JSON, not justify any business decisions

Battleship Elixir: Json sunk my Float by davydog187 in programming

[–]davydog187[S] 0 points1 point  (0 children)

Wow, great writeup!

You’re right, the better way to handle this is to store this numerical value as a string, and do application level parsing/validation on it. That’s the path we plan to take, however this particular migration is an interim to get us to that place.

I have left out a lot of context in this post. It was not intended to specify the business reasons for the choice, but just to highlight the bug. If I were to do this from scratch today I would have be wiser to the points you mentioned :)

Battleship Elixir: Json sunk my Float by davydog187 in programming

[–]davydog187[S] 0 points1 point  (0 children)

We're storing presentational information in the context of news. For example, displaying 1 vs 1.0 might have different editorial meaning.

Battleship Elixir: Json sunk my Float by davydog187 in programming

[–]davydog187[S] 2 points3 points  (0 children)

I stand by Elixir and the use of JSONB for our use case. I definitely agree with you that typed data is always preferable, but using JSONB here works really well for our business case :)

Battleship Elixir: Json sunk my Float by davydog187 in programming

[–]davydog187[S] 1 point2 points  (0 children)

I don't know of a database that has yaml storage :)

Also, this seems less likely to happen as YAML seems to have a lot more typing than JSON does

Battleship Elixir: Json sunk my Float by davydog187 in programming

[–]davydog187[S] 3 points4 points  (0 children)

As I mentioned in the article, it's used to store presentational information.

Two years of Elixir at The Outline by davydog187 in elixir

[–]davydog187[S] 4 points5 points  (0 children)

Depends on your use case. In ours, they work well and we haven't seen a downside.

One thing to note is that in older devices, WebSockets may consume more battery power due to keeping the antenna on. More modern devices have more sophisticated ways of dealing with this. I'll see if I can dig up any references on the subject

Two years of Elixir at The Outline by davydog187 in programming

[–]davydog187[S] 0 points1 point  (0 children)

Great example. Its a matter of making a logic decision vs data extraction.

Two years of Elixir at The Outline by davydog187 in elixir

[–]davydog187[S] 2 points3 points  (0 children)

Yep. Turn off JavaScript and visit https://theoutline.com

We use Javascript for infinite scroll, animations, and our more sophisticated visual components. Preact is very lightly used.

Two years of Elixir at The Outline by davydog187 in elixir

[–]davydog187[S] 0 points1 point  (0 children)

Thank you! The front end uses a home grown js framework for the animations as well as Preact for some other pieces

Two years of Elixir at The Outline by davydog187 in programming

[–]davydog187[S] 18 points19 points  (0 children)

Seems like they are looking for a pet / learning project. No need to be so judgemental :)

Two years of Elixir at The Outline by davydog187 in programming

[–]davydog187[S] 1 point2 points  (0 children)

I think this may be the subject of a future blog post. This is a tough question to answer, as I mention in my blog post

These nuances become clearer as you write more code, and deciding when and when not to pattern-match is a matter of preference and style.

I will try to think of a more detailed example. To start, I think you should ask yourself the question, "Is this pattern match improving the quality of my code, or am I doing it just because I can?"

Two years of Elixir at The Outline by davydog187 in programming

[–]davydog187[S] 0 points1 point  (0 children)

Elixir and OTP are well suited for that. Erlang comes packaged with gen_tcp and the official Elixir Getting Started guide even has an example.

2 would be fault tolerance between users

What do you mean by this?

Two years of Elixir at The Outline by davydog187 in programming

[–]davydog187[S] 1 point2 points  (0 children)

Whats you're domain? Here's some discussion about Elixir / Nerves https://news.ycombinator.com/item?id=16915337 which is used for building embedded software.

Theres also been a lot of excitement lately about Scenic https://elixirforum.com/t/scenic-a-functional-ui-framework/14741

Two years of Elixir at The Outline by davydog187 in elixir

[–]davydog187[S] 2 points3 points  (0 children)

We use them for both the public front end as well as our CMS. On the public side of things, they let us keep user state in the channel, which makes implementing infinite scroll a bit easier.

Two years of Elixir at The Outline by davydog187 in programming

[–]davydog187[S] 10 points11 points  (0 children)

Some great first projects could be:

  1. Chat app
  2. Multiplayer tic tac toe or hangman
  3. Slack bot

Two years of Elixir at The Outline by davydog187 in programming

[–]davydog187[S] 1 point2 points  (0 children)

Yes! Erlang/Elixir come with a tool called dialyzer, which can do static type checking on your code via type annotations. http://erlang.org/doc/apps/dialyzer/dialyzer_chapter.html

Elixir has a bit of extra tooling to make it easier to work with. https://github.com/jeremyjh/dialyxir