4 ms·
The three-dots operator for not implemented code is a clever idea IMHO, if it was present in Ruby I would use it all the time :-)
by izietto 13y ago
The three-dots operator for not implemented code is a clever idea IMHO, if it was present in Ruby I would use it all the time :-)
- xiaq 13y agoYeah, you can actually find many many clever little ideas in Perl 5 and 6. I even find reading the Perl 6 synopsis (http://perlcabal.org/syn/ http://perlcabal.org/syn/) entertaining. The problem with Perl, IMO, is that there are too many clever ideas and it takes way too much to fit all of them together (and they never give up and ditch some of the less clever ones like Python people routinely do), which is why Perl6 is moving so slowly.
- xiaq 13y ago> The problem with Perl, IMO, is that there are too many clever ideas and it takes way too much to fit all of them together (and they never give up and ditch some of the less clever ones like Python people routinely do), which is why Perl6 is moving so slowly. I have to correct my statement about Perl6: it's not moving slowly, but it takes too much to get there.
- Diederich 13y agoA bit of both, actually. Perl6 as an language is remarkably complete. http://perl6.org/compilers/features http://perl6.org/compilers/features Its performance has been absolutely terrible though. They've been (rightly) focused on features first. But note that Perl6 on JVM is doing very well. I believe the effort is about a year old, and they've been performance optimizing it for a fraction of that time. And that's with nearly all of the 'remarkably complete' features. https://github.com/rakudo/rakudo https://github.com/rakudo/rakudo Last time I did a benchmark a few months ago, Perl6 on JVM was very roughly 2x slower than Perl5. With Perl6's native but optional typing, I fully expect that Perl6 on JVM will get even faster than Perl5. This year, I need to evaluate a 'scripting' language to run inside of big Java processes, and I'm going to give Perl6 a very close look.
- BugBrother 13y agoMaybe too many clever ideas, but in the real world we evaluate a language for how is to use when you follow the coding standards etc. There really might be an initial extra cost of some work days, but unlike most people on HN I don't really know... :-) Anyway, you can make a good argument for Perl with the best OO (Moose) of the scripting languages, CPAN (+ Testers, so it works), etc. But please, no more of these language wars, it makes for really boring reading to e.g. see the same arguments whenever Perl is mentioned.
- izietto 13y ago> I even find reading the Perl 6 synopsis (http://perlcabal.org/syn/ http://perlcabal.org/syn/) entertaining. The Operators page (http://perlcabal.org/syn/S03.html http://perlcabal.org/syn/S03.html) scares me O.O
- araes 13y agoI love Perl. Its flexibility and potential terseness are awesome, but there is something funny about a language that has the operator breadth of: : :: .: .:: .. ... {...} .^ ..^ ^.. ^..^ ^^ , ; And several of those have 2-3 uses. Heck, there's probably a way to use only those and some $'s and make something that runs.
- kanatohodets 13y agoIt's even crazier/cooler than that: https://metacpan.org/pod/release/BOOK/perlsecret-1.005/lib/perlsecret.pod#SYNOPSIS https://metacpan.org/pod/release/BOOK/perlsecret-1.005/lib/p... -- lots of (mostly harmless/golf-oriented) fun with combining perl operators.
- jbert 13y ago> The problem with Perl, IMO, is that there are too many clever ideas Perl's learning curve is shallow (easy to pick up) but long (the language is big). One explicit design goal from perl which isn't talked about much is "huffman coding" in the language. i.e. frequently needed language features should require fewer keystrokes. This comes directly from Larry's background as a linguist. For example, English has the word "it" to mean "the thing we're talking about". Perl has "$_" to mean the same thing. The meaning of "it" is dependent on the surrounding context. So it is with perl. Similarly, it can be confusing to have long, runaway sentences using such context dependent words. You can write bad English and bad perl in this way if you're not careful. However, the benefit is that, used correctly, it allows you to express yourself clearly and concisely.
- ionforce 13y agoIn Scala 2.10 there is the ??? alias which throws a NotImplemented exception. It's really nice for stubbing out code that otherwise needs to compile.
- deleted 13y ago[deleted]
- jerf 13y agoIn pre-Perl 5.12 I've also implemented sub not_impl { die "Not implemented"; } which makes it just a if ($some_clause) { not_impl; } which is pretty close (semicolon optional here). Replace the die with your choice of thrown exception or confess or whatever, of course. I'm sure Ruby could do something similar. It may be less pretty but it works, and it is useful during certain types of development, I find.
- chromatic 13y agoIt may be less pretty but it works... The primary goal of the `...` feature was to make example code compile safely. (I implemented the feature in Perl 5.)
- jerf 13y agoOh, yes, of course it doesn't do that, but it's still a useful thing. It's so short it hardly seems worth talking about, but, hey, I went a long time without using such a simple technique myself, so it probably is.
- izietto 13y agoIndeed: def not_impl(reason = 'unknown reason') raise NotImplementedError.new reason end not_impl #=> NotImplementedError: unknown reason not_impl 'TODO' #=> NotImplementedError: TODO You can even define a "..." method: define_method("...") { raise NotImplementedError } send "..." #=> NotImplementedError: NotImplementedError But, as chromatic said, the point is the three dots operator feature
- auvrw 13y agojust b/c it's not a language feature doesn't mean that you can't make your own sort of thing. for instance, the play framework has a TODO result object that is indeed quite handy for stubbing out api endpoints and the like. like the typed/untyped debate, the amount of primitives a language ought to have seems to be a topic of disagreement even among experts (touched on here http://www.infoq.com/presentations/functional-pros-cons http://www.infoq.com/presentations/functional-pros-cons although not the main topic). also, like type systems, primitives seem like something that, while important to consider, are easy to get hung up on, to take a stance and apply it to all languages without the consideration that different languages are good for different types of problems. my own snap judgements of perl were that its notions of context and pragmas make it easy to express one or two ideas both quickly and intuitively, but that its type system makes it difficult to reason about larger programs. so to cap off this ramble, my question to the perl people: what problems are you solving with perl? to me, perl seems to mainly fit two use cases: sys-admin stuff (where it's basically used like bash++, although i realize it's much more powerful than that) and an embedded language for c programs.
- lsiebert 13y agoPerl is used heavily in biology and bio informatics. It's also really really good for messing with text in complicated ways. And it's still in use as a web language. So that's three more use cases. I think you can think of it this way. ANSI C doesn't have a built in linked list, or hash/dictionary, or line count when reading a file, or map or grep or a bunch of things... and you can implement them (though map/grep are a bit tricky) but you have to worry about the implementation, and matching other people's implementation. By having the many useful primitives Perl does, it provides a broader standard interface for doing things, and that makes hacking easier. Perl tries to give you lots of tools to express yourself. If you are a wood carver, you know that you can work wood with very limited tools, but having the right tool in your shop makes things a lot easier and simpler for the expert. So it is with Perl.
- auvrw 13y agoyeah, i'm aware that perl is used by biologists, but the question is more like, "should perl be used by biologists?" no question that c is not a great choice, but what about python? or, hell, javascript, even? for the kind of programs biologists would want to write (i.e. programs that need to describe a system that performs several tasks rather than programs that need to perform one or two specific tasks), it'd be helpful to have a language that not only has data structures like arrays/lists and hashes/dictionaries but also a data model that includes things like classes as a primitive. python in particular has numpy/scipy. perl's syntax for regexp matching definitely makes it a good choice for programs that have to do a lot of string-munging, but that's what i meant by "sys-admin-type stuff."
- retrogradeorbit 13y agoWhy would you need an operator for it? I just use assert False, with the TODO as message.