jononomo

jononomo

At my last company we migrated a large codebase from JavaScript to TypeScript – basically it just amounted to adding a couple of lines to the file, changing the extension to .ts instead of .js and then going through and making sure all your code now adhered to the slightly stricter standard. We also had a separate directory where we had some type-specification files that we had to create for some of the more complex types that we used.

Is there a similar layer that it is possible to add on top of Elixir?

Showing Posts 1 to 10

Marcus

Marcus

Maybe, @spec and dialyzer. See also: How do typespecs / dialyzer compare to Typescript?

jononomo

jononomo OP

Thanks - that was an interesting thread. There seem to be mixed reviews on Dialyzer.

I’d also be curious to hear someone spell out what the upsides are to having Elixir be a dynamically typed language rather than a statically typed language.

All I hear about are the downsides of dynamic typing, but surely there must also be some upsides (other than merely slightly shorter lines of code)?

ityonemo

ityonemo

Upsides to dynamic typing:

Consider the case of launching Task.async within a GenServer and catching the result using the info/2 callback. How does a static typesystem correctly type this situation?

LostKobrakai

LostKobrakai

There are few things, which need dynamic typing: modules defined at runtime, hot code updates, ducktyping (if if quacks it’s a duck), …

But the most important one is (distributed) message passing.

You could also look at gleam and what it can’t statically type.

dimitarvp

dimitarvp

At this point it’s pretty much known that BEAM code cannot be 100% statically type checked. But I do wonder what’s the problem in having static checking in 95% of the places and just use more defensive dynamic dispatch code for those 5% that can’t be typed (speaking about internal implementation of course, not about manual coding in Erlang/Elixir/etc.)

LostKobrakai

LostKobrakai

Isn’t that essentially what gleam does or at least tries to do?

dimitarvp

dimitarvp

From the (not much) of what I’ve read, yes. Still curious if they deal with macros or metaprogramming in general?

zkessin

zkessin

People have been trying to add types to the BEAM since at least the 2005 timeframe, and it always seems to fail on the same few corner cases. (Dynamic Upgrades, Message passing etc)

stevensonmt

stevensonmt

I believe the main developer of Gleam posted on here not too long ago that they do not handle macros yet in Gleam. They have an open issue on Github for discussing a macro system:
https://github.com/gleam-lang/suggestions/issues/22

al2o3cr

al2o3cr

For a start, dynamically-typed Elixir… exists.

There are statically-typed alternatives on the horizon, but they aren’t done yet: Gleam looks to be moving forward at a good speed in public (first release of the actor stuff dropped back in October), and there’s something over at Facebook working in private.

On the flipside: what would “full” static typing bring that Dialyzer doesn’t? Even Gleam has a Dynamic type for when it can’t decide / can’t verify the type (for instance, in the raw OTP plumbing).

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
nseaSeb
AcmeScript — Writing JS hooks as if I were still using Elixir I’ve been having fun building a little something over the last few days: Ac...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews