Code Craft
The art, science and craft of writing quality software

Aug. 23, 2005 - Freedom languages

Posted in Programming

I�ve never met a coding God who didn�t know at least one �freedom language� that they thought was great.Many know several.Some refuse to program in anything else.

What, pray tell, is a �freedom language�?Freedom languages are those languages that put the individual programmer at the center of their philosophical world.They work hard to remove any language constructs that reduce programmer freedom, and add the most powerful constructs available.Many are post-modern languages and most tend to be syntactically dense.

The other kind of language is the �safety language.�Safety languages think first about the creation of contracts between modules, objects and functions.They focus on teams rather than individuals.They remove language features that are confusing or frequently misused so that there are fewer opportunities to make mistakes and so there can be clear separation of concerns and maximum verifiability.These languages are full of barriers and check-points and well-defined paths and they tend to be syntactically verbose.

Right now the �hottest� new freedom language is Ruby with Python second, but the most heavily used freedom language is Perl with Smalltalk second (my estimates, no science involved).The popular safety languages are C++, Java, C#, VB and Delphi. These collectively dominate modern programming.Other less popular safety languages include Haskell and Nice.

Can�t we all just get along?

I picked the terms freedom and safety because they represent a philosophical split that I�m not sure some of the advocates of these languages realize is present.You can sense this split when you listen to the words that the various pundits use when discussing the merits of different languages.

The advocates to safety languages tend to deride freedom languages as �scripting� languages or �fringe� languages.They are only fit for hacking out small projects and putting together demos and whatnot.They focus on static-type-safety as one of the most fundamentally critical elements for ensuring program completeness.They may also talk about execution efficiency (memory, speed, etc).They tend to view freedom languages as improper for a larger team of programmers with mixed skill sets.The heart of their arguments is basically that these languages are not �safe� for large projects.

The advocates of freedom languages tend to talk first about the speed and efficiency of the individual programmer.They discuss the expressive power of different constructs and focus on all the powerful features that the safety languages lack.They point out complex patterns and show off twenty-line systems that do the same thing.They talk more about the ease or purity of things than the safety of things.They are dismissive of static-type-safety and compile-time validation in general.

Tell me when I break it

The preeminent dividing issue is the dreaded �strongly-typed� debate.For a long time almost all of the freedom languages were labeled as �weakly-typed� by the safety advocates.This is inaccurate technically.� Most tend to be dynamically-typed, but for many people this is a distinction without a difference.The safety advocate wants the �compiler� to tell him that function X wants an int but function Y is passing it a string.None of the freedom languages do this.

This seemingly simple request (static-typing) is, of course, impossible to achieve 100% of the time, and the closer you get to achieving it the more energy you waste.It has a logarithmic complexity curve.Casting is largely a tacit acknowledge of this complexity.

A language that is completely statically typed is also limited in what features it can implement.Features like an �eval� statement, or dynamic function replacement, or a host of dynamic polymorphic behaviors become nearly impossible.Many templating and function-passing features also become extremely cumbersome in statically-typed languages.As a result safety languages have eschewed a wide variety of very powerful features as being unsafe or overly hard to use (and hence unnecessary).

Const-ness and checked exceptions (which have natural appeal in a safety language) have similar qualities.Creating systems that manage them with strong guarantees also creates systems that are difficult to use.In C++, the const qualifier has resulted in massive duplication of methods and increased use of templates.In Java, checked exceptions have lead to the worst excesses of code bloat.

Freedom languages have decided that the value of static-type-safety (and static-const-ness and checked exceptions) aren�t worth the cost (in missing power and flexibility) and abandoned these notions altogether.

Protect me from myself

Another place that the difference in philosophy has impacted implementation is in what you are allowed to change.Safety languages tend to restrict what kinds of components can be extended or altered.Freedom languages do not.Smalltalk is, in many ways, the ultimate example of this:

�Where does the user code end and the system code begin?� asks the novice.

�There is only code�, answers the master.��

�But how then shall I know what is mine?� continues the novice.

�There is no me and there is no they�, is the reply.

In Java, on the other hand, it is not possible to extend the Integer or String classes (they are final).In Ruby not only can you extend them it is possible to change the behavior of the parent class itself.It is open for extension and (in a sense) modification!

This is no small matter.If you can�t extend things, replace factory methods, or do other �dangerous� things then you are forced to use some pretty fishy workarounds.This is especially true for testing (which is ironic).In C# or Java, you may find yourself turning unnecessarily to dependency injection because you have no other way to replace a behavior with a mock behavior in a test.In Ruby or Perl you probably won�t (which will let you use your constructor parameters for setting the state of the object and not the state of its environment).

