10 ms·
New language features in Java 7
- jmount 17y agoLooks like Java 7 Path class will finally let you link files (yea, made it up to mid nineties Posix level). Java was always very inconsistent about what was not in the language "because some platforms may not have it (ME)" and "well we put a method there and we will throw if we don't wan't to do it (Iterator.remove())".
- uriel 17y agoI hate Java with passion, but symlinks (and hardlinks) are really atrocious hacks that should never have happened, and for good reasons were deprecated more than twenty years ago by the folks that created Unix in the first place.
- viraptor 17y ago"were deprecated more than twenty years ago by the folks that created Unix in the first place" [citation needed] Also, could you explain some more. Why do you think that they're "atrocious hacks"? They solve some problems in a quite nice way (simple versioning for example)
- fgb9 17y agolotte% ls -l /bin/^(cp echo) --rwxrwxr-x M 4328 sys sys 63454 Jan 10 2007 /bin/cp --rwxrwxr-x M 4328 sys sys 57592 Jan 10 2007 /bin/echo lotte% bind /bin/echo /bin/cp lotte% cp file1 file2 file1 file2 lotte% ns |grep echo bind /bin/echo /bin/cp lotte% ls -l /bin/^(cp echo) --rwxrwxr-x M 4328 sys sys 57592 Jan 10 2007 /bin/cp --rwxrwxr-x M 4328 sys sys 57592 Jan 10 2007 /bin/echo ns|grep /bin bind /386/bin /bin bind -a /rc/bin /bin bind -a /usr/fgb/bin/rc /bin bind -a /usr/fgb/bin/386 /bin bind -a /usr/inferno/Plan9/386/bin /bin bind /bin/echo /bin/cp here's bind(2) man page, in case you're interested in learning some 20 year old technology http://plan9.bell-labs.com/magic/man2html?man=bind§=2 http://plan9.bell-labs.com/magic/man2html?man=bind§=...
- viraptor 17y agoNot sure which point was this supposed to address. It neither proves that links are "atrocious hacks", nor that links were deprecated in any way. Links may be not used in P9 of course, but that doesn't change anything in the rest of the world. If I create a research project which uses pipes as a substitute for sockets, it doesn't mean that sockets are deprecated anywhere else. PS. This does not mean that bind is {better/worse/useless/deprecated/teh-win}. `mount -o bind` on linux exists and is not replacing sym/hard-links anytime soon.
- DannoHung 17y agoYou can't just say something like that unqualified. My life is made better daily by the presence of symlinks.
- rbanffy 17y agoMy life under Windows is made worse daily by its lack of, among other niceties of civilization, symlinks. Hard-links would also be a nice addition. I am sure NTFS supports them deep inside it.
- halo 17y agoNTFS does indeed support both symbolic links and hard links in recent versions of Windows, and they can be created with the "mklink" command-line utility. (see: http://en.wikipedia.org/wiki/NTFS_symbolic_link http://en.wikipedia.org/wiki/NTFS_symbolic_link)
- gaius 17y agoNTFS always supported links, but there was no interface to actually using them from the Win32 subsystem. However the POSIX subsystem could use them since NT 3.5 at least.
- litewulf 17y agoIn fact I strongly suggest you consider ntfslink (http://elsdoerfer.name/=ntfslink http://elsdoerfer.name/=ntfslink) which provides a nice UI for doing all this in explorer. As far as I can tell, reparse points for directories will usually work perfectly well for most of the things you'd expect them to. I use them, and a subversion repository to version control pretty much everything config related on my windows machine.
- huherto 17y agoSeems like you managed to piss off Java as well as Unix guys in a single sentence. But a fair question is what you would use instead of links. I suppose you are talking about plan 9.
- rbanffy 17y agoDeprecated?! When?
- bumblebird 17y agoSymlinks are actually pretty handy. Have you never seen/used: Current -> MyProg_1.8.9 MyProg_1.8.9 MyProg_1.8.8 MyProg_1.8.7 How/why would you do that without symlinks?
- dschobel 17y agoNice to see the language maintainers finally taking the weed-whacker to the syntax. The collection literals are nice too, but why couldn't they infer the type from the following? Map<String, Integer> map = {"key" : 1}; to make the syntax: Map<> map = {"key" : 1};
- smanek 17y agoHow do you know it isn't a Map<Object, Object>? ;-) It's kind of trivial in your example, but with complex objects that implement a lot of interfaces it isn't as obvious what the programmer means.
- viraptor 17y agoYou can always assume that it's the most restrictive type that you want. How many times did you really need Map<Object, Object>, when you initialised the map with {"abc":1, "def":2, "ghi":3} ? Since you can always make it specific what you want, you can assume that the most common case is the "default". That's what c#'s `var` does anyways - if you have a `var a=1;`, 'a' an int, not an object. If you use `var a=new []{1,2,3};`, it's int[], not object[].
- ajross 17y agoOr go one better and extend the language to do true type unification. It's not like this isn't well-travelled territory.
- bad_user 17y agoIt's not. How many OOP languages do you know where type-inference works? I know of none ... Ocaml uses a special syntax for reconciling the type-inference with the inclusion polymorphism that it supports ... (name : sub_type :> super_type). And IMHO it gets ugly. I'm not really clear about what "type unification" you're referring to, but the actual types in Java aren't known until runtime (you usually only know a parent). To change this behavior an overhaul of the entire architecture is needed.
- bensummers 17y agoI'm beginning to wonder more and more whether Duby might be a bright future for writing code for the JVM. http://kenai.com/projects/duby http://kenai.com/projects/duby It uses Java types, doesn't need a runtime, and most interestingly, has a pluggable compiler. The Ruby-like syntax may not be to everyone's taste, but it's nicely compact.
- 10ren 17y agoI found that site hard to navigate. Here's some sample code: http://kenai.com/projects/duby/pages/Examples http://kenai.com/projects/duby/pages/Examples (note to self for own project: make samples very accessible)
- jimbokun 17y agoThese changes will make a concrete improvement to my daily productivity as a Java developer. Definitely removes some of the pain points relative to other languages. If they can also do something about closures, I'll be much happier as a Java developer when this comes out than I am today.
- trapper 17y agohttp://puredanger.com/tech/2009/11/18/closures-after-all/ http://puredanger.com/tech/2009/11/18/closures-after-all/
- madair 17y agoThe Closed By mechanism seems so obvious in retrospect. What a great improvement to stability of applications overall by embedding that simple and error retardant pattern into the language. I'm trying to understand why the collections syntax would create only immutable collections? Anyone know why so?
- gchpaco 17y agoIt theoretically permits optimizations where multiple parts of the code using the same, say, string literal can refer to the same literal. I don't believe for a moment that this is actually happening in Java, but immutable literals are not uncommon in this class of language.
- paulbaumgart 17y agoWhen he says the new collections syntax creates immutable collections, does that mean modifying them creates a copy, or that objects in the collection can't be added/changed at all?
- hello_moto 17y agoI think he meant adding a new item would create a new list. Which makes working with operation expensive but a bit safer.
- akronim 17y agoYou can't add items to immutable collections - if you call add() etc you'll get an UnsupportedOperationException. If you want a mutable version then you need to create a new collection, and can use the immutable collection to provide the starting values, like this: Set<String> mutable = new HashSet<String>(immutable)
- paulbaumgart 17y agoOh, but you can still do: List<String> list = new ArrayList<String>(); list.add("item"); String item = list[0]; right? I guess I was thrown off by the wording- I assumed the line about collections being immutable applied to all collections that use the new syntax.
- JulianMorrison 17y agoWhich is madness that completely misses the point of proper immutable collections (Clojure style) - that you can "modify" them, by creating a new copy with the thing added, and it shares storage with the original and the copying isn't as slow as a copy-by-clone. The first thing people are going to do with these half assed immutable collections is pour the contents out into a mutable container. Which completely obviates all the thread safety and whatnot. I slap my forehead. Do these people have no sense?
- lmkg 17y agoIs the addition of immutable structures going to push the JVM towards more optimization for immutable structures in any way? I ask because of Clojure, not Java itself.
- cabalamat 17y agoNice features, shame they didn't do them 10 years ago.
- _giu 17y agonice new features. the diamond operator looks good. closures will be fun, too! starts to feel like C# (automatic resource management (C#'s IDisposable), language support for collections, strings in switch).
- wicknicks 17y agoNice features... Code will now look a lot cleaner and concise.
- jeremyw 17y agoUnderscores in numeric literals This proposal was just rejected in Go, alas. What a readability difference it makes in Ruby, Eiffel and (originally) Ada.
- ams6110 17y agoHeh. I was going to post that I thought this was a fairly useless feature, certainly not on par with the impact of the other new stuff. But, I can't really say that it is a bad thing... I guess.
- MikeMacMan 17y agoI'm pleasantly surprised by this. Now if we can only get properties...