After having spent much time with Groovy/Java, and a bit with Ruby and a bit with C#, I have a newer perspective on learning new programming languages. Much of my thoughts are summed up by this post from Gustavo Duartes. I liked his choice of words at the top – “language dabbling” – which largely describes my C# and Ruby experience. I’ve done a little bit in them – some paid in C#, some not – but the bulk of my work is in PHP, with a small but growing bit in Grails.
It’s interesting to note his acceptance of “more than one”, but focusing on the “minimal required set”. We tend to think of languages as Java,C#, Python, etc., but competent web developers need to have a handle on SQL and JavaScript as well. Many also get into Flash/Flex/Silverlight too, and while CSS isn’t a *language* specifically, it’s something most web developers should be acquainted with. So, regardless of your serverside language of choice, there’s going to be 2-4 other technologies you need to be at least competent, if not proficient, with. This may be more the realm of small shop and independent developers – people working on larger teams or in companies with divided responsibilities may be able to get away without knowing any SQL or JavaScript, for example.
One of Gustavo’s points was that you lose momentum on your main language when you start dabbling with others. There may be a point there, but I suspect some people end up looking at other languages when they reach a plateau in one. That was certainly my point I reached with PHP. Having used it since early 1996, there’s only so much more I feel I can do with it. Yes, the language is evolving slowly, and I’m not keeping up with the ‘best practices’ of namespacing and such in 5.3, and I could probably architect my apps somewhat more strictly using some of the bigger frameworks out there. However, one of the things you end up learning when you look at other languages is where some of the defects are in your primary language. You may start to see the new ‘best practices’ as work-arounds in language deficiencies.
It’s easy to point at PHP and talk about how “it sucks” and all that, but I’ve had experiences with some friends who’ve moved from Java over to PHP. While this was a somewhat unwelcome move at first, given PHP’s reputation amongst the ‘enterprise crowd’, at least one of my friends is really enjoying being able to be much more productive – more functionality in fewer lines of code – and rethinking some of his approaches to web development. Moving from any statically typed language to a dynamic one is certainly a shift for people to make (and the reverse movement is true as well!), and rethinking those problems we’ve taken for granted can be a real eye-opener.
In the short term, yes, it’s a productivity loss, as Gustavo points out. In the longer term, it can really provide you with many more tools in your toolkit for attacking new problems.
One caveat I’ve noticed to this is the old saying “choose the right tool for the job.”. Great in spirit, but my experiences have borne out that rarely is the definition of “right” able to be agreed on. ”Right” for who? The DBA? The sysadmin? The developers? I had a project I’d recently prototyped in Grails (after an initial first pass prototype in PHP 6 months earlier). The Grails environment allowed for much more rapid prototyping and modeling of data, relationships, screens, and so forth. However, when it came time to accept it, I was told we could *only* build the app on a traditional LAMP stack (I was looking forward to using PostgreSQL on this project as well). Why? Because the limited system administration staff didn’t have the time to learn new skills to manage the new technology choices.
While initially I was bummed out, I can understand the decision making process. I was able to take the db tables from Grails and wrap another PHP ORM layer around them so I didn’t lose all my work, but it certainly put to rest the maxim “right tool for the job.” Who gets to decide?
So, even if you learn new languages and technology, you might not always be able to use the most appropriate tool from a pure technology/productivity standpoint. And sometimes knowing that there are better options out there that you *can’t* use for various reasons adds a level of frustration to the mix that you wouldn’t have. Perhaps we should all stick to just knowing one language and one language only, right? :)
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
PHP, Groovy and language evolution
I’ve been using PHP since early 1996, back in the PHP/FI days. I’ve used it steadily over the years, sometimes full time and sometimes part time, but that’s been pretty much a primary language for me for 12 years now. During that time I’ve seen a lot of language changes, some for better and some not so much.
I remember when PHP5 first came out having ‘discussions’ with a number of people who insisted that PHP5 was way better than 4. I still couldn’t see too many things that PHP5 made possible that were not possible in PHP4. Streams made some data processing nicer, and interfaces made it easier to code which was a bit more self-explanatory. Basically, intentions were made clearer with things like “public protected private” (PPP), but I have not yet seen any web project get done faster or dare I say even much *better* due to those sorts of things.
PPP stuff can make sense if you’re going to be distributing code to others. For example, if you have sensitive properties that might break your code if futzed with. However, the majority of code written is inhouse, and to be used by people who have access to the code and can make changes to visibility properties anyway. Your code won’t break if I change your ‘private’ or ‘protected’ to ‘public. But keeping some of your properties as ‘private’ can make life more difficult for people who have to live with your code later (AKA me!). I had Smarty break on me because I dared to put {$comment->postedDate} in a template, instead of {$comment->getPostedDate()}.
Smarty breaking basically means white screens, so after a few minutes of tracking down the error, I found out the original author had made all the properties private and made get/set methods for them. This was not code meant for others, nor documented in any other way. IDEs certainly can’t deal with these sorts of things very well, and there’s no way an IDE will ever be able to give me ‘code complete’ in a Smarty template for potentially random variables passed in.
During all this, I couldn’t help but think the original developer probably thought they were “doing the right thing” or being “object oriented” by taking the “private and use get/set methods” approach.
I’m not all doom and gloom, or 100% negative on PHP5. Native JSON and better XML support (DOM and SOAP, for instance) *are* examples of things I saw as genuine improvements in the language. Those sorts of improvements remain true to PHP’s original foundation of being a language focused on the web space. Striving for more “OOness” in PHP feels like it’s trying to become more of a general purpose language like Java, but going about it rather clumsily.
This isn’t specifically saying PPP is necessarily bad, but that PHP could have addressed the issue in a fashion more suitable to dynamic languages. Keep reading for an example.
Over the last year or so I’ve been spending more time in the Groovy/Grails world as well as PHP. I’m not a Java person by trade, and more than a few people have asked ‘coming from PHP, why not go right to Ruby for dynamic stuff?’. There’s a few reasons for my interest in Groovy. First off, I had great intros to the technologies by Jason Rudolph and Scott Davis at our local Java user group last year which definitely sparked some interest then and there. Additionally, GORM and Grail’s ‘domain first’ approach to application development feel more natural to me than other technologies. I’m by no means a master of these technologies, but I’m learning more as I go along.
Groovy is a dynamic language built with inspiration from Smalltalk, Ruby, LISP and other languages. It compiles down to Java code, and co-exists with Java beautifully. It seems to exist largly by and for Java developers trying to achieve more rapid development without sacrificing their Java investment.
One of the key things that Groovy does is ignore PPP notations. By default you do not need to indicate any visibility for class properties – simply give a type.
class foo {
String name
Date createDate
}
etc. By default, all properties are private, but respond to dynamically created get and set methods. In the example above, getName() and getCreateDate() would automatically be generated in to Java byte code for you (as well as setName and setCreateDate()). You can override these if need be, but the defaults are pretty sane. Rather than forcing the developer to write (or an IDE to generate) get/set methods for every property, the compiler handles access control under the hood with consistent default behaviour.
PHP could pretty easily implement something like this, and it would be a great productivity boost for people that need to refactor code to implement new features. Rather than having to go through existing code and change *every* instance of $foo->bar to $foo->getBar(), just write your own getBar() method in the main class, which would override the default behaviour. Same thing could be done for setting values too.
Thinking about this closer, I’m seeing Java developers *migrating away* from PPP in an effort to be more (dare I say?) agile. Perhaps agile isn’t the right word – productive is probably more accurate. Groovy also does away with the static typing requirement – just declare something as ‘def’ and run with it.
Said another way, people who’ve had some of the constructs (“high ceremony” as Stu from Relevance might say) for years are actively looking to get rid of them and move to something more productive.
Contrast this with where many PHP developers’ heads are at, with wanting more type hinting in their method signatures, embracing PPP all over the place, and trying to adopt what they see as ‘best practices’ from other languages. At the same time, developers from other languages are having second thoughts about the necessity of some of their dogma, and are looking at dynamic languages like Ruby for inspiration. Sadly, most don’t look to PHP for inspiration, but I think working in PHP, and thinking dynamically, can be a great advantage if dealt with properly.
Is this just a case of ‘the grass is always greener on the other side’? What do you think?
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
Ted Neward on Grails/Rails
Ted Neward does a good job of dissecting a post from Stu @ Relevance on ‘How to pick a platform’. I won’t repeat everything said in those posts – they each do a better job of representing their positions than I could. I would take exception to Ted’s comment towards the end of his post:
My advice to Jane: pick a consulting firm that doesn’t have preconceived dogma about which web framework… or language, or any other toolset… to use.
I’m not so sure about this. Firms tend to have preconceived notions about platforms because they’ve invested time in learning and becoming masters of them. I wouldn’t necessarily want a firm with no .NET experience steering me towards a .NET platform for a project because ‘objective data’ lead them that way. There has to be a bias involved in those sorts of decisions.
The trick, as I see it, is to understand that the firm has a bias going in to the relationship. This assumes that you, the consumer of the service, have some particular IT needs that need to be aligned with (if you’re a Java shop, you’ll look at Java options first before looking farther afield).
Powered by ScribeFire.
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
Latest podcast up
I had a good conversation with Joe Fiorini about balancing his daily work in .NET with a passion and enthusiasm for Ruby on Rails. Have a listen.
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
Why is SUN ignoring PHP, Groovy and other languages?
I’ve had a love/hate relationship with Sun for many moons. They give us OpenOffice, Java, etc. on the one hand, but then come up with byzantine licensing structures (CDDL was Sun, right? and SCSL was for sure) and get antagonistic towards JBoss and others on occasion. Ultimately, trying to ascribe a single mindset to Sun is not possible, just like IBM, MS and other mega-companies. However, I was reminded of this issue again just now browsing dzone.com’s comments on a ‘drop JRuby support’ article. Planetcmd wrote:
But lets be honest, Sun has ^*&^&*)loads of money and only has a couple of developers working on it. I think the real question is how come they’re not devoting equal or more to other JVM languages? Including Jython, Scala, and groovy. They dug up a billion bucks for MySQL.
Exactl y my sentiments. MS really is really making great strides with C#, yet we get very little in terms of Java progression, and there are issues with Apple (Java6 still isn’t available on Macs). For years I heard that “the JVM supports hundreds of languages!” I was hearing this as both theoretical advantage and practical advice as far back as 2001. Yet MS took the lead because they introduced a VM with and handful of solid languages for their .NET VM which appealed to different audiences (vb.net and c# being the mostly widely used). We’ve slowly seen the evolution of groovy, jruby and a few others on the JVM which could be practical alternatives to Java the language running on the JVM, but we see precious few resources from Sun to attack that market. If you don’t court developers, you will lose marketshare over the long haul. The rise of ‘dynamic’ languages (Ruby, Python, and I’d throw PHP in there certainly as well) has shown what’s possible, but there’s little activity from Sun to address the needs of these developers.
So, why should they bother? What’s in it for them? I don’t really have a good answer for this. Just thinking out loud here: Beyond the long term branding and goodwill that sort of support generates, there’s the services and support model, as well as Sun hardware which people may need to grow in to. Open Source generally commoditizes (?) the need for specific hardware – there’s little *need* for me to run any of my apps on Sun hardware. However, that’s just me. Plenty more people may need (or do need ) that sort of support and hardware. Ultimately, the software stack can dictate the mindset of people looking for their hardware and support. An all MS shop, which evolved that way because of the software stack, is highly unlikely to ever look at Sun hardware for any of their needs. Not saying it wouldn’t happen, just highly unlikely. A Java or Unix-based shop would be more likely to look at Sun hardware.
Am I simplifying this too much?
It’s painful to watch Sun *not* support the next generation of languages in a more aggressive fashion (meaning with real money and support and resources). Given that they found a billion dollars to acquire an open source db (mysql), I’d imagine there’s a few million laying around that could be funneled in to language development and support. Java itself isn’t going to get many radical changes in the near future, but languages on top of the JVM will likely be the next area of innovation. Sun seems to be throwing all of its (few) resources in to JRuby, ignoring the other players. IBM is working on a PHP->JVM project, and it’s working pretty well from what I see. Why has Sun ignored that market? It’s easy to just say Sun is jumping on the RoR bandwagon with their support of JRuby, and it’s hard to counter when they seemingly give little effort to expanding the useful universe of JVM languages on their own platform.
Thoughts?
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
Raleigh web job market
If you’re in the Raleigh area and are looking for a job in the web development market, give me a holler – I’ve had recruiters calling night and day. AND they’re not all calling with the same position. That used to happen once in a while – I’d have calls from three recruiters that were all trying to fill the same position. You could tell – easily – by the wording of the position description.
“Night and day” is a slight exaggeration, but I’ve had more contacts in the past 3 months than the previous 6 before that. Talking with both recruiters and employers directly, there seems to be at least an overall *slight* shortage of good qualified workers in the area. There may be a bigger shortage of people in certain areas, and less in others, but on the whole it seems there’s more work than workers right now. I have info on people who need LAMP/PHP, Java and .Net people for either full time, contract or part time work.
I don’t know if there’s just an issue with fiscal years rolling over and new budgets happening, or if there’s some other explanation, but I’ve noticed a very large amount of activity going on here. I just hope the positions get filled, because long term, if not, that would mean employers would look elsewhere to set up shop, expand and hire.
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
Few ideas from last week
I had a few ideas from last week that I wanted to throw out here for posterity.
Grahame was talking about Haskell, and I asked if he was going to wait for JHaskell – or Jaskell – before adopting it. We then quickly realized Raskell (a ruby version) and Paskell (php/perl/python version) would be good computer language names. If anyone wants to make a version of Haskell that runs on top of Ruby, please call is Raskell. Hilarity will ensue.
Gazpacho ice cream and Bar-B-Q yogurt. ’nuff said.
Speaking with Kevin from discogs.com, he suggested that SOLR would be an invaluable part of every LAMP stack. LAMPS is an obvious acronym, but is not terribly inventive. PALMS is OK too, but much like PALM handhelds. My view is that SLAPM (pronounced “slap ‘em”) would be the best acronym. SOLR on Linux with Apache, MySQL and PHP.
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
Linux distros – does personality matter?
I got a question from my brother the other day about why Mandriva wasn’t as well received as a distro. It’s his primary distro, and was mine for about 2 years. I don’t think there’s all that much ‘wrong’ with it, but I went to ubuntu about 2 years ago, mostly to ride the momentum (packaging of current projects, primarily). One key thing that struck me about Mandriva (formerly Mandrake) compared to ubuntu, redhat/fedora, gentoo, debian, slackware and others is that there’s no core personality behind Mandriva.
There’s not behind fedora anymore, but redhat was (in my mind) synonymous with Bob Young. Slackware = Patrick V. Ubuntu = Mark Shuttleworth. Debian = Ian (Murdock?) Gentoo is/was Daniel Robbins. For better or for worse, the early adopters of these distros often feel a connection with the personality behind the project. It’s the same with many popular open source projects in general. Linux=Linus. Perl = Larry Wall. PHP=Rasmus. Rails=DHH. MySQL=Monty. Even though many people complain about his, DJB’s tools (dns, qmail, etc) are widely adopted often *because* of his personal views on competing software, bugs, development and so on. Compare some of these tools and their passionate adoption rates vs Java. Java might = James Gosling in some sense, but I never saw as much passion around Java adoption as around the LAMP stack. Java just felt too ‘corporate’ (not just to me but to many I’ve spoken with during the early->mid ‘net years – ’96-> early ’00s)
Obviously it’s not the same for *all* distros and projects. However, having a recognizable personality/face/name with a project will, I believe, boost its popularity. Am I barking up the wrong tree? Are these wholly coincidental, or is there a causal link between these concepts?
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
Do you ever cut corners?
This is a general question, but possibly aimed at the PHP crowd more because it’s often easier to cut corners when doing development than in other languages.
“Cutting corners” can mean almost anything from skipping unit tests to skipping documentation to lax variable names to almost anything that you know isn’t optimal but you skip for one reason or another. What corners do you ever cut, and what are your reasons?
My own corners tend to be unit tests. Some projects I write them before (rare), some projects I write them after (rare as well) and some projects I don’t use them (majority). There are two primary excuses I use but they both come down to time. For example, at work, the primary project I’m maintaining is un-unit-testable (is that the proper way to write that?). The time it takes to refactor even small portions which any new code I’d write touches is often beyond the time allocated for the thwork. I did make some headway last year in refactoring some sections of the code to make some of the core libraries testable, but I was pulled off that work for another project. Basically, in that case, it boils down to the notion that the company itself doesn’t value testing as much as getting code out on o the floor in to production, nevermind the notion that future changes become that much more difficult and we end up with less confidence in the production code. It’s been a slow evolution to this point, and it’s like we’re the frog in boiling water – the water’s come to the boil only gradually.
I had this idea some time ago that the ‘strongly typed’ platforms such as Java and .NET made unit-testing a breeze, but my view now is that regardless of the language, the notion of having components testable is something that needs to be designed in from the ground up. Java and .NET seem to make refactoring existing code in to testable code much easier, though (“Refactor! Pro!” was simply amazing when I saw a demo).
So, if you ever cut corners on your projects, what do you cut and why?
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
Feeling groovy
I attneded the local java group last night to hear Scott Davis speak about Groovy. My colleague Grahame came along as well. Scott did a great job of going in to enough detail to show the power of Groovy, without going overboard. I recorded the event on audio, and may put that up either here or a section of it on my web development podcast.
In a nutshell, likely my next sphere of experimentation will be in Groovy. This is partially due to Grahame’s raving about it, but also because of the power it seems to provide. While it’s not overly similar to PHP, which is what most of my experience has been in, it does away with a lot of the overhead Java requires or fashion dictates. No getter/setter writing – the system will do some runtime reflection to try to get you what property you’re looking for.
There’s no need to declare constructors, public/private/protected attributes, and many other things that Java has required. It’s not that you don’t need them, but Groovy will assume certain defaults and default behaviour, which greatly reduces the amount of repetitive stuff you’ve been required to write (or generate) in Java. It strikes me as a ‘dynamic’ Java in that respect. While under the hood I know it’s not really, it does give enough utility to make it exciting to work with. At least, Scott’s excitement rubbed off a bit last night anyway!
Has anyone out there made the leap from PHP to Groovy? Given the dynamic feel of both, it seems that it would certainly make an interesting article, series or even book if it’s not already being planned.
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!
- Get better clients!
- Make more money!
- Avoid costly mistakes!
