New Project: Scala.php

31 03 2015

Exciting news!!

The Scala community has spoken, if we already had Scala.js and Scala.css the next natural process is, of course, Scala.php

With Scala.php you could use your beloved language for creating WordPress plugins, Drupal sites and CodeIgniter/Laravel/Fuel/Phalcon/Symfony projects (do not forget to add Scala.css and Scala.js to the mix, the fun will never end with Scala) and deploy your Scala app on GoDaddy!!!

Not only that, in future versions we’ll migrate our fantastic Scala ecosystem to PHP, the train release will continue with Akka.php, Play2.php, Lift.php, Spray.php, Scalatra.php, Spark.php and Scalaz.php (Do you miss your favourite Scala library? We accept PRs)

But our final goal is to mix those powerful languages in to one. Do you miss php’s variable variables in Scala? Worry not. We plan to add all your adored PHP features in Scala via Macros and compiler plugins.

A new golden age is at hand my brethren, a age of prosperity and peace. Come with us to the promise land of SCALA.PHP!!!!





Book Review: Spring Data

5 12 2012

I’m reviewing this book thanks to the good people at Packt Publishing that give me a free copy

Spring Data in is own words is:

…an umbrella open source project which contains many subprojects that are specific to a given database. The projects are developed by working together with many of the companies and developers that are behind these exciting technologies.

So, if you already know the kind of support that Spring Framework give to JDBC you could have an idea: Unified Runtime Exceptions Hierarchy, Templates implementation and so on; but for MongoDB, Redis, HBase and others, including extensions for already supported technologies like the afore mentioned JDBC and JPA

The Spring Data book from Packt Publishing, written by Petri Kainulainen covers the JPA extension and Redis support.

First the good parts:

  • The book is very short (161 pages) you can read all in less than a week
  • The author covers well both topics from the Spring perspective
  • The example code is very well written, well formated and concise (very rare on other Packt books)
  • The author approach is more practice than theory, some people love this approach

Now the bad parts

  • The examples use Spring Java Config. Java Config is a special configuration type that let you write Spring Applications without XML. Although more trendy, this is the least used configuration type and not all Spring users feels comfortable with this configuration, and the tooling support isn’t the best
  • The layer architecture isn’t well defined. The service layer have a lot of implementation details that depends on the data layer, so from one example to the other the services implementations change radically.

    This is “understandable” in JPA examples (Spring Data JPA adds dynamic implementations for Repositories) but in the Redis examples, There’s not a Data layer!!

In conclusion

The book cover well both topics, the code is well written, but have some oddities





KotlinPrimavera 0.1

3 11 2012

The first release for KotlinPrimavera is hot, right from the oven

Check the repo and the docs

KotlinPrimavera is a framework that provide support for Spring Frameworkk inside Kotlin Language





I wrote my first application on PHP

17 09 2012

Why?

A friend needs a small application to sell some courses. The business model will make the use of a proper shopping cart (like Magento) overkill in some aspects and, in the other hand, some specific price rules and the payments process (Integration with Latin American Payments) will need a extensive development.

The hosting was on GoDaddy, so the only option was PHP.

So, here are my opnions

The language

Some readers from years ago (and my close friends) will know that I don’t like PHP. And when you read some horror stories like PHP: A fractal of bad design

