views:

1087

answers:

26

Weird question but here it is. What are the programming concepts that were "automated" by modern languages? What I mean are the concepts you had to manually do before. Here is an example: I have just read that in C, you manually do garbage collection; with "modern" languages however, the compiler/interpreter/language itself takes care of it. Do you know of any other, or there aren't any more?

+16  A: 

Optimizations.

For the longest time, it was necessary to do this by hand. Now most compilers can do it infinitely better than any human ever could.

Note: This is not to say that hand-optimizations aren't still done, as pointed out in the comments. I'm merely saying that a number of optimizations that used to be done by hand are automatic now.

George Edison
That's not that true. It depends hugely on your architecture. Exploiting certain kinds of parallelism, in particular, is one thing that compilers don't really do implicitly. That's not to say that compilers aren't generally a lot better at optimizing code than they used to, but having to optimize by hand is certainly not dead and gone.
Jimmeh
@Jimmeh - It's not that they don't do optimizations so much as this is a new age of parallelism, which brings a whole new area you can optimize.
Edan Maor
@Jim: I mentioned this in the answer.
George Edison
@Jimmeh: I'd say even that depends. Languages like Erlang for example (in fact most functional languages that can mark an invocation as pure), and to a lesser extent libraries like fork-join in other languages, will handle the parallelisation for you (so long as your code matches the idioms they are looking for). And in the spirit of the question, this is done much more efficiently and correctly than a typical human implementation.
Andrzej Doyle
This is true in the sense that compilers get better, in general, kinda-sorta, over time, if you're lucky. And don't move to a higher level language too frequently. On the other hand, the first successful compiled language was FORTRAN, which became successful precisely because of its... optimizing compiler.
Derrick Turk
+13  A: 

Data collections

Hash tables, linked lists, resizable arrays, etc

All these had to be done by hand before.

Gart
Definitely! It is related to a language because a language doesn't come empty, it comes with a standard library
Ion Todirel
Also, some modern languages have built-in data structures (e.g. Python).
Edan Maor
Every sane language has the "array of characters" built-in data structure, better known as a string.
MSalters
+7  A: 

Line Numbers

No more BASIC, no more Card Decks!

Will Hartung
no more goto :)
Ion Todirel
+2  A: 

If you go back to assembly you could find many more, like the concept of classes, which you could mimic to a certain extent, were quite difficult to achieve... or even having multiple statements in a single line, like saying "int c = 5 + 10 / 20;" is actually many different "instructions" put into a single line.

Pretty much anything you can think of beyond simple assembly (concepts such as scope, inheritance & polymorphism, overloading, "operators" anything beyond your basic assembly are things that have been automated by modern languages, compilers and interpreters.)

DulabCMS
+14  A: 

I think writing machine code deserves a mention.

harpo
+1 Honerable mention!!!!!!
David Relihan
Some disagree though: http://www.grc.com/smgassembly.htm
Jeff Moser
@Jeff: With all due respect to Steve Gibson, this looks like the exception that proves the rule. (I admit, ChromaZone does sound really cool -- I'll check it out next time I'm on Windows 95.)
harpo
@harpo: I certainly don't do my daily program in assembly either, I just wanted to show that there were some folks that still use and prefer it for new Windows development even though it's been mostly "Automated" by newer languages :)
Jeff Moser
+9  A: 

Iteration over a collection:

foreach (string item in items)
{
    // Do item
}

Database access, look at the ActiveRecord pattern in Ruby.

The evil goto.

