6 ms·
IMO, this argument is a red-herring: you can write bad code in any language. Perl lit is awesome and erudite: the best idioms are described in the Cookbook. Pr
by anr 17y ago
IMO, this argument is a red-herring: you can write bad code in any language.
Perl lit is awesome and erudite: the best idioms are described in the Cookbook. Programming Perl is a joy to read, Best Practices could be used as a standards guide.
I agree that v5 has some problematic constructs, but, all in all, what Larry Wall & Co did was awesome.
- cmallen 17y ago>IMO, this argument is a red-herring: you can write bad code in any language. I would be delighted to see you cause a segfault in Haskell without taking advantage of an implementation bug. The point isn't that you can or cannot write bad code in any language, it's not that simple. It's a matter of how difficult a language's semantics, type-checking, logical structures, and faculties make it to traverse the spectrum towards bad code. Python has clean indentation baked in at the implementation. All major interpreted languages don't allow you to muck around with pointers. Functional languages strongly discourage mutability. Object oriented languages are really just a foil for context scoping in various ways combined with somewhat sanitary code-reuse that is less likely to introduce type or memory sharing bugs. It really bothers me when people say, "you can write bad code in any language". Of course you can, but that ejects the subtlety and reality of the matter into vacuum. You cannot disregard the effect of the programming environment on the code, and the supposed canard of Perl's write-once read-never is not false but rather, a tendency that it facilitates. I mean, have you seen the number of operators in Perl? http://tinyurl.com/badvbx http://tinyurl.com/badvbx (large 300 dpi jpg, Period Table of Operators in Perl) While this makes Perl the king of golfing, the mental context it consumes to remember all the operators someone else may use in their code (but that you do not) makes reading their code a non-trivial task. This is precisely the thing people complain about when comparing (unfavourably) C++ to C. There's just too much syntax and too many complicated interactions that make it nearly impossible to reason about what the code does, let alone any degree of referential transparency. Potentially one of Lisp's most powerful attributes is as you may have heard, the lack of syntax. The one ever-present syntactic feature in Lisp (paren) is widely mocked as well by detractors! Perl is awesome. It's erudite. It's a fantastic means of parsing and manipulating text (I vastly prefer Perl to awk/sed abuse except for in-line commands.) Perl documentation is really good too. All the meta of what makes a languages pleasant to use, is mostly there for Perl, but the language itself is a syringe of heroin and rat poison, just begging you to abuse the power. And don't mention CPAN. People who accuse Python libraries of being written by amateurs haven't seen the manifest horrors that exist in CPAN. Rubyists have it good by comparison. Can we please drop the "you can write bad code in any language" line now?
- jmillikin 17y agoI agree with you regarding Perl, but you're completely wrong regarding Haskell and Python. Both languages, though high-level, allow direct unchecked access to pointers. > I would be delighted to see you cause a segfault in Haskell without taking advantage of an implementation bug. import Foreign main = peek nullPtr Or, more complicated but less obvious: import Data.Typeable import Data.ByteString data Wrap a = Wrap a deriving (Show) instance Typeable (Wrap a) where typeOf _ = typeOf () main = let Just (Wrap bad) = cast $ Wrap () in print (bad :: ByteString) > Python has clean indentation baked in at the implementation. All major interpreted languages don't allow you to muck around with pointers. >>> import ctypes as c >>> c.string_at(0) Segmentation fault
- cmallen 17y agoThis isn't really part of the usual work environment. Just because you can import a library and go nuts with it doesn't mean it's an everyday part of the language. I mean really, kind of missing the point don't you think? It's not even like Haskell makes it trivial to mutate the pointers in a natively Von Neumann-esque manner. Monads don't count either. Example: how often have you seen unsafe C# code (pointers) used in a production web app? Counterpart to the above: How often do you see pointers used in C? All the time Presenting the pathological case isn't refuting what I'm saying, it's just affirming it by showing how far you have to go out of your way to abuse your memory access, whereas in C, it's just a part of how you code. (Functors, for example.)
- jmillikin 17y agoPointers are absolutely part of the average Haskell and Python work environment -- it's impossible to get reasonable performance without them. Of course, Python programmers like to stick the important parts in an extension module (written in C, naturally), close their eyes, and pretend they're not doing anything "unsafe". > It's not even like Haskell makes it trivial to mutate the pointers in a natively Von Neumann-esque manner. Haskell has a module specifically for manipulating pointers[1]. There's no inherent safety in using Haskell rather than C for pointer based code. > Monads don't count either. This sentence makes no sense, and makes me think you've never (or seldom) used Haskell before. > Example: how often have you seen unsafe C# code (pointers) used in a production web app? Somewhat often -- pointers are used in database adapter, template engines, graphics rendering, and any code which needs to call into foreign libraries. > Counterpart to the above: How often do you see pointers used in C? All the time That's because C is used in code where performance is absolutely critical, which demands having control over memory layout and management. Pointers aren't a symptom of using C -- using C is a result of needing pointers. [1] http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Foreign-Ptr.html http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0...
- sreque 17y agoI've written a complex ruby library and then ported it to perl. Since both languages are basically the same in their capabilities the port was very straightforward. I know both languages fairly well, but if I go back to the ruby version I can read it just fine, while if I look at the perl version it looks like a morass of symbol soup. The language has so much unnecessary syntactic noise that even what I would consider well-written Perl code that I've personally designed and written is still too difficult to read. Also, from my personal experience, in general the average quality of Perl code I've seen, whether it's CPAN libraries or code at I see at work, is much less than the average quality Python and Ruby code I see, which is more of a community problem than a language one, although Perl being the way it is seems to attract a certain class of developers I would rather not have to work with.
- jrockway 17y agoI ported a well-known Perl library to Ruby. It looked terrible and didn't work at all. Turns out the problem is that I don't know Ruby.