Me too

There is one other strange quality to the safety languages.They all look the same.The safety ideal has manifested itself in even the simplest elements of syntax.The providers of safety languages want constructs and syntax that will be comfortable to people who write code in other �major� languages.They want companies to be safe from an inadequately small developer pool.Many languages that started out looking different (Basic or Pascal) have over time morphed to take on the look and feel of the other safety languages.It�s very easy for someone familiar with C++ to read C# or Java or VB or Delphi.They have a lot harder time figuring out Ruby or Smalltalk or Python.Think I�m exaggerating?

What language is this snippet from?

int calculate(int count, int value) {

int i;

for (i = 0; i < count; i = i + 1) {

��� value = value + value;

}

return value;

}

How about this one?

def calculate(count, value)

count.times do

��� value += value

end

value

end

If you can�t tell which language the first snippet comes from, it�s legal syntax in (at least) six safety languages.The second example is Ruby.

Writers of freedom languages are, by their very nature, iconoclastic (sometimes to an annoying degree).In these languages there is no fear about changing an element of syntax that might be common in other languages.Throw and Catch in Ruby, for example, have a much different meaning than in most other languages.

Safety isn�t safe and freedom isn�t free

Both sets of languages are making tradeoffs about what they view as the most important features of a language.The freedom languages are choosing powerful feature sets and the safety languages favor clearer contracts and commonly readable syntax.These are choices about how best to achieve the goals of programming.

Unfortunately, the safety languages get very little of the safety they seek.In the end, anyone who is writing code can bypass the �security� features associated with making the String class final, and not having multiple inheritance hasn�t yet prevented anyone from writing bad class hierarchies.

Type-safety is likewise meaningless if the code subverts types in order to get around difficulties stemming from static-type-safety (an extremely common practice).I�ve probably seen a dozen database systems where the integer id values associated with the various �objects� are left as integers thereby subverting both compile time type safety and run time type safety.These coding practices are much more common in systems where there is a dividing line between values that are objects and values that are not.

Strangely, even the safety in numbers of having a huge base of knowledgeable language experts provides less safety than people believe it does.In practice the bulk of the learning that a new employee goes through (for large systems) is related to either the domain or the specifics of the code base.If the code base is massively bloated and complex, being the best C# expert in the world wont make any difference.The real expertise required when crafting code is much more about design than it is about syntax.

If safety isn�t safe, freedom isn�t free either.Languages like Smalltalk or Python do come with risks.People can do bizarre and �inspired� damage with any language.You will eventually face a hard to figure out dynamic-type issue, and someone will eventually modify a value that was �supposed� to be const. The price of freedom is eternal vigilance.You need to understand complexity and scale in the application and provide people tools to eliminate it.If your project is large you may need pair-programming, code review, extensive unit testing, and continuous refactoring.

Ring the bell for freedom

All other things being equal, I think I�ll choose freedom (if I have the choice).I can risk having to debug an occasional run time error if I can keep my class structures simple.I�m not afraid of confusing someone by strange use of iterators, and bandwagons are noisy and full of hay.��The next time I have a large program to write I�ll take a closer look at the available freedom languages and pick the one that fits my needs the best.Maybe Ruby, Martin Fowler thinks it�s pretty hot :)

[P.S. I have added a meta discussion of this article here.]

Share |

Aug. 23, 2005 - Freedom languages?

Posted by Dave Worth
nuf said!
Permanent Link

Aug. 23, 2005 - TCL for freedom

Posted by Anonymous
I say TCL is a freedom language!
Permanent Link

Aug. 23, 2005 - Haskell: Safe or Free?

Posted by Anonymous

calculate count value = foldl (+) 0 (take count (repeat value))



Probably not idiomatic, but then neither are the original examples above...

Permanent Link

Aug. 23, 2005 - Haskell and Nice are free-er

Posted by codecraft
To be frank, Haskell and Nice are both languages I like and have many features that make them freer (although they are nothing like one another). They violate some of my thesis (which is why they get very short mentions) and have some cool attributes. What I see in these languages (esp. Haskell, Nice is still very much Java on steroids) is a lot less me-too type thought, but a strong desire to improve the half-way static-type systems of the main stream languages and make them more pure. The result is a much freer language in some ways, but still not a free language as I intend it here.
Permanent Link

Aug. 24, 2005 - Freedom Cost $1.05

Posted by Evil One
Having written professionally (e.g. got paid for, to solve a company's problem (OSSers don't bash me)) large systems in Perl, Java, C and smaller ones in Groovy, TCL, Python, C++. I can say without a doubt Java is the best team development language of these. So what the heck does "best team development language" mean?



