The Joys Of Programming

Hypatian wrote:

Unrelated: I came across a blog post today, Why functional code is shorter, with some interesting thoughts about how the expressive power visible in functional languages is mostly about how they make it easy to compose larger programs from smaller pieces, and that this property doesn't require a purely functional language

Yeah, FP was fun. I used OCaml and then F#. In F# it was much easier to write parallel code but it didn't have functors, but I could never find a use for them.

I probably didn't fully grok FP though, and this may be because of what I was writing, but here's my style; when they say 'function' you gotta think mathematical function, i.e. a transformation. You have the data structure you start with, you have the data structure you want to end with. Just as all requirements change, it's usually these two that vary the most and these are what cause the code to change, because the code is determined by the path between these two. It's a simple mental loop, but you get to where you can iterate the mental process pretty quickly. But that was mostly the only process I used, so like I said, I probably didn't fully grok FP. Great for parsing, I built a PEG parser supporting indirect left recursion (thanks to a paper).

Is the wikipedia entry for the C++ kind of f'd up? They're just talking about using function pointers. I'm only familiar with this kind of functor from Boost, but don't you need to store the parameters in an object until you fire the callback? Even with a function with 'no arguments', there's still the 'this' argument. Isn't a functor suppose to bind an object and method to some parameters (usually to be used later in a callback)?

Well, a functor, strictly speaking, is simply a function from one structure to another. (Speaking algebraic structures here.)

In terms of ML-style syntax:

module type Functor = sig type 'a t val unit : 'a -> 'a t val map : ('a -> 'b) -> ('a t -> 'b t) end

And the law that "map f (unit x)" must be the same as "unit (f x)". Of course, most structures have many other useful operations, but you can see how this is a basic signature of any sort of type that operates on arbitrary other types. A couple of examples:

"list", for which "unit x" returns a singleton list [x], and "map f" returns a function that takes a list and returns a new list containing the result of f applied to each element of the list. (And many other operations for making longer lists and doing other things with lists, obviously.)

"parser", for which "unit x" returns a parser that consumes no input and results in the value x, and "map f" returns a function that takes a parser p and returns a new parser that consumes the same input as p, and returns the result of applying f to p's result.

In general, you never write code that works on "an arbitrary functor"--you always want additional operations and laws--but an awful lot of useful structures (monads, applicative functors, arrows, all sorts of kinds of collections) are all also functors.

This is one reason I don't like the term "functors" as used for ML's module functions. It's the same sort of idea, considering that ML modules are meant to embody abstract structures, but it muddies the waters somewhat.

The way I think of ML modules and functors is: they are [em]link time specialization[/em], and that can be quite powerful. The power is hidden somewhat by two things: first, objects are everywhere nowadays, and you can get a lot of similar encapsulation by using functions over objects instead of functions over modules. Second, ML-style functors are often very heavyweight syntax-wise, so they're often a bit awkward to use. However, when you eventually run into a situation where the type system using objects just can't deal with what you're trying to do, it's annoying not to have them. (It's pretty rare, though.)

(As an example of places where it falls apart: Bringing in object types almost always means bringing in subtyping. If you have a situation where subtyping absolutely positively cannot work, that becomes messy quickly. Another trickier place is when you start wanting to write higher-order types. That is: What if you write some code that works on [em]any[/em] collection type? Some collection types, like lists, really don't care what goes into them. Others, like sets, often need comparison functions or the like to be defined on what goes into them. As those constraints grow more complicated, the dancing you have to do to encode things right in even a very expressive language (like Scala, say) can get very very messy. With ML-style functors, the syntax is verbose, but the actual encoding and the semantics of it are very clear.)

And what I mean by "some code that works on any collection type" is something like "Foo[T]", where "T[X]" satisfies an appropriate collection API. Consider the following possibilities:

1) Foo1 works on any T where for all types X, T[X] produces a Collection[X]. So you need to write something that expresses that: "class Foo1[T where for all X, T[X] <: Collection[X]] ..." In this case, the collection class is required to work for *any* type. Probably because Foo1 exposes an API that allows for any type to be used.

2) Foo2 only requires T[Int] to be a valid Collection, because it only uses T on Ints. Why is this important? Imagine you have a BitSet class that implements Collection[Int]. This ought to be usable with Foo2, which only works on Ints, but wouldn't be usable on Foo1, which works on every type. So you need to write something that expresses that: "class Foo2[T where T[Int] <: Collection[Int]]", or possibly "class Foo2[T where T <: Collection[Int]]", or more frighteningly "class Foo2[T where for all X <: Int, T[X] <: Collection[X]".

3) Foo3 is like Foo1, but instead of wanting to require the collection to work with all types, we want the types the collection supports to pass through to the interface of Foo3. So: "class Foo3[S][T where for all X <: S, T[X] <: Collection[X]]", and then some other method of Foo3 involves type S. So now Foo3[Int][BitSet] works, and so does Foo3[Any][List].

