Each language I've used has had its pros and cons, but some features have really shone through as being indispensible, shining examples of how to design a programming language to make programmers happy.
I use PHP a lot at work, and the one thing I really miss when moving to other languages is PHP's foreach:
foreach($items as $item) //iterate through items by value
foreach($items as &$item) //iterate through items by reference
foreach($items as $i => $item) //by value, with indices
foreach($items as $i => &$item) //by reference, with indices
In C#, I'm kind of smitten with the built-in multicast delegate [1] system, as well as the way it handles getters and setters [2].
So what's your favourite/favorite language, and what feature makes it awesome?
Delphi
for the following features:
type
TGraphicClass = class of TGraphic;
TGraphic = class
class function FindClass (FileExt: String): TGraphicClass;
class procedure RegisterClass (AClass: TGraphicClass);
class function SupportsFileFormat (FileExtension: String): Boolean; virtual; abstract;
constructor CreateFromFile (FileName: String); virtual; abstract;
end;
TBitmap = class (TGraphic)
class function SupportsFileFormat (FileExtension: String): Boolean; override;
constructor CreateFromFile (FileName: String); override;
end;
...
initialization
TGraphic.RegisterClass (TBitmap);
...
Result := TGraphic.FindClass (ExtractFileExt (FileName)).CreateFromFile (FileName);
The seamless COM integration, supported by the "implements" keyword [1], the "safecall" [2] calling convention and the Variant type (of which you can write custom implementations [3], and even custom invokable variants for late binding [4]!).
The clear separation of "interface" and "implementation". This is quite common in C++ as well (albeit not inforced), but it somehow got out of fashion in more recent mainstream languages such as Java and C#. If you want class declarations in C# or Java to be anywhere as concise as in Delphi, you'll need to mess with your IDE and with code folding - a feature which is, by design, totally unneccessary in Delphi.
Deterministic destruction.
The intrinsic enum and set types:
const
CWhitespaceChars = [#9, ' '];
CNumericChars = ['0'..'9'];
CAlphaChars = ['A'..'Z', 'a'..'z'];
CAlphaNumericChars = CAlphaChars + CNumericChars;
CTokenChars = CAlphaNumericChars + ['_'];
CNonWhitespaceChars = [#1..#255] - CWhitespaceChars;
CNonPathChars = ['/', '\', ':', '*', '?', '"', '', '|'];
type
TVegetable = (Aubergine, Zucchini, Tomato, Paprika, Onion);
TRatatouille = set of TVegetable;
TPeperonata = set of Tomato..Onion;
In Delphi Prism [5]: Compile-time AOP [6]! Doing AOP with no performance degradation, full support during coding (e.g. in IntelliSense) and without nasty bytecode juggling tricks, how cool is that?
Not Delphi-specific, but useful enough to be mentioned: Generics, anonymous methods aka closures and reflection.
Delphi is not case sensitive. This can be a huge plus.
Nested procedures and functions. You can emulate that with anonymous delegates, but it's a syntactical mess, it runs the risk of accidentally passing out a delegate, and it degrades performance notably.
slices: Whenever you have a collection of items, you carve yourself just the slice of that collection you need.
a = ('a', 'b', 'c', 'd', 'e')
print a[2:] # prints ('c', 'd', 'e')
print a[:2] # prints ('a', 'b')
print a[-2:] # prints ('d', 'e')
print a[:-2] # prints ('a', 'b', 'c')
print a[0:-1:2] # prints ('a', 'c', 'e')
map, reduce, filter functions: Just enormously concise ways to perform operations on collections of items:
t = time.localtime() # today's date/time tuple,
# e.g. (2008, 8, 19, 10, 18, 12, 1, 232, 1)
Filling the collection with default values:
d = map(lambda a, b: a or b, (2000, 10), t[:3])
# d -> [2000, 10, 19]
Filtering a collection:
f = filter(lambda a: a > 10, t)
# f -> [2008, 19, 25, 43, 232]
with statement: Cleaner, more readable code with all the ugliness of the mostly technical detail of file exception handling and resource cleanup modularized into the file object itself.
with open('file.txt') as file:
for line in file:
print line
The Father of regular expressions - need I say more?
CPAN [1] - an exhaustive collection of libraries for just about anything...
What I hate about it though, is the amount of horribly, horribly unmaintainable code, it makes so easy to write, and the lack of proper error handling.
open source community. If you need a somewhat general purpose library or framework, chances are there is an open source version for it in Java.
[1] http://www.cpan.org/say $a[2..5]' I think in Perl6 you will be able to do
say $a[2...]`. - Brad Gilbert
map
, and filter
only they`re called map
, and grep
. - Brad Gilbert
with
statement. - Brad Gilbert
C#. Lots of killer features, many of them sub-features of LINQ (e.g., query comprehensions, iterators, extension methods, lambdas, generics, expression trees, type inferencing, and anonymous types). Some of them existed before LINQ while others were introduced to support it.
Strongly typed ruby-style suffixed foreach with indicies can be done with extension methods:
//items.ForEach((i,item)=>dowhatever(item));
static void ForEach<T>(this IEnumerable<T> items, Action<int,T> action)
{ int i = 0;
foreach(var item in items) action(i++, item);
}
//By-reference: items.ForEach((int i, ref Foo item)=>item = new Foo())
static void ForEach<T>(this T[] items, RefAction<T> action)
{ for(int i = 0;i < items.Count(); ++i) action(i, ref items[i]);
}
delegate void RefAction<T>(int i, ref T item);
LINQ already has a version that returns a collection of mapped values:
static IEnumerable<TResult>
Select<TSource, TResult>( this IEnumerable<TSource> source
, Func<TSource, int, TResult> selector)
Haskell. Its killer features:
It's lazy. This makes many difficult algorithms easy to reason about, and makes your programs more concise.
Example 1: To create a regular polygon with n sides, simply generate an infinite list of points by rotating 2pi/n around the origin, and take the first n items from it.
regularPolygon n sideLength =
take n $ iterate (rotateVertex angle) (r, 0.0)
where
angle = (2 * pi) / n
r = (sideLength / 2) * (1 / sin (angle / 2))
rotateVertex angle (x,y) =
(x * (cos angle) - y * (sin angle),
x * (sin angle) + y * (cos angle))
Example 2: Parallel evaluation. The par function evaluates the first argument in a separate thread and evaluates the second argument in the current thread. The pseq function evaluates the first argument and then the second. Here's a parallel Fibonacci sequence that takes advantage of lazy semantics.
fib 0 = 0
fib 1 = 1
fib n = r `par` (l `pseq` l+r)
where
l = fib (n-1)
r = fib (n-2)
It's purely functional. This means that absolutely no undeclared side-effects are allowed. Functions can therefore be relied on to not have an effect on the rest of your program. Pure functions refer only to their arguments, and are therefore easy to understand.
square :: Integer -> Integer
square x = x * x
Effectful functions have a different type. Instead of returning an Integer, this function returns an IO action that gets an integer from the environment at a convenient time.
getInteger :: IO Integer
getInteger = do {
x <- getLine
return (read x);
}
I use Delphi because it allows me write all types of applications. Web Development (ajax, Web Services the whole 9 yards), Desktop Development, Services, Dlls, .Net, Games, Graphics, you name it. And it comes with decades of well-established principles. And it's so easy to use. huge support base.
It's a language that's very easy to read so it's a breeze taking over legacy code and building on it.
Perhaps the biggest advantage, for me, is that it compiles to an exe or dll. No translation, so effectively runs twice as fast with 1/2 the resource footprint.
I love LOLCode [1] - its killer feature is that it makes me laugh out loud. (;
[1] http://lolcode.com/Right now, if I had to choose one language* to stick to for the rest of my life, I'd most likely go for Ruby.
Every time I use something like
5.times { |i| something_useful_that_uses i }
... I'm smitten again by the everything-really-is-an-object aspect. (Hmm, I'm a little concerned about how those underscores are going to render, looking at the preview below where I'm typing this)
And as for that PHP "foreach" thing, we have (for example)
for item in items
or
items.each do |item| # without index
items.each_with_index do |item, index| # with
depending on your preference.
* I think the list of languages in which I've done some serious development is something like: COBOL, PL/1, C, C++, C#, MS Basic, VB/VBA, Pascal/Delphi, Python, Ruby. I've dabbled in others, but not enough to really have a proper appreciation. In the functional and LISP-derived language areas I am aware that I have, so far, missed something.
for key,value in hash
in Ruby. Doesn't work with arrays (don't know why). - Jules
5.times {...}
blows your mind, I recommend you take a peek at Smalltalk. It isn't necessarily better, but since it is even "OOPier" than Ruby, you might find it interesting. - Oak
Delphi
For its readability. I have often been thrown into 10,000 line applications to fix bugs and other problems. With Delphi I can almost read the code like a book. Makes it easy to find and fix the problems.
For its adaptability. Out of the box you can put together Desktop, Client/Server, N-Tier, Web servers, COM objects, etc., etc., etc. From anonymous methods and generics to inline assembly language. It hasn't failed me yet after 15 years of intensive use. And I can still compile and run applications that were implemented in Delphi 1 15 years ago!
For its sheer productivity! I personally believe that Delphi gives me almost a 2 to 1 advantage over other language platforms in developing almost any kind of application. That converts into dollars in my pocket pretty quickly. And for one company that I worked for, it was instrumental in moving them into the top tier of companies in their field in just a few years because of their ability to respond to changing market conditions.
Larry Drews TheSoftwareRonin
Delphi is my favorite for Windows RAD. Apps compile into a single file executable, no additional runtime files required.
C. For lack of "features". What you C is what you get.
OCaml, its killer feature might be pattern matching. It makes your program very readable :
let rec fact = fun
| 0 -> 1
| n -> n*fact (n-1)
;;
let rec filter predicate = fun
| [] -> []
| h::q when predicate h -> h::(filter predicate q)
| h::q->(filter predicate q)
;;
Ok sorry for that :
So the first function describe the blockbuster factorial function. It's implemented recursively.
So the first function should be read :
*(l.1)* **let** **fact** be a **fun**ction defined **rec**ursively as :
*(l.2)* when given **0** as an argument, returns **1**
*(l.3)* when given **n** as an argument, returns **n-1**
n * fact (n - 1)
? - Svante
Closures
def adder(x):
return lambda y: x+y
add5 = adder(5)
add5(1)
6
List Comprehensions
numbers = [1,2,3,4,5]
squared = [x **2 for x in numbers]
Functional Tools
squared = map(lambda x: x**2, numbers)
Simple syntax that is easy to read and understand. Slicing.
var favourite = languages.Where(lang =>
lang.Keywords.Contains("yield return")
).FirstOrDefault();
I have recently begun playing with Haskell [1], and as Paul mentioned about OCaml, the pattern matching is really nice. Another thing I like about Haskell is the incredibly compact and beautiful list definitions, such as
[a | a<-[1..], a `mod` 3 == 0]
which creates an infinite list of all integers evenly divisible by three. The lazy evaluation [2] (which allows the operations on infinite lists, and much more) takes a while to get used to though. I'm still quite confused about it.
[1] http://en.wikipedia.org/wiki/Haskell_(programming_language)As I've recently started to rank all the major programming languages according to their pulling power [1], my favourite would have to be an obviously female-attracting language like Delphi: elegant and friendly, using proper words instead of resorting to pointless grunty man-squiggles, yet instinctively practical and not at all like frilly, ditzy, slow-to-react Ruby - the only language actually to be coloured pink.
At the other end of the spectrum, there are old favourites like Fortran, which is hopelessly male but in a pleasant pipe-smoking, GWR steam engine, leather elbow patches sort of way that reminds me of my Dad.
On a more serious note, see my answer about the extraordinary language Q [2].
[1] http://www.simple-talk.com/opinion/geek-of-the-week/verity-stob-geek-of-the-week/Delphi for Web Apps, Desktop Apps, Service Apps, DLLs, .Net libs, Game Development, Mobile Development and hopefully soon Mac & Linux development (again), FTW!
At the risk of getting downvoted :), I'll say "Perl 6". Yes, I know it's not in alpha yet, but it's getting closer all of the time. My favorite features? Too many to count, but here are a few:
Subtypes:
subtype PosInt of Int where { $_ > 0 }
Roles:
Known to many as traits [1], they solve many class composition problems.
Junctions (they're automatically parallelizable, too):
if ( $role eq 'manager' | 'consultant' ) { ... }
A mutable grammar allowing for much more powerful macros than what one sees in other languages.
There's plenty more and I fully expect an alpha out by next year.
[1] http://www.iam.unibe.ch/~scg/Research/Traits/F-Script, a SmallTalk-like language that has serious array programming features, and can be used to script Cocoa applications.
Say that you have a list of person objects that have properties like name and date of birth:
persons := {person1, person2, person3}.
We can get their names like this:
persons name.
which would return:
{'Phil', 'Anna', 'Sam'}
and then we could find out who was the oldest by doing this:
(persons at: (persons dateOfBirth ! persons dateOfBirth \ #max:)) name.
which might return
{'Phil'}
F-Script has an amazingly powerful feature set for working with arrays of objects. The killer feature is that any message sent to an array are passed to the objects in the array, and the return value is an array of the return values of that message (the exception is messages that the array implements, such as at:
). So persons name
above passes the message name
to each element in the persons
array and returns an array with all the names.
The second example shows the level of terseness. Basically what it does is that it finds the largest date of birth by reducing the array returned by persons dateOfBirth
with max:
, yielding the largest date. Then it checks each element in a identical array if that element is not equal (!
) to that date, yielding an array of boolean values. at:
can take an index, an array of indices or an array of booleans (where true
would include the element at that index), so passing it the return from the last expression will return only the element whose dateOfBirth
was the largest. Finally the message name
is passed to the retults, returning an array with the name of the only object left.
I don't program in F-Script very much, but I find it a very nice language. For working with large sets of objects that need to be searched, sorted, filtered or joined in different ways I find it extremely terse and powerful. It's like combining SQL with SmallTalk.
I grew up writing PHP and Perl, and Ruby really strikes me as a purer, cleaner version of Perl. Its best feature is how it makes functional programming second nature while still maintaining the "everything is an object" mentality.
Ada
It has full rich and portable concurrency support.
Delphi for .Net / Delphi Prism for unmanaged exports [1], which lets you consume managed assemblies from native code just like any .DLL without requiring .Net interop.
[1] http://blogs.embarcadero.com/timjarvis/2006/11/10/29270In C++ I like that I can still use pointers directly and still have the higher level functionality of classes.
In Python, I really, really like tuples. They are really handy.
In statically typed languages I keep finding myself wanting dynamic typing, but in dynamically typed languages I wish there were a way to statically type some things (particularly function parameters). It's a no win situation.
def f(x): if not isinstance(x, int): raise TypeError()
- new123456
Right now
Who is master: You or the language? You or the compiler? Why continue to bow down to the needs, whims and quirks of an awkward syntax, a finnicky compiler, a static language core? Enough of that. Write Ruby, be happy.
Ruby was built from the ground up with the primary goal of making programmers happy. Ruby makes programming enjoyable, a delight. Ruby gets out of your way, so you can go straight from idea to functional demo as quickly as possible. Ruby is your ally, not your enemy. You do not wrestle with Ruby, Ruby judo throws your problems to the mat and makes them slap it while crying for submission. Ruby was designed for maximum intuitivess; least surprise. Ruby boasts a marvellous consistency and arms you to the teeth with enough standard-library [1], introspective [2], metaprogramming [3], ZOMG-I-Can't-Believe [4]- How-Many-Ruby-Projects [5]- Have-Been-Written-Already [6] ordnance to outshoot Clint Eastwood, Rambo, and Chuck Norris combined. With one hand. On a foreign language keyboard.
I dance with Ruby every day [7]:
[1] http://ruby-doc.org/stdlib/My programming language is my dance partner. She is supple, flexible, versatile, graceful, elegant, powerful, agile, and a delight to the eyes. With only the slightest expression on my part, she knows what I intend, and, without question or resistance, moves with me in perfect harmony. When we dance, I know neither frustration nor surprise; every moment brings only joy.
Smalltalk: write code while your program is running, no compile cycle at all!
I really do not understand why no other language offers this!? Ruby and Python could both offer this feature, but alas no one has done that yet.
My favorite language is Java, mostly because of the great community support and support for multithreading and synchronization.
Also, Java does have its own 'foreach'.
public void foo(String[] a) {
for(String s : a) {
//do stuff
}
}
Weird syntax, I admit. But essentially does the same thing.
I love C++, The pointers and other stuff like the templates etc, are just so powerful. And i am surprised not many people have put in C++. I accept there are languages which make programming easy, but then when you really want to program i guess C++ stands out.
C# Rules!!
Good programmers write FORTRAN.
Really good programmers write FORTRAN in any language.
Not only is it both flexible and elegant, it is the lingua franca of Computer Science.
The combination of Object-Oriented and Functional paradigms without too much work to switch.
Clearly this depends on what you're doing. For web-based apps, I can't go passed the Javascript + PHP combination. Here's why:
Javascript: Built into the browser and gives you complete control over the UI. There is no client-side plug-in required and can use AJAX on-demand to talk to the server.
PHP: Easy creation and manipulation of trees and hashes, is fast, doesn't enforce a specific programming technique or style and has fantastic online documentation.
Common Lisp
Almost all new and shiny things in today's new languages are already there.
Java.
Killer features:
What sucks:
Edit: "Static typing" seems kinda weird as a killer feature. I guess I'm just opposing it to python, which is my 2nd favourite language
I'm happy with C and C++. The language that amazed at first impression was definitely Smalltalk. Coming from crude static languages such as C, or from the dark pits of x86 assembly, the dynamic and totally alive environment sensation that Smalltalk brings to the programmer is really outstanding.
C++ is a beast, is ugly, with non-orthogonal syntax, pitfalls everywhere, undefined behaviour here and there... but who can deny offers you (probably) a range of features and flexibility not available in most languages.
I like assembly very much, altough the x86 is a complicated beast to program compared to cleaner designs like MIPS.
Groovy [1] because of GroovyMarkup [2]. It's awesome to be able to represent code and documents using the exact same syntax. Also, because it adds great syntax sugar to Java.
Io [3] because of the simple, clean syntax [4] and that it has no keywords.
[1] http://groovy.codehaus.org/C#, for a number of reasons.
Type safety, full support for objects, extension methods, terseness, and a very rigorous compiler that doesn't let me get away with sloppy habits that I got used to as a Visual Basic programmer.
In my mind, however, C# is like Java, C, and Visual Basic merged together into a beautiful language with incredible power and flexibility. And, as an open standard, it shows promise as a cross-platform language (though that's not been fully realized yet).
Base[] barr = some_array_of_Derived; barr[0] = another_derived_type
- the compiler will miss this (and there's nothing it can really do), and you get a run time exception. Safe, but not quite as much as I'd like. - Thanatos
ActionScript and FLEX. With 95% penetration, it gives me the opportunity to create consistent client-agnostic applications that can provide extremely rich and highly interactive content in most web browsers - which I would never be able to do using any other mechanism...
C#
killer feature: type safety.
C++.
Other languages, with modern compilers, can be almost as fast as C++. I make my living at being faster than "almost."
Delphi, for the reasons I mentioned here: Is Delphi a good language to learn? [1]
[1] http://stackoverflow.com/questions/2104046/is-delphi-a-good-language-to-learn/2104835#2104835F#; it's a marvelously object-functional language like Lisp (which I love), but is also statically typed (which I also love). However the killer feature is auto-generics and insanely awesome type inference to go along with it.
All programming languages.
The killer feature is that they make your brain work.
My experience is still kinda limited. I have done some VB (6 and .NET) and now work in C#..
I have to say I find the syntax of C# a hell of a lot cleaner than VB, I look at some VB now and it really offends my eyes.
As already stated, a lot of the "goodness" that is C# really comes from the .NET framework and the environment.. We quickly see a lot of the benefits of dynamic languages coming to the static language world due to some awesome compiler "magic" (e.g. the "var" keyword).
That said, once I am done with this lame MCAD and have more experience, I look forward to expanding my knowledge of languages and looking into more functional and dynamic languages :)
A programming language is a tool which suits good for a limited set of tasks and everyone probably has several favorite languages, like a favorite language per programming paradigm (LISP or scheme for functional programming, C for imperative, C++ for Object-oriented etc) and/or favorite language per task(C or C++ for embedded system developing PHP or C# for Web developing).
Speaking about handy features... I really like generators in Python, you write a generator once and then can use and reuse it hundreds of times. Once you've written your generator you can focus on what to do with each item it produces and never bother yourself again with how to get an item.
Templates in C++ are also great, using them your can also express general ideas once and for all. STL is a good example of templates usage.
Unification. I don't have a favorite language, but I do like Prolog's unification. It is a powerful tool and it is frustrating to not have it in the other languages I program in. As others have pointed out, pattern matching is nice. But unification is even better.
PowerBuilder!
The datawindow is an absolute killer for UI development.
Though no serious development happens on this platform for various reasons, it was one of the first languages I worked with and I still find that it has some features which are unavailable in other major UI devlopment RAD tools.
using (MyClass myObject = new MyClass()) { // do something }
is even easier that RAII. - EricSchaefer
using
puts the cleanup responsibility on the user of the class, rather than the designer of the class. In C++, the default behaviour of allocating an fstream
on the stack is the correct behaviour. In C#, if I don't remember put a FileStream
in a using
statement, it can keep that file locked for some indeterminate period of time. - Eclipse
using
statement and it didn't hasn't been garbage collected yet. C++ does away with many common cases of the manual release of resources through deterministic destruction. - Thanatos
C++ is my primary language. Its killer feature is that it lets you touch the low-level details, while still managing to be a portable high-level language. If you know what you're doing, this lets you write well-designed, maintainable applications that are portably efficient with minimal human suffering. (note that the "if" requirement applies to all of the above...)
Haskell is my new favorite language. It has lots of really nice features, but the genuine killer feature is the type system. Haskell's type inference removes the need for most type declarations, while providing the full debugging and performance benefit of strong, static typing. And, its type class system makes C++ templates look sick and pale by comparison. (you still have to know what you're doing, though...)
Haskell's well-known laziness is an interesting feature IMHO, useful and annoying by turns. But it is nowhere near as impressive as its type system.
Perl for its first class support of regular expressions, CPAN, and the fact that it doesn't force any specific programming style on you.
Perl.
Killer feature: Regular expression and a lot of library support at CPAN
Scheme:
I really love the simplicity.. and perhaps, the fact that we can use special characters in variables name..
(define (smaller? x y) (< x y))
(if (smaller? 3 4) (do that))
In python (and other languages):
I really like to be able to use a list on-the-fly whenever I want without losing time and space doing vector ...; I just use li = [1 2 3].
In C# and Java:
I really love the fact that whenever you need something quickly, there's a library that's already been tested somewhere. I remember when I needed to quickly find a way to encrypt password.. it took me what.. 10min? Google, download, paste, install, test.
In Bash:
I really like the historic part.. there're so many hacks everywhere.. anytime I see a new hack, I learn a little bit more about the history of unix :) I also really like the fact that my console is in itself a programming language.. To be more precise on that, I like to be able to code even if I'm not creating a script.. sometime I just want to move files, or search a pattern, or unzip lots of file.. but still, I'll use a for loop. (Instead of selecting, and right+click unzip, etc.)
Finally, C/C++:
I know that performance is not really important for many apps.. however, when you need to really have control of what your code is doing, those languages are awesome. Everything was written with performance.. there's not a push_front method for vectors.. guess why? because it would make the insertion slower. (Even if we can still insert in the begining with an inserter.. :-)
English why?-pick your own interpretation
Java
Delphi
Because of what has been said and it's the fastest and easiest way (and the only one I think) to build native win32 application - and then, in a future version win64 as they said...
Delphi.
Class as a value. The great feature for all construction patterns (like Factory). You can have a variabe holding not a values of some type but a reference to type.
type
TSomeContainer = class
ElementType : TClass;
function NewNode: TObject;
end
function TSomeContainer.NewNode;
begin
Result := ElementType.Create;
// in C#/Java it would be like
// Result = new ElementType()
// but ElementType is a variable that can reference any type
end;
var
container : TSomeContainer;
e : TObject;
begin
...
myContainer.ElementType := TButton;
e := myContainer.NewNode;
// now e containes a TButton object
end
No need for separete class factory type or generic class.
Delphi!
Serious answer: Q [1], a very powerful proprietary language aimed primarily at financial programming. It's a descendant of the K language [2], and is inextricably linked to the kdb+ database [3]. There is an abridged language manual online [4].
Probably its main killer feature is extreme expressiveness. Because of this, a few lines of code can often solve complex analytic challenges with simplicity and elegance.
The following program fragment shows some elements of Q's expressiveness. It reads a CSV file of time-stamped symbols and prices, places the data into a database table and computes the maximum price for each day. It then opens a socket connection to a q process on another machine and retrieves a similar daily aggregate. Finally, it merges the two intermediate tables and appends the result to an existing file.
sample:{
t:("DSF";enlist ",") 0: `:c:/q/data/px.csv;
tmpx:select mpx:max Price by Date,Sym from t;
h:hopen `:aerowing:5042;
rtmpx:h "select mpx:max Price by Date,Sym from tpx";
hclose h;
.[`:c:/q/data/tpx.dat;();,;rtmpx,tmpx]}
One reason why expressiveness is a killer feature is because the (interpreted) code sits comfortably in L1 cache, which means that it executes really fast. I'll try and dig out a benchmark from Google - but I do mean extraordinarily fast.
Another reason why expressiveness is a killer feature is because it's much easier (at least for me) to understand and verify a small amount of code than some bloated OO hierarchy. A code review of the above fragment is much easier than the equivalent 50-100 lines in, for example, C#.
On a less serious note, see my answer here [5].
[1] http://en.wikipedia.org/wiki/Q_%28programming_language_from_Kx_Systems%29I like R
because it's a functional language:
adder <- function(x) {
function(y) { x + y }
}
adder(5)(3)
8
So, adder
is a function of x that returns a function.
Although I like Python too, in this case I prefer R's syntax. Because Python has this artificial distinction between def
and lambda
, although both just define a function:
def adder(x):
return lambda y: x+y
adder(5)(3)
8
The killer features here are first-class functions and function closures. Here are some interesting things you can do:
"Classes":
var createCounter = function () {
var i = 0;
return function () {
return ++i;
};
}
var c = createCounter();
c(); // 1
c(); // 2
var d = createCounter();
d(); // 1
.
var Car = function (name) {
// Private
var on = false;
var speed = 0;
var adjustSpeedometer = function (rpm) {
speed = rpm * 60 * 20 / 12 * 5280;
};
return {
// Public
'turnOn': function () { on = true; },
'getName': function () { return name; }
'setName': function (n) { name = n; }
}
};
var a = Car('A');
var b = Car('B');
a.turnOn();
Currying/Partial Application:
function greet(greeting, name) {
alert(greeting + ' ' + name);
}
var createGreetForPerson = function (name) {
return function (greeting) {
greet(greeting, name);
};
}
var createGreetWithGreeting = function (greeting) {
return function (name) {
greet(greeting, name);
};
}
greet('Hello', 'world'); // Hello world
var greetWithHello = createGreetWithGreeting('Hello');
greetWithHello('Bob'); // Hello Bob
greetWithHello('world'); // Hello world
var greetWorld = createGreetForPerson('world');
greetWorld('Hello'); // Hello world
greetWorld('Good morning'); // Good morning world
Please do add more!
I don't have a favorite programming language, just a flavor-of-the-month, since I'm an admitted language junky.
Right now that flavor is REBOL. Its killer feature is easy creation of domain specific languages, also known as "dialects". REBOL doesn't have a feature? Easy: make a dialect to do it.
Dialects are created by passing a block (a chunk of REBOL delimited by square brackets) to the parse
command, followed directly by another black containing the rules for parsing the block. Here's a silly example:
print-times: func [b [block!] /local rules r i] [
rules: [
'print
set r any-type!
set i integer!
'times
]
if not parse b rules [
make error! "Dang it! Bad syntax!"
]
repeat n i [ print r ]
]
print-times [print "StackOverflow" 20 times]
Alright, so no one's likely to create such a dialect, but they are amazingly useful. For example, REBOL has no list comprehensions [1], but you can use a REBOL dialect to remedy that fact. (I've done just that thing.)
[1] http://en.wikipedia.org/wiki/List_comprehensionI regulary come back to AWK. It's "killer feature" certainly is the "{...}" operator/environment/w.d.y.c.i.
Its really cross platform when it comes to server-side.
I've developed applications in WinXP machine with 1 gb of ram and deployed on HP900 superdome with 16 gb or ram without chaning a single line of code.
Client side has been improved but still not cross platform.
Python has some killer directory/file traversal techniques which I loved when I was developing in it the other week.
Mine used to be C#, mainly because on Visual Studio's awesome graphical editor for making king Windows forms apps. But now that I'm using it at my day job, there is a lot I really dislike. It has lots of new-fangled "wow" features, like generics, linq, attributes, etc... but they all seem to be riddled with caveots, inconsistancies, and just odd design decisions... plus so many of the good add-on libraries are for-pay, not as much open-source stuff out there.
Now I'm back to really liking Java again, due primarily to:
php
runs just about anywhere
in the wild!
REALbasic is my favorite language. It's killer feature is that it is by far the easiest way to create a cross-platform desktop application. I love being able to develop on Mac OS X, but deploy to Windows when necessary.
I'm not aware of any killer feature in the language right now, but it did have extension methods years before C# 3.0 did!
I would vouch for javascript, the reasons being easier learning curve than many other languages Not many changes to the core features apart from new tools and plugins being added
Killer Feature: Its source code is neat & clean and doesn't turn into bracket soup.
Haskell, call-by-need evaluation.
Whenever I use a language other than C++ (and obvious cousins), I keep finding myself saying, "If I had access to the pointers, I could do this way easier."
No one has made a stand for VB so I will! (well, .Net framework at least)
ForEach loops, puh-lease!
ForEach item As String In ListOfStrings
'stuff'
Next
People bag out VB.Net (or just MS in general). But in my line of work, we get judged on time-per-feature, so the less time working on pointer arithmetic the better I say!
Delphi is the best. That is all.
Visual Basic 6
It has everything that a developer will ever want. It is very easy to learn and use. In fact it is so easy that one feels completely at home in just a few hours.
It IDE just the best. It is said to have standards for even driven programming in the times when procedure based programming ruled the programming world.
It is object oriented. One can develop a simple one window program without writing one single line of code.
It does have runtime but Microsoft even today ships the runtime for VB 5 and VB 6 in all windows versions.
It is the only true Host for ActiveX and COM objects. All other languages cannot host ActiveX and COM objects without first importing them and then wrapping them which according to me is a pain in the neck at all times. Even the latest version of .NET does not support all features of ActiveX/COM.
There is a very big industry which is still developing ActiveX. VB is the only language that has probably the worlds largest component/control writers in the world.
Even MS is still developing COM objects in Windows so that others can easily use Windows services.
VB is also suitable for prototyping and such tasks and it is very easy to convert a prototype to a production software very easily.
Finally if it were not for VB then Windows will not have been as popular as it is today. After all any OS is as good as the number of applications available for it. If Apple has released such a development tool for their Mac OS probably it would have had better acceptance then it has today.
Even after being discontinued by MS it is still the most widely used development language in the world.
foreach
was partially copied from Perl. The original implementation of PHP was done in Perl. - Brad Gilbertforeach
loop? - Ken