It means contracts are very usefull, when more than one person is coding (or doing anything else for that matter). Java is probably the "safest" of the common safety languages (though const-ness could make it safer ;)) Imagine a world where I call the bakery and ask for a dozen rolls and instead get 5 transmissions, and in the meantime change the sky from blue to chartreuse. This can happen in many freedom languages. For instance Perl lets you change the start index of lists (arrays). So a method call can literally change the rules of the world.



Yes you can disable just about every safety mechanism, but this is a similar arguement to: Cars shouldn't have seatbelts because the owner could cut them out.



On the other hand safety languages do require many lines of code to acomplish what should be very simple things. Doing so typically makes it near impossible to figure out what a code segment is doing at first glance.



Freedom languages (especially Perl) have taken a bad rap as being "write only". While its certainly true Perl can be indecipherable by everything but the compiler, so can just about any other language. In fact C (a safety language) has an obfuscated code contest. So yes you can write good perl and bad C (or java) and the perl will be better code.



The bottom line is how easy does a language make it to write good code, and how hard is it to write bad code? The cost of ease is freedom, so where do we draw the line? The answer is simple:

* Let me do what ever I want/need

* Control everyone else
Permanent Link

Aug. 25, 2005 - who pays for your freedom

Posted by Anonymous
1) "Me too" Is this a freedom language or a safety language?

calculate 0 value = value

calculate count value = calculate (count-1) (value+value)



Whoa! It doesn't look like either of your code examples - I guess the writers of that language were... iconoclastic!



2) "my estimates, no science involved"

Humbly suggest, your imagination - no data involved.



3) "The popular safety languages are C++, Java, C#, VB"

VB! Presumably VB.Net or have you never used a variant data type?

You missed the safety language par excellence - Ada.

(And ML and Modula and... C++ isn't even type safe)



4) "I picked the terms freedom and safety"

Maybe you should add some context -

*freedom* for the programmer

*safety* for the program user



5) "impossible to achieve 100% of the time"

So tell me, should we find those N errors with static checking or should we just ignore them because static checking isn't complete?



6) "eschewed a wide variety of very powerful features"

Specifically?



7) "checked exceptions"

Apart from Java, which languages use checked exceptions?



8) " If the code base is massively bloated and complex, being the best C# expert in the world wont make any difference"

Nonsense - the best C# expert in the world will understand how they can use all that the language offers to refactor the bloated complex code - it's about semantics not syntax.



9) " I think I'll choose freedom"

I'll have more respect for your choice when you indemnify users of your software against loss and damage caused by software failures - until then your freedom comes at someone else's expense.



Isaac Gouy



Permanent Link

Aug. 25, 2005 - I take it you disagree then

Posted by codecraft
When you tell people you are making stuff up and they complain that you're making stuff up (point 2) you know you're in for a tough day. Seriously, though you raise some good points so let me back off the throttle a bit and try to respond generally.



The goal of the article was to talk about the tradeoffs between languages that give you power (including the power to shoot yourself in the foot) and languages that try to restrict that power so you can't shoot yourself in the foot. Placing languages in two bins was not really the goal, it was a metaphorical tools for that discussion. There is no single language which has all of the safety characteristics I mention, so if that's the point people need to make I hereby and officially grant it.



Even so, C++ was a questionable choice since C++ isn't about safety it's about performance (to truly pin down its ideology). On the other side, how can I have left out Lisp which is the canonical example of a freedom language. C# and Java are all about safety, they tell you so. They have consciously made that choice.



To pretend that choosing safety (static-type-safety for example) is without cost, however, is just to put one's head in the sand. Late binding enables a lot of loose coupling that takes a lot of energy to achieve in an early bound language. Allowing people to add methods to objects at run time is a powerful feature, supporting "eval" like capabilities is a powerful feature, Lisp macros are amazingly powerful (enabling DSLs in a way that is completely impossible in any of the "safety" languages mentioned here and most of the freedom languages as well).



You clearly value the kind of safety the compiler can provide more than I do. You are welcome to your opinion and it has as much hard science behind it as mine so we will not be able to deduce it from first principles. In general my hope is to encourage people to recognize that if you want to write better code you need to look a lot deeper than the semantics of the language. If your language gives you the power to shoot yourself in the foot you need to be careful not to. If it handcuffs you in some way then bring a lockpick to the party just in case you need to use your hands.

Permanent Link

Aug. 25, 2005 - who pays for your freedom?

Posted by Andy Bower
"I'll have more respect for your choice when you indemnify users of your software against loss and damage caused by software failures - until then your freedom comes at someone else's expense." - Issac Gouy