4) Foo4 is like Foo2, but it uses the same collection at different times to work with Ints or Strings. So: "class Foo4[T where for all X <: (Int or String), T[X] <: Collection[X]"

As you can see, this stuff is all getting very very complicated very very quickly. And not only do you have to figure out "how do I express the type that I'm trying to express?", the language implementor has to figure out "how do I let users express the types they're trying to express, and how do I make sure that the type system is sound when they do that?"

And that is why even though Scala's collection classes are pretty awesome to use, trying to understand them fully in order to implement a [em]new[/em] collection sometimes requires deep wizardry.

--

As for the C++ thing: well, C and C++ are rather a mess for functional programming, simply because there's no automatic way to construct closures. You can do it, but you have to build the closure yourself--and that means not only putting the values into some piece of memory to keep them around (in C, you'll often see a void* in this context, sometimes called a "rock", as in something you hide things under), but you also need to *define* the type you're going to use to store that info. (In C, probably a strict. In C++, often the function and closure info together are made into an object.)

In short: you have to do a *lot* of extra manual effort to do higher order functions in C, so mostly people don't do it, except in the easiest (no closure needed) places, or when it's absolutely necessary.

Edit: Now that I'm off my phone and it's easier to look at the C++ example on that wiki page: It looks fine to me. The sortInts function expects an object with an overloaded function call operator that takes two int arguments and returns a bool. If you wanted there to be state (a closure), you'd have state in the compareClass struct, and when you construct the compareClass object you'd give it your state. Also: Ugh, C++.

Any recommendations for a book or site to teach myself C#?

McChuck wrote:

Any recommendations for a book or site to teach myself C#?

I liked John Sharp's Step by Step book when I read the 2005 edition. Here's the latest:
http://www.amazon.com/Microsoft%C2%A...

Thanks! I'll check the Kindle sample out.

I also liked C# in Depth, Second Edition. Manning has Kindle, PDF, and ePub versions in addition to the dead tree version. Buying the paper book gets you all the other versions or you can just buy the electronic versions in all formats (one price for all e-versions, a slightly higher price for all e-versions + physical book).

DanB wrote:

Gah... I have to upgrade an extensive Rails 2.2.x application to rails 3.2.x

So far it looks like the easiest method will just be to start a whole new Rails 3 application and move the code over piece by piece.

In case anyone cares. It turns out that this is a lot easier than I anticipated. Solved most of the new syntax issues and have the application largely running. Now got to comb through the code and adjust everything else in the same style. Might even refactor some of the more hairy bits that have be left to languish for too long while I'm at it.

While I'm thinking of web dev stuff. Jquery plugin namespaces: developers seriously need to quit naming the which their plugin acts on with the class set as .container. Because it's an utter pain getting some of these to play nicely together. Why isn't there a convention that the class name is something like .container_PLUGIN_NAME?

I've been messing around with the Typesafe stack for Scala development in the last couple of weeks and reading some Scala tutorials. Pretty broad set of language features, but definitely fascinating. I want to write some sort of multiplayer game engine with a web front-end. Looks like a great stack to do that on. Any scala guys have a strong preference on lift vs. play frameworks, and database tools?

Mixolyde wrote:

I've been messing around with the Typesafe stack for Scala development in the last couple of weeks and reading some Scala tutorials. Pretty broad set of language features, but definitely fascinating. I want to write some sort of multiplayer game engine with a web front-end. Looks like a great stack to do that on. Any scala guys have a strong preference on lift vs. play frameworks, and database tools?

Funnily enough I just finished working through 7 languages in 7 weeks. I'd love the opportunity to really dig in to Scala or Clojure. Sadly there aren't really any projects here at work that are good fits for either.

DanB wrote:

In case anyone cares. It turns out that this is a lot easier than I anticipated. Solved most of the new syntax issues and have the application largely running. Now got to comb through the code and adjust everything else in the same style. Might even refactor some of the more hairy bits that have be left to languish for too long while I'm at it.

Ha, I spoke too soon. Literally just spent the whole day trying to track down a problem which turned out to be a namespace collision with one of our classes and a somewhat "undocumented" core Rails class

Mixolyde wrote:

I've been messing around with the Typesafe stack for Scala development in the last couple of weeks and reading some Scala tutorials. Pretty broad set of language features, but definitely fascinating. I want to write some sort of multiplayer game engine with a web front-end. Looks like a great stack to do that on. Any scala guys have a strong preference on lift vs. play frameworks, and database tools?

