Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Java Programming

Draft Review of Java 7 "Measures and Units" 220

Jean-Marie Dautelle writes to inform us that the public review period ends on July 8 for JSR-275, "Measures and Units" Early Draft. The JSR-275 will be a major enhancement for Java 7 by providing "strong" typing (through class parameterization) and easy internationalization of Java programs, preventing conversion errors. The latest version 0.8 is available as a PDF. The reference implementation is provided by the JScience project under a BSD license."
This discussion has been archived. No new comments can be posted.

Draft Review of Java 7 "Measures and Units"

Comments Filter:
  • I think everything should be done as derived units from Planck Units [wikipedia.org].
    • My car gets 40 rods to the hogshead and that's the way i like it.
      • My car gets 40 rods to the hogshead and that's the way i like it.

        40 rods per hogshead? Geez, what do you drive, a diesel-powered aircraft carrier?

        I thought my SUV was bad, but it gets 440,000 rods per hogshead.

        • by maelstrom ( 638 )
          For those who don't know, input this query into Google:

          40 rod per hogshead to miles per gallon
    • by fm6 ( 162816 )
      That's sort of like Vernor Vinge's notion that we can replace all clocks and calenders with a system where the only unit is the second (and powers of 10 thereof) and the epoch is the familiar January 1, 1970. There are so many things wrong with that idea, it's hard to know where to start.
  • Similar to Fortress (Score:5, Interesting)

    by Coryoth ( 254751 ) on Thursday July 05, 2007 @01:08PM (#19755901) Homepage Journal
    This looks rather similar to the units and dimensions handling and checking available in Fortress [sun.com], Sun's effort to build a new numerical/scientific computing language. In general it seems like a sensible idea -- having the option of adding extra annotation that allows for more exacting static checking and greater assurance is generally always a good thing. The only downside is that, at least in the java implementation, it is a little cumbersome and clumsy (though maybe that's just par for the course for new java versions). Now if only java could get statically checkable optional contracts as in Spec# we might actually be getting somewhere. At the very least it would be nice if they had runtime checkable contracts, properties and tests as in Fortress. Or perhaps I should just wait for Fortress to finally mature; it seems that will happen faster than java getting the features I'm after.
  • by boxlight ( 928484 ) on Thursday July 05, 2007 @01:09PM (#19755911)

    I've spent most of the last 10 years building desktop and web applications with Java: AWT, Swing, JSP, Struts, J2EE, EJBs, and on and on.

    Through all those years I've had to fight perceptions of Java being hard to distribute, slow, difficult, insecure, and over-engineered. I've done pretty well in the battle, and produced some pretty nice products.

    Maybe I'm having a bit of a mid-life crisis, and I'm wondering where to go from here. I'm looking at alternatives for development: AJAX, Ruby, PHP, and Adobe AIR. But nothing out there (outside of the Microsoft world) does everything that Java does as well -- but Java just doesn't do GUI too well. Although GWT is pretty cool. And I've always thought Applets were underrated and under-utilized.

    The point of this rant? Java 7 doesn't excite me in the least. Me and everyone I know are firmly planted in Java 5 (or is it 1.5? I always forget) and we don't appear to be moving to Java 6 (1.6?) -- so why should we care about Java 7 (1.7?).

    Anyway, that's my rant. Any suggestions are greatly appreciated!

    • Have you looked at Struts 2.x? I know it will sound like I'm self-marketing (which I am), but check out my series of articles -

      wantii.com

    • I'm wondering where to go from here.

      Assembler on bare metal. It'll be a change.

      • by xero314 ( 722674 )

        Assembler on bare metal
        Assembler? Coward. Real programers write direct machine code. (que long thread of "Real Programer" comments)
        • by jjohnson ( 62583 )
          Bare metal? Luxury! Sheer luxury!

          Since I ditched Java I've been coding by arranging large stones in binary patterns.
      • "I'm wondering where to go from here."

        "Assembler on bare metal. It'll be a change."

        I've also programmed in java for a long time - since '99. And I'm totally burnt out on the "yet another UI on top of a db" that seems par for the course in java - and in php, ruby, Qt etc for that matter so that's not really an exciting option for me

        However, I programmed in C/C++ five years before java, and more importantly, I've been using linux since '96 and exclusively since '99. So I got an opportunity to port linux emb
    • by alyawn ( 694153 ) on Thursday July 05, 2007 @01:26PM (#19756145)

      I agree about the features of Java 6 & 7. I code to Java 5 but run in the latest and greatest VM because they continue to make performance enhancements there.

      As for GUI development, I believe that we will see some progress made there. Right now, there is some good competition going on between Swing, SWT, and other toolkits. And now, QT just came out with QT Jambi [trolltech.com] which looks really cool. The bottom line is that eventually, one of these toolkits will emerge and become the defacto toolkit. Remember, cross platform UI is a hard problem to solve. They'll figure it our eventually. Or, you may get tired enough and write one yourself :)

    • by cmburns69 ( 169686 ) on Thursday July 05, 2007 @01:27PM (#19756165) Homepage Journal
      Version 1.7 will come out, and then you'll start moving to 1.6. When 1.8 comes out, then you can switch to 1.7. It seems like very few people actually use the most recent version. I suspect this is because new methods need to be researched, and community support for new features must be developed.

    • by iabervon ( 1971 ) on Thursday July 05, 2007 @01:58PM (#19756549) Homepage Journal
      Java 6 and Java 7 are relatively minor changes. As far as I can tell, the issue is that Sun can't deal with having more than one number in versions. When they revised the Java language, they didn't change the 1 to a 2; they added an extra 2 elsewhere in the name. Then when they wanted to do it again, they didn't know what to change, so they initially left everything the same, and then they discarded all of the stuck numbers. This means that they don't have a way to show the difference between adding a few library features and changing big important things. The difference between 5, 6, and 7 is much like the difference between 1.4.0, 1.4.1, and 1.4.2, and it's not worth upgrading unless you happen to care particularly about a new feature.
    • by onash ( 599976 ) on Thursday July 05, 2007 @02:19PM (#19756795)
      The JSR that I'm excited about;
      - JSR 294 Improved Modularity Support (superpackages); so we can define the API that is public for a library, so the user doesn't have to see all the public functions.
      - JSR 296 Swing Application Framework; which helps us build better Swing GUIs faster in a more standard way.
      - JSR 295 Beans Binding and JSR 303 Beans Validation
      I was really excited about that Consumer JRE / Java Kernel, which was suppose to minimize the size of the JRE so you could bundle a 5mb JRE for a normal Swing Application, but they decided on pushing that to Java 6! so it's arriving as a patch late this year. It will probably include a very nice looking look&feel as well as GUI drawing optimizations using DirectX on Windows.. pretty cool.

      We can also hope for Closures, which would make our GUI code a lot neater.. My company and everyone that I know (except Apple) have moved to Java 6 - and the IDEs such as Eclipse and new technologies like Open-Terracotta are making me love Java! Especially cause we are developing applications / algorithms that run on many different platform.. Java is really the only way cause its fast enough and rock solid.
      • Windows GUI drawing has been done on the DirectDraw pipeline for a very long time. The new backend is supposedly even better, but you can't claim DirectX doesn't have its share.
    • by LWATCDR ( 28044 )
      "And I've always thought Applets were underrated and under-utilized."
      Funny but I have found Applets underrated and over-utilized!
      I think the HUGE number of trivial Applets "Hover buttons" ruined the reputation of Java.
      Things like VNC show the real power of applets. Too bad they where so rare.
    • I've spent most of the last 10 years building desktop and web applications with Java: AWT, Swing, JSP, Struts, J2EE, EJBs, and on and on.

      If have done a fair amount of that too and my biggest gripe: having to write user interfaces in source code or UI builder generating source code! The problem with this approach is that you are tied into some builder and the code generated is ugly. Compare this it to Visual Studio (on MS-Windows) or Interface Builder (on MacOS X) which both generate binary resource files in
      • There are already several of these available for Java using everything from XML [java-source.net] to custom declarative languages like F3 [sun.com].
    • The point of this rant? Java 7 doesn't excite me in the least. Me and everyone I know are firmly planted in Java 5 (or is it 1.5? I always forget) and we don't appear to be moving to Java 6 (1.6?) -- so why should we care about Java 7 (1.7?).

      Modular Java and Kernel JVM (JSR 277 & 294) which should improve Applet start time to be comparable to Flash.
      SwingLabs components, take a look for yourself, these guys are making some nice UI enhancements.
      Java Application Framework (JSR 296) providing a pre-built framework for common application tasks.
      Bean Bindings (JSR 295), so you no longer have to write your own update code.
      JavaFX? I don't know much about this, but it could make GUI development interesting.
      Media Components, this one I'm especially

    • Re: (Score:2, Informative)

      by 3m_w018 ( 1002627 )
      Well, Eclipse [eclipse.org] is a major step in the right direction, despite its shortcomings (the structure of the SWT library and its limitations in comparision w/ Swing, its bulk, etc.).

      When you program Eclipse RCP applications, you don't just spend less time fudging around w/ GUI widgets and more time plugging in large chunks of functionality provided to you (for free) in the framework. Tasks that would have taken me months alone have been shortened up to a matter of weeks...
    • Perhaps JavaFX (Score:3, Interesting)

      by centinall ( 868713 )
      Although still in it's infancy, JavaFX kinda sounds interesting. I've played around with it a little bit, and it's definitely fun. There are several examples out there showing you how it's done and they get the point across pretty well. It's supposed to be an alternative to Flash and Silverlight and although showing promise, it definitely falls short in it's multimedia capabilities(sound and video). Multimedia would perhaps be the killer feature to add to Java 7. Anyway, they're supposedly optimizing Java 7
    • by $1uck ( 710826 )
      Check out Groovy and Grails if you haven't already. Groovy runs on the jvm and although its a different language than java it works seamlessly. Java can use/call groovy classes and groovy can call java classes. There's all sorts of nifty new language features such as closures that should keep you from being bored. Grails is like ruby on rails for groovy although you use your domain objects as starting point instead of your db tables.
    • by caseih ( 160668 )
      While it is not suitable for all the domains you are using Java for, I find Python to be a refreshing breath of air. Python makes programming actually fun again. Not to mention productive. I can't really explain why. Maybe it's a religious thing. I never did pick up Java and have spent years dreading having to use it since I find Java syntax so cumbersome. Paradoxically, I like C++ syntax and I quite like C# (that's mainly because I like the standard runtime libraries in .NET a bit better than Java's
      • Just whatever you do, don't admit to those Python people that you're originally a Java programmer - functional zealots tend to despise anyone that knows what a class is, let alone actually uses them to organize their code! Seriously, though, Python is pretty nice, but coming from a Java background it can be tricky because there are quite a few gotchas regarding scope and structure. References are dealt with in a similar way, though, and data structures are (IMO) much easier to work with in Python than Jav
  • Neat idea (Score:5, Informative)

    by mritunjai ( 518932 ) on Thursday July 05, 2007 @01:14PM (#19755969) Homepage
    Its a one of the several neat ideas being lifted from the Fortress language.

    For the unitiated, Guy Steele (of Scheme fame) is building a new language for scientific computing called Fortress [sunsource.net]. It has some nice ideas that really should have been there by now. The language would have saved countless headaches in not just scientific but probably all mainstream software development projects.

    Of course, its just one of the pet projects in SUN Labs ;)
    • by Coryoth ( 254751 )
      Now if only they could lift the better functional programming support, and support for tests, properties and contracts... The math notation would be nice too, but I suspect that'll be a hard sell to all the non-mathy types out there.
  • Disclaimer: I'm too lazy to RTFA

    I thought we were getting the source code this year, I know we're only halfway through but...
    • you can already get the source for OpenJDK 7 here [java.net]. it's just the JDK, though, as far as i know. i'm also not sure if OpenJDK is technically the same thing as the regular JDK.
  • Yep, still there.
  • Code sample (Score:4, Funny)

    by suv4x4 ( 956391 ) on Thursday July 05, 2007 @02:31PM (#19756949)
    inches i = 10;
    kilograms j = 40;
    dollars k = 70;

    print(i+j+k); // 1.453^10 volts
    • Re: (Score:2, Funny)

      by vigmeister ( 1112659 )

      inches i = 10;
      kilograms j = 40;
      dollars k = 70;

      print(i+j+k); // 1.453^10 volts
      That's because time is money and e = mc^2

      Cheers!
  • by michaelmalak ( 91262 ) <michael@michaelmalak.com> on Thursday July 05, 2007 @02:52PM (#19757193) Homepage
    It's interesting that I was trying to do the same thing with C++ back in 2000, maybe even 1996.

    The idea is based on the philosophy that numbers do not exist in isolation. It is possible to speak of, e.g., the number 5 as an abstract entity unto its own, but that should be rare. Most of the time, "5" refers to the ratio "5:1", where the "1" refers to something tangible. In science, the "1" is denoted with units. The problem is, starting with tabulating machines, then onto electronic calculators, and even multi-gigabyte computers, numbers are almost universally represented (erroneously) as the former -- purely abstract numbers. The units are stripped off.

    As any struggling physics or chemistry student knows, one can fake one's way through a test by doing "dimensional analysis" on test questions. If the units cancel out properly and agree, you've probably got the right answer.

    Compilers should be doing dimensional analysis at compile-time. I had originally hoped to create C++ templates -- which are evaluated at compile-time -- to do this, but I couldn't quite see how to get them to handle all the possible permutations of unit combinations and conversions -- at least not easily. It really needs to be built into the language.

    With a compiler enforcing dimensional analysis, it would force programmers to think through every formula and calculation. Novel unit combinations would arise as a result of creating database reports. E.g. a payroll report might have $/2-week pay period. A conversion somewhere to $/year would be another unit, and the conversion between $/2-week pay period and $/year would be clearly definied in one place rather than sprinkled throughout the code.

    Putting conversions in one place is the first thing I did when I cleaned up some pre-existing source code that I took over. I explicitly created three coordinate systems (device, world, and screen) and created two two-way conversions to go between the levels. Before that, there were conversions all over the place, each a little different, each with different handling of roundoffs and some even with hidden fudge factors. ("Conversions in one place" can be done without developing a units system, as it has its own benefits.)

    I blame a lack of education on the philosophy of numbers for programming languages relying upon naked numbers for so many decades. Rote algorithms for addition, subtraction, multiplication, and division taught in elementary school are the foundation of this vacuous philosophy.

    It could even be responsible for the public's acceptance of no gold standard for the dollar. They're not demanding to know what the reference point of "one dollar" is.

    And of course it's the Federal Reserve that can print endless money for the war in Iraq, thank to the lack of a gold standard.

    So there you have it -- lack of units in programming languages and the war in Iraq have a common cause: the lack of correct philosophy on numbers taught in schools.

    • by ispeters ( 621097 ) <ispeters@alu[ ]. ... a ['mni' in gap]> on Thursday July 05, 2007 @03:26PM (#19757659)

      It could even be responsible for the public's acceptance of no gold standard for the dollar. They're not demanding to know what the reference point of "one dollar" is.

      And of course it's the Federal Reserve that can print endless money for the war in Iraq, thank to the lack of a gold standard.

      I was agreeing with you completely until you said that. There can be no reference point for "one dollar". A currency system lifts the burden of a barter system from its users. Without the dollar, you'd have to bake bread and swap it for internet connectivity, or something. How much bandwidth can you get for a loaf of bread? The same question applies to the dollar. Currency is a tangible way to represent the virtual concept of value. There is no unitary value of value so there can be no fixed unitary value for a currency. A free-floating currency values itself according to what its users think it's worth, which is, IMHO, the only sane way to value a virtual concept.

      Ian

    • Re: (Score:3, Insightful)

      by gatesvp ( 957062 )

      It could even be responsible for the public's acceptance of no gold standard for the dollar. They're not demanding to know what the reference point of "one dollar" is.

      I'll do you one further, as we get further and further from solidity with numbers we will get progressively worse at handling it. As we deal with less and less cash, the money we have simply has less weight. We've all seen this phenomenon, anyone who does everything with cash will typically be better at handling their money, b/c they're "ha

    • by Coryoth ( 254751 )
      Philosophy of numbers is, indeed, an interesting problem, something I've discussed [stuff.gen.nz] at some length [stuff.gen.nz]. Still, one shouldn't reject the fact that numbers in the purely abstract are important and useful -- the process of abstraction [stuff.gen.nz] is fundamental to mathematics, and the question you need to ask yourself is "how much detail can I afford to forget for the problem at hand". The more detail you can safely ignore the simpler and more general your work. Being able to remove consideration of units, or indeed any connec
    • Re: (Score:2, Informative)

      It's pretty easy to do Units/Dimensional Analysis in the D programming language:

      physical.d [csc.kth.se]

      The example is by Oskar Linde.
    • Re: (Score:3, Informative)

      by Vellmont ( 569020 )

      They're not demanding to know what the reference point of "one dollar" is.

      I'm no economist, but this statement confuses me. You're really saying that it was somehow better when someone could say "one dollar equals .1 ounces of gold! (or whatever it was). I'm confused. What's the reference point of what .1 ounces of gold equals... one dollar? Why is referencing the value of a dollar to the value of gold somehow "better"? There's nothing magic about gold.. it's just rare.

      Money is meaningless outside of
      • Why is referencing the value of a dollar to the value of gold somehow "better"? There's nothing magic about gold.. it's just rare.

        Gold has the use as money, mystique and respect through the millenia.

        As long as a dollar can be exchanged for things people want, it has value.

        No, the value of the dollar comes from the IRS. Try using something other than a dollar as money, such as a gold coin. The IRS requires you to attach a fair market value in terms of dollars (Federal Reserve Notes, really), and then pay a

        • Gold has the use as money, mystique and respect through the millenia.

          Yeah, it only has that mystique because we consider it to be valuable --- you've got a tautology here: you've just said here is that gold is valuable because we think gold is valuable. It has very little intrinsic value of its own --- it's reasonably (but not especially) rare, it has some interesting (but not especially interesting) chemical properties, and it looks nice. A currency based on gold is just as artifical as any other fiat c

          • you've got a tautology here: you've just said here is that gold is valuable because we think gold is valuable

            No, I said gold is and will be valuable because it has been valuable -- a prediction based upon a long-standing trend.

            By all means base your currency on a physical object, or not, depending on your favourite economic theory, but you should probably use a basis that actually has intrinsic worth in its own right. Say, a fixed period of standardised human labour? The joule? A loaf of bread?

            Silver has mo

    • What gold standard? (Score:2, Interesting)

      by lennier ( 44736 )
      "It could even be responsible for the public's acceptance of no gold standard for the dollar. They're not demanding to know what the reference point of "one dollar" is."

      I really don't understand this obsession with the Gold Standard. A gram of gold has no intrinsic value either, any more than one US dollar does. (Other than for making connectors on circuit boards). Its value, like the dollar, lies purely in what other people are willing to exchange for it - and like a paper currency, that 'value' can fluctu
      • Now: if you pegged a currency to a basket of useful commodities or social indexes: water, food, housing, textiles, domesticated wildlife, access to healthcare - the things that a person or society can actually *use* as primary units of biological energy and production - then you'd have a currency with *real* intrinsic value, and you could start talking about having a philosophy behind your money

        There are two problems I see with that idea:

        1. If the dollar is pegged to a tenth of a basket, and at that time a bo
  • I don't know... (Score:3, Interesting)

    by Zarf ( 5735 ) on Thursday July 05, 2007 @03:40PM (#19757835) Journal
    ...what the programming language of the future will look like but I know it will be called "Java"!!!

    Case in point: As if EJB3 has anything to do with EJB2 other than sharing the same name.
    • We've definitely entered the "branding" era in software development. Windows Vista and Windows CE have little in common just as J2EE has little in common with JME and Desktop Linux has little in common with a tiny embedded Linux.
  • by Sanity ( 1431 ) * on Thursday July 05, 2007 @03:59PM (#19758095) Homepage Journal
    We have been using the JScience package to record a variety of internal data about a (we hope!) large scale [thoof.com] statistics intensive website we've been building. It is actually a breath of fresh air not to have to worry about accidentally confusing impressions per minute with unique visitors per hour, but rather letting the compiler do the worrying for you. This will be a great addition to Java, but you don't need to wait, JScience's implementation is robust and we've been using it in production for months.

One man's constant is another man's variable. -- A.J. Perlis

Working...