Exploring Frontend Technologies: Elm vs. Svelte
Tags: elm, svelte, webdev, hng
Published: 2024-06-29 12:57:56

I recently joined HNG internship, it's a fast paced, online bootcamp for coders from various backgrounds including frontend, backend, data analysis, and product design. They also have a marketplace for hiring top talent—learn more [here](https://hng.tech/hire). Our first task was to write a technical article comparing two front-end technologies. I initially considered writing about ReactJS, the language we'll use in the bootcamp, but there are already tons of articles about ReactJS. So I decided to write about something less common: Elm, and since I'm to compare with another technology, I'm going with Svelte.

## Let's start with Elm

Elm is a functional programming language specifically designed for front-end development. Created by Evan Czaplicki, Elm compiles to JavaScript and emphasizes immutability and type safety, ensuring robust and maintainable codebases.

Elm is ideal for projects where reliability and maintainability are paramount. Its strong typing and functional programming paradigm make it suitable for large-scale applications that require rigorous code quality and robustness.

One distinguishing feature of Elm that makes it so different is, all functions written in Elm cannot cause **side effects**, they are mandatorily pure. But that doesn't mean you cannot develop dynamic pages with it because even if all the functions are pure, there is still a runtime capable of performing some type of side effects, which includes triggering REST services. This one feature makes development much more predictable and easy to maintain.

Another feature I really loved was **no runtime errors**. Yes, that's right. It's almost impossible to generate unexpected failure while running your applications. Unlike JavaScript that, no matter how hard you try, errors will always find a way to pop it's ugly head up, that doesn't happen in Elm. The compiler will always show where and how an error can occur and force you to deal with it! Like a friend said, "It's like programming with someone helping you all the time not to screw up!".

And if you're new to the functional programming world, Elm's compiler generate very friendly error messages that not only point out the mistakes but also teaches the syntax of the language. How cool is that?

Another cool feature to note is it's package management. Elm enforces semantic versioning and it's possible to compare what has changes from one version of a package to another, using the command `elm diff` followed by the name and the versions you want to compare.

You can learn more about this beautiful language [here](https://guide.elm-lang.org/)

## Now, to Svelte

Svelte, created by Rich Harris, is a relatively new framework that shifts much of the work from the browser to the build step, producing highly optimized vanilla JavaScript. Unlike traditional frameworks like React or Vue, which use a virtual DOM, Svelte compiles components to efficient imperative code that directly updates the DOM.

### Key Features

-  **No Virtual DOM**: Svelte components compile to highly optimized JavaScript that directly manipulates the DOM, resulting in faster updates and smaller bundle sizes.

-  **Reactive Declarations**: Svelte's reactivity is built into the language, allowing for concise and clear state management without the need for additional libraries.

-  **Lightweight Runtime**: Applications built with Svelte often have smaller initial loads and faster runtime performance compared to other frameworks.

### Use Cases

Svelte is particularly well-suited for projects where performance and bundle size are critical. Its simplicity and lack of boilerplate code make it an excellent choice for smaller projects or teams looking to quickly prototype and develop applications.

## Bootcamp Opportunity

If you'll like to join me in the HNG internship bootcamp, register [here](https://hng.tech/internship). They also offer a certification upon completion for a small fee. This internship is a fantastic opportunity to apply your knowledge, learn from experienced developers, and contribute to real-world projects. Don't miss out!

## Conclusion

Svelte and Elm offer unique approaches to frontend development, each with its own strengths and ideal use cases. Svelte focuses on simplicity and performance, while Elm emphasizes reliability through functional programming.