Ion Todirel
Yes! Foreach loop is one of the best control flows ever. I'm really happy they're finally bringing that into C++ in C++0x.
Xavier Ho
+8  A: 
  • First in list, extension method. Facilitates fluent programming

  • Exceptions, compartmentalization of what is the program trying to do (try block) and what it will do if something fail (catch block), makes for saner programming. Whereas before, you should be always in alert to intersperse error handling in between your program statements

  • Properties, makes the language very component-centric, very modern. But sadly that would make Java not modern.

  • Lambda, functions that captures variables. whereas before, we only have function pointer. This also precludes the need for nested function(Pascal has nested function)

  • Convenient looping on collection, i.e. foreach, whereas before you have to make a design pattern for obj->MoveNext, obj->Eof

  • goto-less programming using modern construct like break, continue, return. Whereas before, I remember in Turbo Pascal 5, there's no break continue, VB6 has Exit Do/For(analogous to break), but it doesn't have continue

  • C#-wise, I love the differentiation of out and ref, so the compiler can catch programming errors earlier

  • Reflection and attributes, making programs/components able to discover each other functionalities, and invoke them during runtime. Whereas in C language before (I don't know in modern C, been a long time not using C), this things are inconceivable

  • Remote method invocations, like WebServices, Remoting, WCF, RMI. Gone are the days of low-level TCP/IP plumbing for communication between computers

Michael Buen
+1 for Properties. Man I love Properties.
echo
+2  A: 

Some languages support Dynamic Typing, like Python! That is one of the best things ever (for certain fields of applications).

Xavier Ho
That's not true, arguably. And it doesn't replace a static type system, it's just a matter of preference. It's like saying helicopters sucks and jet packs ftw.
Ion Todirel
I didn't say static typing sucks. You misunderstood. `:]`
Xavier Ho
@Ion Todirel, Dynamic Typing is a replacement for several things you must do by hand in statically typed languages. For example, without generics, you must manually cast. With dynamic typing, you don't. With static typing and generics, you have to mess around with type parameters which can get really complicated in some cases. In extreme cases, reflection can be used instead of generics to reduce the complexity, but then what you have is dynamic typing done by hand. All this complexity disappears with dynamic typing. So it is very true, unarguably. Your helicopter analogy does not apply here.
Jay
@Jay, agree, what I was trying to say is that the original point Xavier was making can be brought via static typing as well, hell with a type system in general. There are advantages and disadvantages with a dynamic or static type system. You can't possible go and say dynamic typing is better than static typing, that simple isn't true.
Ion Todirel
@Ion: When did I ever say dynamic typing was better than static typing?
Xavier Ho
@Ion Todirel, He never said dynamic typing was better than static typing. In fact, he said very explicitly "for certain fields of applications". You have not made a single valid point. If you feel so strongly about static typing, then add your own answer and explain to everyone why static typing is so awesome. Please don't post nonsense on other people's answers just because you don't like their opinions.
Jay
+10  A: 

Event System

Before you had to implement the Observer Pattern all by yourself. Today ( at least in .NET ) you can simply use "delegates" and "events"

KroaX
... and it goes much further, think of threading issues, multicast delegates etc.
Johannes Rudolph
GTK has this pretty well nailed too.
detly
Sometimes I really wonder if that's an improvement... :-)
Brian Knoblauch
Events have a long way to go yet..
BlueRaja - Danny Pflughoeft
+1  A: 

Also built-in functions for sorting(such as bubble sort,quick sort,....). Especially in Python 'containers' are a powerful data structures that in also in other high level and modern programming languages require a couple of lines to implement.You can find many examples of this kind in Python description.

Hossein
+1  A: 

Multithreading

Native support for multithreading in the language (like in java) makes it more "natural" than adding it as an external lib (e.g. posix thread layer in C). It helps in understanding the concept because there are many examples, documentation, and tools available.

kabado
there's no native support, as a language construct, there's just an API, not that revolutionary IMO
Ion Todirel
There is some native support, namely `synchronized`. (Also, the whole of `java.lang` is arguably part of the language.)
Donal Fellows
@Ion Todirel, Some programming languages have message passing built-in that would need to be written manually otherwise. Take a look at Google's Go, or Erlang for examples. Also, when concurrency is not built-into the language, it is difficult to guarantee correctness since the compiler doesn't know about it and my reorder instructions that would otherwise be okay in a non-concurrent program. This is why some people want concurrency added to C++0x.
Jay
lock/synchronized isn't that big, really, it's just syntax sugar around a monitor
Ion Todirel
@Ion Todirel, Yes it is a big deal. Java's synchronized blocks frees the programmer from explicitly releasing a lock. This both simplifies the code and prevents bugs due to accidentally forgetting to release a lock. It is much more than a minor feature. It was quite a revolutionary idea, and other programing languages since then have added this feature. You could say every programming language is syntax sugar around lambda calculus. That doesn't mean everything besides pure lambda calculus insignificant and not a big deal.
Jay
+1  A: 

dynamic library

dynamic libraries automatically share common code between processes, saving RAM and speed up starting time.

plugins

a very clean and efficient way to extend functionality.

kabado
A: 

Data Binding. Sure cuts down on wiring to manually shuffle data in and out of UI elements.

Eric J.
any examples? hehe. just hoping
Ygam
A: 

Stupidity

That's a thing I've gotten lot of help from modern programming languages. Some programming languages are a mess to start with so you don't need to spend effort to shuffle things around without reason. Good modern libraries enforce stupidity through forcing the programmer inside their framework and writing redundant code. Java especially helps me enormously in stupidity by forcing me inside OOPS box.

Cheery
Why the downvotes?
Pindatjuh
Maybe the mention of java's downsides is too much for some. I wonder, why no upvotes?
Cheery
"Stupidity" is not a programming concept. You find stupidity in all fields, not just programming.
Gabe
Indistinguishable from many programming concepts however. People are able to write more spaghetti code than ever before despite abolishment of goto. Software patterns help idiots in writing code that makes up no structure.
Cheery
+6  A: 

Declarations

In single-pass-compiler languages like C and C++, declarations had to precede usage of a function. More modern languages use multi-pass compilers and don't need declarations anymore. Unfortunately, C and C++ were defined in such a poor way that they can't deprecate declarations now that multi-pass compilers are feasible.

MSalters
+2  A: 

Functions.

It used to be that you needed to manually put all the arguments to stack, jump to piece of code where you defined your function, then manually take care of its return values. Now you just write a function!

liori
what language was it? where you manually had to write this?
Ygam
‎A‎ss‎e‎‎m‎bly.
liori
Are you familiar with `GOSUB`?
Gabe
@Gabe, Ha, yeah. I forgot of this "missing link" between assembly and functions ;-)
liori
+1  A: 