My not-at-all-extensive experience was:

  • The max PHP version that GoDaddy support is 5.3.10. So maybe some issues are resolved on later releases, this also limit my framework choices (more on that later)
  • Speaking about frameworks, I suspect that my Framewrok of choice (Yii) hides some language’s oddities from the developer
  • I like the instant-no-redeploy nature, That feels very productive coming from a Java experience (Some frameworks like Play and Grails have this feature too, also JRebel could make this on plain Java projects, but I don’t test it yet)
  • In the other hand that sense of productivity falls when you need to type those strange characters that the language designers love. Also this makes the code very hard to read, Some examples
    • “$” as prefix of every variable and parameter
    • “->” to call a “instance” method. (I don’t know if the language designers have this concept clear)
    • “::” to call class or static method (More on that later)
    • “$this->” as prefix of every instance method call inside the same class (This makes me thing that the whole OOP features are no more than makeup)
    • “self::” as prefix of every class or static method call inside the same class (Please note, that “self::” is a reserved word that represent a “class” but “$this” is a variable that represent the actual instance, “this” isn’t a reserved word. So you could have
      const this = 3

      . Also note that the reserved word is “self::” not “self”, So you could have

      const self = 3

      and continue to use

      self::staticMethod()

      but you could call your instance methods like this

      self::instanceMethod()

      So really “self::” could be the “class” or the “instance”. As you could see, the “fun” with PHP never ends 😉

      UPDATE Sep 18 2012
      Seems that “self::” or “self” aren’t reserved words at all… Oh, the humanity
      END UPDATE
      )

  • The “array” thing that isn’t array nor a dictionary, but could be anything and both at the same time (PHP arrays could be use as metaphor in the Arminian-Calvinist controversy).

    The whole syntax is ugly and very hard to read, and worst of all, could be very error prone, Example (actual code):

    return array(
                array('allow', // allow all users to perform 'index' and 'view' actions
                    'actions' => array('index', 'view'),
                    'users' => array('admin'),
                ),
                array('allow', // allow authenticated user to perform 'create' and 'update' actions
                    'actions' => array('create', 'update', 'course', 'user'),
                    'users' => array('@'),
                ),
                array('allow', // allow admin user to perform 'admin' and 'delete' actions
                    'actions' => array('admin', 'delete', 'pending', 'ready'),
                    'users' => array('admin'),
                ),
                array('allow',
                    'actions' => array('response', 'confirmation'),
                    'users' => array('*'),
                ),
                array('deny', // deny all users
                    'users' => array('*'),
                ),
            );
    

    And I choose not the worst example, this could be grow quickly in a huge mess.

    IMHO, PHP needs named parameters very badly, and the developers need to take a more OOP approach to clean this mess

  • Errors are terrible, Yii will show you some nice error report (But some times isn’t clear where the error is), but other errors will show you a blank page, no design, no purpose, no evil, no good, nothing but blind, pitiless indifference

The framework

I examine some of the myriads of PHP frameworks

  • CodeIgniter was my first option, I like what I see, but in some cases is bare-bones and have a lack of functionality that already come with other frameworks
  • CakePHP 1.3 come with many nice things but is also very restrictive
  • CakePHP 2.0, FuelPHP and Symfony 2.0 don’t have support for the PHP version that I have (I’ll like to test Symfony 2.0, its seems very Java-like)
  • Yii was my option, the last stable version (1.12) have support for my PHP version, is very well documented and are very feature rich
    • Some of my toughs:

      • As I told you before, I suspect that Yii hides some language oddities
      • The framework is well structured, and no more different from other frameworks like Django or Grails
      • Gii, a nice GUI for generate code (Models, controllers, forms, views) is a huge save time, but isn’t so powerful. The code generator that come with Grails is more powerful, and the Django Admin is almost perfect (in fact I’ll love make this project with Django)
      • Yii comes with a great widgets selection, but the syntax to use isn’t so nice (“array” based)
        widget('zii.widgets.jui.CJuiDatePicker', array(
            'attribute' => 'birthday',
            'model' => $model,
            'options' => array(
                'dateFormat' => 'yy-mm-dd'
            )
        ))?>
        //There's another alternative syntax, but I don't test it
        
      • Yii have hundreds (if not thousand) of extensions, but almost every extensions that I try fails miserably.

      The IDE

      I use IntelliJ as always, with the PHP plugin, it’s a very nice environment and have integration with an FTP client, so every change that you made on the code is auto-magically synchronized with the server, that could ensure some errors in production and hilarity.

      The Yii community likes PHPStorm that, in theory, is a Slim-down IntelliJ with only PHP/HTML/CSS/JS/SQL functionality.

      Conclusion

      My experience with PHP, was mixed, The language is really bad, but the instant-redeploy-on-server is nice, also Yii made a great job giving some sanity and features for free.

      I really hope that this will be my last experience with PHP, other options like Django or Grails are much better.





