<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gianluca Tranchedone on Medium]]></title>
        <description><![CDATA[Stories by Gianluca Tranchedone on Medium]]></description>
        <link>https://medium.com/@gtranchedone?source=rss-97a7ccc0869b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*vb97IRS591-sNx69uNEeNA.jpeg</url>
            <title>Stories by Gianluca Tranchedone on Medium</title>
            <link>https://medium.com/@gtranchedone?source=rss-97a7ccc0869b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 03:17:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gtranchedone/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Come possiamo investire i nostri soldi?]]></title>
            <link>https://medium.com/investitori-ribelli/come-possiamo-investire-i-nostri-soldi-85947eb17cdf?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/85947eb17cdf</guid>
            <category><![CDATA[azioni]]></category>
            <category><![CDATA[soldi]]></category>
            <category><![CDATA[risparmio]]></category>
            <category><![CDATA[guadagnare]]></category>
            <category><![CDATA[investire]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 22:01:08 GMT</pubDate>
            <atom:updated>2020-01-23T22:01:08.725Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eIFGBjnB3xL9jGi9cYo9kg.jpeg" /></figure><p>Nell’ultimo blog post abbiamo visto <a href="https://investitoriribelli.it/blog/la-importanza-di-investire">come l’inflazione distrugge i nostri risparmi</a> a lungo andare e quindi dell’importanza di investirli in modo da ottenere l’effetto opposto: una crescita esponenziale dei nostri risparmi nel tempo.</p><p>In questo articolo continuiamo il discorso intrapreso in quel post andando a considerare le varie opzioni che abbiamo per utilizzare al meglio il nostro denaro. Chiaramente, partiamo con il presupposto che lasciare i soldi in cassaforte, in un normale conto bancario, o sotto il materasso non sia un’ottima idea, quindi non li menzioniamo neppure.</p><h3>Cosa possiamo fare con i nostri risparmi?</h3><p>In pratica ci sono solo tre cose ‘utili’ che possiamo fare con i nostri soldi: spenderli, investirli, o risparmiare per investire in futuro.</p><p>Poiché l’inflazione consuma a poco a poco il potere d’acquisto del nostro denaro, spenderlo, per quanto controintuitivo possa sembrare, può essere una buona scelta.</p><p>Spendere 10.000€ per comprare un’auto, per esempio, non produce nessun guadagno, anzi contribuisce ad aggiungere ulteriori spese tra assicurazione e manutenzione; invece comprare un terreno, può farlo. Anche se non abbiamo intenzione di coltivare il terreno o di costruirci sopra un edificio, abbiamo sempre l’opzione di farlo in futuro. In caso di necessità, può anche tornare utile per un accampamento di fortuna. Chiaramente questo è solo uno stupido esempio, ma spero cogliate il senso. Il guadagno su questo tipo di ‘investimento’ è zero, ma è meglio che negativo. Con una spesa del genere possiamo sperare che quantomeno il valore di ciò che abbiamo comprato si mantenga al passo con l’inflazione, conservando il potere d’acquisto del nostro capitale… ammesso di riuscire a trovare qualcuno disposto a comprare l’asset da noi quando ci servisse denaro!</p><p>Un’alternativa leggermente <em>migliore</em> in teoria — ma peggiore in pratica — è depositare soldi in un conto o libretto di risparmio. A differenza di un conto corrente o di una prepagata come la Poste Pay, un conto di risparmio paga degli interessi annui. Purtroppo, però, in genere, questo tipo di conti non paga interessi sufficienti a contrastare l’effetto dell’inflazione. Perdiamo comunque potere d’acquisto ma più lentamente, mitigando, quindi, l’effetto dell’inflazione in cambio di avere liquidità. Il grande vantaggio di questa alternativa è che possiamo accumulare capitale <em>mentre</em> cerchiamo un investimento migliore dei nostri soldi.</p><p>Infine, chiaramente, possiamo investire subito il nostro denaro. Investire, ripetiamo, significa comprare attività, assets, che produrranno per noi un guadagno in futuro. Molti tipi di investimenti non sono asset, pertanto ne vogliamo stare alla larga. Per esempio, quello che normalmente percepiamo come l’investimento più importante della nostra vita, la nostra casa, non è un asset, ma, come dice Robert Kyosaki in <a href="https://amzn.to/2LoInHV"><em>Padre ricco, padre povero</em></a> è una passività (o liability), qualcosa cioè che ci fa spendere soldi invece che farcene guadagnare. Ciò non significa che non dovete comprare casa, ma semplicemente di farlo, se volete, sapendo che nel tempo ci spenderete molto più che il costo d’acquisto.</p><p>Vediamo allora quali sono asset che possiamo comprare con i nostri risparmi.</p><h3>In cosa possiamo investire?</h3><p>Una nota prima di iniziare: per ogni tipo d’investimento ci sono pro e contro, opportunità e rischi. Per ognuna delle opportunità presentate di seguito discuteremo alcuni rischi. In generale, basta stare attenti e sapere cosa si fa.</p><p>Non pensate, però, che, allora, tenendo i soldi banca eliminate completamente i rischi: abbiamo parlato dell’inflazione ovviamente, ma c’è anche il rischio di controparte. Cioè, la banca a cui vi affidate potrebbe fallire, essere forzatamente chiusa, o il governo potrebbe mettervi le mani in tasca. Basta guadare <a href="https://it.wikipedia.org/wiki/Grande_recessione#La_bancarotta_di_Lehman_Brothers">alla crisi finanziaria del 2008</a>, <a href="https://www.ilsole24ore.com/art/prelievi-forzosi-conti-correnti-cipro-torna-paura-AE2AmxnE">al prelievo forzoso fatto dal governo di Cipro dai conti con oltre 100.000€ nel 2013</a>, o <a href="https://st.ilsole24ore.com/art/mondo/2015-06-28/grecia-rischio-liquidita-varoufakis-valuteremo-controlli-capitali-e-chiusura-banche-170937.shtml?uuid=ACFBJRI">alla chiusura delle banche in Grecia nel 2015</a>. Ma torniamo agli investimenti.</p><h3>Investire nel mattone</h3><p>Abbiamo detto che la nostra casa non è un asset, ma ciò non vuol dire che tutti gli immobili lo siano. Comprare case, appartamenti, o locali commerciali con lo scopo di affittarli significa comprare un asset, almeno fintanto che quello che riceviamo d’affitto copre abbondantemente tutte le spese. In questo caso, la parte d’affitto che non finisce in spese di manutenzione e tasse sarà un guadano che potremo reinvestire in altre attività.</p><p>Ci sono, tuttavia, rischi che dobbiamo considerare. Uno ovvio è che gli affittuari potrebbero non pagare, causando non solo una perdita di guadagno ma anche eventuali spese legali per le procedure di sfratto. Un altro rischio, più grave e più subdolo, è che potremmo comprare in un mercato dominato da una sola industria, per esempio, che potrebbe rendere difficile affittare nel caso in cui quell’industria si sposti altrove o sparisca. Per esempio, Detroit, la famosa città americana di General Motors, è diventata in buona parte una città fantasma a causa dei cambiamenti e decentralizzazione nell’industria dell’automobile.</p><p>Detto ciò, tanta gente ha fatto la propria fortuna investendo in proprietà immobiliari. Normalmente, investimenti in immobili hanno un profilo di rischio medio-basso, con un’aspettativa di guadagni altrettanto medio-bassa.</p><h3>Investire elargendo prestiti: peer-to-peer lending</h3><p>Un altro modo per investire è quello di prestare soldi in cambio di un interesse. Mettere i soldi in un conto di risparmio, in effetti è proprio questo: si prestano soldi alla banca, che in cambio paga un interesse. Solo che le banche sono assicurate e i risparmiatori protetti dallo Stato. I privati no. Quando prestiamo soldi a qualcuno, diventiamo in qualche modo noi la banca, ma senza protezioni.</p><h3>Investire in obbligazioni aziendali (bond aziendali): prestare soldi ad aziende</h3><p>Anche le aziende spesso hanno bisogno di prestiti. Possiamo prestare soldi ad aziende nello stesso modo in cui faremmo con una qualsiasi persona.</p><h3>Investire in obbligazioni statali (bond)</h3><p>Infine, per quanto riguarda i prestiti, anche gli Stati hanno bisogno di soldi. Avete presente il debito pubblico? Quel debito lo possono elargire privati ed enti istituzionali (banche, altri governi, grossi fondi d’investimento, etc) e funzionano nello stesso modo che un debito personale o aziendale. Solo, per i governi, alcuni prestiti sono molto brevi (1–3 mesi), altri sono a medio termine (1–10 anni) e altri sono a lungo e lunghissimo termine (20+ anni).</p><h3>Investire nella propria attività commerciale</h3><p>Investire spesso significa comprare qualcosa. Uno dei migliori modi per investire i propri risparmi, però, è quello di avviare un’attività. Chiaramente ci sono molti rischi nel mettersi in gioco così. La nostra attività potrebbe fallire, così come qualsiasi azienda, ma allo stesso tempo il potenziale guadagno è illimitato. Pensate, per esempio, ad aziende di successo come Apple, Google, o Ferrari. Sono tutte partite in un garage, eppure hanno avuto un successo eccezionale.</p><p>Aprire un’attività di successo non significa necessariamente puntare ai livelli di Apple o Google. Basta avere intraprendenza e dedicarci a ciò che più ci piace. Se l’attività andrà bene, saremo un passo più vicini alla libertà finanziaria e, idealmente, la nostra azienda avrà profitti in eccesso per noi da utilizzare al meglio reinvestendoli. Infatti, un buon imprenditore o amministratore delegato (CEO) ha come obiettivo quello di allocare al meglio il capitale (monetario e umano) di cui dispone.</p><p>Imparando ad investire come Warren Buffett, imparerete anche a capire come operano le migliori aziende e come investire il vostro capitale personale e quello della vostra attività in maniera intelligente.</p><h3>Investire in aziende avviate da altri</h3><p>Oltre ad investire tempo e denaro nell’avviare ed espandere una nostra attività, possiamo anche diventare soci in attività avviate da altri. Per esempio, se avviassi un bar e avessi bisogno di capitale per rimodellare il locale oppure per aprire un secondo punto vendita, avrei due opzioni: chiedere un prestito o vendere parte del bar a qualcuno, diciamo il 10%, e utilizzare i soldi della vendita per quello che mi serve fare. Così è per tutte le aziende.</p><p>Perché mai qualcuno dovrebbe voler venderci parte della sua azienda? Per necessità.</p><p>Prendere un prestito ha un costo immediato perché richiede che sia il capitale sia gli interessi vengano ripagati regolarmente — diciamo ogni mese. Il problema con questa forma di debito è che quindi l’azienda deve generare profitto subito per poterlo ripagare. Molte start-up impiegano anni prima di vedere il primo centesimo. Per esempio, l’azienda dietro Tinder ha guadagnato il primo dollaro di profitto solo dopo ben 5 anni di operazione. Aziende come Uber, invece, anche dopo 10+ anni ancora non hanno generato utili poiché tutto il capitale investito nell’azienda viene speso per espandere l’azienda e tenere i prezzi bassi.</p><p>Quando aziende abbastanza mature chiedono un prestito, hanno anche l’opzione di farlo con un piano d’ammortamento unico, ma di solito è difficile riuscire ad ottenere un prestito del genere più lungo di 2–3 anni, a meno che l’azienda non goda già di sostanziali asset fisici — miniere, inventario di qualità, etc.</p><p>In mancanza dei requisiti richiesti dalle banche, per esempio essere operativi da un certo numero di anni, o se l’azienda ha già dei debiti, è difficile ottenere credito.</p><p>Quindi, se non si può prendere un prestito o non è economicamente vantaggioso farlo, l’unica alternativa, è quella di trovare persone disposte a entrare nel capitale societario dell’azienda in cambio della somma desiderata. Il beneficio per l’investitore è che, possedendo parte dell’azienda, quella persona avrà diritto a partecipare nella distribuzione degli utili della stessa, che possono essere potenzialmente illimitati.</p><p>In pratica, se un’azienda guadagna 10.000€ in un certo lasso di tempo, un investitore che ne possegga il 10% avrà diritto a ricevere 1.000€. Un’azienda può decidere, a voto di maggioranza tra i proprietari o a discrezione dell’amministratore delegato della società, di distribuire o meno tutti o parte dei profitti. Nel bar del nostro esempio, dove i proprietari erano solo due persone, questi due decideranno se è nel miglior interesse dell’azienda distribuire i profitti o se utilizzarli per espandere e/o migliorare ulteriormente l’attività.</p><p>I mercati finanziari — la borsa — porta questa idea alle masse dando la possibilità a chiunque di comprare e vendere liberamente <em>azioni</em> delle società listate. Le azioni rappresentano parte del capitale societario di un’azienda. Per esempio, per un’azienda suddivisa in 100 azioni, ognuna di queste rappresenta l’1% della società. Le aziende quotate in borsa normalmente sono suddivise in milioni di azioni. I mercati finanziari non sono altro che piattaforme che ne rendono possibile lo scambio.</p><p>Tutto ciò significa che quando compriamo azioni stiamo effettivamente comprando una percentuale, per quanto piccola, di una certa azienda, diventandone effettivamente soci, il che ci da diritto a partecipare negli utili della società che, quando distribuiti, vengono chiamati <em>dividendi</em>.</p><p>La maggior parte delle azioni sui mercati finanziari vengono scambiate tra privati, cioè i soldi non finiscono all’azienda che le ha elargite. L’unico momento in cui questo accade è durante l’Offerta Pubblica Iniziale (IPO) in cui la società racimola capitale con la vendita diretta in borsa o tramite intermediari, banche normalmente, che comprano le azioni a priori, almeno in parte, e le rivendono in a grossi investitori privati e in borsa. Un’azienda, però, può anch’essa comprare e vendere azioni, e può anche diluire le azioni esistenti dividendole in più azioni, per poi rivendere direttamente sul mercato pubblico per tirar su capitale dopo la IPO. Per esempio, Tesla ha fatto questa operazione varie volte in passato.</p><p>Come per una qualsiasi attività commerciale, il maggior rischio per l’investitore è quello che l’azienda fallisca. L’altro rischio è quello di non ricevere mai utili sufficienti a ripagare il capitale investito e la perdita dovuta alla mancata abilità di investire gli stessi soldi altrove per un profitto almeno pari a quello che pagherebbe un bond governativo, che, come dicevano è considerato a zero rischi. Il vantaggio, come abbiamo detto, è invece che il potenziale guadagno è illimitato.</p><h3>Investire in campagne di Crowdfunding</h3><p>Oggigiorno, si può anche investire in aziende non listate su alcun mercato finanziario ‘pubblico’ tramite crowdfunding. Cioè, invece che vendere parte dell’azienda in un mercato pubblico, che ha regole e requisiti più stringenti, piccole aziende possono vendere parte del proprio capitale societario a piccoli privati. Fare crowdfunding comporta meno spese, sia immediate, sia negli anni, per piccole aziende che vogliono racimolare ‘piccole’ somme, da poche migliaia a pochi milioni di Euro.</p><p>I rischi per l’investitore sono gli stessi che investire in qualsiasi altra azienda. La differenza principale rispetto alla borsa pubblica è che non si possono liberamente scambiare azioni con altri privati, quindi, come per un investimento nel mattone o in altre aziende private, il capitale è bloccato per tempi a volte lunghi. Il rischio di fallimento è anche maggiore, poiché le aziende sono giovani, ma l’aspettativa di guadagno dalle aziende che hanno successo è altissima.</p><h3>Investire in borsa</h3><p>Qualche paragrafo più su abbiamo spiegato cosa sono le azioni e cosa sono i mercati finanziari. Nel corso di questi articoli e <a href="https://investitoriribelli.it/podcast">nel nostro podcast</a> ci focalizziamo principalmente negli investimenti in aziende listate pubblicamente su questi mercati. Prima di lasciarvi, perciò, volevo parlare di quali sono i modi più comuni d’investire in Borsa e di cui parleremo più approfonditamente in futuro.</p><p>Chiaramente, il modo più ovvio per investire in borsa è quello di farlo direttamente. Purtroppo però, per poterlo fare, abbiamo bisogno di un broker che ci dia accesso a certi mercati. I dettagli del perché sia così, per iniziare, non ci interessano. Quello che è importante sapere è che si ha bisogno di un broker per accedere ai mercati finanziari.</p><p>Un broker può offrire sia una piattaforma online sia una app, permettendoci di comprare e vendere azioni e obbligazioni, o darci accesso a tanti altri servizi, incluso quello di investire i nostri risparmi al posto nostro.</p><p>La maggior parte dei broker e consulenti finanziari si prendono cura di formare un portfolio di azioni e obbligazioni che cerchi di farci raggiungere in tempi ragionevoli — e in base alle nostre esigenze — certi obiettivi finanziari. Ci consigliano, quindi, cosa fare e dove mettere i nostri soldi, ma poi siamo noi a dover investire effettivamente i nostri risparmi o a delegarle qualche privato o azienda che lo faccia per noi.</p><p>Alcune piattaforme d’investimento, invece, non ci consigliano direttamente cosa fare, ma prendono i risparmi che gli affidiamo e li investono per noi secondo un certo “profilo di rischio” che associano in base a informazioni e questionari che compiliamo per loro.</p><p>Altri, invece, lasciano a noi pieno controllo e nemmeno ci danno consigli, ma ci danno una piattaforma che ci permette di fare transazioni, e, al più, ci offrono materiale di ricerca, dati finanziari sulle aziende listate nei mercati che coprono, articoli scritti da esperti, e così via.</p><p>Il tipo di broker migliore da scegliere è poi una preferenza personale. In ogni caso, vi invitiamo ad educarvi su come funzionano i mercati, su quali sono i prodotti finanziari disponibili, e su come fare l’analisi di un’azienda — tutte cose che vedremo insieme — così da poter valutare al meglio le nostre opzioni e le persone a cui ci affidiamo.</p><h3>Conclusione</h3><p>Direi, a questo punto, che abbiamo grosso modo elencato tutte le possibilità che ci sono per impiegare i propri risparmi. Ho volutamente evitato di parlare di speculazione sul prezzo di cose tipo legna, valute, Bitcoin, o succo d’arancia — ricordate <a href="https://www.youtube.com/watch?v=B8IoK2VFCwg">‘Una Poltrona Per Due’</a>? — ma per il resto credo che abbiamo coperto abbastanza terreno.</p><p>Nei prossimi articoli esploreremo sempre più a fondo come investire in aziende in maniera intelligente. Andremo quindi a capire quali sono le caratteristiche che cerchiamo in un’azienda e come determinare il prezzo giusto a cui comprarla.</p><p>Vi ricordiamo che <em>Investitori Ribelli</em> non offre servizi di consulenza finanziaria. Tutti gli argomenti trattati sono da considerarsi contenuti generali a scopo educativo e informativo. Pertanto non costituiscono, né sostituiscono, in alcun modo la consulenza di un esperto finanziario. Prima di prendere alcuna decisione finanziaria, assicuratevi di esservi accuratamente informati. Il blog, il sito, e il podcast sono curati solo per la vostra educazione ed intrattenimento.</p><p><em>Originally published at </em><a href="https://investitoriribelli.it/blog/cosa-possiamo-fare-con-i-risparmi"><em>https://investitoriribelli.it</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85947eb17cdf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/investitori-ribelli/come-possiamo-investire-i-nostri-soldi-85947eb17cdf">Come possiamo investire i nostri soldi?</a> was originally published in <a href="https://medium.com/investitori-ribelli">Investitori Ribelli</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Perché è importante investire invece che mettere i soldi sotto al materasso]]></title>
            <link>https://medium.com/investitori-ribelli/perch%C3%A9-%C3%A8-importante-investire-invece-che-mettere-i-soldi-sotto-al-materasso-ae800bbf7744?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae800bbf7744</guid>
            <category><![CDATA[inflazione]]></category>
            <category><![CDATA[risparmiare]]></category>
            <category><![CDATA[interesse-composto]]></category>
            <category><![CDATA[guadagnare]]></category>
            <category><![CDATA[investire]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Mon, 13 Jan 2020 08:01:01 GMT</pubDate>
            <atom:updated>2020-01-19T17:13:43.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*boPHhY_TSxvKBon40pfPkg.jpeg" /></figure><p>Spesso, quando si parla di investimenti, si tende ad associare una connotazione negativa al concetto. Si pensa spesso ad attività paragonabili al gioco d’azzardo, specialmente quando riguardano i mercati finanziari, e si pensa che comportino rischi altissimi con possibilità di ‘vincere’ limitate. È chiaro che, con questa premessa, per chi non l’ha mai fatto o per chi non ha diligentemente studiato come farlo bene, investire il proprio denaro in qualsiasi attività può far paura. Averne è normalissimo, specialmente all’inizio.</p><p>Nel corso delle prossime settimane, in articoli come questo e nel <a href="https://investitoriribelli.it/podcast">podcast</a>, io e <a href="https://medium.com/u/8ae272b78b24">Jessica Lascar</a> vi parleremo di quali sono state le nostre motivazioni per iniziare ad investire, dei nostri obiettivi, di quello che abbiamo imparato, e degli errori che abbiamo commesso nel tempo. Voglio anche mettere in chiaro che non ci sentiamo affatto ‘esperti’ e certamente non siamo dei guru. Abbiamo, dopo tanto tempo e molti sbagli, trovato il nostro modo di operare i nostri risparmi, e stiamo ancora percorrendo i primi passi del nostro cammino da seri investitori. Insieme a noi speriamo scoprirai come investire in maniera intelligente e a guardare diversamente ai rischi.</p><blockquote>Il rischio nasce dal non sapere cosa stai facendo.<br> — Warren Buffett</blockquote><p>Ad ogni modo, quando abbiamo iniziato a lavorare, io e Jessica abbiamo iniziato anche a risparmiare una percentuale del nostro guadagno, regolarmente, ogni mese. Purtroppo, però, per lungo tempo abbiamo semplicemente lasciato quei soldi in banca, senza sfruttarli a pieno.</p><p>Il problema sta nel fatto che, a causa dell’inflazione, i risparmi tenuti in banca, nel salvadanaio, o sotto al materasso perdono di valore nel tempo.</p><p>Avete presente quelle immagini al telegiornale dove si vedono soldi che vengono stampati di continuo? Quella è l’inflazione alla nascita! Quelle banconote e monete vengono create quando una banca centrale come la Banca Centrale Europea (BCE) presta soldi ad uno Stato per finanziare spese e progetti tramite credito. Nuova valuta, però, viene anche creata dalle banche commerciali e servizi di credito quando prestano denaro ad aziende e privati, che sia per un prestito personale, un mutuo, o anche quando paghiamo con carta di credito.</p><p>In più, <a href="https://www.ecb.europa.eu/pub/economic-bulletin/articles/2018/html/ecb.ebart201806_03.en.html#toc4">secondo i dati della BCE</a>, <strong>le banconote rappresentano solo il 54% dei soldi spesi nell’Eurozona!</strong> Quindi, quasi la metà dei soldi in circolazione sono solo digitali, numeri su uno schermo. Non ci rendiamo subito conto che sono in circolazione, che fa sì che la creazione di nuova valuta sia ancora più facile con il sistema attuale.</p><p>Ma perché questo è importante? L’effetto dell’aumento di valuta in circolazione è che il valore della moneta esistente diluisce, e poiché ci sono più persone di prima in grado di comprare gli stessi beni e servizi, il prezzo di questi tende ad aumentare. Come saprete, il prezzo è solo una funzione di domanda e offerta. Se la domanda aumenta a causa di una più facile disponibilità di credito o moneta, il prezzo aumenta.</p><blockquote><em>L’inflazione è l’aumento di valuta in circolazione che porta alla diminuzione del potere d’acquisto della valuta stessa e, come conseguenza, all’aumento dei prezzi.</em></blockquote><h3>Non investire significa fare una scelta che distrugge i risparmi</h3><p>Poiché la nostra società crea continuamente inflazione, il potere d’acquisto dei nostri risparmi diminuisce nel tempo. Quindi, lasciare soldi in banca o sotto al materasso significa effettivamente perdere soldi a lungo andare. Si dice che un’immagine valga più di 100 parole, quindi eccovi un bel grafico:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nre5GVdJ8KD9dXM3AI-WWg.jpeg" /></figure><p>Il grafico vi mostra come il potere d’acquisto di 10.000,00€ cambia nel tempo con un’inflazione al 2%. Nell’esempio, dò per scontato che l’interessa pagato dalla banca in cui abbiamo depositato quel denaro sia irrisorio, quindi non lo conto. Dopo 50 anni, in questo esempio, avremo ancora gli stessi 10.000,00€ iniziali depositati in banca, ma il loro potere d’acquisto sarà drasticamente cambiato. I nostri risparmi basteranno, dopo quel tempo, ad acquistare beni e servizi che oggi costano solo 3.641,70€! 😭</p><p>Considerate che un’inflazione <em>reale</em> del 2% annuo, è storicamente molto bassa. In Italia, <a href="https://www.istat.it/it/archivio/230127">l’ISTAT stima che negli ultimi anni l’inflazione sia stata solo dello 0–1% annuo</a>, ma ci sono stati periodi in cui l’inflazione galoppava al 6–7% e periodi in cui arrivava o superava addirittura il 15%!</p><p>Ad ogni modo, anche l’inflazione dell’ultimo decennio in realtà è stata molto più alta rispetto alla stima. Per esempio, quando lo scorso Natale sono tornato in Italia, ho notato come il prezzo della tratta autostradale tra casa dei miei e casa dei genitori di Jessica sia raddoppiata rispetto a quando eravamo all’università nel 2010. Questo significa che il prezzo di quella tratta è aumentato di circa il 7% annuo in 10 anni! E così ho notato anche altri prezzi cambiati rispetto a quello che ricordavo dai tempi dell’università. Mi pare ovvio, quindi, che i numeri dell’ISTAT non siano proprio giusti… o che siano stati quando meno ‘massaggiati’ da forze socio-politiche.</p><p>Vediamo allora come cambierebbe il potere d’acquisto degli stessi 10.000€ dell’esempio precedente con un’inflazione del 5%, questa volta; quella che in Italia c’è stata, secondo l’ISTAT, negli anni ‘90.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vsKnouGMMpoJuDRSi1__XQ.jpeg" /></figure><p>Wow! Con il 5% di inflazione, dopo 50 anni, i nostri risparmi saranno arrivati a valere praticamente niente! Già solo dopo 10 anni avranno perso quasi la metà del loro potere d’acquisto! E questo senza nemmeno considerare che, almeno in Italia, la maggior parte dei conti bancari hanno un costo annuale che riduce ulteriormente la somma nel nostro salvadanaio! 😔</p><p>Ma allora che possiamo fare per evitare che i nostri soldi vadano in fumo? L’unica soluzione è investirli — ora vedremo come — in modo da guadagnare dai nostri risparmi, invece che lasciarli a subire l’effetto dell’inflazione… e possibilmente farci anche di più.</p><p>“Ma aspetta,” mi direte “il mio libretto di risparmio mi paga degli interessi che tu prima hai ignorato!” ed io vi risponderò “Si, ma quanto sono questi interessi?! L’ultima volta che ho controllato, giusto lo scorso Natale, un libretto bancario o postale pagava ben lo 0.1% LORDO annuo, prima di commissioni e un bel 26% in tasse! Insomma, un netto ben lontano dalle percentuali d’inflazione che stiamo considerando e tranquillamente trascurabile!”</p><h3>Che significa investire?</h3><p>Va bene, abbiamo capito che l’inflazione ci mangia i soldi e che bisogna ‘investirli’, ma che significa? Significa evitare di consumare oggi per poter consumare di più domani. Significa spendere quei soldi per costruire o acquistare attività produttive oggi che ci diano una <em>ragionevole</em> aspettativa di guadagno in futuro. Prima di dilungarci su quali siano alcune di queste attività, anche se alcune le abbiamo di sfuggita accennate, vediamo, invece, quali sono i benefici di investire i nostri risparmi rispetto a tenerli al ‘sicuro’ in banca.</p><h3>La matematica che non ti insegnano a scuola</h3><p>Se ci prendiamo la briga di privarci di qualcosa oggi, lo facciamo perché ci aspettiamo di guadagnarci qualcosa. Poi, moniti di parenti, amici, e media ci avvisano che investire comporta rischi, quindi perché farlo? Vediamolo.</p><p>Ipotizziamo, per esempio, di aver messo i nostri risparmi in uno speciale conto bancario. La banca può utilizzare i soldi su questo conto per elargire prestiti — per esempio mutui — e, per questo privilegio, ipotizziamo ci paghi un interesse del 7% annuo. Questo interesse, però, ci vene pagato su un altro conto. Una volta aperto quel conto speciale non possiamo depositarvi altri soldi e possiamo averne solo uno. In questo caso, il tipo di interesse che la banca ci paga è un interesse <em>semplice</em>, cioè ci viene dato immediatamente a maturità invece di essere reinvestito.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SG62PPhJD07T8kY_VFcrzQ.jpeg" /></figure><p>Il grafico su, mostra tre dati. Il capitale che abbiamo prestato alla banca rimane invariato nel tempo e rimane a 10.000€, rappresentato dall’area nera. Gli interessi che la banca ci ha pagato, più i 10.000€ di capitale sono rappresentati dalla fascia rossa, e dopo 50 anni il nostro gruzzolo sarà salito a un valore nominale di 45.000€. Il potere d’acquisto del nuovo totale, tenendo conto dell’inflazione, è rappresentato dalla fascia blu. Quindi, dopo 50 anni, il nostro capitale iniziale, che una volta poteva comprare beni e servizi del valore odierno di 10.000€, potrà comprare beni e servizi che oggi ci costerebbero 35.000€. Un aumento del potere d’acquisto di 3 volte e mezzo! Non male! 🧐</p><p>La vera magia, però, accade nel momento in cui quel guadagno generato dalla banca può essere reinvestito e a sua volta va generare ulteriore guadagno. Vediamo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AZtUAj-RvK2SQwqv5-Oibg.jpeg" /></figure><p>Come prima, in rosso c’è il valore nominale del nostro capitale totale e in blu il suo potere d’acquisto considerando l’inflazione. Questa volta, però, è tutta un’altra storia! Il nostro gruzzolo è passato, nello stesso arco di 50 anni, da 10.000€ a quasi 300.000€ e potrà comprare beni e servizi che oggi ci costerebbero ben 114.000€. Un guadagno effettivo di oltre 10 volte! 🤑</p><p>Ma non finisce qui! Chi ha detto che dobbiamo investire solo una somma iniziale e andare in letargo per 50 anni mentre i nostri soldi si moltiplicano? Vediamo cosa succederebbe se, partendo da un capitale nullo, mettessimo da parte 500€ al mese, con gli stessi interessi e inflazione di prima.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b69IOwiJgLkCvl3NA0X2lg.jpeg" /></figure><p>Questa volta, in 50 anni avremmo messo da parte una bella sommetta di 300.000€, ma investendo tutti i nostri risparmi ogni anno, a fine anno, il nostro capitale sarà passato a valere oltre 1 milione e 250 mila euro al netto dell’inflazione, mentre il nostro estratto conto ci direbbe che in banca ci sono quasi 2 milioni e mezzo! 😱</p><p>Per darvi il colpo di grazia, sentite questa: <a href="https://www.fool.com/investing/general/2016/04/22/how-have-stocks-fared-the-last-50-years-youll-be-s.aspx">il guadagno che i mercati finanziari hanno dato agli investitori durante gli ultimi 50 anni è stato di oltre il 9% con un inflazione di circa il 4% mediamente</a>. Io però, seguendo l’esempio di Warren Buffett, il più grande investitore di tutti i tempi, punterò ad un guadagno annuale composto del 15%. Considerando sempre l’inflazione attuale al 2%, vediamo che risultati otterrei.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FBV22zfMoeq48kq5DAoGNg.jpeg" /></figure><p>I numeri parlano da soli. Dopo 25 anni avrei già oltre un milione, e dopo 50 anni, ben 43 milioni di euro in banca, con un potere d’acquisto di 20 milioni. 💰💰💰</p><p>In questi esempi, tra l’altro, si vede come l’impatto dell’inflazione sia terribile a lungo andare. Una misera inflazione del 2% più che dimezza il valore dei nostri soldi in relativamente poco tempo!</p><h3>La crescita composta del capitale</h3><p>Come avrete notato, il nostro capitale investito, con i guadagni reinvestiti ad amplificarne l’effetto, ci porta ad un guadagno esponenziale. E in tutti gli esempi ci sono solo tre variabili:</p><ol><li>Il capitale investito (inclusa periodicità di nuovo capitale se serve)</li><li>Il tasso di crescita (l’interesse ricevuto dalla banca, nei nostri esempi)</li><li>Il tempo</li></ol><p>Nel bene o nel male, il tempo è, tra tutti, il fattore fondamentale. Tutte le variabili sono importanti, chiaramente, ma, tra queste, il tempo è quello che più influisce. Come avrete visto dai grafici che vi ho presentato, man mano che passa il tempo la crescita del capitale accelera. Il perché è chiaro: più tempo teniamo i nostri soldi investiti, più questi genereranno profitti; maggiori i profitti, maggiore sarà il capitale investito a ripetere lo stesso processo, creando l’effetto esponenziale.</p><p>Insomma, se leggendo questo post speravate in qualche formula magica per diventare ricchi in un giorno, cadete male. Quello che insieme a Jessica cercherò di presentarvi in questi articoli e nel <a href="https://investitoriribelli.it/podcast">podcast</a> è una formula per <strong>diventare ricchi lentamente, ma certamente</strong>.</p><h3>Allora, come possiamo investire i nostri soldi?</h3><p>Beh, questo articolo è diventato un po’ lunghetto, quindi ne parlerò nel prossimo.</p><h3>Conclusione</h3><p>Abbiamo visto che a tenere i soldi sotto al materasso si perde, nel tempo, potere d’acquisto, cioè quello che possiamo permetterci di comprare con quei soldi.</p><p>Abbiamo poi parlato della causa di questa perdita di valore della moneta, l’inflazione.</p><p>Infine, abbiamo visto come, investendo del capitale ad un guadagno superiore l’inflazione, e reinvestendo quel guadagno, si ottiene un profitto esponenziale.</p><p>Spero, perciò, che vi siate convinti dell’importanza di investire il proprio denaro. Nel prossimo articolo vedremo in cosa possiamo investire i nostri soldi, andremo più a fondo sulla storia di come io e Jessica abbiamo iniziato ad investire, e di come lo stiamo facendo.</p><p>Per questa volta è tutto. Alla prossima!</p><p><em>Publicato inizialmente su </em><a href="https://investitoriribelli.it/blog/la-importanza-di-investire"><em>https://investitoriribelli.it</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae800bbf7744" width="1" height="1" alt=""><hr><p><a href="https://medium.com/investitori-ribelli/perch%C3%A9-%C3%A8-importante-investire-invece-che-mettere-i-soldi-sotto-al-materasso-ae800bbf7744">Perché è importante investire invece che mettere i soldi sotto al materasso</a> was originally published in <a href="https://medium.com/investitori-ribelli">Investitori Ribelli</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring Vapor apps for Testing]]></title>
            <link>https://medium.com/the-swift-web-developer/configuring-vapor-apps-for-testing-7b89f1a6e6a?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b89f1a6e6a</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[vapor]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[server-side-swift]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Wed, 22 Feb 2017 18:02:00 GMT</pubDate>
            <atom:updated>2017-02-22T20:12:09.013Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*qbddpHqoGkaecb2OUavEXg@2x.png" /></figure><p>When you create a new Vapor application using the command line tools the framework provides, there’s no test target created by default. So, what do you need to do to add tests to your new app?</p><p>This guide will help you set up your Vapor project for testing.</p><h3>TL;DR</h3><p>I’ve created an alternative template for Vapor already set up for testing. If you’re creating a new project you can use the following command to kick start a project with testing in mind:</p><pre>vapor new MyApp --template=<a href="https://github.com/gtranchedone/vapor-testing-template">https://github.com/gtranchedone/vapor-testing-template</a></pre><p><strong>N.B. The executable name given by this template is called </strong><strong>Executable not </strong><strong>App , like the default template! You may need to change some of your deployment configurations.</strong> See the notes at the end of this article to see how to update your Heroku configuration.</p><p>If you already have a project set up and you want to start writing tests for it, you’ll have to follow the instructions below.</p><h3>1. Prepare the app for testing</h3><p><a href="https://theswiftwebdeveloper.com/the-swift-package-manager-ce0c7811b219">In my last article I’ve discussed how the Swift Package Manager works</a>, and that is fundamental to understanding how to structure your project for testing.</p><p>In a nutshell, every subdirectory in the Sources folder is considered to be a target. The same applies to the subdirectories in the Tests folder. Also, any folder containing a main.swift file is considered an executable.</p><p>Vapor’s default template creates the following folder structure (I’m omitting some files for the sake of brevity):</p><pre>.<br>├── Config<br>├── Localization<br>├── Package.swift<br>├── Public<br>│   ├── images<br>│   └── styles<br>├── README.md<br>├── Resources<br>│   └── Views<br>├── Sources<br>│   └── App<br>│       ├── Controllers<br>│       │   └── PostController.swift<br>│       ├── Models<br>│       │   └── Post.swift<br>│       └── main.swift<br>└── app.json</pre><p>Vapor creates an App folder <a href="https://theswiftwebdeveloper.com/the-swift-package-manager-ce0c7811b219">that is an executable</a>. Unfortunately, at the time being <strong>XCTest doesn’t support testing <em>executables</em></strong>. Therefore, the first step we have to take is make our App a <em>library</em> so that XCTest can run properly.</p><p>Let’s move the main.swift file from Sources/App to a new folder Sources/Executable. You can call this folder whatever you like; it’s not important.</p><p>As the entry point to the app now lives in a new module, you’ll need to import the App module to use its classes for routing. Add the following line to main.swift:</p><pre>import App</pre><p>Finally, we have to declare that our package now has an Executable target and that it depends on the App module. Update the package manifesto, Package.swift, with the following targets property:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3cf66e01c85a541ef2241cc36abb6231/href">https://medium.com/media/3cf66e01c85a541ef2241cc36abb6231/href</a></iframe><p>Note that <strong>the </strong><strong>exclude property should not contain the entry </strong><strong>Tests</strong>, which was present, until recently, in Vapor’s default template.</p><p>The new folder structure now should look like this:</p><pre>.<br>├── Config<br>├── Localization<br>├── Package.swift<br>├── Public<br>│   ├── images<br>│   └── styles<br>├── README.md<br>├── Resources<br>│   └── Views<br>├── Sources<br>│   ├── App<br>│   │   ├── Controllers<br>│   │   │   └── PostsController.swift<br>│   │   └── Models<br>│   │       └── Post.swift<br>│   └── Executable<br>│       └── main.swift<br>└── app.json</pre><h3>2. Add a test target</h3><p>Now that the app is properly divided into executable and core app domain, you can add a test target and tests to the project.</p><p>To start with, create a Tests directory at the root of your repo. Inside, add a folder called AppTests.</p><p>I like to have the same folder structure for both the App and AppTests directories. Therefore, I’ll add both a Controllers and a Models folders into AppTests. Finally, let’s add some tests. Here’s an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb61bb031f92b32781d4f907bd0c66cd/href">https://medium.com/media/bb61bb031f92b32781d4f907bd0c66cd/href</a></iframe><p>Now, your app should look like this:</p><pre>.<br>├── Config<br>├── Localization<br>├── Package.swift<br>├── Public<br>│   ├── images<br>│   └── styles<br>├── README.md<br>├── Resources<br>│   └── Views<br>├── Sources<br>│   ├── App<br>│   │   ├── Controllers<br>│   │   │   └── PostsController.swift<br>│   │   └── Models<br>│   │       └── Post.swift<br>│   └── Executable<br>│       └── main.swift<br>├── Tests<br>│   └── AppTests<br>│      ├── Controllers<br>│      │   └── PostsControllerTests.swift<br>│      └── Models<br>│          └── PostTests.swift<br>└── app.json</pre><h3>3. Fix the tests on Linux</h3><p>There’s one last problem we have to fix. When running the tests on a Mac, XCTest currently uses the Objective-C runtime to find your tests. However, as there’s no way to do this with Swift, when running the tests on Linux, for example on a CI server, your tests won’t be found, and you’ll get an error.</p><p>To fix this issue, you need to add a LinuxMain.swift file inside the Tests directory. <a href="https://github.com/apple/swift-corelibs-xctest/blob/master/Documentation/Linux.md">As described in the documentation of </a><a href="https://github.com/apple/swift-corelibs-xctest/blob/master/Documentation/Linux.md">XCTest</a>, this file needs to explicitly call a function of the framework with the tests you want to run.</p><p>The recommended way to handle this is to create a static method in each of your test cases and call it from the LinuxMain.swift file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ee0dabdf39695993a586faf6b932a42/href">https://medium.com/media/0ee0dabdf39695993a586faf6b932a42/href</a></iframe><p>With this configuration in place, your tests will run perfectly fine on both macOS and Linux. So, your final application will look like this:</p><pre>.<br>├── Config<br>├── Localization<br>├── Package.swift<br>├── Public<br>│   ├── images<br>│   └── styles<br>├── README.md<br>├── Resources<br>│   └── Views<br>├── Sources<br>│   ├── App<br>│   │   ├── Controllers<br>│   │   │   └── PostsController.swift<br>│   │   └── Models<br>│   │       └── Post.swift<br>│   └── Executable<br>│       └── main.swift<br>├── Tests<br>│   ├── AppTests<br>│   │   ├── Controllers<br>│   │   │   └── PostsControllerTests.swift<br>│   │   └── Models<br>│   │       └── PostTests.swift<br>│   └── LinuxMain.swift<br>└── app.json</pre><h3>Notes</h3><p>This template has an important implication on how your app is executed on the server. In particular you want to make sure that the right executable is being run on the server. By default, Vapor and all tutorials out there assume your executable name is called “App”, however, the executable in our case is called “Executable”.</p><h4>Updating the Heroku configuration</h4><p>If you’re using Heroku to deploy your app, edit the Procfile and change the first occurrence of App to Executable. (Note that the following should be all on one line.)</p><pre>web: <strong>Executable</strong> --env=production --workdir=./ --config:servers.default.port=$PORT</pre><p>When you’re setting up Heroku with Vapor using the Vapor Toolbox, you’ll be asked if you want to use a custom executable name. At that point, you should answer ‘yes’ and type ‘Executable’ as the given name. That will make your Procfile right on configuration.</p><pre>vapor heroku init<br>...<br>Do you want to use a custom executable name?<br>y/n? <strong>y</strong><br>Executable name &gt; <strong>Executable</strong><br>...</pre><h4>Don’t repeat yourself: use a template!</h4><p>I’ve created a template you can use when creating new Vapor apps using the vapor toolbox, like so:</p><pre>vapor new MyApp -template=<a href="https://github.com/gtranchedone/vapor-testing-template">https://github.com/gtranchedone/vapor-testing-template</a></pre><p>This will create a project with the folder structure and configuration described in this article, plus an initial test for routes.</p><h3>Subscribe to Swift Web Weekly!</h3><p>If you’re interested in web development with Swift, <a href="http://swiftwebweekly.com/"><em>Swift Web Weekly</em></a> is a <strong>free newsletter</strong> I’m curating with interesting links related to server-side Swift, HTML, CSS, JavaScript, tools and more. If you don’t like it you can unsubscribe anytime, so why don’t give it a try?! 🙂</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fd53253%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2Fd53253%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href">https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b89f1a6e6a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-swift-web-developer/configuring-vapor-apps-for-testing-7b89f1a6e6a">Configuring Vapor apps for Testing</a> was originally published in <a href="https://medium.com/the-swift-web-developer">The Swift Web Developer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Swift Package Manager]]></title>
            <link>https://medium.com/the-swift-web-developer/the-swift-package-manager-ce0c7811b219?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce0c7811b219</guid>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swift-package-manager]]></category>
            <category><![CDATA[server-side-swift]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Wed, 22 Feb 2017 18:02:00 GMT</pubDate>
            <atom:updated>2017-02-22T18:02:00.543Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBS89hx22xdpXR9d3aBHUw@2x.png" /></figure><h4>An introduction</h4><p>Swift 3 adds a new tool to our toolbox: the Swift Package Manager.</p><blockquote>The Swift Package Manager is a tool for managing the distribution of source code, aimed at making it easy to share your code and reuse others’ code. The tool directly addresses the challenges of compiling and linking Swift packages, managing dependencies, versioning, and supporting flexible distribution and collaboration models.</blockquote><p>Many languages have a package manager built by the authors of the language or the community around it. If you come from an iOS background, you can think about the Swift Package Manager as a <a href="http://cocoapods.org/">CocoaPods</a> for pure Swift modules, one that doesn’t integrate the code into your Xcode project, but only downloads and manages the sources… for now. Or if you come from a Ruby background, you can think about it as <a href="https://rubygems.org/">RubyGems</a>.</p><h3>What is a package manager?</h3><p>A package manager is a tool that takes care of installing, updating and deleting software for your machine or project. It also helps to build a new package.</p><h4>Packages</h4><p>A package is simply a library or program that has a <em>Manifesto</em> declaring its properties for a specific package manager to read.</p><p>Packages are often required to follow the <a href="http://semver.org/">semantic versioning</a> scheme, where the software’s version is defined using three numbers separated by dots, each with a specific meaning. Version x.y.z indicates a <em>major</em> release x, <em>minor</em> y, and <em>patch</em> z. Where the <em>major</em> release indicates breaking changes in the API, the <em>minor</em> an addition or change in behavior but compatible API, and the <em>patch</em>, only bug fixes, performance improvements, or improved documentation.</p><h4>Dependency Management</h4><p>Besides automating the tasks of downloading or deleting source code and executables, a package manager’s primary function is to build a dependency tree that ensures dependencies integrity on your machine or project.</p><p>Managing dependencies correctly becomes especially important when the packages you want to use depend on other packages to perform their tasks. If you use multiple packages that depend on another one, the manager’s job is to ensure that this requirement can be satisfied.</p><p>Imagine you use three packages:</p><ul><li>Package A — has no dependencies</li><li>Package B — depends on Package D (an external package, not in our dependencies list)</li><li>Package C — also depends on Package D</li></ul><p>There are multiple scenarios that a package manager has to handle. There are at least three common scenarios that the tool has to consider:</p><ol><li>Both Package B and Package C depend on the same version of package D; for example they may both depend on version 1.0.</li><li>Package B depends on a specific version of Package D (e.g. =1.0.2) and Package C depends on a compatible version of Package D (e.g. ~&gt;1.0, which means major version 1, minor 0, any patch version)</li><li>Package B and Package C depend on incompatible versions of Package D. For example, Package B may depend on version 1.0 and Package C on version 2.0.</li></ol><p>In both case 1 and case 2, all dependencies can be satisfied. In case 1, version 1.0 of Package D will be used for both.</p><p>In case 2, Package C has a soft dependency on version 1.0, so it will be happy with any version 1.0.x. Package B, instead, has a hard requirement on version 1.0.2. The package manager can use that version (1.0.2) to satisfy the requirements of both Package B and C.</p><p>In the third scenario, Package B depends on version 1.0, but Package C depends on version 2.0. The two versions are not compatible and therefore the dependencies cannot be satisfied. The package manager’s job, in this case, is to fail and inform the user of the problem. This problem is commonly known as <a href="https://en.wikipedia.org/wiki/Dependency_hell"><em>dependency hell</em></a>.</p><h3>How does the Swift Package Manager work?</h3><p>The SwiftPM helps us both create and consume packages. Let’s see how.</p><p><em>NOTE: you can run the command </em><em>swift package --help from a Terminal window to get a list of available SwiftPM commands and options.</em></p><h4>The Anatomy of a Package</h4><p>To the SwiftPM a package is any folder containing the following:</p><ul><li>The <em>Package Manifesto</em> — a file named Package.swift that has to create a Package object from the PackageDescription module.</li><li>Swift Source files</li><li>An optional Tests folder organized in a similar fashion as the Sources directory and optionally containing a LinuxMain.swift file for running tests on Linux.) Subfolders in the Tests directory represent test modules and will contain your test cases.</li></ul><p>The package source files can be organized in either one of the following structures:</p><ul><li>In a Sources/Source/src folder containing either Swift sources or subdirectories containing Swift source files, where each subdirectory is considered to be a different Swift module.</li><li>In a set of directories containing Swift sources, where each subdirectory is considered to be a different Swift module.</li><li>At the root of your package, alongside the Package.swift file. In this case, the whole package is considered a module.</li></ul><p>For example, a module’s structure could look like this:</p><pre>.<br>├── Package.swift<br>├── Sources<br>│   └── MyModule<br>│       └── MyModule.swift<br>└── Tests<br>    ├── LinuxMain.swift<br>    └── MyModuleTests<br>        └── MyModuleTests.swift</pre><h4>Library vs. Executable</h4><p>An important note goes to the type of modules a package can contain. Any module that contains a main.swift file is considered an <em>executable</em>. If that file is not present, SwiftPM will consider the module a library. <strong>Executables are meant to be command-line applications, while libraries are meant to be embedded in other modules and packages.</strong></p><h4>Authoring a Package</h4><p>To facilitate things, SwiftPM allows you to create a new package using the command swift package init. <strong>You should execute this command in an empty directory</strong>.</p><p>This is what you get when you run the command:</p><pre>.<br>├── Package.swift<br>├── Sources<br>│   └── MyPackage.swift<br>└── Tests<br>    ├── LinuxMain.swift<br>    └── MyPackageTests<br>        └── MyPackageTests.swift</pre><p>Let’s now have a look at the Package.swift file:</p><pre>import PackageDescription</pre><pre>let package = Package(<br>    name: &quot;MyPackage&quot;<br>)</pre><p>Simple, eh? Of course, there are way more you can specify than just the package name. Let’s have a look at a more complex example:</p><pre>import PackageDescription</pre><pre>let package = Package(<br>    name: &quot;MyVaporApp&quot;,<br>    targets: [<br>        Target(name: &quot;Executable&quot;, dependencies: [&quot;App&quot;])<br>    ],<br>    dependencies: [<br>        .Package(url: &quot;<a href="https://github.com/vapor/vapor.git">https://github.com/vapor/vapor.git</a>&quot;, <br>                 majorVersion: 1,<br>                 minor: 5)<br>    ],<br>    exclude: [<br>        &quot;Config&quot;,<br>        &quot;Database&quot;,<br>        &quot;Localization&quot;,<br>        &quot;Public&quot;,<br>        &quot;Resources&quot;<br>    ]<br>)</pre><h4>Consuming Packages</h4><p>If you’re building a web app with Swift, the quickest way to get started with SwiftPM is to use it to consume packages. <a href="https://vapor.codes/">Vapor</a>, <a href="https://kitura.io/">Kitura</a>, and all other web frameworks built with Swift heavily rely on the package manager. The trick is that the projects this framework create are Swift Packages themselves! You read that right. <strong>To consume a package your project has to be a package itself!</strong></p><blockquote><strong>To consume a package your project has to be a package itself!</strong></blockquote><p>Consuming packages, then, becomes just a matter of declaring dependencies in the <em>Package Manifesto</em>.</p><p>As I’m writing this article, <strong>there’s no support for integrating Swift Packages in iOS, macOS, watchOS or tvOS apps</strong>. However, support for doing so is being considered for a future release of SwiftPM.</p><h3>Problems with SwiftPM</h3><p>Compared to other packages managers, the first version of SwiftPM has a few problems. The main ones related to users not being able to point a package’s source to a branch or local path. Only tags on a remote git repository are allowed at the moment.</p><p>Luckily most of this issues are already fixed for Swift 3.1 or Swift 4. <a href="https://lists.swift.org/pipermail/swift-evolution-announce/2017-January/000307.html">Others issues and improvements are being considered for future releases</a>. You can check what’s coming in the Swift Package Manager on the <a href="https://apple.github.io/swift-evolution/">Swift Evolution website</a> (filter for “package” or “package manager” to see only related proposals).</p><h3>Where can I find Swift packages?</h3><p>Another problem with the Swift Package Manager is that, unlike similar tools available for iOS or other languages and ecosystems, there’s no built-in functionality to search for packages. Discovery is a feature that the team behind the Swift Package Manager is considering for the future but hasn’t been prioritized yet.</p><p>That said, others have come forward with their solution:</p><ul><li><a href="https://packagecatalog.com/">IBM’s Swift Package Catalog </a>— my personal favorite so far.</li><li><a href="http://swiftpack.co/">Swiftpack</a> — a minimalistic alternative to IBM’s Package Catalog.</li><li><a href="https://swiftmodules.com/">SwiftModules</a> — another alternative to note, although I never use it.</li></ul><h3>Contribute!</h3><p>As a final note, I’d love to see more people contributing packages for the entire community to consume. Especially if you already have Pods you contribute to or if your code can be run cross-platform and doesn’t rely on the iOS SDK. Make them available; <strong>it’s easy!</strong></p><h3>Subscribe to Swift Web Weekly!</h3><p>If you’re interested in web development with Swift, <a href="http://swiftwebweekly.com/"><em>Swift Web Weekly</em></a> is a <strong>free newsletter</strong> I’m curating with interesting links related to server-side Swift, HTML, CSS, JavaScript, tools and more. If you don’t like it you can unsubscribe anytime, so why don’t give it a try?! 🙂</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fd53253%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2Fd53253%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href">https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce0c7811b219" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-swift-web-developer/the-swift-package-manager-ce0c7811b219">The Swift Package Manager</a> was originally published in <a href="https://medium.com/the-swift-web-developer">The Swift Web Developer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Atom for Web Development with Swift]]></title>
            <link>https://medium.com/the-swift-web-developer/using-atom-for-web-development-with-swift-6ab42ac415c2?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ab42ac415c2</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[atom-text-editor]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[server-side-swift]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Wed, 08 Feb 2017 09:02:00 GMT</pubDate>
            <atom:updated>2017-02-20T23:53:58.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rgWx38gXWbHJb2_M3z9gdQ.png" /></figure><h4>Why it’s a good idea to use it + favorite packages and tips</h4><p><a href="https://swift.org/">The Swift programming language</a> is great for building apps and, when Apple made it Open Source, it became appealing for <a href="https://theswiftwebdeveloper.com/web-development-in-swift-3f5061b29f8d">server-side development</a> as well.</p><p>If you work on a Mac, you’re probably editing all of your Swift files using Xcode. On Linux, however, there’s no such commodity.</p><p>As you probably know, Xcode is an Apple-made IDE that provides a beautiful interface, autocompletion, inline documentation, jump-to-reference, and many other features that are simply not available elsewhere when it comes to Swift or apps development for Apple platforms.</p><p>However, Xcode has a few problems. First of all, Apple created it for developing apps for their operating systems and, although it supports several file formats, it’s not very useful for many of them. For example, there’s no autocompletion for HTML, CSS or JavaScript. Thus, when you’re editing such files, Xcode becomes a plain text editor with no added benefits. Xcode <a href="https://realm.io/news/jalkut-extending-xcode-8/">cannot be easily extended</a> either. Moreover, its refactoring tools are inherently broken or entirely non-existent for Swift.</p><p>Despite all of that, and no matter how poorly it <a href="https://twitter.com/xcodehascrashed">crashes sometimes</a>, Xcode remains the only real choice for developers building Swift apps for Apple platforms. But what about web development?</p><p>Because of the proprietary nature of Objective-C and the environments, it’s used for, nobody but <a href="http://www.jetbrains.com/objc">JetBrains</a> tried to build a competitive IDE. For Swift, though, there might be an opportunity for developers to create new cross-platform tools, made to enhance the web development experience in the language. No one seems to be pursuing that route yet, however. I suppose that there’s just not enough interest right now.</p><p><a href="http://www.jetbrains.com/objc">AppCode</a>, JetBrain’s IDE, isn’t yet up to the task either: although it’s been improving lately, the Swift tools aren’t as good as the Objective-C ones today. Perhaps we’ll see AppCode evolve more rapidly once Swift gets ABI stability. Anyway, there’s still a problem with AppCode: it’s only available for Mac, as it relies on some of Xcode’s tools under the hood. Hence, if you want to use it, you have to have Xcode installed as well.</p><p>So, what about working on Linux or just hating Xcode for web development? Is there nothing we can do?</p><h3>Enter Atom</h3><p><a href="https://atom.io/">Atom</a> is a powerful, free, cross-platform text editor that can easily replace Xcode for <a href="https://theswiftwebdeveloper.com/web-development-in-swift-3f5061b29f8d">Web Development with Swift</a>. It’s built and maintained by GitHub and the growing community that has been contributing hundreds of Open Source packages to expand its capabilities. In fact, Atom is itself Open Source and was built with <a href="http://electron.atom.io/">Electron</a> using web technologies such as HTML, CSS, and JavaScript, and was designed from the ground up to be easily extended.</p><p>Atom is so versatile and “hackable” that Facebook engineers created an <a href="https://nuclide.io/">IDE</a> on top of it to be used as their primary editor across the company. Notably, some of the Facebook engineers ditched Xcode for Atom + Nuclide because Apple’s IDE is too slow and clumsy with their massive codebase.</p><p>In the video below, Chris Wanstrath, one of GitHub’s founders, gives an introduction to Electron and Atom in the first few minutes of his keynote at GitHub Universe 2016 (the intro to Atom starts at minute 9.40):</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fu9s_W8lCrDU%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Du9s_W8lCrDU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fu9s_W8lCrDU%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/009443ac70bed80de601d47b257fdeff/href">https://medium.com/media/009443ac70bed80de601d47b257fdeff/href</a></iframe><h3>Using Atom for Web Development with Swift</h3><p>I’ve been using Atom as my editor of choice for web development of Ruby on Rails and Swift web applications for a while now. Out of the box, the app is pretty decent already as it comes with a fair amount of built-in packages. However, it’s still just a text editor. What makes it shine are the community contributed packages.</p><p>For iOS apps development I continue to prefer Xcode, mainly for the code completion features it offers. When using plain Swift and its <a href="https://github.com/apple/swift-package-manager">Package Manager</a> instead, as you would when developing server-side applications using one of the popular Swift web frameworks, Atom can get code completion too!</p><p>What follows is a comprehensive list of all the community packages I use.</p><h4>Text and Code Editing</h4><ul><li><a href="https://atom.io/packages/linter">linter</a> — required by other language-specific linters.</li><li><a href="https://atom.io/packages/sort-lines">sort-lines</a> — does what you would expect: alphabetical lines sort.</li><li><a href="https://atom.io/packages/atom-beautify">atom-beautify</a> — perfect code indentation for most source code files.</li><li><a href="https://atom.io/packages/autocomplete-paths">autocomplete-paths</a> — autocompletes file paths you reference in the project (works when editing HTML, CSS and JavaScript files.)</li><li><a href="https://atom.io/packages/api-docs">api-docs</a> — doesn’t have Swift nor any <a href="https://theswiftwebdeveloper.com/web-development-in-swift-3f5061b29f8d">Swift web frameworks</a> right know for legal reasons. You may want to use <a href="https://kapeli.com/dash">Dash</a> to fill the gap or as a replacement but that only works on macOS.</li><li><a href="https://atom.io/packages/dash">dash</a> — requires the <a href="https://kapeli.com/dash">Dash</a> app, but it only works on macOS.</li><li><a href="https://atom.io/packages/highlight-selected">highlight-selected</a> — highlights repetitions of the selected word within the open files.</li></ul><h4>Swift</h4><ul><li><a href="https://atom.io/packages/linter-swiftlint">linter-swiftlint</a> — Swift linter.</li><li><a href="https://atom.io/packages/language-swift">language-swift</a> — Swift syntax highlighting.</li><li><a href="https://atom.io/packages/swift-debugger">swift-debugger</a> — works great with Swift web frameworks but not so much with iOS / macOS apps as it depends on products built with the <a href="https://github.com/apple/swift-package-manager">Swift Package Manager</a>.</li><li><a href="https://atom.io/packages/autocomplete-swift">autocomplete-swift</a> — adds code completion for Swift code, but similarly to swift-debugger it only works if you’re only using plain Swift and the Package Manager.</li></ul><h4>Vapor</h4><ul><li><a href="https://atom.io/packages/language-leaf">language-leaf</a> — support for the Leaf templating language used by <a href="https://vapor.codes/">Vapor</a>.</li></ul><h4>Front-End Development</h4><ul><li><a href="https://atom.io/packages/linter-htmlhint">linter-htmlhint</a> — HTML linter.</li><li><a href="https://atom.io/packages/linter-csslint">linter-csslint</a> — CSS linter.</li><li><a href="https://atom.io/packages/linter-eslint">linter-eslint</a> — ES6 linter.</li><li><a href="https://atom.io/packages/emmet">emmet</a> — a fantastic plugin that adds HTML and CSS shortcuts. See a preview below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*-F0JHI5lS3GgbpICi2O35w.gif" /><figcaption>Writing HTML with Emmet</figcaption></figure><h4>Productivity</h4><ul><li><a href="https://atom.io/packages/todo-show">todo-show</a></li><li><a href="https://atom.io/packages/terminal-plus">terminal-plus</a> — broken on the latest version of Atom. Otherwise, it’s a fantastic plugin that adds a terminal to Atom.</li><li><a href="https://atom.io/packages/expose">exposé</a> — reproduces macOS’s Exposé feature.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iHAP-6L87Xl_e4NPvvIVpw.png" /><figcaption>Atom’s exposé package</figcaption></figure><h4>Atom UI and Utilities</h4><ul><li><a href="https://atom.io/packages/sync-settings">sync-settings</a> — syncs your Atom’s packages, settings, snippets and custom configurations to a <a href="https://gist.github.com/">Gist on GitHub</a>.</li><li><a href="https://atom.io/packages/pigments">pigments</a> — adds color previews to colors declared in code.</li><li><a href="https://atom.io/packages/color-picker">color-picker</a> — lets you pick colors from within the Atom’s text editor.</li><li><a href="https://atom.io/packages/atom-import-sf-mono">atom-import-sf-mono</a>— allows using Apple’s San Francisco Monospace Font in Atom, and it’s glorious!</li><li><a href="https://atom.io/packages/file-icons">file-icons</a> — see image below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*9_bmrBbNkiK4mfJBve3RWQ.png" /><figcaption>Atom’s file-icons package preview</figcaption></figure><h4>Git</h4><ul><li><a href="https://atom.io/packages/git-plus">git-plus</a> — allows running git commands from within Atom.</li><li><a href="https://github.com/littlebee/git-time-machine">git-time-machine</a> — exactly what I need from Git: see a file’s history and compare each version with the current copy.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQSXyABNegf_QDYD8B928A.gif" /><figcaption>Atom’s git-time-machine package</figcaption></figure><h4>Fun</h4><ul><li><a href="https://atom.io/packages/autocomplete-emojis">autocomplete-emojis</a> — adds Slack’s / GitHub’s :[emoji-name] autocompletion.</li><li><a href="https://atom.io/packages/activate-power-mode">activate-power-mode</a> — adds the cool effect shown below to when editing; can be toggled on-demand or automatically after typing a customizable number of characters within a time range in the active buffer.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*r65vKSRu_TZpsUt-FecwQg.gif" /><figcaption>Atom’s activate-power-mode package</figcaption></figure><h4>Noteworthy (although I don’t use them)</h4><ul><li><a href="https://nuclide.io/">nuclide</a> — Facebook’s IDE for web and mobile development built on top of Atom.</li><li><a href="http://modocache.io/nuclide-swift-ide">nuclide-swift-ide</a> — a Swift IDE built on top of Nuclide. It’s worth a try, but it’s not ready for prime-time yet.</li><li><a href="https://atom.io/packages/vim-mode">vim-mode</a> — for VIM lovers.</li><li><a href="https://atom.io/packages/minimap">minimap</a> — if you fancy a mini view of the entire file you’re editing, this is for you. It’s a port one of the most loved features of Sublime Text, another popular text editor.</li><li><a href="https://atom.io/packages/minimap-highlight-selected">minimap-highlight-selected</a> — text highlighting that goes hand in hand with minimap.</li><li><a href="https://atom.io/packages/rest-client">rest-client</a> — A REST Client for Atom. Simple but effective. I prefer <a href="https://www.getpostman.com/">Postman</a>, though.</li></ul><h3>Pro Tips</h3><h4>Befriend Atom’s Command Palette</h4><p>The Atom’s command palette contains all the available actions Atom can perform. When you install a plugin, the commands that package support are added to the palette. You can activate the palette from wherever you are in Atom with the shortcut cmd-shift-P .</p><h4>Settings</h4><p>The first thing I do on a fresh install of Atom is changing three things:</p><ol><li>The Settings -&gt; Editor pane has several options I customize to my personal preference (e.g. soft wrapping, horizontal guide, ignored files, etc.)</li><li>Toggle the built-in tree-view package’s options to hide SVC and editor ignored files so that they don’t clutter the interface (e.g. this would remove .DS_Store files and the .git/ folder).</li><li>Inspect the settings of all packages and change them to my preferences.</li></ol><h4>Spell Checking</h4><p>Atom comes with a spell-check package but it’s not enabled by default, nor it’s active for all file formats. You can change this in the package’s settings. Note that you can find out what are the ‘scopes’ for the file formats you’re interested into spell-checking by opening one a file with the format you’re looking to spell check and using the Editor: Log Cursor Scope from Atom’s command palette.</p><h4>Keep Everything in Sync</h4><p>The <a href="https://atom.io/packages/sync-settings">sync-settings</a> package lets you sync your packages, key bindings, preferences, settings, and customizations to a <a href="https://gitst.github.com/">GitHub Gist</a>. I highly recommend doing it from the first setup. Over time it’s only natural that you’ll end up customizing Atom, change preferences for the packages you install or add your own snippets. Even just remembering what the packages you use were is reason enough to sync everything up.</p><h4>The Atom Package Manager</h4><p>Atom comes with a package manager you can access from the command line that does what you would expect: manage and install Atom packages.</p><pre>apm --help<br>apm install [package_name]</pre><h4>Command line tool</h4><p>You can also open and create files and folders from the command line using the atom command:</p><pre>atom foo.txt</pre><p>or</p><pre>atom path/to/my/file/or/folder</pre><h3>What about Sublime Text?</h3><p>As with many things, among developers there seem to be a religious divide between people who prefer <a href="http://www.sublimetext.com/">Sublime Text</a> and those who choose Atom instead. Surely Sublime has been around for longer and has had more time to mature. On the other hand, it costs money, the UI isn’t great (to my taste), and you could argue that updates don’t come in as often as Atom’s.</p><p>My personal preference lies with Atom because it’s Open Source, free and super easy to customize using HTML, CSS, and JavaScript. I also love its docs: the <a href="http://flight-manual.atom.io/">Atom Flight Manual</a> provides an excellent starting point for new users. Finally, I prefer Atom’s UI over Sublime’s quite a bit.</p><p>Of course, this is just my opinion. You can even use <a href="http://www.vim.org/">VIM</a> or <a href="https://www.gnu.org/software/emacs/">Emacs</a> if you fancy that!</p><h3>Where to go from here</h3><p>My preference for writing web apps in Swift right now lies with Atom, although I miss some of the features Xcode provides. For example, I miss the jump-to-definition feature. When I find myself in need of documentation or signature definitions, I open Dash. The experience, though, is not as good.</p><p>There’s still a lot of room for developers to improve Atom and its Swift compatibility by building custom packages. For example, the Nuclide + Swift project is fascinating and might be the ultimate tool to make Atom the perfect replacement for Xcode.</p><p>If you use Atom, what are the packages you like the most? I’m always on the look for neat additions to my arsenal! Also, will you be contributing to packages? If so, let me know!</p><h3>Subscribe to Swift Web Weekly!</h3><p>If you’re interested in web development with Swift, <a href="http://swiftwebweekly.com/"><em>Swift Web Weekly</em></a> is a <strong>free newsletter</strong> I’m curating with interesting links related to server-side Swift, HTML, CSS, JavaScript, tools and more. If you don’t like it you can unsubscribe at any time, so why don’t give it a try?! 🙂</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fd53253%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2Fd53253%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href">https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ab42ac415c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-swift-web-developer/using-atom-for-web-development-with-swift-6ab42ac415c2">Using Atom for Web Development with Swift</a> was originally published in <a href="https://medium.com/the-swift-web-developer">The Swift Web Developer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Skim the crap off your codebase!]]></title>
            <link>https://medium.com/hackernoon/skim-the-crap-off-your-codebase-b7bb79202d65?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7bb79202d65</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Mon, 06 Feb 2017 09:02:00 GMT</pubDate>
            <atom:updated>2017-07-15T22:17:52.145Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*U5pR-nfTyBk7y7izw-ykZw@2x.png" /><figcaption><a href="http://alistair.cockburn.us/Hexagonal+architecture">Hexagonal Architecture</a>. Source of the image unknown.</figcaption></figure><h3>Skim the dirt off your codebase!</h3><h4>How to clean up a 3+ years old project and live happily ever after.</h4><p>We’ve all been there: a software project was lucky enough to live on for years after the initial development, however, somewhere along the line it started to get crippled by patches and workarounds that were only meant to be temporary, but nobody ever got to clean up.</p><p>As a contractor, every few months I move to a different company. I’ve worked with start-ups and well-established companies alike. I’ve once joined a project early in the development process, left the team after shipping the app, and found myself working on that same project almost three years later. That was quite an experience! The only code I wrote left in it was a bunch of blank lines scattered across a few files. I’ve worked on projects at all stages of their lifetime. Nevertheless, I often find the same problems. Luckily, the solution also stays the same.</p><p>The problem I find most often is that, as projects grow in complexity and feature set, they also become harder to change. The time required for developing new features keeps increasing and breaking stuff becomes easier and easier. Knowledge of distinct areas of the codebase tends to stay in the head of one person or of a small group. Other developers on the team usually don’t bother learning how something works until they have to, and as the people leave, that knowledge gets lost forever.</p><p>The number one enemy of good code is code itself. It’s the growing net of dependencies, the lack of isolation, the lack of documentation. It’s also the tempting voice inside your head saying that’s OK if you just add one more method to an already fat class. Because if you do it, you’ll be done already, your feature or bug fix will be complete, your manager happy and everybody will cheer at your ability to move fast (and break things that will come chasing you back in a day or so, just for you to patch some more).</p><p>Perhaps you promise yourself you’ll go back and do things properly. However, before you know it, the whole project looks like an indecent mess and doing the simplest things turns into the most difficult job ever.</p><p><em>Disclaimer: what I’m saying is nothing new. People have written hundreds of pages about </em><a href="http://amzn.to/2jLINYV"><em>Working with Legacy Code</em></a><em>, </em><a href="http://amzn.to/2kagYgt"><em>Clean Code</em></a><em> or </em><a href="http://amzn.to/2kacPZL"><em>Refactoring</em></a><em>. However, it never seems to be enough. The same problems keep resurfacing. Therefore, I’m just making my part in trying to get some principles burned in people’s mind, as well as in my own.</em></p><h3>Software programming is more like gardening than engineering</h3><p>Would you do the same if you were working on a building, a bridge, or trying to launch a rocket into space with people on it? I hope not! I know some do, though. Just <a href="https://www.ft.com/content/f1b3768a-6e94-11e6-a0c9-1365ce54b926">look at what happened in Italy a few months ago</a>! Or look at <a href="http://www.thisismoney.co.uk/money/mortgageshome/article-3548584/Wonky-windows-dodgy-wiring-holes-walls-Beware-builders-flogging-shoddy-new-build-homes.html">the poor quality of homes in the UK</a>!</p><p>For a long time, programming software has been compared to constructing a building. Perhaps it’s a good comparison, or maybe not. Some elements make programming look like engineering: you have to analyze a problem, come up with a good solution, make sure you take the right measures, build it, test it and <a href="https://www.theguardian.com/uk/2000/jun/12/2">hope it won’t fall on itself</a>. However, it’s so cheap to change things in software and so unpredictable sometimes that <em>you know</em> it’s going to happen. As Andy Hunt, author of <em>The Pragmatic Programmer</em>, puts it:</p><blockquote><em>There is a persistent notion in a lot of literature that software development should be like engineering. […] It doesn’t work that way with software. […] Software is much more like gardening. You do plan. You plan you’re going to make a plot this big. You’re going to prepare the soil. You bring in a landscape person who says to put the big plants in the back and short ones in the front. You’ve got a great plan, a whole design.</em></blockquote><blockquote><em>But when you plant the bulbs and the seeds, what happens? The garden doesn’t quite come up the way you drew the picture. This plant gets a lot bigger than you thought it would. You’ve got to prune it. You’ve got to split it. You’ve got to move it around the garden. This big plant in the back died. You’ve got to dig it up and throw it into the compost pile. These colors ended up not looking like they did on the package. They don’t look good next to each other. You’ve got to transplant this one over to the other side of the garden.</em></blockquote><blockquote><em>- Andy Hunt, author of </em>The Pragmatic Programmer.</blockquote><h3>Fixing rotten codebases</h3><p>What can we do when we find ourselves working on a nasty codebase? Perhaps we’ve just joined a team in need of help, or maybe we lost control of the ship, and we’re struggling to get it on track.</p><p>The only solution for that problem I’ve found is to <strong>push the crap to the edges first, then remove it</strong> altogether. What that means is that we have to make an effort to isolate parts of the codebase in little black boxes that each serve one, and only one, purpose. Small, contained blocks of code are easier to understand and to change. We can test them independently from the rest of the application and refactor them as needed. In short, we have to:</p><ol><li>Isolate</li><li>Test</li><li>Refactor</li></ol><h4>Divide and conquer</h4><p>The first step is to identify small, contained pieces of functionality and extract them into their own containers. I’ll call them <strong>modules</strong>.</p><p>The goal is to create boundaries of interaction between the main app and the self-contained features. By doing so, we’ll have code that’s easier to understand and maintain. Or at least, we can take a piece of code nobody understands anymore and minimize and redefine how the main app interacts with it. Taking those infected areas of the codebase and isolate them also avoids spreading the disease even more.</p><p>When separating a module, it’s best to create a new package/framework to contain it so that the old code cannot access any of it anymore. Once confined to its own universe, we can define an <em>interface</em> through which the rest of the world will interact with the module. That interface will be part of the package, and we’ll do the necessary conversions within the module. This way, when we go change the implementation of the module for any reason — e.g. to clean it up — no other code will be affected.</p><p>Initially, you’ll have to face the wall of dependencies, but that is the problem you’re solving in fact! Those dependencies have to either be injected into the module or the module has to depend on some other module to get them.</p><p>A perfect way to achieve that is avoiding passing the same <em>type</em> of data around. Use <a href="https://en.wikipedia.org/wiki/Protocol_(object-oriented_programming)">protocols</a> and <a href="https://en.wikipedia.org/wiki/Data_transfer_object">DTOs</a> as much as possible, instead. Doing so will make your code even easier to understand and maintain. A small drawback is that you may need to write a bit of code to conform to those protocols or to convert your data models into (and from) this intermediate objects. It’s OK to repeat yourself a little here. The advantage is just too big to ignore.</p><p>For example, modules won’t have to depend on others to know about the types they need. They can just <em>define</em> what they need. In your main app, you can extend types to conform to a protocol or convert them to other types. Your module’s code will also be way easier to test, as defining stub and mock objects for your tests won’t require a burden of dependencies and state maintenance.</p><blockquote>Push the crap to the edges first, then remove it!</blockquote><p>As a final note, what you extract doesn’t necessarily have to be something poorly written or incomprehensible, although the greatest benefit comes from isolating those parts of the code. Pulling out well-written pieces will help over the long run too.</p><h4>Test</h4><p>With an interface for the module in place, we’re able to test it in isolation. Hence, we’ll be able to ensure a consistent, functional behavior, and automate the process using a <a href="https://en.wikipedia.org/wiki/Continuous_integration">Continuous Integration system</a>.</p><p>Tests will serve both as a way to clarify the scope of the module and prevent regression. They’ll also be a nice documentation of the expected behavior when someone new has to use that code. With the revitalized understanding of what the extracted segment has to do, we’re able to identify more areas that we can move out of the module or prune altogether.</p><p>Testing is an essential part of the process and shouldn’t be ignored. It’s the base upon which we can stand when refactoring the module. With tests, we can be confident that we’ll catch regressions. Dependencies and weak spots will surface as you’ll find places that aren’t easily tested. Life will be good.</p><p>Confidence is key. As programmers, we’re afraid of change when we lack confidence in our ability to catch regressions. We’re scared of breaking things, and we should be. Having a set of automated tests running across the entire codebase at each commit can free us from the burden of fear.</p><h4>Refactor</h4><p>The final step is refactoring. Once everything is isolated and tested, you’ll find that the codebase will already be in a way better shape than it was before. To isolate the code something had to change. Blocks had to be rearranged, and communication cleaned up behind a new interface. To test the module other parts had to become more testable.</p><p>At this point, you’ll have to take a significant decision: to refactor or not to refactor. Some of the modules will be in perfect shape. Some will still be black boxes you didn’t dare touching. I know. It’s OK. You didn’t test all of it because you were afraid of changing and breaking things. It’s not ideal, but we can live with it. Isolating that component was already a great achievement. Other requirements were piling up in your backlog, and you were getting nervous. You didn’t want to disappoint your manager.</p><p>Here’s the thing, though. You’ve come a long way, and the light is just around the corner. You can see it already. If you’re going to get to <em>make your codebase great again</em>, you’ll have to endure. It will take time; you’ll have to balance the refactoring work with the time your company requires you to devote to new features and enhancements. You’re in a position that allows for that. However, the devil is in the detail.</p><p>To prevent the codebase to get crippled again, you’ll have to keep nurturing it. There’s no way around this. Trust me. I’ve been there. Time and time again I’ve avoided testing or refactoring because of time, pressure, overconfidence, boredom. It never paid off. I’ve always been bitten by my lack of endurance. It’s not fun. Never again. Wouldn’t you like to keep working on a healthy codebase, where everything works as expected and very few bugs are ever introduced? If your answer is ‘yes,’ then you know what you have to do. You’ll have to test and refactor those crappy parts of the codebase that are still left.</p><h3>Maintaining a healthy garden</h3><p>Even once you’ve isolated the best and worst part of your codebase, wrapped them in a reasonable suite of automated tests, and refactored everything, you’ll still be in danger. There’s no stopping. The job isn’t finished. Sure, your app will be in its best shape ever. However, it’s not going to last long if you don’t keep caring. As I mentioned in <a href="https://medium.com/@gtranchedone/working-with-legacy-code-44656ae19186#.kif7zez3d">an old article</a>, according to Michael Feathers, author of <a href="http://amzn.to/2l0J3IP"><em>Working Effectively with Legacy Code</em></a><em>,</em> “<em>legacy code</em> is simply code without tests.”</p><blockquote>Legacy code is simply code without tests</blockquote><p>Test Driven Development, the practice of writing automated tests and code in short cycles — we’re talking <em>seconds</em> short — with the tests being written before the “actual code,” comes very handy to maintain our <em>garden</em> in a healthy state.</p><p>An important note is that you should <strong>try to avoid as much as possible to have modules depend on one another</strong>. Again, use protocols and DTOs to avoid spreading dependencies! Those constructs are invaluable friends.</p><h3>Where to go from here</h3><p>Congratulations for making it this far! I know this mustn’t be the easiest or funniest piece to digest. As I mentioned towards the start of this article, what I’m saying is nothing new. It’s all pretty old stuff. I stand on the shoulders of giants. We all do. Therefore, I highly encourage you to take some time to read through the original article describing the concept known as <a href="http://alistair.cockburn.us/Hexagonal+architecture"><em>The Hexagonal Architecture</em></a>, which emphasizes the importance of isolating the core domain of your app from external dependencies and interact with them using <em>ports</em> and <em>adapters.</em> When I mentioned that you should define clear interface layers through which the main app and the tests communicate with a module, I was referring exactly to that type of architecture. You may also want to have a look at a similar concept known as <a href="http://scs-architecture.org/"><em>Self-Contained Systems Architecture</em></a>. Good luck with your refactoring!</p><p>If you’re interested in developing web applications using <a href="https://swift.org/about">Swift</a>, Apple’s new super cool and efficient programming language, you may want to subscribe to <em>Swift Web Weekly</em>, a weekly newsletter I’m curating with the best links on the Internet on the topic and anything related.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fd53253%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2Fd53253%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href">https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href</a></iframe><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7bb79202d65" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/skim-the-crap-off-your-codebase-b7bb79202d65">Skim the crap off your codebase!</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Development with Swift]]></title>
            <link>https://medium.com/the-swift-web-developer/web-development-in-swift-3f5061b29f8d?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f5061b29f8d</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[server-side-swift]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Wed, 01 Feb 2017 08:02:00 GMT</pubDate>
            <atom:updated>2017-02-20T23:54:29.174Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LnWMpET6CvZhhCJmfllqwQ.png" /></figure><h4>What Server-Side Swift means for web development and why you should care</h4><p>Since its announcement in 2014, <a href="https://swift.org/">Swift</a> has taken off to become one of the most popular programming languages on the planet. Not only that, according to <a href="http://stackoverflow.com/research/developer-survey-2016#technology">a survey by StackOverflow</a>, <strong>Swift is the second most loved programming language</strong>; <strong>the third most trending</strong> as well. In just over three years, that’s a remarkable achievement.</p><p>For some people, what made Swift appealing was the new syntax, the modern and functional features, and the inherent safety. For others, it was the promise Apple made to Open Source the language within a year from its launch. That made experienced Objective-C developers dream of using the same tools they were already familiar with to build scripts and server-side applications.</p><h3>Swift in the Cloud</h3><p>In December 2015, <a href="https://swift.org/">Apple kept its promise</a> and started adding support to the language and standard library for Linux. An effort is also being made to port Foundation, libdispatch (also known as Grand Central Dispatch) and other libraries to that operating system.</p><p>Surprisingly, the Swift repository attracted quite a response with several pull requests opened on day one. Several developers around the globe are contributing to the language, while others focused their efforts in building libraries and frameworks. With Swift open source, many developers dedicated time to building frameworks for server-side development.</p><p>One year later, in fact, at WWDC 2016, <a href="https://www.youtube.com/watch?v=CRX1Zs7tIH0">Apple has even brought IBM on stage to talk about their web framework: Kitura</a>. Shortly after, Apple announced the creation of a new group within swift.org, dedicated to the design and development of <a href="https://swift.org/server-apis/">Swift Server APIs</a>. This group is made of people from Apple as well as the major Swift web frameworks: <a href="http://www.kitura.io/">Kitura</a>, <a href="http://vapor.codes/">Vapor</a>, <a href="http://perfect.org/">Perfect</a> and <a href="http://www.zewo.io/">Zewo</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCRX1Zs7tIH0%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCRX1Zs7tIH0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCRX1Zs7tIH0%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/16312563e90954649ecb6e17b1a92662/href">https://medium.com/media/16312563e90954649ecb6e17b1a92662/href</a></iframe><p>Clearly, Swift on the server is getting traction and a big push from Apple as well. In fact, although many developers don’t even know what Swift is, <strong>interest in using it to build Server-Side applications is growing by the day</strong>.</p><p>Just three months ago, Perfect, the most popular web framework for Swift right now, had over seven thousand stars on GitHub. Today, that number has grown to over ten thousand. Vapor, the second most successful, follows with almost nine thousand stars. By comparison, Ruby on Rails, one of the most famous open source web development frameworks of all time has collected about thirty-five thousand stars over its ten years lifespan.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FpOEauzdwvAzok%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Ftaylor-swift-shocked-pOEauzdwvAzok&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FpOEauzdwvAzok%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="267" frameborder="0" scrolling="no"><a href="https://medium.com/media/197a63876814808db95d98953572c4f6/href">https://medium.com/media/197a63876814808db95d98953572c4f6/href</a></iframe><h3>Is this hype worth the attention?</h3><p>The answer is simple: absolutely yes!</p><p>Apple is pushing hard on Swift. A lot of effort is being made to ensure the language is easy to understand and easy to learn; that it’s performant and fun to use. Companies like IBM are betting on it, are investing heavily in its development and are building tools built on top of it.</p><p>Let’s have a look at the actual benefits of adopting Swift on the server.</p><h4>Swift is performant!</h4><p>Benchmarks show that Swift is much faster than most other languages traditionally used on the web.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7qVwSatAPQnYB59e8er1sA.jpeg" /><figcaption>Swift speed performance. Source: <a href="https://realm.io/news/tryswift-chris-robert-end-to-end-application-development-swift-backend/">https://realm.io/news/tryswift-chris-robert-end-to-end-application-development-swift-backend/</a>.</figcaption></figure><p>Similarly to being performant, Swift also has a very low memory footprint compared to other languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EPysD2EkVlw6xHuAu13yHw.jpeg" /><figcaption>Swift memory performance. Source: <a href="https://realm.io/news/tryswift-chris-robert-end-to-end-application-development-swift-backend/">https://realm.io/news/tryswift-chris-robert-end-to-end-application-development-swift-backend/</a>.</figcaption></figure><p>The existing Swift web frameworks greatly benefit by these qualities of the language and <strong>perform better than popular web frameworks used in other languages</strong>. Just as an example, <a href="https://medium.com/u/a623350b656a">Ryan Collins</a> recently compared the performance of the major Swift web frameworks against Node.js. These are the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*vWuy_r-zaKg3bYJYAld8eg.png" /><figcaption>Source: <a href="https://medium.com/@rymcol/linux-ubuntu-benchmarks-for-server-side-swift-vs-node-js-db52b9f8270b#.v6f9hjvsz">https://medium.com/@rymcol/linux-ubuntu-benchmarks-for-server-side-swift-vs-node-js-db52b9f8270b#.v6f9hjvsz</a></figcaption></figure><h4>Economy</h4><p>In the current Cloud economy, memory and CPU usage are among the key measures used to charge for hosted infrastructures such as <a href="https://amazonaws.com/">AWS</a>. With the performance it provides, <strong>businesses can save real money</strong> by moving to Swift.</p><h4>Safety first</h4><p>Swift is a <em>type-safe</em> language, which means the language helps you to be clear about the types of values your code can work with. If part of your code expects a String, type safety prevents you from passing it an Int by mistake. Likewise, type safety prevents you from accidentally passing an optional String to a piece of code that expects a non-optional String. Type safety helps you catch and fix errors as early as possible in the development process.</p><h4>Developers productivity and mobility</h4><p>Another benefit is that <strong>Swift developers can own a whole project end-to-end</strong>. By building both server and client sides using the same tools and technologies, teams can move faster, have a deeper understanding of the entire stack, and onboard new members faster.</p><p>Such flexibility can be extremely attractive for companies structured after the <a href="https://www.youtube.com/watch?v=Mpsn3WaI_4k">Spotify’s model</a> or something similar, where small, contained groups own entire sections of the business.</p><p>Agencies and Startups can also benefit from having a more homogeneous team by moving people as needed and therefore potentially elude times when business is slow or when there’s sudden spike in workload. Again, being able to do so translates into real money savings.</p><h4>A vast community</h4><p>There’s an incredible community surrounding Swift already, made of course by iOS and macOS developers. And that community is also one of the most active in the Open Source space right now. The <a href="https://swift.org/package-manager/">Swift Package Manager</a> already counts <a href="https://swiftpkgs.ng.bluemix.net/">dozens of packages built for Swift</a>, and many others will be added over time. Nowadays many frameworks built in Swift only support CocoaPods, although they have no dependency on iOS. We can only hope those will be made available via the Package Manager soon.</p><h3>Alternatives</h3><p>I’ve recently come across <a href="https://medium.com/javascript-scene/how-to-build-a-high-velocity-development-team-4b2360d34021#.wbjoqce17">this article</a> by <a href="https://medium.com/u/c359511de780">Eric Elliott</a> where he urges developers to use JavaScript for developing both servers and clients:</p><blockquote>JavaScript is the standard language of the web platform, and your app should be written in JavaScript on both the client and the server side. Why?</blockquote><blockquote><em>JavaScript is the most popular programming language on the planet</em>, and the easiest to hire for.</blockquote><blockquote>There are more working open-source solutions in JavaScript than there are in any other language. Your team will have to write less code from scratch.</blockquote><blockquote>JavaScript is the only language that can run universal code natively across the entire web platform stack, including clients, servers, and mobile.</blockquote><p><a href="https://medium.com/javascript-scene/how-to-build-a-high-velocity-development-team-4b2360d34021">How to Build a
High Velocity
Development Team</a></p><p>Those are all valid points. Although he was referring to browsers, native apps can be developed in JavaScript using <a href="https://facebook.github.io/react-native/">React Native</a>; therefore you could build everything using one language. However, platform-specific code has to be ported first or bridged to the JavaScript engine to make it work, and performance can be an issue.</p><p>I see Swift being in a similar position: it can be used to build native apps for all Apple devices, it can be used to develop server-side apps and in templating languages such as Leaf to render HTML, and it can even be used to build <a href="http://modocache.io/how-to-port-the-swift-runtime-to-android">Android apps</a> (sort of). Sure you’ll probably need JavaScript on the web, but the safety, performance, cost savings, and developer happiness that come with using Swift outweigh this, in my opinion.</p><h3>Swift is going to be a big part of the web’s future</h3><p>We’ve seen how Swift is getting incredible traction from the community. We’ve also seen adopting Swift for server-side development comes with several advantages, including team productivity and costs efficiency.</p><p>Top companies outside of Apple are investing in the development of Swift, web frameworks and packages. And let’s not forget that Swift is a fantastic language to for teaching programming, and <a href="http://swifteducation.github.io/">several schools and universities are teaching CS courses with it</a>.</p><p>To conclude, I’m very excited about Swift on the server and for web development in general. I believe we’re going to see an increasing number of people and companies moving in this direction in the coming months and years. It’s a fantastic time to be a Swift developer.</p><h3>Subscribe to Swift Web Weekly!</h3><p>If you’re interested in web development with Swift, <a href="http://swiftwebweekly.com/"><em>Swift Web Weekly</em></a> is a <strong>free newsletter</strong> I’m curating with interesting links related to server-side Swift, HTML, CSS, JavaScript, tools and more. If you don’t like it you can unsubscribe at any time, so why don’t give it a try?! 🙂</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fd53253%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2Fd53253%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href">https://medium.com/media/ffaf0ce3afaec90ca5c3029f06559db4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f5061b29f8d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-swift-web-developer/web-development-in-swift-3f5061b29f8d">Web Development with Swift</a> was originally published in <a href="https://medium.com/the-swift-web-developer">The Swift Web Developer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I’ve decided to move my blog to Medium]]></title>
            <link>https://medium.com/@gtranchedone/why-ive-decided-to-move-my-blog-to-medium-6aa2d3efc7e5?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aa2d3efc7e5</guid>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[blogging]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Sat, 10 Sep 2016 18:41:14 GMT</pubDate>
            <atom:updated>2016-09-10T18:41:14.256Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m not a prolific writer nor a good one but every now and then I still feel the need of sharing something with the world.</p><p>Over the years I’ve had several small blogs. Hosted on <a href="https://www.blogger.com/home">Blogger.com</a>, <a href="https://wordpress.com/">Wordpress.com</a>, self-hosted using <a href="https://wordpress.org/">Wordpress.org</a> and <a href="https://godaddy.com/">GoDaddy</a>, built from scratch as any nerdy software engineer would do and published using <a href="https://pages.github.com/">GitHub Pages</a> and <a href="http://jekyllrb.com/">Jekyll</a>. I even created a blog for my <a href="http://cocoabeans.io/">company’s website</a> as a Rails app, hosting it on <a href="https://heroku.com/">Heroku</a>. Basically I can say I’ve “tried ’em all”.</p><p>Now I’m starting out on Medium and I’ve decided to migrate over some of the articles on <a href="http://gtranchedone.com/">gtranchedone.com</a> and shut that blog down.</p><p>It’s not that those platforms aren’t any good. They all have their strengths and drawbacks. It’s just that they don’t really work for me.</p><h3>Moving to Medium</h3><p>Building and maintaining a good looking site and blog is a lot of work. I don’t write new content that often, which means I would be spending more time trying to make my blog pretty and functional, rather than maximising the time I can spend on articles. On Medium, typography, sharing features, SEO, content management, and many more details are taken care for me. So<strong> I can focus my attention on the content I write</strong>.</p><p><strong>Medium looks gorgeous </strong>and the writing experience is stunning. Its editor offers a seamless experience and provides the right balance of minimality and formatting features to make you want to write anything with it.</p><p>If I ever wanted to manage multiple content flows again, I wouldn’t have to build and maintain multiple blogs. I’d only need to create different <strong>publications</strong>. Probably I won’t use this feature much myself, but it’s there if I ever wanted to use it!</p><p>Medium offers <strong>a lot more exposure</strong> than what I could dream of achieving by myself with my own content alone. It has built an amazing community of readers and writers who are engaged with the content and spending meaningful time on the platform. I may not get a long time frame for getting my articles noticed, but that’s an issue that exists everywhere else as well.</p><p>Most of all, at the end of the day I don’t make a living out of my writing. I don’t need fancy features for getting people to sign up to newsletters or to sell stuff. If I did, I would probably try to have my articles on Medium and redirect traffic to my products’ landing pages.</p><h3>What about the drawbacks?</h3><p>As usual, not everything is gold. Before making my mind into moving to Medium I had many concerns, however for each of them I found a solution that made me comfortable enough to moving over. Here are some of them:</p><h4><strong>What if Medium shuts down or if they change their policy to own my content?</strong></h4><p>I thought about this a lot, and at the end I’ve realised I could still save my posts somewhere else, if done with with minimal effort! For me, that place is GitHub. For you it may be <a href="https://evernote.com/">Evernote</a> or a folder on <a href="https://drive.google.com/">Google Drive</a>, <a href="https://dropbox.com/">Dropbox</a> or simply your computer. What I currently do is to write an article using Markdown formatting in a text editor on my Mac, store it in a repository on GitHub and when I’m happy with it I copy and paste the content on Medium, apply formatting and schedule the finished piece for being published. Medium has minimal article formatting, which make it very quick to adapt from Markdown. I only wish Medium offered automatic formatting for pasted Markdown content or better yet, export to Markdown so that I could simply write an article and export it in my repo when I’m done with it.</p><h4><strong>Will I lose my identity if I move to Medium?</strong></h4><p>It’s true that Medium doesn’t offer custom domain for personal articles (those not associated with a publication) but they are still associated with your unique username. People tend to have the same username on all social media channels this days - I definitely do - and therefore I don’t see my identity getting lost. Quite the contrary indeed.</p><h4><strong>Is what I write really mine?</strong></h4><p>Well, <a href="https://publishers.medium.com/">for now it seems to be so</a>. If this ever changed, by storing all my posts and images on GitHub, I could always go back to my own blog with minimal effort. There’s also an ‘export’ feature, but it isn’t a really attractive solution.</p><h4><strong>Is it worth the effort?</strong></h4><p>I hope so! Only time will tell that! 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aa2d3efc7e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with Legacy Code]]></title>
            <link>https://medium.com/@gtranchedone/working-with-legacy-code-44656ae19186?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/44656ae19186</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-craftsmanship]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Fri, 09 May 2014 00:00:00 GMT</pubDate>
            <atom:updated>2016-09-10T18:34:25.826Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FTIZ8HYzRamfC326jY8Wng.png" /></figure><p>Every software engineer feels a sense disgust when hearing the words <em>legacy code</em>. Strictly speaking legacy code it’s code you “inherit” from someone else, however, the term is more broadly used to indicate a piece of software that’s no longer maintained. Often it’s code that, although deprecated, is still in use because of dependencies spread across a large system. Anyway, Michael Feathers has a better definition</p><blockquote><em>To me, </em>legacy code<em> is simply code without tests. I’ve gotten some grief for this definition. What do tests have to do with whether code is bad? To me, the answer is straightforward, and it is a point that I elaborate throughout the book:</em></blockquote><blockquote>Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behaviour or our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse.</blockquote><blockquote><em>You might think that this is severe. What about clean code? If a code base is very clean and well structured, isn’t that enough? Well, make no mistake. I love clean code. I love it more than most people I know, but while clean code is good, it’s not enough. Teams take serious chances when they try to make large changes without tests. It is like doing aerial gymnastic without a net. It requires incredible skill and a clear understanding of what can happen at every step. Knowing precisely what will happen if you change a couple of variables is often like knowing whether another gymnast is going to catch your arms after you come out of a somersault.</em></blockquote><blockquote>— Michael Feathers</blockquote><p>I wish I had read Michael Feathers’ <a href="http://www.amazon.co.uk/gp/product/B005OYHF0A/ref=as_li_ss_tl?ie=UTF8&amp;camp=1634&amp;creative=19450&amp;creativeASIN=B005OYHF0A&amp;linkCode=as2&amp;tag=gtranchedone-21">Effectively Working with Legacy Code</a> when I first started programming. I’ve had it on my Amazon wish-list for a long time. One day I’ve purchased the book but I’ve committed the sin of not reading it until just a few days ago. <strong>If you are — or want to be — a software engineer you absolutely have to read this book now! </strong><a href="http://www.amazon.co.uk/gp/product/B005OYHF0A/ref=as_li_ss_tl?ie=UTF8&amp;camp=1634&amp;creative=19450&amp;creativeASIN=B005OYHF0A&amp;linkCode=as2&amp;tag=gtranchedone-21"><strong>Go get it!</strong></a></p><p><em>Originally published at </em><a href="http://gtranchedone.com/blog/2014/05/09/working-with-legacy-code"><em>gtranchedone.com</em></a><em> on May 9, 2014.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44656ae19186" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The App Store Business: do we need Paid Upgrades or can we live with In-App Purchase only?]]></title>
            <link>https://medium.com/@gtranchedone/the-app-store-business-do-we-need-paid-upgrades-or-can-we-live-with-in-app-purchase-only-5ad33e4b659e?source=rss-97a7ccc0869b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ad33e4b659e</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[app-store]]></category>
            <dc:creator><![CDATA[Gianluca Tranchedone]]></dc:creator>
            <pubDate>Tue, 27 Aug 2013 00:00:00 GMT</pubDate>
            <atom:updated>2016-09-10T18:36:40.363Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qeMwFhKh9aDbtnQuB0_x-A.png" /></figure><p>Since the introduction of the App Store, and even more when the Mac App Store arrived, a lot of discussion has been made around apps’ pricing models. Only last year a debate about the need for paid app upgrades raised among developers, but it eventually fade off… until a couple of weeks ago, when Apple released Logic Pro X as a separate, full-priced, app — deprecating the existing Logic Pro on the Store.</p><p>With this launch, <strong>Apple has reclaimed its intention of not allowing any paid upgrade to apps</strong>. Moreover, by a quick <a href="http://daveaddey.com/appstore/">analysis of the apps featured by Apple in the last few months</a>, it also appears that they prefer the freemium model over paid apps in general, although most of theirs aren’t actually free. Games are the only kind of apps that actually sees a major featured rate even when they’re in sale or free. <strong>What developers can do then to guarantee themselves an income after the initial sale then?</strong></p><p>As well noted by <a href="http://www.imore.com/apple-puts-its-price-tag-where-its-policy-charges-full-price-logic-pro-x-mac-app-store">Rene Ritchie in his article about the Logic Pro X update</a> and what it means for developers, publishers basically have 3 ways to handle apps’ updates:</p><ul><li>Keep the same app and make the update free for each existing customer.</li><li>Make a new app and temporarily reduce its cost, so existing users don’t have to pay full price again, and allow new users to take advantage of the reduced price as well, which might be good to boost the ranking of the new app.</li><li>Make a new app and keep it at full price so everyone, existing users and new users alike, pay top dollar.</li></ul><p>Each of this has a drawback for either the developer or the customer… or both, as somebody might argue. Many have already faced the hard choice of going for one of this options and results, we saw it with <a href="https://twitter.com/gedeon/status/357980681965543425">Twitterrific</a>, may vary. If you are an independent developer and you haven’t updated an app for a while like me, or if you’re reworking one of your apps from scratch you’re likely to face this choice yourself.</p><h3>The case for trial periods and paid updates</h3><p>Some people rightfully raised concerns about visibility on the App Stores. How are people supposed to find your great apps among hundreds of similar apps? Just search for ‘Twitter’ or ‘Todo’ or ‘Calendar’ on the App Store and you’ll get hundreds of different results, all formatted the same way and most likely with similar app icons. Now, this might appear as a separate issue, and in part it is, but what happens when hundreds of developers start publishing and keeping on the Stores two or more versions of the same app? We’ll have millions of apps, all doing the same things and therefore polluting the App Stores, which of course means that the chances to be visible to customers gets greatly reduced compared to what it used to be once or what it is today.</p><p>I agree with Elia Freedman when he says that <a href="http://eliainsider.com/2013/07/29/the-app-store-problem-is-not-price/">the App Store problem is not price</a>. Trials might improve discovery of great apps without getting the user to spend money on different apps before they find yours. Moreover it would cut the need for a ‘light’ version of the app and thus for duplications that make other apps less visible. I’d also like to see videos embedded in the details page of apps on the App Store.</p><p>Somebody, I can’t remember who, also argued that <strong>with iOS 7 the discovery of good apps should get a boost thanks to the new design which will make old/non-maintained apps look… well, old</strong>. I couldn’t agree more. This is a perfect time to update your app if you’ve been delaying it for a while and it’s also a good change to submit the update as a separate app and charge full price for it.</p><p>This leads us to the paid upgrade proposal many are trying to push. Although I can see why fellow developers want to charge for upgrades I actually agree with the position taken by Apple on this front: you should publish a new, separate, app if, and only if, you feel the effort needed to produce it overcome the disadvantages that doing so implies. Otherwise, you should take advantage of the in-app purchase mechanism to charge for your latest and greatest features.</p><h3>The solution</h3><p>I don’t fully agree with Dave Addey when in his post ‘<a href="http://daveaddey.com/?p=1084">Apps are too cheap</a>’ he says:</p><blockquote><em>Although IAPs can be used to purchase additional functionality, this doesn’t fit with user expectations of how new functionality is generally made available. The expectation is that if an update is free to download, any new functionality within that update should be free to access, and shouldn’t require an IAP to unlock it.</em></blockquote><p>What I expect as a user from an update is that known issues had been resolved, that something got improved or that there’s <em>some</em> new feature. Updates, by all means, don’t have to only contain new features that are given out for free. Apps like Evernote and many games quite successfully have integrated this philosophy of ‘freemium upgrades’ to their product development cycle. <strong>Apps can get new features reserved to services Premium subscribers or available through In-App Purchase</strong> (either as a one-time purchase or as a subscription) and Games can get new levels available as achievements or as a purchase.</p><p>What’s the advantage of using in-app purchases over payed upgrades? — you may ask. First of all <strong>purchasable features would allow to keep the cost of your app low, if not free in the first place, potentially making your app be downloaded by more people</strong>. At that point only those interested in the paid features will buy them. It’s your responsibility then to promote those features to your users and make them want them. You can choose to sell the ‘premium’ feature individually or/and in bundles. This would also allow to get some extra analytics on how popular a feature is and will make it easier for you to decide whether it’s worth to keep it or not. Moreover, if you decide to pursue this model, an in-app trial of those premium features would move the control of what many have been asking for to you, and will let the users try your full app before having to choose whether to buy extras or not. Of course some of the paid features could be sold as an upgrade bundle within the app.</p><p>Still, as Apple or Tweettie 2 did, at some point releasing a new version of your app or game as a separate entity on the App Store might make sense. This, though, shouldn’t become a rule for all updates, but only for <em>some</em> major versions of your software, when it really makes sense to do so. If you ‘over-release’ updates as separate apps you might get the side effect of loosing visibility and customer trust, not to mention that Apple might prevent you from releasing yet another app with same/similar features than other software you sell on their stores.</p><p>How are you dealing with new features for you apps’ updates?</p><p><em>Originally published on </em><a href="http://gtranchedone.com/blog/2013/08/27/the-app-store-business"><em>gtranchedone.com</em></a><em> on August 27, 2013.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ad33e4b659e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>