[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison
- From: Jay Carlson <nop@...>
- Date: Thu, 18 Jul 2013 19:06:38 -0400
Perhaps a note in the Lua manual at the top of the string library pointing to table.concat would be good. It's an essential function for working with strings, and the choice of table.concat vs string.concat is mostly arbitrary anyway.
Having a pointer in the string documentation may help novices avoid loops with s=s..foo. There *are* a lot of amateur programmers out there. What proportion are reachable, versus the fraction who happily leave a trail of broken software behind them--that I don't know.
On Jul 15, 2013, at 12:48 PM, Daniel Bolgheroni wrote:
> Maybe this should be of interest:
>
> hxxp://raid6.cxm.au/~xxxxxxx/posts/arena/
OK, quoting from that page:
C:
while(i++ < imax+1000){
...
strcat(gstr,str);
"My language runs my obliviously O(n^2) algorithms faster than yours." "OK..."
One argument against adding strlcat to GNU libc is that it only encourages people to manipulate strings in C. C++ wasn't always better; it was pretty easy for new users of the MFC string class to go O(n^2).
gcc 4.7 will optimize away some strlen-related calls for you, but it's not ultra-heroic. (See http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00188.html .)
> In Java pretty much any call that does something can be a failure point unless enclosed within ugly try-catch statements.
That's almost exactly backwards. In Java, just about anything can be a failure point *IF* enclosed in try-catch. If you don't understand an exception, DO NOT CATCH IT.[1]
Anyway, later:
> However in many cases returning something is better than nothing. Application may not do exactly what's expected but it may be considered to be better than crash. Perhaps you want your application to keep running despite minor error instead of terminating. Maybe particular part of application is not too important to try-catch absolutely everything. I've seen many examples of this in web applications when seemingly innocent operation is in fact a fatal failure point leading to application crash. Several times I had to troubleshoot Java and Python web-apps made by different teams, in different companies, in different time but all of them used to crash on string transformations because of uncatched/unhandled exceptions when unexpected character came from database. Needless to say this was causing a great deal of frustration for users of those applications.
Penetration and code review teams in different companies at different times thank this author for his or her help in letting them head for the bar early.
I feel a little bad beating on this person; I write lots of shoddy code prototyping. But I don't elevate it to a design principle.
Jay "Tables;-- Carlson
[1]: Re-raising a nested exception to conform to a method signature is an exception to "don't catch" I guess.
- Prev by Date:
Re: Lua 5.3 work1 Considering math.isinteger or type()
- Next by Date:
Re: Lua 5.3 work1 Considering math.isinteger or type()
- Previous by thread:
Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison
- Next by thread:
Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison
- Index(es):