AstonJ

AstonJ

Cool things you've seen in other languages/frameworks

Inspired by @dogweather’s thread about Active Record Doctor, have you seen any impressive or cool things in other non-BEAM languages or frameworks? If so please share!

When taking part please note…

  • This is not a “I’d like to see X in Elixir or Phoenix" type thread.
  • It is not even a thread about things that may or may not be a good fit for functional programming.
  • It is just a thread to share cool things you’ve seen in other languages or frameworks :icon_biggrin:

Why?

Who knows, it might spark someone’s imagination to do something cool in Elixir themselves :003:

Please do not use this thread to criticise other languages or frameworks - let’s keep it focused on the positives.

Most Liked

dogweather

dogweather

Rust has a relational db library that connects to the db while you’re coding and uses the metadata to verify your code at compile-time.

13
Post #3
matt-savvy

matt-savvy

Elm’s time traveling debugger.

Step backwards or forwards through the state of your program.

12
Post #8
TwistingTwists

TwistingTwists

Perfect spot to come to get nerd sniped.

Watching this space :laughing:

AstonJ

AstonJ

Ruby has something similar, keyword arguments - which allows you to name parameters:

def add_values(first:, second:)
  first + second
end
add_values(first: 5, second: 3)

Can be called in any order:

add_values(second: 3, first: 5)

Can be used with positional arguments:

def add_values(first, second:)
  first + second
end
add_values(1, second: 2)

And you can supply default values:

def add_values(first: 0, second:)
  first + second
end

I like how Rails generally has a lot of things built in that almost all apps/sites might use.

Recently I noticed Rails now also have a built in rate-limiter, super handy!

And something I have used in almost every Rails site is caching, which can really help make a site feel fast and responsive.

As an example:

This is cached and the cache is busted when the updated_at field changes. It might not look like much but there are a lot of things that need to be calculated and pulled in - the category names and hover colours need to be worked out, the icon and colour in the top right needs to be worked out, the domain name is stripped from the full url, the tags need to be classified and displayed as portals or tags etc. That’s a lot of CPU per page without caching.

On top of that you can cache queries and set them to expire from as little as a minute to a day or more. I do this for even relatively simple queries as it can give you some protection against DDOS attacks.

    def latest_spotlight
      Rails.cache.fetch("latest_spotlight", expires_in: 1.hour) do
        Topic.where(category_id: Category.in_the_spotlight).includes(:image_upload).last
      end
    end

Without caching a Rails page load can show more than 20% CPU usage, with caching, as little as 1%.

acrolink

acrolink

Nothing. All cool things I have found in Elixir.

Where Next?

Popular in Discussions Top

New
adamu
When starting a new project, do you have any go-to libraries you pull in out of habit/preference? For example, Ash, Credo, Mox, ExMachin...
New
fredwu
Hey folks, Just wanted to share my journey and experiences so far. Preface: I’ve been using Elixir for about 10 years now, so relatively...
New
fireproofsocks
I’m not a Lambda fan-boy because I think it’s overprescribed as a cure-all for every possible problem when in reality, Lambdas are best s...
New
lud
Hello, I just extracted the boilerplate management code that I used to work with in previous years: It is yet another generic input d...
New
New
billylanchantin
If you’re not familiar with this fun bit of math lore, Paul Erdős, the famously eccentric, peripatetic and prolific 20th-century mathem...
New
bartblast
Hey there! :slight_smile: I’m working on updating the Hologram website home page and would love to get your input. Current situation: ...
New
bartblast
It’s time to implement JavaScript interop for Hologram! Eventually, there will be Hologram wrappers for most APIs, but sometimes we’ll n...
New
ScriptyScott
Hey Folks, I just spent the last couple of days doing a deep dive into using Swoosh with Amazon’s simple email service, check out this t...
New

Other popular topics Top

freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New

We're in Beta

About us Mission Statement