Hmm.. I don't think I have seen *any* piece of software indemnify users against loss. If you are so convinced about the safety of your "safe" language then perhaps you should do this for the applications that you write. Until then I shall have less respect for your comments such as the above.
Permanent Link

Aug. 25, 2005 - Maybe we can have both

Posted by Christopher Diggins
I found this blog interestng, well-written and intelligent. I find the distinction between freedom languages and safety languages appealing. I am currently developing a programming language called Heron, and I am attempting to straddle the line of freedom languages and safety languages. Heron is foremost a safety language but I am trying to provide freedom at the same time. You may be interested in my latest post at: http://www.artima.com/weblogs/viewpost.jsp?thread=124797 which explains how I try to straddle the line. I wrote the blog entry just before reading yours, but I find it relevant.
Permanent Link

Aug. 25, 2005 - indemnify users

Posted by Anonymous
Andy: 'Hmm.. I don't think I have seen *any* piece of software indemnify users against loss.'

afaik most try to specifically exclude any legal action against negligence - what does that tell you about software quality?
Permanent Link

Aug. 25, 2005 - Computer Assisted Programming

Posted by Greg Buchholz
For a slightly different view on the static typing front, you might want to check out my latest rambling...



http://kerneltrap.org/node/5591.



If nothing else, it might be fun to shoot down my stealth fighter analogy ;-)
Permanent Link

Aug. 26, 2005 - disagree with what?

Posted by igouy
1) Is this a freedom language or a safety language?

calculate(0,Value) -> Value;

calculate(Count,Value) -> calculate(Count-1,Value+Value).



2) "making stuff up and they complain that you're making stuff up"

Maybe when you are making-stuff-up you could say exactly that rather than dressing-it-up as an estimate ;-)



3) "I take it you disagree then"

I was too distracted by specious generalities to figure out what the point was!



For example: "safety languages. They all look the same"

C family languages look the same.

Pascal family languages look the same.

ML family languages ...



ML family languages don't look like C family languages and don't look like Pascal family languages - Java does not look like Ada, does not look like OCaml.



You've chosen to label the commercial mainstream of C family languages as "safety languages" and simply ignore the rest - that's why they look the same.



4) "To pretend that choosing safety (static-type-safety for example) is without cost..."

It's about cost/benefit.

Google "soft typing"



Permanent Link

Aug. 26, 2005 - disagree with that

Posted by Matt
"1) Is this a freedom language or a safety language?

calculate(0,Value) -> Value;

calculate(Count,Value) -> calculate(Count-1,Value+Value)."



What are you talking about? Where's the definition for calculate, Value, and Count?



"2)..."



Pass.



"3) "I take it you disagree then"

I was too distracted by specious generalities to figure out what the point was!"



Speciousness is intrinsic to generality. The original poster was focusing on the languages that people actually use in the wild. I will agree that it is a bit much to state that all statically typed langauges share identical syntax. Of course, they do share constructs used to handle static typing, but the same can be said for dynamically typed languages.



"4) "To pretend that choosing safety (static-type-safety for example) is without cost..."

It's about cost/benefit.

Google "soft typing""



One man's trash is another man's treasure.



Permanent Link

Aug. 26, 2005 - static typed languages are poo-poo

Posted by Anonymous
I'm so sick of trying to use hashes and arrays in Java. What a serious pain! I really abhor any language that doesn't have builtin support for hashes and arrays. Python and Ruby have it goin' on. As for freedom, good unit testing takes care of any safety worries. Unit testing in python is so quick and easy. Unit testing in Java is soooo long and painful that it's difficult for me to test completely because my unit tests grow larger than my code and I fall asleep at the keyboard and bang my head. I work in a Java shop and I've finally convinced my group to write test in python because it's so much quicker (how? cPAMIE). Poo-poo to java. It makes my wrist ache. Hooray for Python and Ruby.



And don't get me started on the bloat that is Java. Sheezam - could the java jvm take any stinkin' longer to start up? I'm really glad the classloader decides to load all 6 million core java classes on startup.



Poo-Poo to static languages.



Django makes me happy. Struts makes my spleen ache. I've bloody well had enough of J2EE too. It's like the Sun engineers got paid by the line.



Poo-Poo to Perl too. Too much stinkin #@$%&$#^$% running about.



"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." - Franklin



For me, hashes and arrays without all this #$@#@%#$ casting are an essential liberty. I also can't stand having to create a java class just to return back more than one value from a java method. Tuples? Tuples? My kingdom for a tuple. "She's got huge tracks of land..."



Permanent Link

Aug. 26, 2005 - Where's the definition for calculate, Value, and Count?

Posted by igouy
calculate(0,Value) -> Value;

