 Wednesday, January 09, 2008
OK, so I've been using Python quite a bit lately and I've been enjoying it. I've been getting stuff done with it too. Python inter-operates with COM quite well and that saved me a lot of pain yesterday. However, learning Python has caused me pain in other areas.
Yesterday I had to perform some maintenance in a C# ASP.NET app that I had written not too long ago. Even though I use the CoolStorage.NET and some other nice time savers, it has become painful to write C# code. It's just too verbose.
I used to marvel at people who claimed that you don't need an IDE to develop with Python. I thought that was blasphemy as Visual Studio was the bee's knees in C# development. However, I'm amazed at how much more I'm engaged in coding when I'm writing Python (or JavaScript). You have to pay attention to what you're doing, no IDE is going to help you out. However, this heightened state of concentration is actually fantastic for writing good code.
I use Notepad++ as my editor for Python (and JavaScript and HTML, etc) when I'm not using C# and Visual Studio. I find its adequate for the job and it does have a function/method browser built in. It also does HTML auto-complete and it can highlight a psp template file where I have Python, HTML and JavaScript all in one file. It's also very stable, something that Visual Studio is not.
Visual Studio 2005 is flaky. Sometimes all my Windows will rearrange or reset. Other odd things happen and I find myself re configuring my layout from scratch. Actually worse than scratch because every thing is helter skelter around.
The worst part though is the amount of code I have to write to keep the compiler happy. I know what I want to do and I know how I want to do it but I have to tell the compiler what I'm doing ahead of time so that it's happy. Honestly, this is a great feature for a newbie or someone who really doesn't want to learn the language. However, it becomes a burden after a while. The C family of language has so many tokens (symbols like { [ ( ; , for while do foreach if) that your code becomes very noisy very fast. Python is nice and clean which is something that I've come to appreciate.
I think I've found a better appreciation for Python (and JavaScript) because I've used C#/C++/Java. For my everyday programming needs Python can handle everything I need to do. However, at my current job getting Python into the mix might be a bit hard. However, it might be worth it. We spend so much of our day writing Programs that should just be nice and easy scripts. We have so many programs and projects that could easily be one python file. We do a lot of file transfer and validation.
So yes, I'm feeling the pain of C#. I just don't need/want that bug IDE and big language for what I need to do.
Python does it faster, smaller and cleaner.
 Sunday, December 16, 2007
Or ORM's Are Not the Whole AnswerOR Some ORM's Are A Better AnswerOne point I feel I need to make. So many people seem to think that at some point an ORM will appear that will just magically work. It will map all your entities to objects and "just work." So an endless parade of ORM's continue to lurch forth from the hinterlands. I'm amazed that people like Bruce Eckel think that an ORM powerful enough will just solve the problem. The thinking is usually something like "we can shield the user from that ugly, mean SQL with some nice procedural and markup tricks." I've come to believe that anytime you try to hide/wrap/abstract a powerful technology/language (SQL, JavaScript, HTML, etc) you end up with at best a leaky abstraction and at worst a complete mess. SQL is concise and powerful. It doesn't need to be hidden. It's not that hard to understand. It's at least easier to understand than most of the ORM frameworks. It's quite ridiculous what kind of code acrobatics you must perform to add parameters to a query. One of the biggest problems with an ORM is predicting what kind of code they will generate/execute. The more considerate frameworks include a logging function of some sort. This is nice but when I go to look at some code and I find a bunch of ORM garbage code, I find myself wishing for the SQL. I used to hate embedded SQL, then I realized there really is nothing wrong with it, and it fact it's preferable as I found out what a web page is doing all in one file, without analyzing a (now unsupported) ORM or trying to find a stored procedure in the database. The stored procedure approach is not that bad, I just find myself shying away from them as code re-use is a myth. Yes, now I've become a true OOP Heretic. Code re-use, especially between projects, is a rarity. And this is the major problem with ORM's, they tend to emphasize the one object for every situation paradigm. If I have an employee table, naturally I will have an employee object, if I'm an OOP ORM Myrmidon. So I try to use this Employee object for my employee edit screen, my employee absence report, my employee salary report, my company org chart, etc, etc. However, I soon find my nice clean ERD and UML diagrams become corrupted by the business needs. We have to join in extra tables. Pretty soon we are writing all manner of custom logic in our programming language of choice. We have to use a little somthing like join_to(tables.employee_benefits).get_by(table.columns.user_name='a%').limit(10).sort_by(table.columns.user_name). We are wasting resources by bringing back unneeded columns. Because the One True Employee contains fields for every situation, we populate the whole object for every request. We can resort to lazy loading and other performance optimizations for expensive entities. The Better SolutionThe answer is that there is no answer. However, I think the frameworks like CoolStorage.NET and the db library in Web.Py have a nice ability to load data from queries into objects. This takes away about 80 percent of the pain of Database/Object interaction and let's us use queries specific to the Use Case at hand. I think the best we can do is to use the best tool for the job, in the case of talking to databases that tool is SQL. We should use SQL and take advantage of automatic mapping. Learning SQL one time is much better than learning a new ORM every year. I feel the same for HTML, JavaScript, CSS and the rest of fundamental technologies of our trade.
 Saturday, November 24, 2007