Intro to Scala (Spanish)

25 06 2012

This are the slides from my Scala talk in the past Colombia JUG reunion.

Enjoy





Book Review: Scala in Depth

14 06 2012

Maybe you don’t like Scala, but you couldn’t argue that Scala isn’t a hot topic on the development community.

Manning has published their first exclusive Scala book (Other Manning’s books touch Scala topics), Scala in Depth. Other books in Scala are been prepared by Manning

The author, Joshua D. Suereth works in TypeSafe the company behind Scala. As described in the title, this book touch some scala topics in the deepest way.

So, if you’re looking a beginner Scala book, I suggest you Programing in Scala second edition [Odersky, Spoon & Venners 2010], ’cause this book assumes that you know the language basics, and don’t come with a gentle introduction to the Scala world.

General

Seems that Suereth is a very seasoned Java developer. Many examples in the first chapters explain the differences between both languages, even using Spring framework; and the chapter 10 (Integrating Scala with Java) have a lot of useful information (and hard to find in other resources). The approach to the book is so deep, that many examples include bytecode analysis (indeed, very geek). Also many chapters covers the type system, making this book a perfect companion to the developers coming from an OOP background

Suereth makes a great work teaching those hard concepts, and the book never turns boring.

The worst part about this book is the code formatting. Many examples in the book have erros and Suereth favors a REPL approach that, IMHO, is very hard to read in a book. Also the source code that comes with the book don’t come with any instruction and only two chapters have a build.sbt file. But those problems are minor compared with all the useful information that the book have.

Content

Chapters 1 and 2 are an “Introduction” to Scala, but don’t expect to learn languages basics here (Chapter 2 have many useful tricks to work with Option[T]).

Chapter 3 covers coding conventions, very useful (Many corner cases covered here are a little spooky)

Chapter 4 to 7 covers almost every topic on Scala’s OOP flavor. (Including many cases that aren’t covered in other books)

Chapter 8 covers the Scala collections library, nothing too fancy, but is very well explained

Chapter 9 covers Actors. (Actors are a very hard and broad topic to only on chapter.)

Chapter 10 is about Integrating Scala with Java and cover many cases that could arise in a mixed project.

Chapter 11 cover many topics in functional programing like Category theory, Monads and Functors, a good introduction but I think that I’ll need twenty more books to grasp and use in a proper way this concepts.

Conclusion

This is an excellent book for those that have a previous experience with Scala. The OOP chapters are superior to other Scala books, the functional chapter is good introduction to this complex topic. The code could be better, but don’t affect the overall experience. 5 stars





Book Review: Spring Web Services 2 Cookbook

3 05 2012

I’m reviewing this book thanks to the good people at Packt publishing that give me a PDF copy to read

I’m a SpringSource Certified Instructor and Spring WS is one of the most difficult part to teach en every course. And not because the framework is complicated, is the technology (SOAP) that is very complicated. So, having a book in the topic at hand is a very good thing.

First of all the good parts:

  • This is the first book on Spring WS and do a very good work covering every corner case. Is, by far, more complete than the official documentation
  • And when I say “every corner case” is TRUE (seriously, the whole enchilada), from things like using XMPP to send a SOAP message to secure a WS using WSS4J, including Spring Security and many more things.
  • The book also cover Web Service with REST (without covering security ) and Spring Remoting

Now, the (very minor) bad parts:

  • This format (a Cookbook) is not the best way to teach topics in a deep way
  • The code looks horrible (at least in the PDF version) and is very hard to read. This is epidemic in other Packt publishing books (Hey Packt’s friends, take note). Reading the code from the example code is better, but, the code have little or no documentation at all and is poorly formated.
  • The implementation details in some examples aren’t the best. The use of some deprecated classes, building new instances just to call static methods, using XPath without XPathOperations (a nice interface that define some very helpful XPath methods) and so on
  • In the Spring Remoting part the authors don’t cover HttpInvoker that is the more natural way to communicate two Spring applications. (In fact HttpInvoker is nicely cover in the Spring documentation, so is just a matter of taste)

