0% found this document useful (0 votes)
15 views

Porting Perl Package To Elixir

Ruben Amortegui discusses moving from Perl to Elixir. He was attracted to Elixir for building real-time and IoT applications. He explores the necessary tools for Elixir development, including Ecto for databases, Test::Unit for testing, and Phoenix for web development. He ported his Perl e-commerce cart plugin Dancer2::Plugin::Cart to Elixir as EcCart to get started with Elixir. EcCart is now available on Hex.pm and its code is on GitHub.

Uploaded by

white rabbit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Porting Perl Package To Elixir

Ruben Amortegui discusses moving from Perl to Elixir. He was attracted to Elixir for building real-time and IoT applications. He explores the necessary tools for Elixir development, including Ecto for databases, Test::Unit for testing, and Phoenix for web development. He ported his Perl e-commerce cart plugin Dancer2::Plugin::Cart to Elixir as EcCart to get started with Elixir. EcCart is now available on Hex.pm and its code is on GitHub.

Uploaded by

white rabbit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
You are on page 1/ 23

From Perl to

Elixir

Ruben Amortegui -
@ramortegui
http://rubenamortegui.com
https://github.com/ramortegui
Agenda

● How I meet Elixir


● Personal needs to be productive
● Case: Porting EcCart from Perl to Elixir
Meeting Elixir
● Background
– Java
– PHP + JavaScript
– PHP and JAVA (joomla and XML-RPC)
– Ruby on Rails
– Perl 5
– Meteor
Meeting Elixir
● New challenges
– IOT
– RealTime apps

● Which options do I have?


– Ruby
– JavaScript
– Perl5
– Php
– Elixir?
Elixir

● Pros ● Cons (opportunities)


– Ready to scale – No working
– Syntax like Ruby experience on
Functional
– Has a Web programming
Framework
– Lack of packages
– Battletest Virtual
Machine BEAM
– Jobs ( ? )
Trying elixir, what do I need?
● Database ● Testing ● Web
abstraction Framework

● Package ● Version
manager Manager
Trying elixir, what do I need?
● Database abstraction
– Javascript: Bookshelf.js
– Java: Hibernate
– Ruby: Active Record
– Perl: DBIx
– Elixir: Ecto
Trying elixir, what do I need?
● Testing
– Javascript: Jasmine
– Java: Junit
– Ruby: Rspec, minitest
– Perl: Test::More
– Elixir: Test::Unit
Trying elixir, what do I need?
● WebFramework
– Javascript: Express.js
– Java: Spring
– Ruby: Rails, Sinatra
– Perl: Catalyst, Dancer
– Elixir: Phoenix
Trying elixir, what do I need?
● Package manager
– Javascript: npm
– Java: maven
– Ruby: rubygems
– Perl: cpan
– Elixir: hex
Trying elixir, what do I need?
● Version Manager
– Javascript: nvm
– Java: Switchng env variables?
– Ruby: rvm
– Perl: perlbrew
– Elixir: asdf
Where to start?
● How can I do the things that I’m doing with my
current programming language?

● Dancer2::Plugin::Cart
Dancer2::Plugin::Cart
● It’s a plugin for Dancer2 apps to help the developer
to manage a e-cart and guide the checkout process
on webstores.

– Routes
– Data Structure
– Functions
– Hooks to grow and add features
– Config setup
Dancer2::Plugin::Cart
● LIVE DEMO
How I started
● Phoenix
– Easily to modify existing code
– It work’s in a different way as the frameworks that
I’ve been known.
Eg. Plug, |> , Session
● Elixir
– Elixir In Action
● Get familiar with funcitonal programming, Elixir, and OTP
concepts.
Trying Elixir
● iex ( irb on ruby, re.pl )
● Defining variables
● Pattern matching
● Control Flow
● Data Abstractions
– Maps, Structs
Implementing EcCart
● The first version:

--- /dev/null
+++ b/lib/ec_cart.ex
@@ -0,0 +1,2 @@
+defmodule EcCart do
+end
Implementing EcCart
● Define EcCartItem
● Add funciton to add Items
● Add function to calculate subtotals
● Define EcCartAdjustment
● Add EcCartAdjustments
● Add function to calculate totals
● Add server to preserve states by process id
● Add cache to manage multiple servers by id
● Add supervisor OTP
Implementing EcCart
Implementing EcCart

● Published:
https://hex.pm/packages/ec_cart
● Source Code:
https://github.com/ramortegui/ec_cart
Implementing EcCart
● LIVE DEMO
Summary
● Elixir is facinating.
– Love the approach of funcitonal programing.
● A lot of tools ready to be productive
● EcCart is avaiable on Hex.io
● I’m working to make easier the development of
webstores in elixir.
Thanks!

Q & A?

@ramortegui
http://rubenamortegui.com
https://github.com/ramortegui

You might also like