Why are things made so complicated in web design?

Ever since Linq came out over 3? years ago (Earliest post about it that i have was from June 25 2008) I’ve been madly using it as much as I possibly could. I didn’t find it to be just some kind of syntactical sugar, or at least I learned it wasn’t eventually. Which? I don’t remember and really it doesn’t matter. Point is I’ve been a huge proponent of it and the various fun that came with. (Func, Action, anonymous types, ect) Now I had heard that it was based on functional programming but I had no real idea what that meant. It was just some kind of programming cultists and people with tin foil hats use. Let’s be honest, in the “Beer league” of programming, there was no respect for it.

Now flash forward a couple months ago when I went on a painful trek as I tried to find a language that could do more then what C# could handle. Far as I was concerned, I had out grown it. Like VGER (And Spock for that matter) I had outgrown the world of C# and needed something more even though I wasn’t sure what that something was. “It knows only that it needs, Commander. But, like so many of us… it does not know what.”

I thought I could find satisfaction in a new language even though I had failed before at that. I looked into Ruby, Scala, Python (Again), Boo, but something just didn’t take. It wasn’t long before I realized that they are ultimately like C#. Sure some are dynamic, some are intelligently typed, but in the end they were the same. It was just a question of how I liked the language to look, but not how things were done. Meet the new boss, same as the old boss.

It was at that point I decided to just put my shoulder down and start running toward the unknown. Toward a functional language. My first stop was F# and it was surprisingly amazing. I finally found a language that would make me keep up and not the other way around. I put a ton of time into it for 3 months, but stopped. It wasn’t the language itself, the functional design, or performance. It really came down to the half —ed implementation that The good professor Microsoft decided to eh… implement. File structure (Or literally lack thereof) was painful. It’s inability to use the built in MSTest UI was even worse. To add to that, the only way I could get a nice debug enabled testing framework was through Resharper and even then I’d have to run every test in an assembly before it would add it to the suite. Add in it’s failure to work with Entity Framework without a third party library, Power Pack and well FFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU…

Ok… So I think you might get that I am a little bit mad about the situation. The reason isn’t that I’m trying to be an -ss but I REALLY LIKED F# AND THINK IT DESERVES BETTER THAN JUST TO BE SOME LAME -SS SIDE PROJECT.

I’ve learned this lesson before though and I just stopped bothering… at least three times until last Tuesday when I really, for really, not joking this time, quit F# for good. Yeah I’m not good at giving up on things.

Annoyed and looking for something to fill my need for functional languages, I decided to go all out. If I’m going to be functional (Programming functional not as in functional alcoholic) I’m doing it the full way. That’s right, I have turned to Lisp… just kidding. I am going full Haskell. Yes that language that is never talked about in name lest it release some demon or some weird looking dude when said three times in front of a mirror. That Haskell. Even before I knew what a functional language was, I had heard of it and was told to never look it in the eye and to keep on walking. I’m not sure why there is so much fear and secrecy around Haskell. I realize that, as the old cliche goes, people fear what they don’t understand, but the fear/hate people had for it seemed irrational. Like it was some kind of invading army hell bent on instilling some sort of dictatorship. I know I’m being a bit hyperbolic but the point is that people treated like it was a personal attack on programming. Like it’s existence was purely for insult and nothing else. Good thing I’m too dumb for my own good and ignored the warnings… it just took me four years to do so. (But in my defense, I hate quitting to a fault so I thought I should ride out the .Net stack.)

Now with this move it caused two problems: I had to take off the .Net training wheels and figure out how to even get Haskell to compile. The other was… How the –ck do I handle database oriented persistence? I mean for C# you have NHibernate, LLBLGEN, Subsonic, that entity thing… you get the point. There’s no shortage of ORMs for the .Net world. Tried to see if there was one for Haskell, but I started really thinking about this. One of the issues I had pondered with functional languages is how do you relate a database to objects if you aren’t really using an object oriented model. It’s quite a conundrum. (I spelled that right the first time.) I mean I’m sure you can force out some kind of object like model if given enough time, but was it really needed? To this I say no! (I think)

