Learning JAVA, any advice?

Status
Not open for further replies.

Blacken00100

Ars Legatus Legionis
10,130
Subscriptor
That's one way to look at it. I kind of come from the other side of things, that that's the baseline and not having that is broken. (I guess that'd make anonymous inner classes syntactic salt.) Perhaps it's more the traditionally negative connotations to "syntactic sugar" than the actual phrase that makes me frowny.

Also, it should probably be noted that anonymous inner classes don't really act the same way, at least internally, and there are (sometimes onerous) performance considerations that come from using them as a substitute. Though, you're right, if you have the discipline to use them--which frankly I don't think is necessarily that common in the Java ecosystem, though I'm readily willing to admit I can't prove it--they do act somewhat similar. Actually using them correctly is a bear, though, and are really the foremost example I can think of to depict a bad pattern being developed to counteract the failing of the language.
 
Blacken00100":3w26o1ur said:
That's one way to look at it. I kind of come from the other side of things, that that's the baseline and not having that is broken. (I guess that'd make anonymous inner classes syntactic salt.)

Perhaps it's more the traditionally negative connotations to "syntactic sugar" than the actual phrase that makes me frowny.
Syntactic sugar is something that makes the syntax nicer but which doesn't alter the semantics or capabilities one iota. In Java, first-class functions are exactly that.
 
Kalila":162p7619 said:
Who said anything about Java being in place of FP languages?

You are far better off learning FP using something like Haskell or one of the implementations of SML that does lazy evaluations etc very well than the half assed implementations of languages such as C#.

Re-reading, I think I misread your distaste of C/SML/LISP as first languages as a tacit endorsement of Java as a passable catch-all language. Assuming that your argument is "you don't have the maths basis to work with FP languages in an adequate manner and freshmen, by definition, haven't taken the maths courses they need, so trying to work in FP is an exercise in failure", anyway.
Kind of the same way that it appears that you somehow contorted my less-than-ringing endorsement of C# as a starter language for an endorsement of it as a good FP language?
 
DrPizza":gp8bdwj4 said:
Thanks to Java's anonymous (inner) classes, first-class functions (including environment capture) are indeed syntactic sugar that provide no additional expressive power.
Taking that logic to the extreme, you could call the majority of the language (for loops, ternary conditional, synchronized, switch, methods accepting more than one argument, etc.) syntactic sugar. But syntax has a profound impact on the approaches people take to solving problems. The difference in convenience between
Code:
map (+1) numbers
and
Code:
map(
  new Function<Integer, Integer>() {
    public Integer eval(Integer value) {
      return value + 1;
    }
  },
  numbers
)
is big enough that the first is ubiquitous in its language and the second is seldomly found in its.
 
D

Deleted member 43669

Guest
Ah! I came in late to recommend SML or another purely functional language.

If you want to learn "CS" programming you will have to learn imperative/procedural, functional, declarative (i.e. SQL and Prolog) and a Lisp.

Both Java and Python are valid to teach imperative/procedural. While I have a strong dislike of Python (and an irrational hate for saying it's the *ONE* language for learning programming), I have to admit it's got some advantages wrt. Java:

  • REPL (Eclipse's interactive code execution is not suitable for learning... and I haven't played with BlueJ for more than 10 minutes)
  • Doesn't force OO down your throat, simpler main()
  • Transparent/fast compilation and lightweight

but it also has disadvantages- at least to my tastes: dynamic typing, duck typing, whitespace as indentation. Java has few advantages in comparison- the byzantine API has its charm, concurrency is pretty interesting, it has non-wonky immutability and you have Hadoop... plus, as a general CS tool it might be interesting to have a performant language (you might want to do some number crunching).

Anyway, neither language is comparable to say, SML for teaching functional. They are there to teach you about the prevalent imperative world.

If I were to teach imperative, I'd also take a look at Eiffel, Ada and Smalltalk, which might be better in some areas than Java and Python.
 
newwb":lyq4zgu6 said:
The difference in convenience between
Code:
map (+1) numbers
and
Code:
map(
  new Function<Integer, Integer>() {
    public Integer eval(Integer value) {
      return value + 1;
    }
  },
  numbers
)
is big enough that the first is ubiquitous in its language and the second is seldomly found in its.

Yeah, this is a pretty good example of expressibility.

Because in C# that basically reduces to:
Code:
map((i) => ++i);
...because C# has proper lambdas. And that sort of thing is extremely common in modern C# code, due to it being ubiquitous in LINQ usage.
 
First you put the properties file in your classpath, then the XML file with properties placeholders configures your functions, gets processed with XSLT and loaded into the container, which looks for a license agreement file in a path determined by an environment variable, and if your license is valid, it starts the Enterprise Factory Server web service listening on port 8523. To apply a function, just annotate your input beans for auto-serialization to XML and the factory sends them to the enterprise server for processing. Simple as that. :)
 
That's the great thing about Spring Framework - it's lightweight so it integrates with just about anything. Just configure an IntegerFunctionFactoryBuilderFactoryConfigurationBean and inject IntegerFunctionFactoryBuilderFactoryClients wherever you need them and you're good to go.

OK, I've taken this way too far...but seriously, this is what Java dev is like these days :(
 
newwb":2nvtgphg said:
DrPizza":2nvtgphg said:
Thanks to Java's anonymous (inner) classes, first-class functions (including environment capture) are indeed syntactic sugar that provide no additional expressive power.
Taking that logic to the extreme, you could call the majority of the language (for loops, ternary conditional, synchronized, switch, methods accepting more than one argument, etc.) syntactic sugar.
Indeed you could, and unsurprisingly none of those features are found universally.

But syntax has a profound impact on the approaches people take to solving problems.
I don't think that's especially true. I think people take the approach that they prefer and/or first learn, and then use that approach regardless of syntax. You can write Fortran in any language, if you put your mind to it.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
I think people take the approach that they prefer and/or first learn, and then use that approach regardless of syntax

I thought that was spretty much the entire thrust of Blaken's argument with MisterMagoo...

I would be intrigued to know if MisterMagoo actually realised that the he had access to closures and function objects in java. I still wouldn't call it first class functions incidentally because they are not first class (i.e. reified [1])

1. If a language is like Lisp and allows itself to be changed to include the functionality that would count too.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
You are a data point (i.e. An anecdote) concerning whether learning java first causes you to be less likely to be aware of the existence of potentially more powerful programming constructs due to their not being possible (say veridic generic types, something rarely supported in imperative centric languages) or verbose to the point of being less expressive and idiomatic (the case here, though the latter part is IMO of course)

Of the approx 20 people I have met who identified themselves as learning either java (or COBOL then java) as their first language only 3 were aware of anon types, and only one was aware of environment capture (and didn't know the more common term of closure)
I'd just like to add another data point.
 
ShuggyCoUk":1o1fkcl8 said:
You are a data point (i.e. An anecdote) concerning whether learning java first causes you to be less likely to be aware of the existence of potentially more powerful programming constructs due to their not being possible (say veridic generic types, something rarely supported in imperative centric languages) or verbose to the point of being less expressive and idiomatic (the case here, though the latter part is IMO of course)

Of the approx 20 people I have met who identified themselves as learning either java (or COBOL then java) as their first language only 3 were aware of anon types, and only one was aware of environment capture (and didn't know the more common term of closure)
I'd just like to add another data point.

Thanks for clarifying, I am aware of and have used anonymous classes. Admittedly I was not familiar with the term closures being used to describe them. Out of the 20 people you describe did any of them use additional languages to java or have a desire to?

What I'm trying to illustrate is that if you are a pure java developer, and are happy to be so (I obviously dont share the view that such a stance is a particularly bad thing). What are the benefits of them being aware of constructs that are not available to them?

I think one of causes of the different view points here is how someone views the act of programming. For many people its a means to an end, essentially a trade skill that they can ply to earn a wage. For others its viewed as a form of art which they dedicate much of their life to in the pursuit of perfection. These are two obviously very different approaches to the same act. Personally, I've accepted that I will probably never to be the standard to get down very close to the metal and be writing in assembler or something similar. I'm perfectly happy with that fact, I view software development as a job that I enjoy and is generally a lot less stressful than other jobs I've had while paying a lot better. I will always want to keep up with the latest developments in the tools that I use and learn new skills where I can (I'm currently trying to make the transition to c# through some simple XNA games).

However at the end of the day, its in the quest of a stable well paid position that leaves me enough time and money after work to enjoy my life with my family. I dont think that attitude makes me a bad developer, it certainly will restrict my skillset from reaching "superstar" status, but if I produce the code to the expected standard of my employer and they are happy while understanding and respecting my own limits, whats the problem?
 

Fristie Blade

Ars Tribunus Militum
1,722
Subscriptor++
MistaMagoo":10q6ut07 said:
What I'm trying to illustrate is that if you are a pure java developer, and are happy to be so (I obviously dont share the view that such a stance is a particularly bad thing). What are the benefits of them being aware of constructs that are not available to them?
If you look at it from the "want to learn programming (general)" angle, then the lack of certain features will impose certain limits on paradigms to use, so missing out the total spectrum.
If you look at it from a practival "get the job done" angle as you do, sure you can get all your jobs done and the language will be good enough if you never plan to go out of Java any way.

Then again, if it is just about getting a job done, why not learn VB6 ;)
 
Fristie Blade":37mtq57c said:
MistaMagoo":37mtq57c said:
What I'm trying to illustrate is that if you are a pure java developer, and are happy to be so (I obviously dont share the view that such a stance is a particularly bad thing). What are the benefits of them being aware of constructs that are not available to them?
If you look at it from the "want to learn programming (general)" angle, then the lack of certain features will impose certain limits on paradigms to use, so missing out the total spectrum.
If you look at it from a practival "get the job done" angle as you do, sure you can get all your jobs done and the language will be good enough if you never plan to go out of Java any way.

Then again, if it is just about getting a job done, why not learn VB6 ;)

Wouldn't learn VB6 as its not a skill that will create the same opportunities as java ;)

Regarding the learning programming in general angle, you are always going to have to start on one language. It seems safe to assume that one language is always going to lack some features in comparison with other languages. So if you are going for the total spectrum approach this isint really an issue because you are going to add additional languages to your skillset anyway. Its just a case of in what order, I dont agree that learning java (or any language for that matter) is going to damage someone to such an extent that they would not be able to continue learning others.
 
DrPizza":1ym0a2qg said:
Blacken00100":1ym0a2qg said:
(And classifying stuff like first-class functions or closures as "syntactical sugar" is...interesting.)
Thanks to Java's anonymous (inner) classes, first-class functions (including environment capture) are indeed syntactic sugar that provide no additional expressive power.

That's not completely accurate, is it? I don't think an anonymous inner function can modify a variable in its surrounding scope, they have to be final.
 
Stupendous Man":2q9aoawx said:
That's not completely accurate, is it? I don't think an anonymous inner function can modify a variable in its surrounding scope, they have to be final.
How does that matter? In a purely functional language, no variable can be modified, but surely it contains first-class functions.
 
Stupendous Man":zh1iwmwv said:
DrPizza":zh1iwmwv said:
Blacken00100":zh1iwmwv said:
(And classifying stuff like first-class functions or closures as "syntactical sugar" is...interesting.)
Thanks to Java's anonymous (inner) classes, first-class functions (including environment capture) are indeed syntactic sugar that provide no additional expressive power.

That's not completely accurate, is it? I don't think an anonymous inner function can modify a variable in its surrounding scope, they have to be final.
They can't rebind variables in their surrounding scope, but they can call methods on them. But there's a good reason for that; they can escape their surrounding scope, so rebinding would be meaningless.

Haskell can't modify any variables, ever, at any time, in any context, for any reason, but I don't see anyone complaining about that.
 
Status
Not open for further replies.