In conclusion

This a very good book, the authoritative reference for Spring WS





My thoughs on Kotlin

3 08 2011

As a JetBrain’s Fan boy

I’m totally fan of JetBrain’s products. I’m using IntelliJ since the 4.0 version, even I develop a plugin for it. And seriously guys, this people know A LOT of programming languages; JetBrains develop IDE’s for Java, Python, (J)Ruby, HTML, JavaScript, PHP (originally developed by the community) , Objective C/C++, and have plugins for Groovy, Scala, AspectJ, ActionScript/Flex, SQL, JSP (including EL and JSTL), ERB, HAML, LESS, SASS, XML, YAML, Velocity, FreeMarker, Django Templates, Clojure, CFML (same as PHP) and many others. (without count, .Net products)

The development API for those IDE’s is so powerful that the community already contribute with many others (Including some esoteric languages): Arc, Bash, Erlang (this plugin is developed in Scala, EPIC geek) Fantom (very good plugin, seems to be abandoned, 😦 ), Gosu, Go (exists plans to develop a stand alone IDE using the IntelliJ Community Edition), JFlex, Lua, OCaml, Scheme, Power Shell and many others. Those plugins vary in quality from WOW to Eww!!, but is a good indicator for the quality of the language support on JetBrains products.

But, also Kotlin isn’t the first language that JetBrains develop. BaseLanguage is the language that come with MPS (Meta Programming System). MPS is a implementation of Language Oriented Programming paradigm. In plain English with MPS you can develop your own DSL and the MPS IDE will give you support, How? Extending the BaseLangauge (or creating a new one if you want). MPS isn’t too mainstream (A Hipster tool) but is already battle tested. YouTrack The JetBrain’s issue tracker was developed with MPS.

I think that we’re in good hands, JetBrains have all the experience and the knowledge to create a very good language, and of course with SUPER COOL IDE support from day 0. Also the feedback of the community is HUGE in the Kotlin Site. If JetBrains could embrace the community and listen them, they could develop a very successful language.

As a Scala Fan boy

I love Scala, Scala is my new best friend. I learn in two years with Scala more Computer Science than in five years with Java. Scala is a beautiful language that never end to inspiring me and amazing me (also scaring me).  Since I develop with Scala I’m a better developer; my code, even in others languages, seems to be more thread safe, more functional; but also Scala makes me a better son, citizen  and brother. Scala will lead us to a new golden age of prosperity and peace, a new renaissance of arts and philosophy. A beautiful new world.

But, let’s face the truth (please brothers of the Scala church, don’t kill me as a blasphemous) Scala’s complexity isn’t a Myth. (But I don’t agree with Gavin King)

Let me explain. If you come from a first world country with a very good High School program and Computer Science program like Swiss, Sweden or Norway; Scala isn’t complicated, but for people like me, that come from a third world country, with a Educational System “a little below the average” is complicated. I found myself studying countless hours to have “a little below the average” proficiency with Scala, I’m not complaining, was a VERY fun time, but, seriously guys is complicated.

Scala is more complicated than Java. Sure, you can use Scala as better Java, but is like buy a Lamborghini Gallardo to recharge your iPod, yes it’s works, but you’re losing a lot of features. In the other hand Kotlin IS a better Java, with good additions. A Java developer will be proficient in Kotlin in a fraction of the time, compared with Scala.

But Scala and Kotlin don’t need to be mortal enemies, If we can achieve a good interoperability between Kotlin, Java and Scala, we can have polyglot projects, so we can use the right language for the right type of problem. Also if you want to learn Scala a very natural way will be Java -> Kotlin -> Scala.

As an IntelliJ Scala plugin user