From my experimentation, I prefer Play! to Lift, it seemed a little better constructed and documented but they both are fine. I think Lift is probably more focused on traditional web applications (heavy on the server processing) while Play! is more Web 2.0-ish (AJAX, client-heavy apps). Neither are all that great for doing REST stuff, if that is what you want to do. Scalate is nice for that, or Unfiltered (which is still rough but looks promising).

The biggest bummer to using Scala is how bullsh*t sbt is. It is wonderful when it works but royally sucks when it does not. The docs are cryptic at best and the features change from version to version so most of the helpful doc on the net is useless. The repository situation seems to be in a bit of a flux as well; it appears a lot of packages moved from sonatype to typesafe at some point in the recent past. But the package's docs have not been updated so trying to get all the moons aligned to build something is akin to herding cats while hitting yourself in the forehead with a hammer while riding a unicycle on a tightrope over a pit of lava. I'm not bitter though. Or hateful.

Also, feature fragmentation in Scala is another bummer. A lot of stuff is still on 2.8.x, some other stuff is on 2.9.x. 2.10 is on the horizon as well. So that cool library you want to use? Maybe it's available for the version of Scala you want to use. Maybe not. Maybe it is but good luck finding it in an accessible repository.

IDE support for Scala is getting better although development on the "official" Eclipse-based Scala IDE has slowed quite bit over the last 6 or so months, which is too bad because it is almost a great tool, despite being based on Eclipse. IntelliJ IDEA 12 has some nice, if simplistic, Scala support.

Despite having said all this, I still herd the cats with a sore forehead because I think the Scala ecosystem will be pretty awesome, whether that be in a year or five. The language itself is, as you say, fascinating, it is pretty easy to pick up and use while still being extremely powerful, and has the great expanse of existing Java libraries available to it. So despite my ravings, I still am optimistic about the future. The community is still very young so terrible tools are kind of expected.

Is your company using it? Are you hiring?

Mixolyde wrote:

Is your company using it? Are you hiring? ;-)

Man, I wish. On both counts.

RolandofGilead wrote:

Is the wikipedia entry for the C++ kind of f'd up? They're just talking about using function pointers. I'm only familiar with this kind of functor from Boost, but don't you need to store the parameters in an object until you fire the callback? Even with a function with 'no arguments', there's still the 'this' argument. Isn't a functor suppose to bind an object and method to some parameters (usually to be used later in a callback)?

C++11 has closures of a sort, I believe, but it's basically a glorified function object. ie. you still have to specify which fields you want preserved in the closure, which is the same as defining a one-off object with operator() overloaded. In D, returning a delegate (a function pointer with context) basically copies the local stack frame into dynamic memory as the context portion.

It's done. Any constructive feedback?

Hmm. With a slow connection, it took a while for the ArialBlack font to load alongside the giant image. That made it pop into place very very disconcertingly. Sadly, I know that there's no good standard way to handle font loading events yet. Still, it seems rather heavy for a single phrase. (And it seems especially odd to put it next to a body font that is not Arial but Helvetica, if both are available.)

The "kid riding a bike" clip art is clearly clip art, and the color values are different enough from the other two (less professionally-taken) photos that it stands out. I'll add to Hyp's comments about the fonts: the headers don't seem to be anti-aliasing; at this size, the jags are noticeable. (I'd consider giving them some slight color, too, to set them off more from the body text.)

On the "Mission" page, I reeeally want to click on the "You/12 weeks/etc." square (which, notwithstanding, are a great piece of design IMO).

Content: the biggest question I have that isn't answered in the FAQ is "Which technologies will I learn?" I infer that you are using a Windows stack of some kind from one question in the FAQ and the reference to "Microsoft-centric organizations" in the "Hiring Network" section, but I know nothing else. If you're being deliberately tech-agnostic, you should mention that, too.

Notwithstanding that, I think it's pretty awesome. I hope the guild does well and serves as a template to others.

Yeah, I'm not really a designer, so the font idea was the guy I'm working with. I'll putz around with it a bit. I had forgotten to compress the banner images, so they should perform better now.

Agreed on the stock photos, I really want better "action" pics of the training overall, but I think it's going to have to wait until I start my first cohort. I got a local ACM group to volunteer for the shots I have. Eventually I'll remove all the stock photos.

Good point on the FAQ

The software guild thing looks really good, and if I were hiring I'd love to talk with your graduates, but I can't find what 'local area' you're supporting. I presume it's around Ohio from your GWJ location, but that would be one of the first things I'd look for if I were either a prospective employer or student.

Keep us up to date on your progress - if it takes off, maybe we can start a chapter up in Seattle too!

Looks pretty great.

One little thing; don't let the browser handle rescaling your logo (i.e. this image http://www.swcguild.com/images/logo.png) it currently looks terrible with no anti-aliasing. You can't/shouldn't trust browsers to rescale images because they don't typically handle anti-aliasing. If you want it in the smaller size you're presenting it in the page header (which according to the .logo css is 250x50) then you should produce a 250x50px version for use in that location.