Type inference

In languages like F# or Haskell, the compiler infers types, making programming task much easier:

Java: float length = ComputeLength(new Vector3f(x,y,z));

F#: let length = ComputeLength(new Vector3f(x,y,z))

Both program are equivalent and statically type. But F# compiler knows for instance that ComputeLength function returns a float so it automagically deduces the type of length, etc..

Stringer Bell
C# has type inference too, using the var keyword.
Coxy
Actually you can do the same in C# using:var length = ComputeLength(new Vector3f(x,y,z));
Wysawyg
@coxymla and Wysawyg: Yes but only with C# 3.0. Well I replaced C# with Java so it's less arguable.
Stringer Bell
and C++0x with auto (I'm kind of hoping they lifted the name from B)
McBeth
Another one that I think is just different. It might technically be "automated", but it's not necessarily an improvement. Type inference is nice in some situations, not so nice in some others.
Brian Knoblauch
@Brian Knoblauch: On which situation are you thinking of, when you telling this?
Stringer Bell
Type inference is really nice on smaller, rapidly developed applications because it saves time. Where it falls down is on maintainability of very large, complex, long running apps. The explicit types make it easier to track what's going on when debugging such enterprise apps. It also helps catch errors when refactoring methods. So, sometimes it's good, sometimes not, depends on your application.
Brian Knoblauch
A: 

OS shell Scripting, bash/sh/or even worse batch scripts can to a large extent be replaced with python/perl/ruby(especially for long scripts, less so at least currently for some of the core os stuff).

You can have most of the same ability throw out a few lines of script to glue stuff together while still working in a "real" programming language.

Roman A. Taycher
COBOL/CICS anyone? :-)
Brian Knoblauch
+1  A: 

Good String Types make you have to worry less about messing up your string code,

Most Languages other then c and occasionally c++ (depending on how c like they are being) have much nicer strings then c style arrays of char with a '\0' at the end (easier to work with a lot less worry about buffer overflows,ect.). C strings suck.

I probably have not worked with c strings enough to give such a harsh (ok not that harsh but I'd like to be harsher) but after reading this (especially the parts about saner seeming pascal string arrays which used the zeroth element to mark the length of the string), and a bunch of flamewars over which strcpy/strcat is better to use (the older strn* first security enhancement efforts, the openbsd strl*, or the microsoft str*_s) I just have come to really dislike them.

Roman A. Taycher
+2  A: 

Programming itself

With some modern IDE (e.g. Xcode/Interface Builder) a text editor or an address book is just a couple of clicks away.

mouviciel
I'll go along with the modern IDE advantages, but I don't know that I'd use Xcode/Interface Builder as my example as they're arguably one of the weaker IDEs out there.
Brian Knoblauch
+4  A: 

Pattern matching and match expressions

In modern languages you can use pattern matching which is more powerful than a switch statement, imbricated if statements of ternary operations:

E.g. this F# expression returns a string depending the value of myList:

match myList with
| []       -> "empty list"
| 2::3::tl -> "list starts with elements 2 and 3"
| _        -> "other kind of list"

in C# you would have to write such equivalent expression that is less readable/maintanable:

(myList.Count == 0) ? "empty list" :
   (myList[0] == 2 && myList[1] == 3 ? "list starts with elements 2 and 3" :
      "other kind of list")
Stringer Bell
+1  A: 

A whole bunch of the Design Patterns. Many of the design patterns, such as Observer (as KroaX mentioned), Command, Strategy, etc. exist to model first-class functions, and so many more languages have begun to support them natively. Some of the patterns related to other concepts, such as Lock and Iterator, have also been built into languages.

T.R.
A: 

Context Switching.
Most modern programming languages use the native threading model instead of cooperative threads. Cooperative threads had to actively yield control to let the next thread work, with native threads this is handled by the operating system.

As Example (pseudo code):

volatile bool run = true;
void thread1()
{
   while(run)
   {
      doHeavyWork();
      yield();
   }
}
void thread2()
{
   run = false;
}

On a cooperative system thread2 would never run without the yield() in the while loop.

josefx
A: 

Variable Typing

Ruby, Python and AS will let you declare variables without a type if that's what you want. Let me worry about whether this particular object's implementation of Print() is the right one, is what I say.

zaratustra
A: 

Auto Type Conversion.

This is something that I don`t even realize that language is doing to me, except when I got errors for wrong type conversion.

So, in modern languages you can:

Dim Test as integer = "12"

and everthing should work fine...

Try to do something like that in a C compiler for embedded programming for example. You have to manually convert all type conversions!!! That is a lot of work.

RHaguiuda
I don't know VB or how its implemented so some aspect may be useful but that looks horrible.
Roman A. Taycher
+7  A: 

Memory management, anybody? I know it's more efficient to allocate and deallocate your own memory explicitly, but it also leads to Buffer Overruns when it's not done correctly, and it's so time consuming - a number of modern languages will allocate and garbage collect automatically.

rwmnau
This should be #1, without question
BlueRaja - Danny Pflughoeft