calculate(Count,Value) -> calculate(Count-1,Value+Value).



That is the definition for a recursive function 'calculate' with 2 parameters Count and Value - it's equivalent to the Java-esque and Ruby examples.



Permanent Link

Aug. 26, 2005 - Not a Stealth Fighter

Posted by Darius
I've answered Greg's analogy on a reply to his blog.



Summarized, in business systems at least, we're not programming a stealth fighter, we're programming the entire armed forces while the battle is going on.



This day in age, we probably need to keep reevaluating fundamental assumptions every day.



Darius
Permanent Link

Aug. 26, 2005 - safety languages == bondage languages

Posted by Anonymous
sometimes you want bondage. particularly in platform code (think linux kernel, apache httpd, mysqld) where resource allocation is no joke. outside of this there is a diminishing argument for bondage languages, with the exception being chop shops where hundreds of low-skill coder who cannot be trusted churn out disposable business logic.
Permanent Link

Aug. 26, 2005 - Middle Ages

Posted by Darius
A stealth fighter is an engineering problem and solvable with tools for the engineering mind.



Compared to society�??s skill and knowledge of physics and engineering, our knowledge, tools, and skills of human nature, morality, psychology, changing market patterns, and politics, and our predictive ability in those areas, are still back in the Middle Ages.



We need tools that can quickly represent, reflect, and leverage our rapidly accelerating increase of knowledge and rapidly accelerating changing vocabulary in all these areas.



Are you able to write programs in non-roman alphabet based languages as the world keeps shrinking and flattening? Do your compilers understand non-ascii files? Are you willing to change your compilers to do so? There are just too many assumptions in the compiler. Speakers of other languages consider current int'l character standards too roman language biased already. Will an accent mark in a variable name kill your program?



"Long live Rome & the Emperor" but barbarians are at the gate.

Permanent Link

Aug. 26, 2005 - UnRoman

Posted by Darius
Can you even write comments in your code in Taiwanese, So. Korean, or friendly Arabic?
Permanent Link

Aug. 26, 2005 - Great post

Posted by Anonymous
I particularly like the labels "free" and "safe". My personal light bulb moment was with Python 2.0, when we discovered, midway through a tight project, that the Windows SSL support was utterly broken by a small bug. Python being Python, we could reach into the library object and fix the stray reference. With Java, we would have had to ditch the SSL feature altogether.
Permanent Link

Aug. 26, 2005 - How is C++ a "safety language?"

Posted by Anonymous
The subject says it all ... how is C++ a safety language?
Permanent Link

Aug. 26, 2005 - hey that pic of u, looks at bit like...

Posted by Anonymous
Kevin Spacey
Permanent Link

Aug. 26, 2005 - Static Typing Where Possible, Dynamic Typing Where Needed

Posted by Tim Lucas
Nice blog post. A interesting essay which dissects the arguments used in free vs safe languages is Static Typing Where Possible, Dynamic Typing Where Needed, Erik Meijer and Peter Drayton. The abstract: "This paper argues that we should seek the golden middle way between dynamically and statically typed languages."

http://pico.vub.ac.be/~wdmeuter/RDL04/papers/Meijer.pdf
Permanent Link

Aug. 26, 2005 - Untitled Comment

Posted by Anonymous
"It has a logarithmic complexity curve"



That's quite a claim, care to back it up ?
Permanent Link

Aug. 27, 2005 - "It has a logarithmic complexity curve"

Posted by Anonymous
"It has a logarithmic complexity curve"



Yeah, I'll back that up....

ShiptoOrderVO voCentralShipto_Temp = (ShiptoOrderVO) (voAllocationS.getShiptos()).get(centralShiptosA[j]);



casting sucks. no really, it sucks big time.

Of course, the guy who wrote the code above sucked too so we fired him, but the following, while still having a high 'suck' factor is a wee bit more readable, eh gomer?

voCentralShipto_Temp = voAllocationS.getShiptos().get(centralShiptosA[j]);



still sucks, but now I can read it without help from my sister.



This sucks too:

((ShiptoOrderVO) shiptos_System.get(centralShiptosA[i])).setProducts(null);



I mean, crud, if Microsoft Excel can think for me and strip off leading zeroes from a text string because no one on earth can possibly want a string containing numbers, then by George, why can't my programming language trust me to call a method without having to cast the world?



Everytime I have to write a casting statement in Java I feel like I've somehow failed my family, that I'm less of a hero to my kids than they deserve, that my car, although it needs a new fan belt, deserves a better driver than me, that I don't quite deserve that 99 cent Bean Burrito Especial, that I should just pack it up, go home, and watch Frequency for the soundtrack.



