Theresonly1 Posted July 10, 2008 Posted July 10, 2008 Hello. Im a computer scientist student in 3rd year uni and soon to be graduated then i'll be a qualified professional computer scientist. I was wondering is it bad or good to just learn/know 1 programming language? Throughout my years in uni so far ive been doing Java as my university is concentrating on Object Oriented. It is therefore my knowledge will be full of Object oriented programming techniques with Java once i leave uni to go out in the big world of working. Then this means in my opinion i will be restricted with just that one skill and knowledge of Java. :-( And when i get a job (hopefully) i will need to learn some new language & concepts (doubt people use java in organisation) totally new all again for that job. Huh..This is mad... looks like the things we learnt in education will go to garbage!!! So after all knowing one language.. I just want to hear view from lots of other people. Feel free to discuss!
bascule Posted July 10, 2008 Posted July 10, 2008 Learning only one programming language will severely limit your ability to program, particularly in the case of Java as the language is rather convoluted and incorporates paradigms developed in other languages in verbose and wonky ways. I'd recommend learning at least one low level language (e.g. C or assembly) to familiarize yourself with how CPUs actually execute instructions, and one high level language, particularly from the Lisp family (Scheme is a good choice) to familiarize yourself with functional programming. Once you've done this, you'll hopefully begin to see paradigms you learned from other languages translate into the one you're working in. Learning Erlang has dramatically changed how I write Ruby, for example. All that said, the Pragmatic Programmers (you should consider picking up their eponymous book) recommend learning one new language a year (although I doubt they've stuck to that themselves).
D H Posted July 10, 2008 Posted July 10, 2008 I agree with much of what bascule said except classifying C as low-level. Yes, you can imbed assembler code inside C, but hardly anyone does that. C is much closer to Java than it is to assembler. C is a purely procedural language. Java is an object-oriented langauge with a lot of procedural language with concepts and has a distinctively C-like syntax. If you want to learn assembler, learn assembler. This is not a bad idea, because in the end practically every programming language boils down to assembly. An exception to this are the old Lisp machines, but nobody uses them anymore. I recommend learning a language based on some other programming paradigm. For example, Lisp or Scheme for functional programming, Prolog or CLIPS for logic programming.
bascule Posted July 10, 2008 Posted July 10, 2008 C is much closer to Java than it is to assembler While both C and Java are regarded as third generation languages and asm regarded as a second generation language, I strongly disagree that C is closer to Java than it is to assembly. Java is a language which compiles to bytecode that runs on a virtual machine and provides garbage collection. There's no direct memory access whatsoever. This means that short of accidentally accumulating references you didn't mean to, Java programs won't leak memory or crash due to memory corruption. In this regard Java is a huge step forward over C or ASM. (language purists will regard this as a step first taken by Lisp) C is a language which exposes the least common denominator of CPU features at the language level, adds a stack, and does little more. For this reason C has been given the moniker "portable assembly". In addition to the language environment being sandboxed in a virtual machine with a garbage collector, there's the aforementioned object oriented programming with all its nifty bells and whistles like inheritance and polymorphism, which is a huge paradigm shift from C, as well as things like exceptions (which really need a garbage collector to be useful), and in Java 7, closures. Yes, finally Java will allow higher order functions and functions which enclose their lexical scope (both of which require a garbage collector to be useful)
D H Posted July 10, 2008 Posted July 10, 2008 (edited) In short, you don't like C on some religious basis. C is little different conceptually from Fortran, PL/I, Ada. Algol, Pascal, and other languages of the procedural/imperative programming paradigm. All have functions/procedures, arrays and pointers, structured programming, data structures. On top of these basic procedural/imperative programming concepts, C adds the ability to access memory absolutely (so does Ada, as do many other languages) and the ability to manipulate memory at a very low level. People who write device drivers appreciate the ability to access memory absolutely. Without this ability they would have to write their device drivers in assembly. Hardly anybody else ever uses this capability. The same goes for the ability to embed assembly language in C. Just because C adds the ability to access and operate on memory at a very low level does not mean C is a low-level language.. Very few people use these capabilities. To the vast majority of programmers, C is much closer to Java than it is to assembler. Edited to add Even Java (Java SDKs, to be precise) provides the ability to access memory absolutely. This ability is critical for writing device drivers, and that is exactly one of the things that Sun aimed for in developing Java. Edited July 10, 2008 by D H Even Java provides low-level capabilities!
Klaynos Posted July 10, 2008 Posted July 10, 2008 Once you've learnt one it is far easier to learn another, esspecially going object oriented -> object oriented.
Cap'n Refsmmat Posted July 10, 2008 Posted July 10, 2008 Yeah, at this point learning a new language for me has become a matter of learning the specific syntax and a few basic bits and then calling it good. The rest carries over from other languages.
D H Posted July 10, 2008 Posted July 10, 2008 Procedural/imperative languages are all pretty much the same. Layering object-oriented concepts on top oif a procedural/imperative language involves a slightly new style of thinking. Jumping to a completely different programming paradigm such as a functional or logical language involves a quite different style of thinking. The paradigm in part dictates the way one thinks and solves a problem. This is why it is a good idea to learn multiple languages and different programming paradigms. A linguist who knows only one spoken language is not much of a linguist. A linguist who knows only languages from one branch of one language family is not much of a linguist, either. A good linguist has some familiarity with languages from multiple language families. The same goes for computer scientists.
bascule Posted July 11, 2008 Posted July 11, 2008 (edited) Just because C adds the ability to access and operate on memory at a very low level does not mean C is a low-level language.[/i']. Here's an obfuscated example program to really drive this point home: #include <stdio.h> int main() { char *foo = "Hello, world!"; printf("%c\n", foo[1]); printf("%c\n", 1[foo]); printf("%c\n", *(foo + 1)); printf("%c\n", *(1 + foo)); } The four printf() statements you see are all doing the same thing: an addition operation, followed by a dereference. Because C's array[index] is just doing pointer arithmetic, it doesn't really care what array and index are, it just adds them together and dereferences the result. Because of that, index[myarray] is semantically equivalent to myarray[index]. This is one of many examples of how C is weakly typed. There's absolutely no runtime type checking on any operations you perform at all, and the compile time type checking is extremely limited (even compared to a language like C++) Procedural/imperative languages are all pretty much the same. That's not true at all. C has no data structures available as first class language constructs or in the standard library. Some procedural languages make things like dicts/hashes first class language constructs, others include them in the standard library. The only "data structure" C affords are contiguous blocks of memory that you can perform pointer arithmetic on to access various elements. Any other data structures will require a 3rd party library (e.g. glib) or you brewing your own. This is yet another example of why C is a low level language. Even Java (Java SDKs, to be precise) provides the ability to access memory absolutely. This ability is critical for writing device drivers, and that is exactly one of the things that Sun aimed for in developing Java. I don't think having a Foreign Function Interface (in Java's case, JNI) really says anything about the language environment in general, and shouldn't be a consideration when comparing language features (beyond: does it have an FFI?) It's not so much for device drivers as existing with existent C / C++ libraries. Java isn't a systems programming language... "device drivers" run in kernel context whereas Java runs in user context. The only exception might be something like the JavaStation (Sun's Java equivalent of a Lisp machine), but those flopped. Edited July 11, 2008 by bascule
D H Posted July 11, 2008 Posted July 11, 2008 (edited) The four printf() statements you see are all doing the same thing: an addition operation, followed by a dereference. Because C's array[index] is just doing pointer arithmetic, it doesn't really care what array and index are, it just adds them together and dereferences the result. Because of that, index[myarray] is semantically equivalent to myarray[index]. This is one of many examples of how C is weakly typed. The dereferenced value still has a type. In the case of your example, it is a char. The type depends on the underlying array type. C is not weakly typed in this regard. You just don't like the fact that 2[foo] can be used in lieu of foo[2]. "Doctor, it hurts when I do this." "Don't do that then." There's absolutely no runtime type checking on any operations you perform at all, and the compile time type checking is extremely limited (even compared to a language like C++) C is a statically typed language. It does compile time type checking, not runtime. yes, you can override the static type checking in C with a cast. Once again, "Don't do that then." C has no data structures available as first class language constructs or in the standard library. Some procedural languages make things like dicts/hashes first class language constructs, others include them in the standard library. The former statement makes me wonder if you have ever used C. Regarding the latter statement, most other languages from the era don't provide these constructs either. If the lack of hash tables makes a language equivalent to assembler, then that means that Ada, Fortran Pascal, PL/I, etc. are also equivalent to assembler. In short, you don't like C for religious reasons. You are among many who think C is bad for the environment, causes global warming, and kills puppies. Edited July 11, 2008 by D H
bascule Posted July 11, 2008 Posted July 11, 2008 C has no data structures available as first class language constructs or in the standard library. The former statement makes me wonder if you have ever used C. For the record: I used C as my primary programming language for over 10 years. Can you name one data structure in libc?
D H Posted July 11, 2008 Posted July 11, 2008 Can you name one data structure in libc? FILE (stdio.h), tm (time.h), div_t and ldiv_t (stdlib.h)
bascule Posted July 11, 2008 Posted July 11, 2008 FILE (stdio.h), tm (time.h), div_t and ldiv_t (stdlib.h) You're confusing abstract data types with data structures. Data structures allow you to structure data within your application. Some examples of data structures: arrays, lists, dicts/hashes, binary trees, red black trees, b-trees, skip lists.
D H Posted July 11, 2008 Posted July 11, 2008 You're confusing abstract data types with data structures. Data structures allow you to structure data within your application. Some examples of data structures: arrays, lists, dicts/hashes, binary trees, red black trees, b-trees, skip lists. Arrays are "data structures" and data structures (i.e., structures) are not? Please! C, like most procedural/imperative languages of its time, provides built-in support for arrays and user-defined data structures. C, like most procedural/imperative languages of its time, provides no support for generic data structures such as hashes, b-trees, etc. If that is your main gripe against C, it also applies to Ada, Fortran, Pascal, PL/I. Those languages are not assembler. Programming in assembler requires a different mode of thinking than programming in one of those 1956-1990 era procedural/imperative languages.
bascule Posted July 11, 2008 Posted July 11, 2008 Arrays are "data structures" and data structures (i.e., structures) are not? Please! As I said earlier: The only "data structure" C affords are contiguous blocks of memory that you can perform pointer arithmetic on to access various elements. Those are C's idea of "arrays". An "array" access in C is equivalent to a pointer arithmetic operation followed by a dereference. Among other things: C arrays don't know their own size C arrays don't provide bounds checking C arrays aren't resizable (except using something like realloc) In other words, C's arrays are a pretty pathetic excuse for an array compared to other, higher level languages. Their low level nature, particularly the lack of runtime bounds checking, is the cause of the overwhelming majority of security vulnerabilities in existence today. This all goes back to C's M.O.: the first class language features C provides are all based on things the processor can do.
D H Posted July 12, 2008 Posted July 12, 2008 Those are C's idea of "arrays". Arrays and pointers are different entities in C. You appear to be conflating the two. double x[3]; double *x_ptr = x; int x_size = sizeof(x); int p_size = sizeof(x_ptr); On most computers, x_size will be 24 and p_size will be 4 or 8. x_ptr is a valid l-value, x is not. They are conceptually different things. I will admit that C's treatment of arrays is poor. This is the biggest misfeature of C that make many Fortran programmers reluctant to turn to C. (They also decry the lack of an exponentiation operator.) Note well: die-hard Fortran programmers most likely view languages such as python with even greater disdain they view C. You have ignored structures and you have ignored that other languages of the same timeframe do not offer built-in or library support for things like lists, hash tables, trees, ...
bascule Posted July 12, 2008 Posted July 12, 2008 Arrays and pointers are different entities in C. You appear to be conflating the two. While there's marginal differences in compiler semantics for arrays declared on the present stack frame versus pointers, internally they're identical (i.e. an array lookup is a pointer arithmetic operation followed by a dereference) Note well: die-hard Fortran programmers most likely view languages such as python with even greater disdain they view C. Any such animosity is entirely reciprocal, I assure you. You have ignored structures and you have ignored that other languages of the same timeframe do not offer built-in or library support for things like lists Ever heard of Lisp?
D H Posted July 13, 2008 Posted July 13, 2008 Ever heard of Lisp?I had Symbolics machine #2 (second hand), so yes, I have heard of Lisp. Lisp is a functional paradigm lanugage. I was talking about procedural paradigm languages. You are ducking the question. Moreover, there was no such thing as standard Lisp until 1999. Every dialect was different from the others. The simplest dialects of Lisp had little more than cons cells (and hence lists) as built-in data structures. If you wanted anything more complex than that you had to roll your own.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now