4 ms·
Programming Can Be Fun Again
- acangiano 15y agoFunctional programming is admittedly fun, at least for those who are mathematically inclined. The problem is that it's hard, at least at this stage, to justify using a functional programming language as your main tool. Want to develop web applications? Nothing from the functional programming camp comes even close to the polished experience of using Ruby on Rails. Yes, I know about Play and other web frameworks for Scala, Clojure, and Haskell, but - and I repeat - they aren't even remotely close to the level of support, libraries, plugins, and documentation that you can get from the Rails world. Want to develop mobile apps for iOS or Android? That's typically Objective-C or Java territory. Yes, you can develop Android in Scala, but you are a pioneer then (and you are virtually on your own if you encounter any issues with the stack, as very little documentation and community support is available for it). Want to develop desktop applications? Again, functional programming languages are rarely the best supported option. C#, Objective-C, C++, or even Object Pascal (Delphi) are all fine choices. Opt for Scala, Clojure, or Haskell and you'll find little documentation and support, and in the case of the first two, you'll have GUIs that look anything but native. So what are these functional programming languages good for? So far I've only found them to be good at doing heavy lifting in the back-end or in GUI-less scripts. An important spot for sure, but not the most prominent one to justify adopting either as my main tool. I love functional programming languages and I wish I could drop everything and write web apps in Clojure or Haskell. But the hustler in me wants to get stuff done and cannot justify the world of pain and waste of time I'd experience, especially when there are already tools that are simply better suited for the task at hand. Should a project of mine scale to the point of needing a fast functional programming language for core functionality in the back-end, I'll be happy to employ it there.
- haliax 15y agoCompletely disagree about Ruby on Rails, the experience of using happstack ( http://happstack.com/index.html http://happstack.com/index.html ) blows it out of the water. The RAM Cloud database is really natural to use; it eliminates problems like object-relational mismatch and SQL injection by letting you do everything in idiomatic Haskell. Plus, the type-system, monads, and algebraic datatypes make it much easier to write clean, correct code. Albeit, only once you've passed the learning curve.
- mobileman 15y agoThat learning curve is the problem. Building a business ultimately requires people to be cogs at some level.
- cconroy 15y agoWhy functional programming? Functional programming maybe hard in the beginning but it's much simpler to program in once you wrap your head around it. Backend web dev? There are lots of nice simple frameworks or you could build your own. Do you really need everything rails / django offers -- I find minimal and lightweight is best. You are essentially building an service that can interpret http. Devices? If you want to do iOS or Android you can use javascript, css, and html instead of the native approach (see phonegap et al.). Javascript is a functional language -- in that it supports higher-order functions like scheme. (See http://yuilibrary.com/theater/douglas-crockford/crockonjs-3 http://yuilibrary.com/theater/douglas-crockford/crockonjs-3) "...world of pain and waste of time experience..." or getting shit done in what I know how to do is not a good approach for a programmer.
- pessimizer 15y agoI really adore using Erlang with Webmachine, jQuery Taconite, and erlydtl for web projects. It's usually not a morally safe option for other people's projects (because what are the odds of them finding an Erlang programmer to work on it after I'm gone?), but it's a joy for my own projects. Easy, and as functional as you want to be:) edit to add links: https://github.com/basho/webmachine https://github.com/basho/webmachine http://www.malsup.com/jquery/taconite/ http://www.malsup.com/jquery/taconite/ https://github.com/evanmiller/erlydtl https://github.com/evanmiller/erlydtl
- Dn_Ab 15y agoI disagree in terms of Desktop. writing F# apps targetting .NET, mono or monomac is equivalent to C#. The only cost is some initial time with t < 2 hours to write a dsl to wrap your interface xaml to F# or for forms create a dsl for your interface.
- wccrawford 15y agoSome of us never thought it stopped being fun.
- georgieporgie 15y agoI've recently started having fun (for the first time in years) tinkering with Project Euler problems, writing C#, and playing with Arduino. Android looks like it's going to be fun, but so far it's a lot of mucking around the huge infrastructure they created, trying to figure out how to do what I want. C++ is no longer fun for me.
- edoloughlin 15y agoI've been working on a Cloure project for a few months now and, as the article says, it just felt natural to use the objects that came directly from the (relational) database without doing any ORM-type manipulation. My years of non-functional experience meant that I've had this niggling doubt that I've been doing the right thing. It's nice to have some validation...
- alexatkeplar 15y agoDean Wampler keeps repeating this idea that ORMs have been an epic wrong turn for coders and that SQL-wrangling functional tools like Scala Play's Anorm represent a much more efficient way forward. I agree that being able to map/filter/fold over record collections is very cool, and definitely part of the solution, but it's crazy to think that going back to embedding brittle, non-type-safe, non-DRY, database-specific SQL calls into a host functional or OOP language is the best way to do this. We're using Squeryl for Scala and very happy with it - it's fully type-safe, uses very easy to define case classes for each db record type, and crucially allows all of that FP fold/map/filter goodness over the data models which are exposed. Joyless heavyweight frameworks and flabby design patterns are definitely the problem, but Dean's survivalist-style head back to basics and raw SQL isn't going to let us build rich complex software in 2011.
- glassx 15y ago"programming did become fun again when I started using functional programming as my main paradigm" That's exactly what happened to me. Even though I mostly program in C# (at work) and Ruby (for personal projects) these days, my code and my team's is full of functional idioms, mostly thanks to LINQ, lambda support in C# and lazy evaluation (IEnumerable generators). Now our code is much shorter, way more readable and much safer compared to what it used to be. We avoid mutability and state changes (meaning, we don't use mutable variables or flags), most functions are testable by themselves, code reuse is much better, objects are much thinner, and even 17 old interns are fluent on such idioms by now. In fact, most new hires already come with LINQ experience, which is cool. I don't know why the "fun" factor was increased so much, but it did for me. I believe it is because we're forced to think in a straight, linear way that produces the cleanest, safest code possible. It is like some kind of puzzle. It's just like working in Haskell: you have to think before you code. Well, also it helps a lot that mundane tasks such as calculating the largest number in a list is reduced to list.Max()...
- Dn_Ab 15y agoAs someone who only does functional programming I do not think their power lies in their erm functionality. I have a hypothesis. I think the key lies in how easy is it to look at your code and trigger the pathways in your brain associated with elegance. No offence to Java, it gets the job done but due to boilerplate, the likelihood of your code resulting in such triggers is much less than say clojure or scala. Consider the popularity of CofeeScript, node.js, python, ruby. These are not idiomatically functional languages but due to reduced boilerplate they too also make it easier for your code to be appreciated on an aesthetic level. What is the gain in this? I have a belief that an appreciation for elegance is the natural outcome in a universe with a principle of least action. Prefer the explanation which takes less energy to unfold. So anways what happens is that your brain rewards you for writing code that tries to be elegant and turns aesthetic knobs. Pushing you for more and more of a hit. And you start to become more motivated to write code that rewards you thusly and a side-effect being programming is more enjoyable and you are more likely or encouraged to write code that is appreciable. Since code is meant for humans, as a start, optimizing in this way is ideal. Train yourself to appreciate algorithmic and mathematical elegance and you reap the rewards there too.
- Meai 15y agoI don't know functional programming but I agree with your sentiment. I even think this is the reason why languages like C++ and Java are abused so much. Over the years of use, people start learning little tricks and hacks, and they want to deploy those. They find them elegant, while everyone else who has to read them...actually thinks they are horribly overcomplicated. C++ template programming is awful, but some people love it because they love how elegant their code can become. They love that they can immerse themselves in the language features. Unfortunately this provides a net detriment to the code you are writing. No matter how good your code is, someone will have to read it again, even if it's just you. Code should be simple. I believe code should be difficult to write bad. In the common languages though it's very easy to write undecipherable code. In Javascript for example, it's hard to write code that needs more than a few moments to understand. It's even hard to write "class" hierarchies!
- michaelochurch 15y agoI find C and C++ fun to write. The difference is that functional languages make (50th-percentile) code fun to read. In C++ and Java, even 90th-percentile is a bitch to read, hence people don't. At best, those responsible for maintaining it will skim it. This is also why the "broken windows" pattern (once things get ugly, people "hack" them and they get uglier) sets in so rapidly in C++/Java projects. Functional programming encourages beautiful code (although it certainly can be ugly.) A consequence of this is that people, even if they're not skilled enough to write pretty code, actually read code-- not because they need to, because they want to-- and become better programmers as a result. Functional programming, for a passionate programmer, refines the aesthetic sense and 2-4 years of it will give most people the skill to be a passable software architect (whether they are passable or great depends on talent IMO). Not so with C++ or Java. You can spend 10+ years in those languages and get really, really good at optimization but still have no aesthetic sense. You also learn faster when using FP languages because you can do more in them. You get to see the consequences of your architectural decisions long before the project goes multi-developer and is handed off to someone else or a team. Functional programming is not a great career move. It makes you a difficult fit for 90% of jobs that are out there, and it makes a lot of people think you're a hipster jackass. But it's rocket fuel for your skill as a programmer.
- mobileman 15y agoI think this is one of the commentaries I've read on FP. I was a FP junkie and DSL addict until I realized my business was going to fail because I couldn't hire the right people at the budget I had. It is why I'm an alcoholic now. Java makes me drink as I wait for Ocaml to be main stream
- earl 15y agofrom the article: " as a Scala advocate, many developers complain to me that the immature support for Scala in IDEs is a real blocker for introducing the language in their Java environments. I understand the practical issue of meeting this now-typical expectation of Java shops, but I actually don’t really care. I seldom use IDEs anymore. My Scala code is so compact that I use Emacs for it." sUnless you happen to be doing greenfield development, this is a dealbreaker -- I like using scala, but it has to call / manipulate the enormous api surface from 1.5mm lines of existing java. And for that, I need tool support.