4 ms·
Immutability means it's a lot easier to change your code safely. And the functional style encourages better separation of concerns, again making it easier to ch
by lmm 14y ago
Immutability means it's a lot easier to change your code safely. And the functional style encourages better separation of concerns, again making it easier to change something in one place. Strong typing is really good in a large codebase for making it harder for errors to propagate - if you make an error in a given function that changes the return type, you can immediately localise the problem to that function.
Writing the initial code is likely to be if anything slower in a functional language; the real advantage comes in maintenance.
(disclaimer: I don't actually know haskell, though I've used several functional languages and written functional-style code in several more)
- ozataman 14y ago"Writing the initial code is likely to be if anything slower in a functional language; the real advantage comes in maintenance." Definitely disagree with this. As with anything, with practice, you get very fast at writing Haskell code. the expressive/strong type system and type inference means you'll catch errors early while writing code at a higher/denser level than even today's popular dynamic languages, resulting in a net increase in programming speed (for me).
- lmm 14y agoAs a python guy (still the densest language on the programming language shootout AFAIK), I find I can run a unit test before most languages would compile. More to the point, I don't make type errors when writing the first version of a piece of code; it's when changing it that the type system becomes invaluable. Of course, this is different for different people.
- nightski 14y agoI generally agree that I rarely make type errors when first writing code in Java or C#. I must say though, it really isn't the same with Haskell because of how much more expressive the type system actually is. Of course with practice one improves there too.
- rohshall 14y agoCompletely agree about the changing code part. I program in Ruby and I often wonder what I have broken whenever I change some code. (I know I am supposed to write a lot of tests, but it becomes a big chore to write tests for all the test conditions.) By the way, I would not call Python one of the densest language by any means. It is one of the nice and straightforward languages to learn which is expressive as well.
- igouy 14y agoWhat do you mean by "densest"? Please give us a URL to the benchmarks game web page that you think shows Python is the densest language. >>I don't make type errors when writing the first version of a piece of code<< Maybe you just don't test the first version well enough :-)
- lmm 14y agoI was going by http://shootout.alioth.debian.org/u64q/which-language-is-best.php?gpp=on&ifc=on&java=on&ghc=on&sbcl=on&csharp=on&v8=on&hipe=on&vw=on&php=on&python3=on&lua=on&perl=on&jruby=on&yarv=on&xfullcpu=0&xmem=0&xloc=1&nbody=1&fannkuchredux=1&meteor=1&fasta=1&fastaredux=1&spectralnorm=1&revcomp=1&mandelbrot=1&knucleotide=1®exdna=1&pidigits=1&chameneosredux=1&threadring=1&binarytreesredux=1&binarytrees=1&calc=chart http://shootout.alioth.debian.org/u64q/which-language-is-bes... . (the most naive/obvious approach - all benchmarks have weight 1, code size has weight 1, other factors have weight 0). I know it measures gzipped code size; I think that's a reasonable measure for "density". Looks like I'm out of date, ruby 1.9 has overtaken python. Guess it's time to learn ruby.
- igouy 14y agoCaveat lector -- http://shootout.alioth.debian.org/help.php#comparecodeused http://shootout.alioth.debian.org/help.php#comparecodeused "This paper [pdf The Effect of Language Choice on Revision Control Systems] compares one scripting language, Python, with C in the domain of revision control systems, as large working implementations exist for both languages. It finds no clear evidence that scripting languages produce smaller systems…" http://plg.uwaterloo.ca/~migod/846/2011-Winter/projects/Simon-LanguageChoiceVCS-report.pdf http://plg.uwaterloo.ca/~migod/846/2011-Winter/projects/Simo...
- trhtrsh 14y agoThat chart doesn't show what you think it shows. > Remember - these measurements are just of the fastest programs for each of these programming language implementations If you add in speed, even at a size:speed weight of 5:1, Python's advantage disappears. So, the fastest python code is smaller and slower than the fastest haskell code, ignoring any slower code that may be denser. Also, "gzipped code size" is a horrible measure of density: what everyone hates about Java is how redundant programs are (access modifiers, type declarations), which gzip would compress nicely, but doesn't help programmers (except where Eclipse auto-completes, I guess).