Look at the whole blimey J2EE specification. The major part of it (outside of EJBs, cause who in their right mind would suffer that pile of dog doo), is a web framework built around 3 hashes (well, three objects which serve as hashes), the request, the session, and the application. Great - lets write a static language which requires bloody casting and then create a framework where everything (if it follows a decent mvc design) has to be shoved in a hash and then cast out again. What's the point of having java check my classes only to find my jsp files have syntax errors. Ah yes - jsp compilers. Have you ever tried BEA's jsp compiler? Speedy ain't the word. That piece of doo takes FOREVER to compile jsp pages.



And then there's stinking junit testing of struts objects. Since I'm statically typed, I have to jump through all sorts of blimey hoops and mock objects to test the most popular java framework - struts. Ever tried cactus? It's called that because when you try to use it, it feels like someone brushing your teeth with a cactus. Holy cow is that complicated.







Permanent Link

Aug. 27, 2005 - Freedom Versus Terror

Posted by Anonymous
The reason people choose jaundiced words is because their arguments are weak. I've maintained an awful lot of both types of code, and the "freedom" languages (whose proper domain is one-shots) appeal to "programmers" who _think_ they're "gods" and _think_ their programs actually work (and which often do work in a few test cases). As Mr. Hoare would have it, "so complex there are no obvious deficiencies".



In a Python program you might know that the member variable "location" holds a string with the name of something, and in a C++ class you might know that the member variable "location" holds a string with the name of something. Because you're a good programmer you never assign anything except a string to those variables, and you never get a run-time error (Pyton) or hear a peep from the compiler (C++).



Actual programmers never notice the type-system in strongly typed languages because they never offend against it. Strong types are just one of the more trivial forms of self documentation.



Your confusion might stem from your misidentification of Java as an actual programming language. It's just a typical academic exercise in taking a good idea mixed with a hundred absurd ideas to extremes. How it ended up in business is probably all down to marketing and paid-off columnists. Lisp and Smalltalk are pretty similar.



C++ the language is hardly a safety language, but it's not really a bad language; mostly it's the proverbial length of rope. C++ the programming culture is the problem; it tries too hard to be a "freedom" language with "Object& operator[](const char *)" etc., and ends up being not much of anything.



C with the warnings turned off is the ultimate freedom language. But who would turn off the warnings? No sapient being interrupts a defense mechanism.
Permanent Link

Aug. 27, 2005 - What the good giggly wiggly are you freaking talking about?

Posted by Anonymous
"""

I've maintained an awful lot of both types of code, and the "freedom" languages (whose proper domain is one-shots) appeal to "programmers" who _think_ they're "gods" and _think_ their programs actually work (and which often do work in a few test cases). As Mr. Hoare would have it, "so complex there are no obvious deficiencies".

"""



What??? Python? Complex? You're smoking rope. have you ever looked at the java code? Like some of the popular graphing packages? Holy cow (sorry Hindus). To sum up my feelings, I would quote Turner's Viewpoint (http://linux.sys-con.com/read/44251.htm?CFID=40068&CFTOKEN=10E0BF65-13FF-81B2-18E4532D1BE0D8BD)



"""

Imagine if the Perl cafe and Javahut were across the street from each other. You walk into Javahut, and ask to sit down. "I'm sorry," says the person at the door. I'm not actually the hostess, I'm a Factory class that can give you a hostess if you tell me what type of seat you want." You say you want a non-smoking seat, and the person calls over a NonSmokingSeatHostess. The hostess takes you to your seat, and asks if you'll want breakfast, lunch, or dinner. You say lunch, and she beckons a LunchWaitress. The LunchWaitress takes your order, brings over your food, but there's no plates to put it on because you forgot to get a CutleryFactory and invoke getPlates, so the Waitress throws a null pointer exception and you get thrown out of the place.



Dusting yourself off, you walk across the street to the Perl cafe. The person at the door asks what kind of seat you want, what you want to eat, and how you want to pay. They sit you at your seat, bring over your food, collect the money, and leave you to eat in peace. Sure, it's not the most elegant dining experience you ever had, but you got your food with a minimum of pain.

"""





I'm not arguing that Java isn't a real language - it is. It's just a pain in the rumpus to use. As for you claiming it's not, I think that shows you're either very ignorant or well steeped in relativism - believing your opinion makes truth. I would tend to believe most people would define a programming language as found in the wikipedia (yeah, being there doesn't make truth, but I need a hyperlink)



http://en.wikipedia.org/wiki/Programming_language



According to that, Java IS a programming language. So, I believe that makes you a Turkey Butt (gobble gobble). There's hope for you ==> http://www.turkeybuttdiapers.com/