I think that the Scala support IntelliJ support is very good. Some great names in the Scala community are using IntelliJ and they are happy with it. Some FUD spread around the community with the announce of Kotlin thinking that maybe JetBrains will stop the development of the Scala plugin. Guys, this is the real world; the Scala plugin helps JetBrains to sale many IntelliJ licenses… JetBrains never will stop to develop the plugin as long as be good for business. Period

As a IntelliJ Power user

Obviously I use IntelliJ every day, but also I develop plugins. If JetBrains could use Kotlin to be more efficient in their developments all the users will win. But also they can test their new toy in a very hard scenario (Believe me guys, IDE’s are on of the most challenging scenarios for a language, and a developer).

As a business man

I have my own company (an one-man-army operation) I’m the Chairman, CEO, CTO, Sales manager, Development manager, Help Desk operator, architect, developer and tester. If I want to survive competing with other companies (big and small) I need a extra advantage, a secret weapon. My secret weapons are my tools (for more info on the subject you can read this post from Paul Graham). With IntelliJ, Spring Framework, Spring Integration and others, I actually defeat some bigger companies, with more developers, resources and money; delivering projects in a fraction of the time and costs with more quality. Scala provides me a huge competitive advantage… as long as I work alone.

But my little baby is growing, in less than a year I’ll  contract a few developers to achieve more bigger projects. Teaching Scala to a development team could be very challenging and frustrating and I COULD lose part of my advantage. But Kotlin seems to be a safer bet, More similar to Java, better integration, better IDE support, a huge productivity boost compared to Java… Kotlin could give more business value than Scala… heartbreaking history but true

But also if the language is successful (and have all the factors to be a success) there’s a lot of opportunity business waiting for us: Books, conferences, seminars, courses, libraries, tools, frameworks, certifications, t-shirts, mousepads, mugs and others, in fact a new beautiful world.





Flex on Java:Review

8 09 2010

The people of Manning books give a MEAP copy of “Flex on Java” from Bernerd Allmon and Jeremy Anderson

In my company we are developing an ERP for a mid-size company dedicated to sale construction supplies on Leticia, Colombia. The application is a port from a Seam based application to a Flex/Spring application (BTW, Seam is a HORRIBLE framework, avoid it  if you can). So this is a great opportunity to review this book

First of all, the copy that I have is MEAP version so, this is not the final book and can contain some rough cuts and unpolished parts (if I can obtain the final version I’ll update this review)

Chapter 1:Some Flex with your Java?: A general introduction to the main topics of Flex and, of course, Java. A nice introduction for the rookie, but I don’t think that a rookie want to read this book. Flex and Java are big Behemoths and think to dominate both with just one book is silly. Also we have our first “Hello World!”, and IMHO the main problem of this book: (actually, not so relevant) The majority of the example codes aren’t in the last versions of the frameworks.

Chapter 2:Beginning with Java: This chapter cover the development of a Java Web Application with AppFuse (I read about this framework but I never use before) and Maven, once more time good information for the Rookie (Including how to install a JDK, yes, you read well). The application expose some WebServices and have the DAO Layer with Hibernate, the IoC with Spring and the Web Layer with Struts and JSP. Thumbs Up for no including IDE related content

Chapter 3:Getting Rich with Flex: Very good chapter, nice examples, and a valuable information for all the developers that are new in Flex, although don’t replace a good book in Flex, contains enough information to start and see the power of this framework. Thumbs Up for don’t use Flash Builder.

Chapter 4:Connecting to Web Services: This chapter is worth of the total costs of the book. The code quality are amazing, as never see before on others Flex books. The authors introduce the MVP (Model View Presenter) Pattern, a good way of organizing the code of a RIA. Although I never use the MVP is very nice to see a good example of how you can organize the code to call WebService/RemoteObject.

If you, like me, are not new to Flex and Server communication you’ll know that all the examples in the web and in the books use the <mx:RemoteObject> tag, very well for small examples but when your application grows up you’ll have a lot of copy-n-paste code in all the application. Well this chapter teach you how avoid this nightmare.