In my previous post about what people use computers for, I stated that computers are for saving state. Duh. I felt I needed to make that clear to myself as I explored functional programming languages like Erlang, F# and Scheme. State seems to be a dirty word relegated to second class citizenry in a functional world.
I think that functional language have an uphill battle for mainstream acceptance. A bit bolder, I think they are a small niche and always will be a small niche. In fairness, I think most of literature on functional languages portray them as a special purpose languages. As the saying goes, the right tool for the job. Microsoft is looking for F# developers to write driver validation software.
My goal is to find languages that are applicable to general purpose problems. I'm not a mathematician and I don't need so solve theorems. Most of the programming jobs I've completed involved storing and manipulating some shared stated, a database.
Yet another realization courtesy of a man seeking to explain the failure of the best language on earth.
Local state in programming is just like scratch paper for mathematics. Some rare gifted individuals don't need it and can do the calculus in their head. For the rest of us scratch paper and number two pencils are the only alternative.
While debugging, I can inspect the state of the system, either with the debugging facilities or with well placed print statements.
So local state helps us understand our systems. Global state, again databases, are the reason our systems exist. Some in the Erlang camp want to wish this away. However, I think Erlang advocates understand that Erlang was built for telecom switches. Erlang's usefulness in general purpose programming is yet to be determined. If you're building a system that manipulates global shared state (most of the web applications in existence), choosing a language that waves its hands at shared state in the name of concurrency might not be your best choice.
Now we come to the revelation stage of our journey. What can we do in mainstream languages to deal with global shared state (databases) effectively? I've found something in my own development work that is effective for me. It's not a new language, but in fact, works in many languages, including C# and Python.
My solution may not be a silver bullet, but then I might not be hunting werewolves. I can't claim to have invented it. For from it. All I can claim is that I've seen this pattern work across languages. I can also tell you that it might be a wooden stake, useful if you are hunting vampires.
 Friday, November 23, 2007