Who __thinks__ themselves a god now, eh Mr. Webster?





"""

Actual programmers never notice the type-system in strongly typed languages because they never offend against it. Strong types are just one of the more trivial forms of self documentation.

"""



Um, sorry homer. I am an actual programmer and I notice the type-system. I notice every stinkin' day. It's not just self documentation. It's a hinderance and a pain. Boo. Hiss.



As far as python - well, if I need to see what's stored where, I can just take a walk. It's nothing to walk 30 lines of code in Python compared to 500 in java (spread out in 12 files).



"""C with the warnings turned off is the ultimate freedom language.""" Huh? Yeah, freedom to malloc all day long. Living on an island by yourself is the ultimate freedom too, but I like a little Sci-Fi channel every now and then. You can have your C freedom...





Permanent Link

Aug. 27, 2005 - Giggly Wriggly

Posted by Anonymous
So the guy says Python code is complex (it's beyond complex, it's ungodly hyper-complex (*)) and you demur proving pretty conclusively that you don't even know what complex _means_; then you toss Python against Java, proving pretty conclusively that you started typing your response before you finished reading his comment; then you catch up and rag on him for denigrating Java, proving you have too little integrity to scroll back up and insert C++ where you wrote Java before, you'd rather post a nonsensical comment. Boo hiss! Really, you're an actual programmer about the way Java is an actual programming language.



You probably think Malbolge is an actual programming language just because it's in Wikipedia.



(*) Complexity actually relates to how many state variables are necessary to model the behavior of a module or function. In languages like Python where, as the guy says, "Python being Python, we could reach into the library object and fix the stray reference" you can no longer debug the library object by examining the library code, and the next package over the encounters the same problem and fixes it in nearly the same way will step all over your fix - - these languages are intrinsicly more complex than C. Gotta note, though: Global variables drasticly increase complexity, that's why they're bad: so even in C it really comes down to coder discipline. C++ is obviously about as bad as Python but in a different direction. But the flabbier (freeer!) languages require a great deal more coder discipline and generally get a great deal less.
Permanent Link

Aug. 28, 2005 - Untitled Comment

Posted by Dave K
This article reminds me of a quote I saw recently that I think summarises the distinction:



"Java was designed to make it hard to write bad programs. Python was designed to make it easy to write good ones."

Permanent Link

Aug. 28, 2005 - Untitled Comment

Posted by Scott Lamb
You said "[Haskell and Nice] violate some of my thesis (which is why they get very short mentions)"



I paraphrase this as "this contradicts me, so I will ignore it." I don't understand this attitude, and I don't care to. These are the languages you should be focusing on most. These are the languages that tell you to rethink your bogus thesis. And they're not alone - Haskell was not the first language with type inference, if that's what you're referring to.



I also don't buy your interchangeable safety languages argument. Yes, a C++ programmer can read Visual Basic easily. Can a Visual Basic programming read template-heavy C++ code? No, it'd break his fragile mind.



You may be confused because you can _compile_ your snippet in C++. That's not important. What's important is that a modern C++ programmer would not write that. integer-based for loops are not the standard C++ style; forward iterators, for_each, and canned algorithms are.



The truth is, C++ isn't a safety language at all. You can do lots of unsafe things in it. It's not particularly legible. It's not easy. It's just fast. The standard C++ library data structures are really, really fast. A lot of that has to do with tricky idioms involving meta-programming through templates. It's easy to screw that up and get a 50-line difficult-to-interpret compile error. (C++ is the only language in which I ever have trouble getting my programs to _compile_. And then I have to get them to _work_ like any other language.) It's easy to screw up and get segfaults or other weirdness at runtime.
Permanent Link

Aug. 29, 2005 - Untitled Comment

Posted by Brian
True, dynamic languages are a bit less safe, but not really:



http://brianray.chipy.org/Python/IsPythonSave.html
Permanent Link

Sep. 14, 2005 - Dude, where's my seat belt?

Posted by Aristotle Pagaltzis, http://plasmasturm.org/
> In languages like Python where, as the guy says, �??Python being Python,

> we could reach into the library object and fix the stray reference�?� you can

> no longer debug the library object by examining the library code, and the next

> package over the encounters the same problem and fixes it in nearly the same

> way will step all over your fix



Just because you +can+ do �??unsafe�?� things doesn�??t mean you should, or that you should do them with reckless abandon, or that the language encourages you to. It just means that when you find yourself having no other choice, you still have a last choice left �?? as opposed to none.



It also means that, within the confines of a single library (or, in general, codebase) with its own internal conventions, you can do very interesting and powerful things that enable you to write less code. The number of bugs is roughly linearly correlated with the amount of code.



