30

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?

8
  • 2
    Good question. Is there any other field where one generation has given so much of value to the next?
    – harpo
    May 15, 2010 at 6:42
  • It's actually not the 'language itself' that takes care of garbage collection. This is done at program execution, e.g. by a virtual machine. May 15, 2010 at 6:47
  • @chris: I stand corrected, edits in progress.
    – yretuta
    May 15, 2010 at 7:07
  • 18
    This question is better suited to be a community wiki.
    – Xavier Ho
    May 15, 2010 at 7:54
  • 3
    Some of the answers below are turning me into a Smug Lisp Weenie... a good time to be reminded of the computing industry's short memory, I suppose. May 18, 2010 at 12:34

27 Answers 27

22

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.

5
  • 3
    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
    May 15, 2010 at 7:56
  • @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
    May 15, 2010 at 14:54
  • 2
    @Jim: I mentioned this in the answer. May 15, 2010 at 17:50
  • 1
    @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. May 18, 2010 at 11:56
  • 1
    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. May 18, 2010 at 12:32
15

I think writing machine code deserves a mention.

3
  • Some disagree though: grc.com/smgassembly.htm
    – Jeff Moser
    May 24, 2010 at 20:43
  • @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
    May 25, 2010 at 14:57
  • 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
    May 25, 2010 at 19:57
14

Data collections

Hash tables, linked lists, resizable arrays, etc

All these had to be done by hand before.

3
  • Definitely! It is related to a language because a language doesn't come empty, it comes with a standard library
    – user90843
    May 15, 2010 at 8:14
  • 1
    Also, some modern languages have built-in data structures (e.g. Python).
    – Edan Maor
    May 15, 2010 at 14:51
  • 1
    Every sane language has the "array of characters" built-in data structure, better known as a string.
    – MSalters
    May 18, 2010 at 12:05
12

Iteration over a collection:

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

Database access, look at the ActiveRecord pattern in Ruby.

The evil goto.

1
  • 3
    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
    May 15, 2010 at 7:22
11

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.

1
9

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"

4
  • 1
    ... and it goes much further, think of threading issues, multicast delegates etc. May 15, 2010 at 17:52
  • 1
    GTK has this pretty well nailed too.
    – detly
    May 18, 2010 at 11:54
  • Sometimes I really wonder if that's an improvement... :-) May 19, 2010 at 18:17
  • Events have a long way to go yet.. May 24, 2010 at 20:42
8

Line Numbers

No more BASIC, no more Card Decks!

0
8
  • 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

1
  • 3
    +1 for Properties. Man I love Properties.
    – echo
    May 15, 2010 at 7:08
8

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.

4

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")
2

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.)

2

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

6
  • 3
    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.
    – user90843
    May 15, 2010 at 8:12
  • 1
    I didn't say static typing sucks. You misunderstood. :]
    – Xavier Ho
    May 15, 2010 at 8:30
  • @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
    May 24, 2010 at 20:57
  • @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.
    – user90843
    May 25, 2010 at 4:01
  • 1
    @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
    May 25, 2010 at 4:39
2

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!

3
  • what language was it? where you manually had to write this?
    – yretuta
    May 22, 2010 at 1:07
  • Are you familiar with GOSUB?
    – Gabe
    May 24, 2010 at 20:43
  • @Gabe, Ha, yeah. I forgot of this "missing link" between assembly and functions ;-)
    – liori
    May 24, 2010 at 23:13
2

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.

1
  • 4
    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. May 19, 2010 at 18:19
1

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.

1

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.

5
  • 1
    there's no native support, as a language construct, there's just an API, not that revolutionary IMO
    – user90843
    May 15, 2010 at 8:10
  • 1
    There is some native support, namely synchronized. (Also, the whole of java.lang is arguably part of the language.) May 18, 2010 at 12:31
  • @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
    May 24, 2010 at 21:06
  • lock/synchronized isn't that big, really, it's just syntax sugar around a monitor
    – user90843
    May 25, 2010 at 3:53
  • @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
    May 25, 2010 at 4:27
1

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.

1

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..

7
  • C# has type inference too, using the var keyword.
    – Coxy
    May 18, 2010 at 12:44
  • Actually you can do the same in C# using: var length = ComputeLength(new Vector3f(x,y,z));
    – Wysawyg
    May 18, 2010 at 12:47
  • @coxymla and Wysawyg: Yes but only with C# 3.0. Well I replaced C# with Java so it's less arguable.
    – elmattic
    May 18, 2010 at 13:27
  • and C++0x with auto (I'm kind of hoping they lifted the name from B)
    – McBeth
    May 18, 2010 at 13:42
  • 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. May 19, 2010 at 18:22
1

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.

0

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.

0

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

1
  • any examples? hehe. just hoping
    – yretuta
    May 22, 2010 at 1:08
0

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.

0
0

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.

0

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.

0

How about built-in debuggers?

How many here remember "The good old days" when he had to add print-lines all over the program to figure out what was happening?

-1

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.

3
  • Maybe the mention of java's downsides is too much for some. I wonder, why no upvotes?
    – Cheery
    May 21, 2010 at 10:47
  • "Stupidity" is not a programming concept. You find stupidity in all fields, not just programming.
    – Gabe
    May 24, 2010 at 20:46
  • 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
    May 25, 2010 at 5:38
-2

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.

1
  • I don't know VB or how its implemented so some aspect may be useful but that looks horrible. Oct 21, 2010 at 17:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.