Favorite Programming Language Features?
johnnyb asks: "I'm curious what everyone's favorite programming language features are. I'm looking for both the general and the specific. I'm especially looking for features that few people know about or use, but are really useful for those who do know about them. What are your favorite programming language features?"
"A couple of examples to kick off the conversation:
- Continuations
Continuations are very interesting, because they can be used to implement a number of flow-control features such as exceptions, coroutines, cooperative multithreading, and are better at modelling web interactions. This is a more general feature, but most people use these in conjunction with either scheme or ML.
- Tuple-returning
It is a huuuuge time-saver when languages like Perl allow functions to return tuples. Instructions like '($a, $b, $c) = $sth->fetchrow_array()' is a wonderful thing.
- The flip-flop operator [Perl's '..' operator]
Another perlism that I just think is cool. Read more about it here.
Object-oriented programming.
;)
For me it's just easier.
(Especially with XCode displaying it as a little blue box, it makes the concept easier to grasp for beginners)
Error 407 - No creative sig found
Beautiful syntactical simplicity.
*cough*C*cough*
karma: ouch!
; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
j/k
Tcl and Postscript both offer lists and lists within lists, without having to do anything fancy. Perl does have this, to an extent, but only on static lists. Anything dynamic adds a few lines of code and confuses things pretty easily. Of course, all of this came from Lisp, but I learned car and cdr and that was more than enough for me.
In short, lists only work when recursion is right at the tip of your fingertips in your language. If XSLT-2.0 works on tree fragments, we will have lists there as well.
I think's java's concept of anonymous inner classes is simply superb... it enables runtime aggregation of small objects while preventing you from having to create hundreds of named external helper classes to implement the behavior.
It's certainly not an unknown feature, but I couldn't live without it.
DiscDividers tabbed plastic CD dividers: divider cards f
I feel the one of the strongest features of Java (or any language) is a standardized documentation feature (i.e. javadoc) and "readability". Being able to easily understand what another developer's intentions and "gotchas" are is invaluable. Perl, for example, can be obtuse without even trying very hard.
.. and now, 50 rebuttals from the Perl crowd.
It's simple: I demand prosecution for torture.
Next I love ruby's block system, especially for stuff like this.It comes in super handy for a ton of stuff. Especially when I'm doing XML.
Also, there is another thing that I first discovered in pythonSave me a temporary variable, w00t.
Lastly, its not really a language feature, but in any object oriented language I love being able to serialize the objects. It's so simple to use pickle or any other serialization library and just write objects out to file or network. I never have to design a binary file format ever again. It's even better when you use Ruby and you can marshall objects into XML or YAML with a single method. Then you've got a human readable and editable file format that you can magically transform into objects again later. Super useful.
The GeekNights podcast is going strong. Listen!
This is less of a favorite feature, and more of a feature I wish we had. What about having the representation of the language independent of the code itself? I think this will eventually happen and could really revolutionize things. I believe the inklings of separating 'physical' representation from the code were there in some languages like Algol 60 and CS work in the 1960's, but it never caught on (perhaps hindered by other features of those works?).
... then ..."? Better yet, really like Perl's "$_"? If you want it to be displayed like this, turn it on. Otherwise, say you don't like this feature, and it will automatically replace the "$_"'s (either implicit or explicit) with the variable to which it refers. Again, no problem.
In a little more detail, suppose I write a C program. It will have lots of functions and conditionals with their "blocks" surrounded by braces.
But what if I prefer my "blocks" to be started and ended by brackets instead of braces. Better yet, what if I am tired of typing these and would like indentation to control this. Or whatever -- start end commands, if you like. The point is that these are minor sytactic idiosyncracies, and we all have preferences. Why not store the code in an underlying format (XML would be okay, were it not for the bulk of it)? As long as there is a one-to-one correspondence between all possible representations, you could view it however you want.
And so on for all syntactic features. Prefer "if-fi" construction to "if () {}"? Or "if
At this point, I feel like I am repeating myself, but let me continue for a little bit. It would let each user have his/her personal favorite representation. We already let them control the colors of their syntax highlighting, lets take it a step further.
Hell, if you want to use a graphical viewer for those C programs, akin to LabView, go for it! Or (in my opinion) a much better graphical programming environment with a graph structure. The point is: you write it how you want and save it. It appears to another coder how he/she wants it to appear, but the content is exactly the same.
In short: why isn't this done? It seems like a spectacular step in unifying programming languages a bit, and letting each user tailor his preferences while maintaining compatibility. As long as there was simple one-to-one correspondence, the translation from physical representation to underlying code and back would be quick and fairly easy to handle. Are there any modern projects which attempt this? Or *any* which attempt it with some success?
On a somewhat related note, is it possible to put a "hook" to a comment in the code, and with the proper viewer have that comment displayed along with the code (say when you click the "hook", move your mouse over it, or drag the "hook" to a "comment box")? If this last paragraph doesn't make sense, please ignore it.
Write once, read never ;-)
-psy
Yeah, Perl can be obtuse. Personally, I find that less-experienced programmers write clearer Perl code. Basically, there are many idioms and shortcuts that, used sparingly, can create extremely readable and intuitive code. However, just as using the same pronoun to mean several different things in the same sentence, using too many of these features makes code hard to read.
Take $_, for example. I am relatively inexperienced at Perl (I have used it a lot, but I don't know a ton about it), and I usually don't use $_ unless I'm absolutely sure it will be what I think it is. Often, I prefer to use a specific variable name in constructs like foreach where the variable will be used several times in the loop, just because it makes things a little clearer.
Personally, what I like about Perl is that, in the same way that PHP has functions for everything on earth, Perl has every data structure on earth built in. It's nice not to have to worry about how to organize data. Perl also just seems very intuitive to me. In my opinion, and inevitably opinions on this will differ, Perl makes concepts like pointers/references, hash tables/associative arrays, and arrays/lists simple enough that you can use them without extra effort, but versatile enough that you aren't stuck reinventing the wheel when you want a slightly different structure. That's basically one of the things that makes me prefer Perl to C--in C, I have to do so much stuff by hand: conversions, array insertions and such, but in Perl, everything does what it should without extra effort. Of course, Perl isn't for everyone or everything, since these built-in features come at a performance cost, but, for what I use it for (little scripts and such), it doesn't matter.
Maybe the ease of working with data is what makes the rest of Perl programs so sloppy or cryptic sometimes... I guess when you have to create and manipulate data structures by hand, you can (and must) put more thought into what the data structures should look like.
Tired of free iPod sigs? Subscribe to my blacklist
I like some of Perl's magic, some borrowed from predecssors, Particularly (read from all files given on the command line), and various switches such as -n, -p and -i that simplify away common code.
Were that I say, pancakes?
MS C++ when it auto-fucks inline assembler!
Wow, I coded a JMP there, somehow its now a JNE. Hmmmmmmmm... How'd I figure that out? Deadlist on a compiled executible. Never NEVER told me it'd do that. Just did it. Almost as bad as MASM...
Sucks having to compensate for compiler errors!
gene
Closures and Currying are two of my personal favorites.
Overloaded Functions are sweet.
I am also quite fond of operator overloading.
Ruby blocks, lambda functions, lazy evaluation.
:)
And C++
Marxist evolution is just N generations away!
regexp functions -> functions that do what the regexp do. eg result = regexp.removeSpace(word);
Easy to understand syntax.. instead of && use AND, instead of OR use OR, etc. kinda BASICish syntax.
Garbage collection that works, unlike java where sometimes it losses things, because of programmer error. IE: if I can do it the garbage collector should clean up after me, if it can't then it should not let me do it.
Definatly object oriented, Java / C# / C and Perl are all cool for their ability to do objects, so its python. There is more....
Only 'flamers' flame!
Does slashdot hate my posts?
I really really love the keyword "friend" in C++. It invites objects of other classes to touch one's private parts.
I like methaphors of pleasant real live experiences in a programming language. (That is why I hate the functions "kill" and "die".)
Just to confuse people do this:
main() {
int x;
int y[2];
x=1;
y[1]=10;
printf("%d\n", y[x]);
printf("%d\n", x[y]);
}
What will happen?
My favourite thing is languages that can execute strings of their own code.
:= &("{ || nVar += 43")
For example, clipper can do this via blocks:
cVar
Python has the same thing via "exec":
>>> b
NameError: name 'b' is not defined
>>> exec "b=2"
>>> b
2
This means you can build up strings of code at runtime and execute them, or store field-specific database logic in another database table, and fetch it when needed.
C# is not quite so convenient - you have to build up a complete class and compile it, but it can all be done in memory at runtime so it's just a little more work. Clipper and python can both affect the current scope directly (which can be both bad or good, I suppose).
I believe ruby has blocks similar to clipper (probably better), but I don't use it, so I'm not sure. I also don't use perl, so I have no idea if it supports this...
This sig is part of your complete breakfast.
I would like to inquire as to what illicit substances have been utilized by you prior to the creation of that comment.
Functions as first class citizens, that is functions can be returned from functions and provided as arguments as functions. The basis of the functional paradigm and it makes life much much simpler.
Pattern matching (some ML:)
fun has_a [] = false
| has_a 'a'::_ = true
| has_a _::xs = has_a xs;
Simple elegent functions requireing much less if_then_else's.
Automatic garbage collection and bounds checking: enables me to write the code to do the job, not the memory management.
Polymorphic typing: I can write general functions:
fun contains x [] = false
| contains x x::_ = true
| contains x _::xs = contains xs;
That will work with any type for which equality is defined.
These are the reasons I hate C for general programming. The most important thing is efficient algorithms, without them no amount of low level optimization will help. With good algorithms, functional languages are now normally at least as fast... (and much much easier to debug and even verifiable).
From non-functional languages, the object model is wonderful when used properly.
Smalltalk & co's complete environment is a nice feature.
I also have a soft spot for BBC BASIC with its speed, interactivity and simplicity. These are combined to allow windowed applications including at least one web browser and anyone can start programming simple programs (which is missing from most modern computers)
Then there's the specialist languages. They have all sorts of nifty features (Mathematica is a good example) but I wouldn't expect them in an everyday language.
This is not the issue it was ten years ago, but one feature I absolutely want tightly integrated into my language is robust string handling. I still like perl's best (although perhaps only because I know it best). It simply seems to be more tightly integrated into the language as a whole.
"He who would learn astronomy, and other recondite arts, let him go elsewhere. " -- John Calvin, commenting on Genesis 1
Hey, johnnyb, where else have you posted this question? When you get answers, will you analyze them and post your conclusions? It could be interesting.
A lawyer & digital forensics examiner. Also an expert on open source software (OSS).
in C, I have to do so much stuff by hand: conversions, array insertions and such, but in Perl, everything does what it should
I am all for scripting languages such as perl and my favorite python, but this isn't the way I would describe it.
In C, some stuff needs to be done by hand, but it does what you want it to do.
In many scripting languages, it does what the interpreter thinks it should do and getting things to act the way you want is much harder if this differs from what the interpreter thinks it should do.
Both approaches have their uses. Some things are just easier in Perl/Python/whatever. Some are easier in C.
But after the adjustment, I've truly grown to love its spartan clarity and simplicity. I can hardly stand to look at the redundant brace-littered syntax of Java, C or Perl now.
Mike
"Not an actor, but he plays one on TV."
1) I must be incrementable.
2) I must be dereferenceable.
3) You must get from begin to end in a finite number of steps.
4) The type you get when dereferencing I (I's value type) must be comparable to V.
Because of this, you can use the same find function to search through arrays, lists, vectors, maps, sets, strings, streams, and more, even though none of them inherit from each other or implement a common interface in the OOP sense.
Additionally, there's no complicated syntax for the user of the library:The great thing about abstraction is that it avoids duplication. Avoiding duplication lets you test/debug/prove correct once for greater reliability. Once you wrap your head around this simple example, you'll be surprised how deep the rabbit hole goes.
man... on almost every language by default you cant combine as easily as you can with PHP. With a simple . you can save yourself wonders of time. Maybe even go out with girls now :P
for example....
wow it cut off my example:():P
Complete agreement! It's much easier and readable. It would be great if MS used that for Visual Basic, instead of the ugly End If construct. Much more comfortable for people who have to work with VB every once and a while. Some people get too attached to the English language.
"it's not about aptitude, it's the way you're viewed" - Galinda
I use Common Lisp.
Lisp has almost no syntax, so it's extremely regular (barring exceptions like LOOP). Because it's so regular, it's easy to build macros that do powerful things.
Macros can completely transform the source, at compile time, but with the full power of the language. Having that ability, together with simplicity, means that it's easy to build a complete mini-language for one's manager or web designer to use on the site, and easy for them to learn it, since you can explain the syntax in 5 minutes or less, and they don't have to learn 50 built-ins to use it.
Common Lisp's conditions system not only allows exception-handling, like Python, but can also have an entire protocol for controlling execution flow built on it. More about that in the conditions chapter of Peter Seibel's forthcoming book.
Lastly, having a generic-function-based object system means that a method can "belong" simultaneously to more than one class, at the same time. So, instead of having a method inside a class, you call a method with any number of objects of various classes, and it figures out from the type of the object what method to run, of all the similarly named methods. You can even specialize a method on a particular object or objects, instead of a particular class or classes! Multiple dispatch rocks.
Property law should use #'EQ, not #'EQUAL.
What makes Perl sloppy or cryptic was that it was designed to make it easy to create quick hacks. Remember Larry Wall's Great Programmer Virtues: Lazyness, Impatience and Hubris. Perl was designed to make laziness easy; once Perl was written, you could be very lazy in your programming and things would still work.
I'm an experienced programmer who's done relatively little Perl, although its use is increasing significantly in my work. Like you, I deliberately avoid use of $_ because I find it a very confusing concept, and I think it encourages the creation of confusing code. And even though you and I avoid it, the beginning Perl books are full of it and that makes it almost inevitable that most will use it.
For some reason, I always, always hated that $ you have to put in front of variable names. I know it makes all sorts of interesting things possible, but for some reason I've always found it hard to read.
Still, it's tough not to love associative arrays built into the language. It really makes a lot of normally tough things a snap, and I'm sure their coding of it is a lot faster than anything I would have done.
D
They are used behind the scenes higher languages to create loops. They are still visible in most programming languages usually through the 'if' keyword.
Without the branch, the simple manipulation of the Program Counter, there would be nothing more than calculators.
Clean syntax. Not one that forces me to lean on my shift key and decorate my code with punctuation characters. The "noise" gets in my way so much that I can't even stand to program in perl anymore. I just can't take syntax like sub foo { dostuff @{$blah->{woof}}; etc... } anymore. Semicolons drive me bats.
Python's ok. Tcl is closer to the ideal syntax, but oy what a feature poor language. Lisp's really nice. Forth would be about perfect, but it makes you work at such a low level most of the time (fact is, most people just don't build it up that much) that your code looks noisier than perl, more like APL even.
Of course I like modern features, like automatic memory management, structured exceptions, first class functions, pattern matching, currying, asynchronous execution, concurrency, and so on. But I just can't express concepts well in a language that makes me clad every expression in so much syntactic scaffolding.
I've finally had it: until slashdot gets article moderation, I am not coming back.
Ranum is citing this as an example of a way that existing tools -- such as GCC -- could be enhanced in such a way that programmers using currently popular languages (C/C++) would have a better security safety net without having to be retrained in practices (like checking for buffer overflows) that while obvious are still under-utilized in most software. The whole article is interesting reading, but this remark about Perl's taint mode seems like one of the best concrete examples of a modern protective language feature.
DO NOT LEAVE IT IS NOT REAL
Forth is also powerful if low level. Basically build a language from the ground up.
For the high-end Smalltalk and Scheme.
This is what I want: For the first criteria, if, at any point, you are forced to make contact with a 32-bit environment, then the platform fails the test.
For instance, if the platform requires you to use either Java or SQL, then it fails.
SQL fails because it is essentially an ASCII-based language that has almost no sense of primitive data types whatsoever, and its only undefined binary type, the binary BLOB, maxes out at 2^32 = 4 Billion bytes [so much for high-quality MPEGs of, e.g., Gone With The Wind].
Java fails because, as recently as the Java 1.5.x Beta, it cannot take long ints as array indices. For instance, the following will not even "compile" [i.e. "javac," whatever that is] under the Java 1.5.x Beta:
So your "middleware" for this hypothetical 64-bit platform is forbidden to touch either SQL or Java.As for the strong data typing, I want the environment to be natively aware of
According to Professor Kahan, Matlab has [or has had] some serious problems here: So: Any takers?The java code should have read as follows [I didn't notice that the shift operator had been caught by the
Languages without "real" unification feel unexpressive or too low level. Whenever I program in something other than prolog (which is most of the time) I miss it.
Example: [foo(A,x)|B] = [foo([p,q],x),C,d,e].
which implies that A = [p,q], B = [C,d,e], and C remains unconstrained.
There are 10 kinds of people: Those that understand ternary; those that don't; and those that don't care.
for zope-related crap (when i'm in the slave pit, not doing cool stuff) lambdas whip ass.
you can stuff functions into session variables - how's that for obtuse!
Keep your packets off my GNU/Girlfriend!
And no, C based languages dont have them. But Delphi/Pascal does.
Then you can do things like
if (var in set) then
begin
end;
Then you can use + and - to add and remove items from the set.
Bad User. No biscuit!
A nice example is a generic "find" function
Remember the Swedish rock group ABBA? How many instances of the substring ABBA occur in the following string [and what should your generic "find" function have as a return value]?
Extra Credit: Tell me what a generic "replace" function should do when told to replace "ABBA" with "The Bee Gees".PS: I learned just the other night that ABBA soloist Anni-Frid Lyngstad was the product of Nazi Aryan eugenics experiment [dubbed "the Lebensborn"].
I excrement you not:
Mike
"Not an actor, but he plays one on TV."
How ironic that you used the English cognate a mere four words later!
how to invest, a novice's guide
Huh. How odd. C/C++ can do this just fine. (Well, C++ with C99 support makes it easier).
...
#include <stdint.h>
int main() {
int64_t theLong = 1;
theLong = 32;
theLong += 1;
double *theDoubleArray = new double[theLong];
delete[] theDoubleArray;
return 0;
}
The ABI guys are still trying to figure out how to map all the double sizes. Right now, sizeof(long double) on my x86 machine gives me 12 bytes 96 bit. There is also talk of making a "long long double" of 16 bytes. Sooner or later they'll figure it out.
In C++ you could always create a class and overload all the operators to create a custom 128-bit type that acts just like a native type and is strong typed.
Then C99 gives you native complex types, but that's another story.
The world is neither black nor white nor good nor evil, only many shades of CowboyNeal.
You could do this in perl if you wanted to. For instance, you can code perl in Latin. It's done using the Filter::Util::Call module, which lets you preprocess your perl code. Read Damian Conway's discussion about it. He gives a simple example using Klingon keywords and talks about implementing a Switch function in perl.
My God, it's Full of Source!
OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
You just described the .NET Common Language Runtime. Lots of different languages that compile to the same bytecode representation.
Huh. How odd. C/C++ can do this just fine...
Does "C++" have a tape backup package? [As in Seagate-Veritas Backup Exec? Or CA-Cheyenne ARCserve?]
Does "C++" have seamless background mirroring to a failsafe mirror server? [Preferably in a peer-to-peer relationship, but Master-Slave will do in a pinch.]
Does "C++" distribute loads across multiple redundant servers?
Does "C++" have a querying capability? [I.e. can C++ "query" itself the way a relation database can "query" itself?]
Does "C++" have data transfer protocols? With encryption?
Can "C++" authenticate against something like Novell Directory Services, or Microsoft Active Directory?
Or do I have to write all this stuff by hand?
Dude, I want the whole nine yards, but, to get it, I practically have to re-invent a multibillion dollar company like Oracle, or Informix.
Surely there's somebody out there with prepackaged database product that's truly 64-bit and that has native support for strongly typed primitives!?!
Or a "genetic" high-level[1] language were you build a basic skeleton of the problem (constraints as it were), and have it evolve to the optimum design.
[1] Borrowing from AI, Neural, GA, and Fuzzy to make this happen.
The computed goto is great.
// the unary && operator
void *vp;
some_label:
vp = &
goto *(vp);
Oh yeah... fill a jump table with pointers and
you can do some pretty cool stuff.
Let's not forget __asm__ with automatic register
assignment, the ability to place a variable into
a specific section of the executable, the ability
to associate a variable with a specific register,
the __builtin_expect and __builtin_constant_p
builtins... gcc kicks ass.
4.321**2 instead of pow(4.321,2)
I didn't ask for HTML. I chose plain text and I
// the unary && operator
damn well expect Slashdot to accept full ASCII.
I'll try "Code" now. Grrr.
void *vp;
some_label:
vp = &&some_label;
goto *(vp);
The very best features of languages are those that allow me to effortlessly write code that runs on as many different platforms as possible. In today's world, there should be absolutely no reason to be tied down to a single platform.
Python absolutely excels at cross-platform stuff.. and while C/C++ is fairly good, there are still compatibility problems between different implementations of the language that follow different standards.
And if you want to do anything GUI, you need a good cross-platform windowing library like wxWidgets.
I like C-like syntax, but for easy prototyping, automatic arrays and hashes are sooo neat! much nicer than garbage collection IMHO. perl makes them easy, once you get over the $,%,@ line noise
my main problem with that is (besides perl's ugly syntax) that arrays and hashes are different things. that alone makes me use PHP more often than perl.
but in PHP I have choose all the time between the array/hash thing and the 'object' thing. I'm sure that internally the objects are managed with hashes, but the syntax make them diferent objects (in extreme cases i have to convert one to the other and back again).
that's what's turning me towards Pike... arrays are hashes, and object-like syntax is just syntactic sugar over the hash! (and 'splices' are nice too)
so, for me now is Pike first, then PHP, and if i have to recurse to Perl... then i might try C++ (with STL), just because i find it far more readable!
-Kz-
I'm surprised I haven't seen this listed yet. In java I use reflection often and at the cost of a little processing overhead, it allows me to add remove fields from a database with very little code change.
I generally like to use struts in web applications and find I often have to tranfer values from an action form to a java bean and vice versa. Using the org.apache.commons.beanutils package it is incredibly easy to do this, and beanutils uses reflection to do this with.
My second choice would be good regexp support. IMO, Perl is the best at this and I also like the Java regexp package in 1.4 as well.
Umm... you're not going to find a database with all of these features. You might be able to find a combination of programs from different vendors (Oracle, Veritas, Novell) and some libraries that will let you interface with the database in a reasonable manner (Rogue Wave, OCI, whatever).
If I'm going to get a database, I want one that focuses on being a database... not something that is a "backup-enabled mirroring RAID-based load sharing encrypted connection AD-integrated solution". That's not a product, that's 10 pounds of overblown marketing drivel stuffed into a 5-pound bag.
If I'm going to get a database, I want one that focuses on being a database... not something that is a "backup-enabled mirroring RAID-based load sharing encrypted connection AD-integrated solution". That's not a product, that's 10 pounds of overblown marketing drivel stuffed into a 5-pound bag.
But that's why Oracle [or DB2, or Informix, or SQL Server, or whatever] costs, oh, $50,000, and a C++ compiler costs, oh, $500.
You can be a cheapskate, buy your own C++ compiler, and write all that stuff from scratch, or you can ante up, purchase the pre-packaged product from Oracle, and save the twenty years of your life that you would have spent writing it from scratch.
I just want something like "Oracle" [or "DB2" or "SQLServer" or whatever] that's truly 64-bit, i.e. that's got at least ONE interface that's truly 64-bit, not a bunch of 32-bit bullshit [like SQL-92, or Java 1.5.x] masquerading as 64-bit.
And strong typing of primitives would be really swell, too. [Yes, we do scientific computing out here in flyover country!!!]
http://www.oreilly.com/catalog/korn2/index.html
...
/ src/et c/profile
Everything I learnt from it, and all these useful
features like
if [[ $foo != @(From\ )* ]]; then
set -A arrayname -- $(head -1 file)
let i=0
while (( i "
let i+=1
done
and more stuff like that.
If you want to update your system to have this
kind of powerful shell too, read
http://wiki.mirbsd.de/MirbsdKsh
and, for prompt lovers who don't like the
simplistic '$ ' PS1,
https://mirbsd.bsdadvocacy.org:8890/cvs.cgi
gl hf
My Karma isn't excellent, damn it! (And
Only slightly ;-)
Every bloody emperor has his hand up history's skirt [Peter Hammill/VdGG]
Yea, C rocks - after all, it's portable assembly
language with some syntactic sugar (for, while).
I miss a goto in ksh, though.
My Karma isn't excellent, damn it! (And
#1 Garbage collection. a.k.a. automatic memory management. Not very sexy, but by far the single biggest productivity boosting feature of any language. I hate housework. It is just a waste of time.
:)
#2 No pointers, no buffer overruns, no memory corruption. Related to the first point. Memory corruption is just so hard track down. You can keep your pointers, I've already got an OS, I don't need to write my own.
After spending years programing asm and C on a platform with no memory protection (Amiga), and then later C++, I think I've paid my dues here.
#3 Stack traces. Not a language feature per se, but it takes a lot of the drudge work out of debugging.
#4 Python's 'for' loop for iterating over the contents of a list or array:
for thing in myarray:
mutate(thing)
It is easy to remember, easy to type, much easier to read, and you use it _all_ the time. Compared to the same code in C, C++ or Java, it is a godsend.
#5 Dictionaries, a.k.a. associative arrays. It just makes a lot of problems much much simplier and faster to solve. Sure, most other languages have dictionaries available as a class, but when they are seamlessly built into the language you use them as easily as any other primitive datatype.
--
Simon
If I did that, no one would be able to help me if I get something wrong - e.g. I screwed up in my custom syntax or metadata or my code, and I'm not sure where.
And it would be harder for me to learn from other programmers programs and integrate their code.
Ultrageniuses and Uber Programmers are free to write their whole entire universe of code, but I bet crappy programmers like me will still stick to using what tons of people are using, and reusing other people's work (e.g. CPAN) and learning from _their_mistakes_.
Life is too short to only learn from your own mistakes.
So that a remote attacker can cause a system to run arbitrary code of the attacker's choice.
:).
Very useful when you need to do things that the system was never designed to do.
Whole industries and many thousands of jobs depend on such useful ideas.
For stack-based hardware, FORTH is very powerful. A tiny interpreter (even on chip-level) and screamingly fast. PostScript is similarly stack-based, but its huge base vocabulary is less than ideal for beginning programming.
In a similar vein, I've been pondering the feasibility of a no-GP-register CPU. Low addresses (say, the first 31 words) are stored on-chip, the rest in slower memory. Data is accessed via two memory-address registers (a la the M reg in the old 8080, which turned into (HL) in the Z80) to lend itself to load-store internal implementation. 30-bit (or 62-bit) addressing, a RISC architecture, predicates all around, everything vector-able (including predication).
Bah, I'm up too late. Brain is fuzzy.
I've found TCL's slave interpreter very useful. It allows you to execute "uncontrolled" TCL code securely, trapping/substituting/exposing whatever you want. Variables can be exposed, hidden, readonly, etc.
In particular, I find it useful when allowing an application written in TCL to be scripted. The TCL application can remain robust and reliable, even when the user code isn't.
Can You Say Linux? I Knew That You Could.
I like the $ coz I use the <<"EOT"; stuff a lot.
;).
e.g.
print <<"ENDHTML";
<html>
<head><title>$title</title>
</head>
<body>
Unquoted:<b>$blah</b><br>
Quote d: ${\( htmlquotearray($blah) )}
</body>
</html>
ENDHTML
Witho ut the $ or other special character this would be very difficult. Not sure how you'd do that sort of thing in other languages.
In addition to the associative arrays, I like CPAN - as you mentioned, there are plenty of experts around who produce better code, and with CPAN I get to reuse their work, thus raising the average code quality of my programs AND reducing the amount of work I do
Perl has a standardized documentation feature: PODs. You can embed all manner of documentation alongside your code and then see the output (much like a man page) by running 'perldoc [perl module]'. If you use classgen you get a POD skeleton in your perl modules.
I do agree that standardized documentation built into a language is quite powerful.
It's an easy way of developing a command-driven interface (which is useful if you're developing a web-app or even for limited-functionality command shells).
So for example, the user's command is stored in the variable $cmd. We then have hash %cmds which stores all the possible commands like this:
What that means is that we use %cmds as a look-up table of commands, looking for the command given by the user in $cmd, and if it exists in the table, it's executed, if not, nothing happens. It's secure in the sense that garbage data entered by the user is just ignored, they can only do things that we specifically allow them to do (similar to having a default-drop firewall ruleset, I suppose).
Using the above example in the context of a website in CGI, lets say the user called the CGI as "index.cgi?cmd=foobar", well, then the anonymous subrouting $cmds{foobar} is executed, giving the user access to that page, and then if they go to "index.cgi?cmd=bazqux", then $cmds{bazqux} is executed. It's immune to buffer overflows or any trickery like that, because any command that isn't specifically defined in the hash fails the "defined" test, and nothing is executed. Even if it was executed, you'd just get a runtime error saying you can't use an undefined value as a reference to a subroutine to execute, which would translate to an HTTP500 error to the user, keeping security intact. The 'defined' test just allows you to catch the exception and print a nice page to the user explaining the command was not recognized instead of throwing the 500 error at them.
Come on, over 100 comments and nobody said regexp operator?
//, m(), qr()/%r(), etc.
I can't stand re.replace('...'), re.match('...'), etc. That's why I like Perl and Ruby, which provides with re operators such as
Python's raw string still sucks for regex.
i typed /foreac in firefox... to no avail.
hmmm... shirly someone would have mentioned foreach by now. and stop calling me shirly.
then i searched for foreach. not a single (at least modded) post has mentioned it.
any language that has a foreach or at least while () or equivalent lets you get things done quicker than you can say lickety-split.
raw assembly also lets you get it done lickety-split. learn vector programming.
there's a spectrum for ya.
Special variables, multimethods. meta-object-protocol, lisp-syntax, lisp-macros,
Dyslexics have more fnu.
> a standardized documentation feature
Oh, like POD (in Perl) or docstrings (in elisp)?
Cut that out, or I will ship you to Norilsk in a box.
I'm in love with the CPAN. I especially like search.cpan.org -- I have a
bookmark keyword set up in Mozilla for it, and it's the one I use most often,
more often than the keyword for dictionary.com, probably even more often than
the one for Google. I don't just use it to find new modules, either; I use
it to quickly check the docs for modules I already use. Every language should
have a mirrored public repository like the CPAN, complete with an automatic
installer like CPAN.pm that comes standard with the language tools.
Cut that out, or I will ship you to Norilsk in a box.
I dont remember what the syntax actually was but when you defined a structure, you could point into its members with with.
like if the structure had members x and y and structure was named coords you could do something like this
var own_x;
with coords
begin
x=own_x
y=123.13
end
yush
perception is reality
... a good API and toolkit.
I especially like Cocoa.
> #1 Garbage collection. a.k.a. automatic memory
> management. Not very sexy, but by far the single
> biggest productivity boosting feature of any
> language. I hate housework. It is just a waste of time.
Garbage collection does not free you from memory management. It simply converts one kind of problem into another: namely it eliminates accesses of unallocated memory, but it creates memory leaks instead. The thing is, it is not always easy to figure out when you no longer need a block of memory. That's with garbage collection it is supposed to be good practice to "free" your pointers anyway, by assigning NULL to them. Why they can't just use STL containers instead, I don't know.
> #2 No pointers, no buffer overruns, no memory
> corruption. Related to the first point. Memory
> corruption is just so hard track down. You can
> keep your pointers
You won't have any memory corruption if you don't use arbitrary indexes to access your arrays. For example, when iterating over a container, you run your iterator from ctr.begin() to ctr.end(); no corruption possible. The other cause of memory corruption is using unverified data to directly access your arrays. That happens when you ask the user for a number and then use it to index; this is wrong in so many ways, I can't even begin to list them all. Verify your data, and you will not have any data corruption.
> #3 Stack traces. Not a language feature per se,
> but it takes a lot of the drudge work out of
> debugging.
#include
backtrace_symbols()
> #4 Python's 'for' loop for iterating over the
> contents of a list or array:
>
> for thing in myarray:
> mutate(thing)
#define foreach(t,i,c) for(t i = c.begin(); i #5 Dictionaries, a.k.a. associative arrays. It
> just makes a lot of problems much much simplier
> and faster to solve.
map m;
> Sure, most other languages
> have dictionaries available as a class, but when
> they are seamlessly built into the language you
> use them as easily as any other primitive '
> datatype.
You can use map as easily as any other primitive data type of the same category: as an array.
m["january"] = 31;
cout "january has " m["january"] " days" endl;
Just because you can write it that way, does not mean you should. Should you blame makers of underware for letting you put it on over your clothes? Just because Superman can do it, does not mean you should.
Compilers. Because coding in hex blows.
One of my favorite features of PHP is the ability to define a function, then call it by dynamically constructing a string and using call_user_func. It's great, allows for reduction of code by creating functions/objects that have names that can be easily instantiated.
Along the same lines, the fact that PHP allows you to retrieve and use object variables dynamically is wonderful ($var = "name", $obj->$var is the equivalent of $this->name). It allows for incredibly fast and robust code development. Loose type checking is always an issue in these cases, but the benefits well outweigh the downfalls.
--trb
Most important features that I constantly miss in mainstream languages:
* products (tuples)
* sums (distinguished unions with pattern matching)
* no 'null' pointer (use sums instead)
* higher order functions!
* type inference
* parametric polymorphism
* parametrized modules
* static typing with type safety guarantees!
It's worth trying a modern typed functional language like ML if you don't know what these are; there's more to the world of programming than C-like scripting languages.
I mean come on, how many languages in which you can do this?
=================
Unix is very user friendly, it's just picky about who its friends are.
Simple by what metric? Ever written a parser for C?
If you want simple syntax, try Scheme or Lisp. Opinions differ on its beauty (it grows on you, though).
Laugh all you want, but I program mostly in the computer algebra system Maple. My favorite feature of its language is that identical objects are stored only once by the system - you effectively use pointers for everything, and it is completely transparent. There are a lot of crazy hacks you can do with this functionality, keeping in mind that it incurs no extra overhead.
In Soviet America the banks rob you!
I really love javadoc, it makes life so much simpler when generating documentation.
make the language that can be inputted by voice commands and has the smarts to do what you tell it, e.g. "Give me a program that manges a database of 1 million people in c++". You'll probly have to run it on a coustom bulit computer that has as "parts" a dozen trained programers;)
Almost all of PostScript, which actually makes a pretty find command line language.
'using' in c#
Actually what I'm wanting to do, eventually, is write a book about great programming constructs people have probably never heard of, or don't understand well.
My last book took me 3 years to find the spare time to finish, so I don't suspect I'll have this done anytime soon.
I was originally going to just analyze scheme's features, but then I realized that many languages have features that need to be recognized, too. my original outline was going to be:
* Memory Management
* Symbolic programming - an intro to Scheme
* Functional Programming & Functional Programming Patterns
* Closures and higher-order functions
* Advanced Flow Control w/ Continuations
* Compile-Time programming 1: Macros
* Compile-Time programming 2: Partial Evaluation
* Compile-Time programming 3: C++ templates
* Lazy evaluation
* Lazy data structures
However, if I decide to open it up to other languages, I have no idea how I'm going to organize it or even how I will decide what to include.
Anyway, it was originally posted just to Advogato, but then I remembered that the only threads on Advogato that get any real response are flame-wars, which is sad because Advogato could be a real cool place. Then I thought "you know, this would make a good 'Ask Slashdot' as well. However, I don't expect the quality of responses on Ask Slashdot to be as good, although I expect there to be a LOT more of them.
Engineering and the Ultimate
Everything-as-an-object in, for example, Ruby and Smalltalk.
Look out honey, 'cause I'm using technology; Ain't got time to make no apology
- Strong typing: Much like pig and elephant DNA just don't splice, one should not be allowed to add characters to integers then divide by floats and expect a sensible result.
- Type inference: I want a language that can figure out what I'm doing without having to specify every last detail. And I want it to be able to tell me when I'm trying to splice said pig and elephant DNA.
- Higer order/first class/anonymous functions: makes life and coding so much nicer.
- Pattern matching: pretty and powerful.
- An interactive environment: why should I have to compile my whole freaking program to test one little function?
- Paradigm neutrality: if a problem is best solved with object, let me use objects. If an algorithm is most naturally expressed functionally, gimme that. If imperative code is what I need, let me use it. If I want to mix'n'match hand me the blender
- Native and byte-code compilation: choose between speed and portability depending on your needs
Thank goodness there's OCaml there to provide all this for me in one happy little package...-30-
Macros can completely transform the source, at compile time, but with the full power of the language. Having that ability, together with simplicity, means that it's easy to build a complete mini-language for one's manager or web designer to use on the site, and easy for them to learn it, since you can explain the syntax in 5 minutes or less, and they don't have to learn 50 built-ins to use it.
Could you give an example of this? Every person who's ever made a living doing LISP raves about LISP in this way. I've never seen the magic here or had the necessary ah-ha moment. I've seen some really really ugly code in LISP that looks like it took about 4x longer to write than it would in VB or Java though; so it is off-putting that way.
Thanks!
Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
.NET byte code does NOT typically contain the source code within it. So, what you have is the raw IL which resembles so much assembler. On top of that, IL can be obfuscated to remove any meaningful identifiers. IF the IL does contain the source code, it's only because the IL was compiled for usage in a debug environment. And then, the IL will be the source language of the developer of the program, not the source language of your choice.
;+)
Granted, a reverse engineering from IL to language source is possible, but it's never perfect and almost always messy.
So, in short, IL != source code.
Same thing applies to Java byte code, BTW.
Feel free to prove me wrong. I'd be happy to use your product.
Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
Nice point. But if it's the only word you use it's not that easy to grasp. And much of the time you don't say it at all, you imply it instead. I think you get the idea about it; if used sparingly it's fine, but if it's all you talk about it gets pretty confusing.
:-).
Hope it helps
D
Or another example:This is complete quicksort algorithm written in haskell. Please compare the code above to an average implementation of quicksort in your favourite C or java library.
There you are, staring at me again.
Syntactic minimalism without sacrificing semantic richness.
Examples would include the Lisp and Forth families.
Anyone know of any others in the same spirit?
But my grandest creation, as history will tell,
Was Firefrorefiddle, the Fiend of the Fell.
Unrestricted integer size (e.g., Lisp bignums)
Have persistent objects between program invocations. It's so tedious and buggy to have to write to a file when a program ends and then read it again when you start it up again.
Regex as operator, IMHO, is God-send in Perl. Regex-as-object in Python is clunky (too many step to apply a regex), and PHP implementation as function is confusing.
foreach() is a close second. I think Java and C# now have this operator too (unsure about Java). If I where stuck using the repetitive and redundant "for (assignation; stop condition; incrementation) { block }" construct for simple list iteration, it would make me scream.
If you are familiar with Perl, I suggest you read "Advanced Perl Programming" by Sriram Srinivasan from O'Reilly. Reading this baffle me with the flexibility and ingenuity of this language. While I don't advocate using all these techniques (tie, closure, typeglob, etc) in production code for maintainability purpose, knowing your options is certainly a good thing.
:wq
With Common Lisp Macros, you get the ability to add most any feature you may want. Obviously, they work better in a CL environment with all of its other functions and capabilities. But with Macros, you can even add many of those if they weren't already present.
Simple example is something like an OOP paradigm. Perhaps you don't like CLOS. Perhaps you like Smalltalks better. You can readily add that style of classes, methods, and objects using macros.
High level languages are about abstraction, CL Macros let you create your own abstractions, not just the ones the language gives you.
So, macros let me make my own language features.
If the language has classes, it would be nice to also have class invariants checked before the entry to a public function and after the result, so :
would (essentially) translate to :
Ideally this would be something that could be turned on and off either at compile or run time on a class by class basis.
Functions as first class objects, including currying would also be very nice (like this in haskell)
An unnamed "tuple" type (like in haskell or python) is great for handling multiple return values from functions. For example to get both the quotient and remainder from integer division :
Iterators are really nice - including the ability to define new iterators on classes (and it would be best if primitives were somehow included in classes). It should be possible to wrap iterators in functions. For example, instead of :
It would be nice to be able to define an iterator that produces all the (i,j) pairs :
Or even, given a mapping function :
The stupidest name for the best concept. My code constantly grabs some sort of resource -- files, mutexs, com objects, whatever -- that need to be "freed" somehow (Release, delete, free, etc).
Old style: "free" it at the end of the method
Problem: doesn't work with exceptions. Easy to forget with early returns. You have to add an ugly try/catch/finally block in each method, meaning that variables have to be declared in ugly and inconvienient spots.
Solution: "free"Me classes:
Result: No matter what happens (almost), the object will be "free"d. I can return early; I can have exceptions; I can do whatever, and the object is "free"d.
The same concept can be used for classic C files (fcloseMe), for all the myriad ways of allocating memory (there must be a half-dozen in C++ on Windows), etc.
Smart pointers are the same idea, but IMHO drag in too much baggage -- you have to spend too much time figuring out the thousand-line smart pointer template, you have to do a lot of work to know if one smart pointer type can be converted into another, the boxing/unboxing thing looks awful...the list goes on. And the only work with one type of memory resource, when in reality in C++ on Windows there are lots of types of memory that have to be managed.
Want a sig like mine? Join ACM's SigSig today!
Agreed. As an editor and a programmer, I've seen terrible abuses of English and code. I've learned to appreciate simplicity and locality in both.
Woe to the language developer who invents some sort of passive voice programming, though.
how to invest, a novice's guide
I love(d) Pascal. It was simply the coolest bestest language going.
Sure Kernighan likes to bash Pascal... says it isn't suitable for serious system level programming.... but then again how does he explain MacOS?
Ah well I am a C++ java type like everyone else these days.... but I love Pascal still.
I am very small, utmostly microscopic.
Back in ye ol' days of line numbered BASIC, you could use a READ/DATA pair to stuff arrays with initial values, something like this:
dim ar$(3)
for x = 1 to 3
read ar$(x)
next x
data "Monty", "Python", "Rules!"
Great way to load fixed value lookup tables with a minimum number of lines. Of course you wouldn't use it except for large enough arrays (including multidimensional, just nest the loops).
TOP SECRET Microsoft(c) Code
Project: Chicago(tm)
Projected release-date: Summer 1998
*/
#include "win31.h"
#include "win95.h"
#include "evenmore.h"
#include "oldstuff.h"
#include "billrulz.h"
#define INSTALL = HARD
char make_prog_look_big[1600000];
void main()
{
while(!CRASHED)
{
display_copyright_message();
display_bill_rules_message();
do_nothing_loop();
if (first_time_installation)
{
make_50_megabyte_swapfile();
do_nothing_loop();
totally_screw_up_HPFS_file_system();
search_and_destroy_the_rest_of_OS/2();
hang_system();
}
write_something(anything);
display_copyright_message();
do_nothing_loop();
do_some_stuff();
if (still_not_crashed)
{
display_copyright_message();
do_nothing_loop();
basically_run_windows_3.1();
do_nothing_loop();
do_nothing_loop();
}
}
if (detect_cache())
disable_cache();
if (fast_cpu())
{
set_wait_states(lots);
set_mouse(speed, very_slow);
set_mouse(action, jumpy);
set_mouse(reaction, sometimes);
}
printf("Welcome to Windows 98");
if (system_ok())
crash(to_dos_prompt);
else
system_memory = open("a:\swp0001.swp", O_CREATE);
while(something)
{
sleep(5);
get_user_input();
sleep(5);
act_on_user_input();
sleep(5);
}
create_general_protection_fault();
If you want simple syntax, try Brainfuck or Befunge.
"They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
It's very common for a developer to want to open a file, read from (or write to) it, and close it. No matter what happens (in this idiom) we always want to close our file. Errors or exceptions should not prevent the file from being closed, so, in most languages, we'd have to remember to close that file in every branch of our code.
Now, one solution to this would be to have open files be objects that know to close themselves when being garbage collected (Python does this, I think), but this means that if we have an error, and fail to remember to close the file, we're guaranteed to have an error if we try to open that file again later in the same run of the program. For long-running processes this is, of course, fatal.
Macros to the rescue!
In Lisp, if we wanted to read from a file without worrying about all that, we'd say:or if we wanted to write to it:In this example, WITH-OPEN-FILE is a macro that adds code to the beginning and end of whatever code it contains, so that a file is opened, a stream is attached to the file, the variable name we give it is connected to the stream, our code runs, and then, *even if we had an error or just jumped out of our code into some other area of the program*, the file is properly closed.
Of course, we could do all this bookkeeping ourselves, but now we don't have to, and this is not something we could easily do concisely with functions alone. Further, now we just don't have to ever worry again about whether a file gets closed properly. It just works.
Multiply the conceptual savings from this macro across a whole slew of similar macros, and the effect is very much like defining a new, higher-level language that frees the developer from messing with the low level details, but preserves those details so that they're available when the developer actually wants to use them directly.
Now, my original assertion was about using macros to aid in building manager-friendly or web-designer-friendly mini-languages, and I haven't talked about that. Part of this is because I'm most familiar with one implementation of that in particular (PSILISP, my web application framework), and it's not done yet. Nevertheless:
In PSILISP, assuming you've already defined a page called PAGEONE, you can sayand it's easy for the web designer to understand what's going on, even if said designer doesn't know Lisp in the first place.
Property law should use #'EQ, not #'EQUAL.
Ok, I think I understand your post. BUT, what I don't get is how macros get LISPers all excited about macros when macros look so much like regular function calls.
.NET; it's productive as all hell).
For example, if PSILISP were just a bunch of functions in Java, we could write code that would do essentially the same thing with the same number of lines of code. Furthermore it COULD (though it often isn't I admit) be just as readable as the LISP version. No?
Really, I'm not trying to be difficult. I'm just missing the magic here. I'm sure that part of what I'm missing is context. If this were the 1970's and I were faced with decision to choose the most productive environment and I got to decide between something like BAL, COBOL, FORTRAN, or LISP; I'm sure I would choose LISP. In the context of that day and age, LISP and macros WOULD be magic. And, I'm not saying LISP is no longer useful, it just has a much more mature heritage and I'm sure that its younger cousins probably stole much from it.
BTW - If you would like to see a web development framework that provides a full object oriented treatment of web development semantics, give Tapestry a look. Granted, it's a Java framework, but you may find some inspiration for features there. In particular, you might like to see the components that Tapestry provides a developer. It is, by far, the best UI layer framework for web development I have found in the Java world. I compare its productivity to the ASP.NET framework, which I have also used for work (say what you like about
Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
I love them, plain and simple. Dynamic polymorphism over more than one parameter makes things so much nicer.
I recently wrote a small blog entry on what my favorite features would be.
I started PSILISP mostly because I was frustrated with the prevalence of web frameworks that treated pages as having only the most tenous connection to other pages. That is, the decision of which code to run for this URL/form/session state combination was made too early in the response process, and usually depended almost entirely on the URL.
In any case, this is far off topic.
It's true that anything you can do with macros can be done with non-macrified languages (as far as I know). It's just that with macros, you can have the additions appear to be built into the language, and you don't force users to build object oriented code even where that's overkill. In PSILISP, I'm using macros to do the same sorts of things that I used to use mix-ins for, in Python, but now, I worry less about the details of how it's implemented (after I write it), since it's just like any other built-in.
Here's an example of a macro that doesn't something you can't do, as far as I know, in Python:
Suppose you're writing some larger app, and you'd like to have something happen whenever your app prints something (work with me, here; you can come up with a less contrived example of this, I'm sure).
So, everyplace you now haveyou'd like it to save the variable name and value.
So, you can write an (untested) macro:to shadow the built-in print statement. Of course, this is a fairly fragile implementation of PRINT, and would break in lots of cases as written. However, you haven't had to change any of your original code, with the possibly hundreds of print statements like this, and now you're getting the formatted string in your logfile or database or whatever SAVE-VALUE does with it, and in that string is not only the variable value, but the source *name* of the variable as well!
How would I do this in Java? Could it even be done without choosing from the outset to use a non-builtin to do my low level printing? I'm quite sure you couldn't do this in Python without resorting to changing the builtin print function in C (for CPython).
The important thing is that you can build new language features for Common Lisp that are written in Common Lisp, and can be used exactly like any other language features. In fact, most of the "built in" functionality of Common Lisp can be implemented in terms of macros, though there are a few built-ins that are only possible as "special operators".
Property law should use #'EQ, not #'EQUAL.
Indention, syntax coloring, loop/conditional indicator lines (not to forget ability to collapse loops/conditionals for readability). Playing with KWrite with some PHP sure makes me look at my other code editors with a heavy sigh. Of course all those GUI featurees as copy paste, etc. too.
"Enjoy what you're doing! If it becomes drudgery, you're doing it wrong!" - Jim Butterfield
My absolute favorite feature is a job market which favors practitioners of the language.
It is one of my interview questions to allow me to figure out where coders stand. What amazes me is the number of arguments it will cause until somebody compiles it and figures out what is happening.
The other big ones these days is trying to determine if somebody has *nix. I have been asking applicants how to create new processes, and ppl professing to have years of *nix experience will tell to spawn a new process by fork. When I ask what it returns, it is then "a handle to the process". When I ask how to switch the executable, they have no idea. Finally ask what exec is, and the answer is, no idea. Amazing. Total MS coders (or possibly VMS), that are too lazy to even look over standard *nix code or books.
I prefer the "u" in honour as it seems to be missing these days.
For whatever I'm trying to accomplish, I want a language that can do what I need it to do to accomplish the task. Preferably, that lets me get the task done in a time under the amount of time that I have been given to complete it.
,and other times when it's irrelevent to the environment that the program's going to run it.
[and when run, will complete the task within the accepted specifications, such as run time, memory utilization, etc]
There are times when the right language for the job is assembly, and there are others where it'd be a shell script.
There are times when it's appropriate for me to spend my time with memory management
A language might work well for a particular situation, but I think it's unrealistic to think that any one feature is going to make me always want to use a particular language.
Build it, and they will come^Hplain.
Think of $_ like "it". You can use it in everyday speech to get your point across in the minimum amount of words, or you can be verbose and spell everything out.
...should be read as "for each page, split it on the spaces." In this situation, in fact, the "it" is optional, but leaving it out makes things even more confusing unless you're writing something quick-and-dirty, which has no place in a full application:
If you're writing something which is going to be used in the long term, it's wise to avoid the use of $_, not least because (by default) it's a global symbol and so you can get some weird bugs by one bit of code clobbering another's "it", like this:
I don't look at the features alone in a language. Usually, I look at what its primarly used for. I use C because it's a general-purpose language, that has a strong issued standard, with ANSI compiler compliance. I find that beginner programmers who like languages with lots of features(i.e C++), they get carried away and don't learn the language like they should. C++ is an extremely complex language, that is hard to use correctly.
What are you going to do when you need a true 128-bit environment? It used to be that 32-bits seemed like more than anyone could ever use. Now that's starting to no longer be the case for certain applications, and 64-bit is becoming more important.
I don't think it's reasonable to expect certain bit lengths for primitive types (unless your application is very specialized, i.e. nobody else is ever going to want to run it). Primitive integer types are never going to be able to do all the computations necessary (wake me up when they sell cheap 4096-bit computers to compute RSA keys); the primitive types should be seen as tools for performing a fairly limited range of computing tasks (ditto with floating point; IEEE 754 is not a magic cure-all for numerical robustness). The rest is up to the programmer, language designer, or library designer.
Also, I'm not sure what you're talking about with regards to SQL, but none of that stuff is really closely defined in the SQL standard itself. Many high-quality databases are more than capable of storing more than 4 GB of data in a single field. Storage size limitations reflect the underlying database backend more than the programming language used. The native protocols for databases are more than capable of transferring data in pure binary as well.
I have been a C++ -er since about 14, and i have begun coding Perlwise. Something so simple as being able to say
'foreach(@array){ print $_;}'
is a world of difference. Kicking one's self over fence post errors is now a thing of the past, and i love it.
IMOH it is the simple conveniences like this that are done 100000000000 in a program that really make life better simply by volume of use. Oh, and this is lang. independent, but loosely typed, memory managed-ness is a great thing too. Not having to think to hard about where things are going (just knowing how to get them back) allows for much more thought to be applied to problems of form, rather than semantics and specifics.
sigSEGV - doy!
I think this is one of those rites of passage all experienced programmers probably go through. At some stage, your experience of different languages gets to the point where you understand that the underlying concepts transcend the syntax of any specific language. A natural next step, particularly if you've seen the sort of parsing graphs used by compilers, is to assume that throwing out the "awkward" text syntax in favour of some whizzy graphical scheme will make things much easier. Some people have even done PhDs on this subject.
Unfortunately, when you try it in practice, you find it's not nearly as clear-cut as you thought. Like all that nasty, unnecessary punctuation found in many programming languages, it turns out that using a concise, precise text format is often far easier both to read and write than any graphical alternative. What can be done in one line of regex in Perl takes a whole screen of graphical representation via flow charts and state machines.
I wish you luck in your exploration of graphical alternatives, but I'm afraid the odds are pretty heavily that after a while, you'll come full circle, and understand that all that nasty "bracket crap" is there for a reason, and has survived for decades because that reason is sound.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
Question your musical taste? ;-)
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
You mean like the whole concept of declarative programming, as seen ubiquitously in the functional and logical language worlds?
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
- I like the idea C came up with of the ++ operator (and --, and to a lesser extent some of the equal codes such as *=,
/= etc.), e.g. instead of
- I like the idea Pascal came up with to distinguish an assignment from a comparison. The equal symbol = is only used for comparison. To assign a value to a variable you must use the "becomes" symbol
:=. This eliminates the possibility of nasty errors in C such as
Paul Robinson <Postmaster@paul.washington.dc.us>A = A+1; You have
A++; or ++A; depending on whether you want A to be increased before using it or after you use it.
if B=C { being used where they should have used if B==C { N.B. Yes, I know there are checks in certain cases that require you to put certain of these type of expressions in () to allow them without getting compiler warnings, and I also know that there have been attempted system hacks where this type of exploit has been attempted to grant priveleges by doing a comparison using = instead of ==.
If assignment used a special sequence that can't be used in any other case (or did not allow assignment inside of a statement), check code that implemented root access hacks (A test for privelege against the user's privelege code which grants the user root privelege) would be impossible in the first place.
The lessons of history teach us - if they teach us anything - that nobody learns the lessons that history teaches us.
My main problem with functional languages is with I/O: all the literature claims that monads are the 'natural solution' to that kind of processing, but I always thought it was just a lazy cop-out and it certainly doesn't feel right among the rest of the syntax.
For the uninitiated, a normal (functional) function must always produce the same output with the same parameters so something like wouldn't work because any given name is bound to a certain value and is therefore immutable.
I personally feel that the mathematically oriented people are making this too difficult, and would prefer that the RealWorld were abstracted into a few 'magic' functions; for example, the 'function' GetScreenContents would take as a hidden parameter the actual current contents of the screen -thus the functionality (hehe) would stay intact:would produce the same output (namely the string "Please enter your name:" whereaswould produce a different output. Sure, it's a sort of a hackish way of doing it but I think it'd fit better
I must admit -and I'm ashamed of this- that I don't know LISP or any variants thereof. I started with imperative languages and am only slowly unlearning those patterns so that I can actually use functional languages (and I've done a bit in Prolog). It seemed easier to start with Haskell than, oh, CLOS or something. So I'm getting there!
Regarding Ruby: yeah, it is a simple abstraction of a common idiom -well, a few idioms. Blocks can be used as closures, high-level functions, lambda functions and iterators. There's just something intangibly cool in how Ruby does it. I could bridge it to your earlier argument about C++ generics vs. functional polymorphism: the same thing can be achieved many ways but this is just the best one
Marxist evolution is just N generations away!
I totally agree about functional languages and monads. They're theoretically elegant solution to a major practical problem, but always seem far too awkward in actual use (though I'm no expert on this subject).
What I'd like to see is the reverse approach: an imperative language that supports higher-order functions, currying, etc. properly. I don't see any problem with this approach, yet the most (only?) serious attempt to bridge the imperative/functional gap so far seems to be OCaml, which starts from a functional approach and adds imperative-like features (and, IMHO, not particularly cleanly). One need only look at the flexibility evident in scripting languages that provide basic support for functional programming concepts to see the potential.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
I must say I like lists and 'infinite' lists, recursion, lazy evaluation and currying.
Is what got me hooked on it. The language behavior and features (perl 4 man pages) were described in a conversational and friendly manner, as if the manual page were trying to explain to you why the features were added, where they appear in other languages, and how they're different or the same in Perl.
I don't need to tell you that most technical documentation is usually written as if it were an oversight. When I saw the quality of Perl 4's included documentation, I had a high degree of confidence that the perl interpreter itself was of high quality, and that the author understood *language*, both computer and human.
Try to point me to another language's documentation that's as friendly as Perl's.
The problem is when you _think_ your custom reprentation is perl+, but actually it's NOT, it's closer to php++ than perl+.
Translating the program to Java may[1] better indicate there's a problem, but who knows what perl+ is? Maybe even you don't.
Also translating php++ to Java may generate source that has 10x the number of lines and is harder to understand compared to something that's natively written in Java that does the same thing.
For the scenario you cite to be practical, too many things would have to be perfect or near perfect, or even possible.
In such a world we'd all be speaking languages that could be losslessly translated to esperanto or parrot-bytecode and vice versa, with zero misunderstanding.