For a (brief) while, I was learning F#. It proved an interesting excursion. If you into mathematical correctness F# and OCaml maybe just the languages for you. Myself? Well I'm looking for something with a little more to offer in the functionality department. I want a language where I can do most anything. I'm willing to sacrifice mathematical niceties.
Python seems to be that language. Python is one of the languages I knew I would love when I tried it, so I've held off diving into it until I had gone through almost every other one. I've journeyed through Lisp, Scheme, C++, C#, Java, Ruby, F#/OCaml and dabbled in a few less known like Factor and Cat.
Python Advantages:
- Available and almost every platform (every platform I'm interested in)
- Terse clear syntax
- Whitespace (yes, I do enjoy the whitespace!)
- Easy to learn, easy to teach (I taught C++ to undergrads during my time in Hell)
- More complete than Ruby
- Better documented than Ruby
- Good riddance to the Edit/Compile/Wait/Debug loop (hello Edit/Test, Edit/Test, Edit/Test...)
- Python is available on the CLR as Iron Python and on Java as Jython.
Disadvantages
- It's not C# (heh)
- It's not Java (heh, heh)
- Performance (slower than the above)
I believe that Gabriel is correct and that worse is better. Worse as in Python is not Lisp. Even Dr Norvig, chief brain in a jar at Google, thinks Python is good for something.
Note that Python is one of the four languages in use at Google. Google has, in fact, hired the Frost Giant.
Python is used in game scripting. My favorite game series of all time uses Python as the scripting engine.
I've also found one of the best Web Frameworks to date to use with Python. I'll detail that it a future post.
Right now Project X is moving forward on rockets fueled by Python. This is the most complete proof of concept I've completed in an alternate language (not C#) and I'm LOVING it.
 Wednesday, October 17, 2007
Michael Feathers asks if syntax is important.I think the answer is maybe. Certainly a language with a familiar syntax will allow you to pick it up faster if you have already learned a language with similar syntax. For example, I found Java very easy to understand since I had a background in C#. Of course, there are the countless winers who complain about lisp's syntax or lack thereof. One tricky point is syntax that is legal in one language but not so in another. I constantly found myself typing foreach in java just to be kicked in the head by the compiler. I think syntax really matters for the first month or so of learning a new language. Once you get beyond that you are able to "think" in the new language and your ideas start showing up in your new language.
 Monday, October 15, 2007
Technically its more like a few hours spread over a week but so for so good. I've come to begin to understand functional concepts. Currying and partial application now seem to be rather easy to understand but hard to explain to someone else. However, what I really love is not necessarily the functional aspects, rather the terseness of the language. I especially like type inference. I'm not sure why we couldn't have had that sooner in C#. In languages like C# you expect an IDE to be present so it works really well in situations where you have a toolset to back you up. It also works really well in scripting languages (Ruby, Python, etc). However, with F# (and OCaml) you get the benefits of strong static typing with the benefits of less typing. I really like it. It seems that many concepts are just simpler in F# rather than C#. I also see cases where it is easier to define a smaller single use type (like when you query a small set of data from a database) than to declare a full blown class. I think many times I've found it a pain to create a whole class when I really don't need to reuse it. Again, these are just first impressions. Things may change as I get farther into the tutorials and learning processes. I find F#/OCaml very easy to learn. As I was working on Scheme/Lisp it syntax always felt alien. I was learning a lot but it didn't fell quite right. F# just seems to feel good. Probably because it is close to C# in some ways. I really need to get into a small project with it to see if I really like it. Once I have a real world application under my belt I can usually tell if I'm going to keep a language in my toolbelt or put it back on the shelf for another time. I also think I have a solution for the ASP.NET development. I'm going to use ASP.NET without ASP.NET... (I'll explain more in the future, but if you read some of my previous posts, you can probably figure out what I'm going to use.)
 Friday, October 12, 2007
My latest language is F#. After considering PLT Scheme for my latest side project I thought I should do some more investigation first. I had briefly considered Factor. While Factor is coming along quite well, It's not quite ready for prime time.
I remember looking at Ocaml because of the speed and type safety of the language. However I was initially turned off by the syntax. I then moved onto Python. I think Python's syntax is clean but I miss compile time checking for errors.
So after seeing another post on F# on Reddit, I decided to check it out. At this point it all come back to me. F# has a Visual Studio plug in. You get intellisense and all kinds of nice features. There is even a top level REPL (Read Eval Print Loop) that lets you test out code very easily. I had decided against Boo because it lacked Visual Studio support and #Develop doesn't quite do it.
I dug into a few Ocaml tutorials (yes, these work very well for F#). I soon found myself loving the language as I began to understand the power that these ML derivatives have. All I can say is wow.
F# lets me use the years of built up C# libraries and expertise I have, yet also write powerful and elegant code. I do say I like the syntax quite a bit better than Scheme. I hate typing all those () as they tend to make your fingers hurt
Now I just need to figure out the web story for F#. It appears that you can use it with ASP.NET but I need to do some more research.
 Thursday, October 11, 2007
Everytime I try a new language or technology I eveluate it based on what it can do for me. Will it make more productive or will it teach me something. I'm not a big believer that learning language X will make you a better programmer in language Y. I think there is some truth in that but not as much as some would lead you to believe.
Above all else, I look for pragmatic solutions. What can technology do for me? I think Ruby on Rails is a decent example of pragmatic software. It has its flaws but in the right scenerio I think its a very practical solution.
So when I go down the rabbit hole with some new language/platform, etc, I'm looking for benefits. I know what C# and ASP.NET can do for me. I've used them long enough to know the ups and downs and i'm constantly looking for ways around those low points. ASP.NET webforms is a great example. I hate using them. In anything but the most simple situations, they break. They "leak" in that they are not the best way to abstract the web. They represent the underlying web server event cycle more then anything. And they are painful to use.
I've looked at Boo, Nemerle, F#, IronPython, L#, Cat and probably some that I can't remember JUST in the .NET realm. This doesn't include my research into Lisp, Scheme, Scala, Factor, Ruby, etc. These .NET technologies have other benefits like cross platform abilities that make them attractive. With the .NET languages/tech, I'm looking for ways to solve or alleviate my C#/ASP.NET pain.
Boo seems to be a good language. It lacks good Visual Studio support though. This means I lose productivity to gain a cool language.
IronPython has a sweet spot in scripts and possibly web pages. I like the quick turnaround of editing a script and seeing the results without the long compile time.
On the framework/library front there is ProMesh.NET and MVC framework that replaces WebForms. It's pretty good but it still has some bugs. There is also MonoRail but I haven't gotten the courage and the time to test it out. It looks massive and I don't really get Inversion of Control and Dependency Injection yet. However, they sound odd and a bit scary. Do I really need them just to have a decent web framework? I don't need these in PHP.
A solid win on the ORM front is CoolStorage.NET. This thing blows the doors off of anything else I've used bar none. It is the optimal combination of light weight yet powerful features. I think CoolStorage wins by being a C# first project. It is not a clone of a Java project. CoolStorage takes advangtage of attributes and generics to produce a terribly productive product.
So with one win and so many that qualify as so close yet so far, what is a practical programmer supposed to do? The only thing I can do is spend hours testing out new languages and frameworks to see if there is anything out there. At least at the end of the day, if I don't find anything, I know that C# is king and I'm not left wondering.
So I must continue my crusade for the best even though most days its a big pain. I've recently found F# and it looks very nice. Visual Studio support, a real REPL and syntax and conciseness like a scripting language yet with a typing system more powerful than the one in C#.
So yes, these little discoveries are worth all the pain of downloading, installing, and compiling countless new programs. I can put my mind at ease and keep up on the latest developments. In the end there is something to be said for intellectual stimulation and if there is practical use then all the better.
© Copyright 2008 Chris Weber
Theme design by Bryan Bell
newtelligence dasBlog 1.9.6264.0  | Page rendered at Friday, July 04, 2008 6:31:27 AM (Central Standard Time, UTC-06:00)
|
On this page....
| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 29 | 30 | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 10 | 11 | 12 | | 13 | 14 | 15 | 16 | 17 | 18 | 19 | | 20 | 21 | 22 | 23 | 24 | 25 | 26 | | 27 | 28 | 29 | 30 | 31 | 1 | 2 | | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Search
Navigation
Categories
Blogroll
Sign In
|