Just at a glance:
On mission.html, the text for the HTML5 and CSS3 boxes is identical. Maybe change it up or at least move the boxes further apart.

Also, a couple of typos on that same page:
In the Relational Database Fundamentals box: "business applicaitons"
Under the Intensive Learning section: "eat, sleep and beathe code"

And I agree that identifying which region you're talking about would be helpful.

Got a new job!
According to the interview(I interviewed with the whole team(including product manager) + the dev manager):
Agile, scrum, sprints
Self-organizing, self-managing
Actual unit testing, adding unit tests to legacy product, some TDD on new product
Continuous Integration
Legacy - Java, New - .Net & Java
Single DB engine (Last job had 4, and no DBA)
A DBA!
No phones on developer desks! The product manager handles all product-specific communications and the dev manager handles all internal stuff.

Super excited.

Congrats, duckilama!

duckilama wrote:

Got a new job!
..
Legacy - Java, New - .Net & Java
..
No phones on developer desks! The product manager handles all product-specific communications and the dev manager handles all internal stuff.

Super excited.

Congrats. Though the phone thing seems weird to me. I'd be interested in hearing why they're using .Net when they've been using Java all this time.

RolandofGilead wrote:

I'd be interested in hearing why they're using .Net when they've been using Java all this time.

Deep searing self-loathing!

Sorry, my MS troll slipped out.

*Legion* wrote:
RolandofGilead wrote:

I'd be interested in hearing why they're using .Net when they've been using Java all this time.

Deep searing self-loathing!

Sorry, my MS troll slipped out.

Don't worry, I hated Java long before I briefly liked MS (.Net 4.0).

Grats Ducki!

RolandofGilead wrote:
duckilama wrote:

Got a new job!
..
Legacy - Java, New - .Net & Java
..
No phones on developer desks! The product manager handles all product-specific communications and the dev manager handles all internal stuff.

Super excited.

Congrats. Though the phone thing seems weird to me. I'd be interested in hearing why they're using .Net when they've been using Java all this time.

I find a lot of shops doing this. I think Java is going the way of Cobol. It will take time to get there, but soon it will just be embedded and legacy stuff. What .NET isn't taking away Ruby is eating on the other side.

bandit0013 wrote:

Grats Ducki!

RolandofGilead wrote:
duckilama wrote:

Got a new job!
..
Legacy - Java, New - .Net & Java
..
No phones on developer desks! The product manager handles all product-specific communications and the dev manager handles all internal stuff.

Super excited.

Congrats. Though the phone thing seems weird to me. I'd be interested in hearing why they're using .Net when they've been using Java all this time.

I find a lot of shops doing this. I think Java is going the way of Cobol. It will take time to get there, but soon it will just be embedded and legacy stuff. What .NET isn't taking away Ruby is eating on the other side.

This has not been my experience/observation at all. In fact, I've seen more Java lately thanks to Hadoop.

FeralMonkey wrote:

Just at a glance:
On mission.html, the text for the HTML5 and CSS3 boxes is identical. Maybe change it up or at least move the boxes further apart.

Also, a couple of typos on that same page:
In the Relational Database Fundamentals box: "business applicaitons"
Under the Intensive Learning section: "eat, sleep and beathe code"

And I agree that identifying which region you're talking about would be helpful.

Thanks, I actually had those boxes fixed and forgot to apply it!

The region I left off deliberately for now, trying to figure out how to work it in... I'm thinking to franchise this model if it takes off.

duckilama wrote:

Got a new job!
According to the interview(I interviewed with the whole team(including product manager) + the dev manager):
Agile, scrum, sprints
Self-organizing, self-managing
Actual unit testing, adding unit tests to legacy product, some TDD on new product
Continuous Integration
Legacy - Java, New - .Net & Java
Single DB engine (Last job had 4, and no DBA)
A DBA!
No phones on developer desks! The product manager handles all product-specific communications and the dev manager handles all internal stuff.

Super excited.

Congratulations - that sounds like an awesome get

SixteenBlue wrote:
bandit0013 wrote:

Grats Ducki!

RolandofGilead wrote:
duckilama wrote:

Got a new job!
..
Legacy - Java, New - .Net & Java
..
No phones on developer desks! The product manager handles all product-specific communications and the dev manager handles all internal stuff.

Super excited.

Congrats. Though the phone thing seems weird to me. I'd be interested in hearing why they're using .Net when they've been using Java all this time.

I find a lot of shops doing this. I think Java is going the way of Cobol. It will take time to get there, but soon it will just be embedded and legacy stuff. What .NET isn't taking away Ruby is eating on the other side.

This has not been my experience/observation at all. In fact, I've seen more Java lately thanks to Hadoop.

Oracle is killing Java.