One of the concepts I’ve had to learn early on with functional programming is Tuples. Essentially a tuple is stuff bound together.

Could be a key value pair:

(“firstName”,”Sean”)

Could be a list of various strings grouped together:

[(“Sean”,”111 Cool Lane”,34),(“Andre”,”111 Stupid Street”,33)]

Point is, it’s stuff grouped in a like way. In fact, it has to be grouped in the same way. Take the one above for instance. It is a “list” of (string, string, integer). As long as anything added to it has the same signature, everything is great. If they don’t:

[(“Sean”, “111 Cool Lane”, 34), (1, “111 Stupid Street”, 33)]

Well… Kaboom. Now here’s the interesting part (One of many I hope): If you have a list of tuples and you squint real hard, you might mistake them for classes. After all, isn’t that what a class is? A bunch of stuff forced to be represented in a set way? If you think about it, this is basically how dynamic languages like Python or Javascript work. The “class” is just a bunch of key value pairs. You can call a property on an object like this:

something.DoStuff

Or you can do it like this:

something[“DoStuff”]

Yes it’s psuedo code and probably not 100% correctly represented, but that’s not the point. The point is that an object can be made of from key value pairs… Basically like the tuples above… and that’s where it gets really interesting.

I started to think about what would it take to represent a user. Say you have a plain user with Id, FirstName, and LastName. Well you could have a class:


public class User
{
public int Id {get; set;}
public string FirstName {get;set;}
public string LastName {get;set;}
}

Or you can have a tuple:

[(("FirstName","Sean"),("LastName","Isawesome"), ("Id", 1))]

Now here’s the funny part: I originally didn’t think the tuple representation was possible due to a possible type conflict. But sometimes in our most idiotic times there can emerge a real idea. The idea is simple:

WHY THE –CK DO WE SPEND SO MUCH TIME FORCING TYPES IF MOST OF THE TIME WE JUST NEED STRINGS!?!!

I know, it sounds odd at first but if you really think about it, does it matter if an Id is an integer? Sure in the database, but outside of it? Here’s a typical MVC round trip:

You take in a json string and turn part of it into an integer. You push that integer to a class (Model or other wise) and then use the class to transport that Id to be used as a string in a sql query or it gets converted to some other database happy type. It then is pulled back out of that database friendly type and pushed into an integer so it can hydrate a user class. Then the id is passed into a model so it can be turned into a string for html or json.

This begs the question:

WHY THE –CK DO WE SPEND SO MUCH TIME FORCING TYPES IF MOST OF THE TIME WE JUST NEED STRINGS!?!!

Think about and I mean really think about it. How often do things typed as integers (Or decimal or date or whatever the –ck you want) get used for anything but to be aimlessly typed and retyped? How often do any numbers get used for anything number related? In the world o’ web development there is very little use for numbers. Sure you might have to sum them up, but doesn’t it seem more logically to start as a string and only type when it’s needed as opposed to type something to anything but a string when all it ever will be used as is a string? It makes no –cking sense. None.

But maybe somewhere you might have to validate that the number falls within a certain range… GREAT! Convert to an integer and check!.

But maybe it has to be a proper date. –CKING GREAT CONVERT AND CHECK!

But, but what about when persisting to a database… THIS IS A GOOD REASON… eh to convert.

If there’s anything I’ve learned from the newfangled ideas of lean and such; it’s that you build only what you need. Don’t over complicate. Don’t over think. Don’t pass go and collect 200$. If there is no reason to type something as an integer, then why would you? Join the revolution. We can win this one or look like complete –sses while trying. I can’t promise which, but I can promise one will happen.

This is just the begining…

4 thoughts on “Why are things made so complicated in web design?”

  1. Awesome man.  I am recently unemployed for speaking such blasphemy at my research job.  Check out Combinatorial Algorithms by Donald Knuth.  The entire discipline was developed before computers got fast…

  2. also…isn’t type just a different flavor of “rec,” where the members are matches inside the body of the function? (recursion being a “while” with a boolean holder…)

Comments are closed.