In that way, the safety achieved by static typing is a self-fulfilling prophecy.



> But the flabbier (freeer!) languages require a great deal

> more coder discipline and generally get a great deal less.



First: that is an assumption about the programmer, not the language, and I prefer my language not make assumptions about me. Thank you.



Second: it doesn�??t really help. Just because a language prevents you from making some basic structural mistakes does not mean code written in it is automagically semantically sane. I�??ve seen the worst kind of pretzel logic implemented in all kinds of different languages. But the static typing scaffolding gets intertwined with the pretzel logic in safety language, so that refactoring tends to be more work and harder work. Conversely, in freedom languages, you can often collapse huge swathes of gunk into 3 or 4 lines �?? once you do understand what is going on.
Permanent Link

Jan. 17, 2006 - We will have both...

Posted by Benjohn Barnes
Chris Diggins, half way down, asks if we can both. I agree with his sentiment a great deal.



[As an aside, he's developing a "safe" language with "freedom" features, and I think that's the wrong way to go. I think a "freedom" language where you can then add on meta data about static restrictions would be the ideal way to go. But that's unimportant, I suppose :)]



I definitely think that the two ways can be put together perfectly well. The advantage of that is you can start out all agile, if you want, and hack stuff together, refactor, and add safety as you see fit or see / find a need. On the other hand, for ease in a large team, or with multiple teams, you can lay down an interface from the outset that acts as a contract, if you need to do that.



On the subject of the strange and idiosyncratic syntax - I think there's definitely a place for that too. In my ideal langauge, you would describe a particular facet of a whole system using the most suitable syntax for that. If that meant first describing a new syntax, then you could do that too.



That's my take. I'm pretty sure it'll all end up like that :) It's just a matter of when...

Permanent Link

May. 9, 2006 - Untitled Comment

Posted by Anonymous
You might want try to avoid writing opinion pieces on subjects which you seem to have a very poor grasp. Go read "Types and Programming Languages", try writing a large program in Haskell, and then try writing your opinion piece after you actually know something about the design of programming languages and modern statically typed languages.



The only "freedom" your so called languages give you is to not only shoot yourself in the foot, but also in the head.
Permanent Link

Jun. 15, 2006 - Does anyone know how to send newsletter?

Posted by Anonymous
We have growing electronic newsletter mailing list, and I'm desperate to find decent, reasonably priced software or shareware for list management and distribution. We've been using Outlook and ACT and they're not working well. I was found <A href="http://www.glocksoft.com/em/">bulk email software</A> for sending newsletter. Are there other good options to help save my sanity? Does anyone know of any good hosting company that can handle bulk email? We need to send newsletters to about 900 customers without the hassle of restrictions. Thanks!
Permanent Link

Aug. 8, 2006 - Updating your blog.

Posted by JournalHome
Hi,



I noticed that your blog is number 1 on JournalHome.com, but why don’t you update it anymore?



JournalHome.

Permanent Link

Aug. 13, 2006 - Untitled Comment

Posted by Anonymous
Interesting read. Sure there are some nitpicks I have but that's just what they are, nitpicks. I generally agree with what you said.



For personal projects I enjoy "freedom" languages and always turn to them. But at work when I'm forced to work with x number of coworkers on a team, all of which vary greatly in their skill and intelligence, then I am very grateful for "safety" languages. So much so that I often think about further "safeties" I'd add to a language (and its underlying framework) to make it even safer.
Permanent Link

Sep. 10, 2006 - Performance not safety

Posted by Anonymous
As pointed out, CXX (for some reason this blog drops the plus plus on the name?!?) is valuable not so much because it's safe (though const correctness can do a lot) but because it has excellent performance characteristics.



This is not just runtime speed. It's also resource usage. CXX programs usually but not always do very well on both counts, programs written in Python and Ruby are always terrible at both.



If you don't think that matters, then I guess you never tried to sell a slow/bloated program on the open market competing against nimbler competitors.



It's worth noting that it's the static safety features of the language that give it this sort of edge .... you get the full benefit of optimizing compilers and reasonably high level constructs (like the boost foreach) that compile down to near optimal opcode sequences.



Anyway modern CXX with garbage collection and a good foreach macro is actually quite pleasant, though there are indeed many unpleasant CXX codebases out there I will admit.
Permanent Link

Share and enjoy
  • Digg
  • del.icio.us
  • DZone
  • Netvouz
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb
<- Last Page Next Page ->

Kevin Barnes

Code Craft is the place for my thoughts, rants, ideas and occassional jokes on what it means to write code, why some people are better at it than others, and how we think about software in general.

Copyright (C) 2005, Kevin Barnes. All rights reserved.