Chapter 5:BlazeDS Remoting and Logging: This chapter cover the Spring Flex project in very detailed way. For me this is OK, I’m a fan of Spring ( I’m  SpringSource Certified Spring Professional) but not all the developers love Spring. So, will be nice if the book cover another options like GraniteDS and integrations with EJB3 and Seam (The HORROR). Thumbs down for don’t including information about Exception Translators and the proper way to manage them

Chapter 6: Flex Messaging: Messaging is one of the more powerful features on Flex. This chapter have a LOT of technical details, is very deep and not for the faint of heart. But if you’re using Flex and Java, surely you’re not of them, right?

Chapter 7:Securing and personalizing your application: Spring Security deserve a book for his own, but this chapter makes a good work explaining the basics of Spring Security and his integration with Flex. Good examples and good theory, much better than the Spring Flex documentation

Chapter 8:Charting with Degrafa: This is the chapter that I enjoy less, Why? ’cause Degrada only works in Flex 2 and 3, and my current projects are on Flex 4, however AFAIK Degrafa is integrated now with Flex 4, so, hypothetically speaking, the theory in this chapter will help you with graphics on Flex 4.

Chapter 9:Desktop 2.0 with AIR: Great Chapter, AIR is a very compelling technology, and is huge plus if you can turn your Flex Web App in AIR Desktop App, but don’t lies yourself, most of the times this is Phantom requirement (A requirement that don’t exists), so Choosing Flex ’cause you can make Desktop apps easily when your app don’t have this requirement is a no-no.

Chapter 10:Testing your Flex application:Unit Testing is a requirement on all modern application development cycle. Flex Unit Testing is not very different from Unit Testing on other languages, so if you already knows how to do Unit Testing, you will dominate Flex Unit Testing in a breeze. This Chapter also covers Continuous Integration with Hudson Server, another hot topic (BTW I prefer TeamCity from JetBrains)

Chapter 11:Flex on Grails: Grails, my deadliest enemy, we meet again. You hate me, and I hate you… jokes apart, seriously, I’m not able to run any Grails example, and for my own mental health I don’t make the example in this chapter, but the code seems pretty easy, (Grails code is very easy, if it works is another question) but don’t expect that Grails auto-magically generates MXML code, so it’s not reduce drastically the amount of work that you need to do a mid size app.

Conclusion: Flex on Java is a very well written book, the code examples have a great quality and are production-ready, a very rare characteristic in programming books.

I like:

  • Code quality
  • Explanations on some hard topics
  • IDE-Agnostic

Don’t Like:

  • The book use some outdated libraries
  • Some important topics aren’t well covered
  • Don’t cover other connection options apart from WS and BlazeDS

NOTE: 9/10





IntelliJ IdeaX: First Impressions

28 08 2010

I’m an absolute fanboy of all JetBrains Products. And now I’ll write mi first impressions on IdeaX, the last (and yet not final) version of IntelliJ.

  • First of all, this is BY FAR the best EAP (Early access program, by definition is more buggy than a beta version) version of IntelliJ, very stable, much more responsive and quick that the 9.0.3 version.
  • The UI have many improvements on Mac OS X, better status bar, very beautiful scroll bars and Open file dialog
  • ActionScript and Flex have a good looking new icons and many improvements on refactoring and intentions like delete unused namespaces declaration on MXML (this works on other *xml files too)
  • The editor now have a ‘soft wrap’ function
  • The database console now use a editor tab for queries, but right now don’t have auto-completion of table and columns names.
  • Support for LESS and SASS
  • Ruby and Python plugin have the same features of the latest RubyMine and PyCharm products
  • Not related to IdeaX itself, but JetBrains is making a good work on plugin development documentation, as plugin developer I’m very happy whit this, and of course, we’ll see a lot of new plugins in the future.

Seems like the JetBrains friends are making a good work with their flagship product, surely this new release will be an EPIC WIN for all IntelliJ Users