Draft Review of Java 7 "Measures and Units"
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."
Wow, this will make Java nearly one half as powerful as C#!
Seriously, Java folks, if you want stay employable, buy a C# book because Java was DOA.
Take it from me, I work in HR at a Fortune 500 company, so I know a thing or two.
i suspect MS will rip off this idea soon enough, so i will never have to go back to java programming ever again. at least, i hope so. seriously, how come this is the first that i've heard of this kind of idea? it's one of those where i wish i would have thought of it first. it seems so obvious now.
Looks like the death-blow for c#? I realize that there will be a lot of c# projects in MS shops, but Java has been around so long and continues to grow.
Dice.com results:
'java' - 16799
'c#' - 7305
'.NET' - 12042 (inclusive of c#)
Website Hosting
I think everything should be done as derived units from Planck Units.
No folly is more costly than the folly of intolerant idealism. - Winston Churchill
Additions of features like this are useful for applications that need unit of measure conversion. I can think of a number of situations where using a mechanism like this rather than writing my own conversion could be useful. Also adding the ability to extend it yourself with custom unit's could be very helpful in some cases.
How much do additions such as this add to the overall footprint of the language? I understand that this project may not be very large but how many parallel projects such as this are being added to the codebase. I'm not sure what the benefit of adding this directly over having it available as a library. In many cases we need to keep several java instances on the same server(app specific, multi versions) this means that this footprint growth get's multiplied across the multiple instances.
This signature would be better if I was creative.
My car gets 40 rods to the hogshead and that's the way i like it.
Badass Resumes
This looks rather similar to the units and dimensions handling and checking available in Fortress, 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.
Craft Beer Programming T-shirts
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!
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. 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
- mritunjai
...more bloat-ware "functionality".
This sounds like something that was put in as a request by someone dealing with offshore work and who got shoddy code back...
"Java developers who work with physical quantities (such as developers in the scientific, engineering, medical, and manufacturing domains) need to be able to handle measurements of these quantities in their programs."
Really? No kidding? It's called a requirement.
So we are adding functionality to give poor developers yet another crutch to lean on, catering to the stupid?
"Inadequate models of physical measurements can lead to significant programmatic errors. In particular, the practice of modeling a measure as a simple number with no regard to the units it represents creates fragile code. Another developer or another part of the code may misinterpret the number as representing a different unit of measurement. For example, it may be unclear whether a person?s weight is expressed in pounds, kilograms, or stones."
And it's Java's responsiblity to "fix" this problem?
"Developers must either use inadequate models of measurements, or must create their own solutions. It is less than ideal for every developer to solve this problem. A common solution can be safer and can save development time for domain-specific work."
So it's one-size-fits all? B.S.
What happens when I have to interface Java with something else, a database, another language?
If I've already solved these problems within my system, will I have to go back and change everything because someone changes a runtime setting?
I'll be flamed for sure (espec. by the usual Ruby suspects), BUT... I was once where you are now, and I ain't lookin back. ;)
My 2 cents anyhow, for what they're worth (...wait...2 cents?)
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...
Summation 2
Well at least it's 2 whole cents. Too many people say stuff like "just wanted to add my .02 cents" which IMO deals a severe blow to their credibility.
I like basketball!!1!
Which has got to be a good thing. British Imperial units are obsolete even in Britain, but still see some use. While they have the same _names_ as american units, they are different sizes. It's quite annoying to deal with code using imperial or u.s. units, but much more annoying if you don't even know which, or if the programmer didn't understand there is a difference, and used physical constants from a british textbook in america or vice-versa.
Yeah, these days I am really enjoying python programming, java doesn't do it for me.
Python already has a fantastic module (Unum) to do units stuff - I think it covers everything this Java work does.
if you like making nice GUIs, check out WxPython.
Yep, still there.
How cute, the toy programming language edges slowly towards some sort of 'standardization' just after it released (partial) source code.
Java is a great 'learning' language for kids / computer science students, teaching them the basics of OOP.
Java is also great for making applets (read crapplets), and of course javascript based web pages.
There may be MORE java jobs out there, but look at the salaries they are 'commanding', better to be a waiter.
It's a natural extension of templates.
My chemistry teacher in high school taught us to think this way, you got no credit for your math unless you carried the units around.
- There doesn't have to be a big performance degradation, most of the work can be done at compile time.
.
- Like templates, you are free to ignore all of this if you want to, keep coding the way you have been, and maybe dabble with it where it's convenient.
- It's okay to accept some overhead in the name of helping to ensure program correctness. If you disagree with this statement, then you'd better be prepared to show me the blisters on your fingers from entering code via the front-panel switches.
- If there's a real concern for performance, there can be a run-time switch to turn off the checking, which you can enable after you've run the code through all your testing.
Just because it's easier, more beautiful, compact, and enjoyable doesn't make it a two-seater miata! /and when i thought programming really wasn't fun, and there was just too much toil-per-feature, i found it myself. and at least programming is fun again! //Python3000 will have interfaces
CS majors know the time/space tradeoff, but they never get taught the 3rd, crucial, tradeoff of the set: comprehension!
inches i = 10;
// 1.453^10 volts
kilograms j = 40;
dollars k = 70;
print(i+j+k);
This can only lead to one thing. Or rather, many confusing things.
1. "Measures and Units" version 1.0. 2. "Measures and Units" Enterprise Edition. 3. "Measures and Units" on struts. 4. "Measures and Units" version 1.1. 5. "Measures and Units" version 1.2. Compatible with code written in 1.0, but not 1.1 nor EE. 6. "Measures and Units" for mobile devices 1.0. (Compatible with 1.1, but not 1.2, 1.0 nor EE.) 7. "Measures and Units" 1.3 for SunOS. (Requires a patch to the OS to make it work)
This will make our unit conversions so much easier.
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 indicating how things should be laid out. With Interface Builder you design your GUI and then tell which are the handlers in the source code for handling the UI even. For me this is the one thing that needs to be sorted out in Java if it is going to be taken seriously for desktop applications.
Jumpstart the tartan drive.
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.
People who work at Verizon have as much right to post as anyone else.
Such that if a.qty = 1 and a.unit = foot
and b.qty = 12 and b.unit = inch,
c
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
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 to handle JavaFX and JavaFX Script and this is perhaps one of the features that "might" encourage people to upgrade.
https://openjfx.dev.java.net/
Btw, JavaFX was previously known as F3 (Form Follows Function?) for those that may be looking up more details and examples of it.
...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.
[signature]
We have been using the JScience package to record a variety of internal data about a (we hope!) large scale 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.
What aspect of C$ is poorly designed compared to Java?
I didn't know Verizon posted around here.
Please answer the same question for C#.
Actually I find this JSR very interesting. However I wish it also covered Money. Money is very complex as well and used in most business software. It has problems that are similar to that of units and measures.
Python is fucking retarded.
Whoever thought it was a good idea to use TABS instead of BRACKETS needs to be shot in the face for being a retard.
"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 fluctuate wildly. Gold is simply a fiat currency on a global scale, and its arbitrarily assigned market value bears no relation to any true wealth. The same for every single other investment or speculation commodity, be it diamonds, yen, shares, futures, tulips or bets on horses down at the local track. If its value derives entirely or mostly from *other people's subjective valuation of it* then it's an illusion, a Ponzi scheme that just hasn't collapsed yet - but drop someone in a desert with the choice between a gold bar and a bottle of water, it will.
Gold's main value as a currency was because 1) it didn't corrode, 2) it wasn't useful for anything else, and 3) it was produced at a slow but mostly constant rate (but not at a rate usefully matching the actual growth of economies, leading to huge abberations like Spain's inflationary spiral after gaining South America's goldfields, and the gold rushes of the 1800s)
Basically gold was just a crude mechanical approximation of a cryptographic reputation protocol implemented in ore. Its failings as an estimator of personal and social worth are legendary. We can do a lot, lot better.
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.
You are not a brain: http://books.google.com/books?id=2oV61CeDx-YC
"Mi camión que tiene una potencia de 400 cerdos bate a este LandsRover con una aceleración punta de 666 patas de cerdo por latido del corazón de cerdo al cuadrado".
Es que "We've using the new Marranos's system" to be the new proposal for the "camioneros's idiot people".
The camioneros's leader is Homer Simpson.
Too cryptic? It's lesser cryptic than the imperial feet!!!
It's a bit of joke when we encounter MS .NET competitors in the mid-large size arena.
Firstly they die on price as they have endless expensive requirements for MS product.
Secondly the die on portability. Our stuff scales to Z-series mainframes down to laptops, Linux, BSD, OSX *unix and MS Windows are all supported. Our competitors: Works on all kinds of OS - XP _And Vista.
Thirdly they uniformly offer MS SQL Server as _the database. We support 19 database targets including that one.
It makes me laugh. Monolithic vs choice. Most businesses will go choice in my experience.
Speaking as one of the dev guys for my company's custom IDE written in Python: "Hell No".
Swing is loads better than WxPython for... for... just about everything.
I mean, good god! Take a ListCtrl control. Now put something in it. What's that, lassie? You say you want to associate an object in memory with the item in the list? Too bad! You can only attach a long integer to it, not an object reference. So you need to maintain your own lookup table between those objects and the GUI row items at all times! Doesn't that sound like fun?
Almost as fun as needing to practically hardcode a block of integer IDs to make events that link button clicks to function calls. What fun!
Too many people say stuff like "just wanted to add my .02 cents" which IMO deals a severe blow to their credibility.
Coincidentally those are the people who work for Verizon.
this nation, under God, shall have a new birth of freedom. -- Lincoln, Gettysburg Address
Now, Sun, if you would just fix the damn date, time, and calendar arithmetic class library! Or is 12 years not enough time?
Obviously, the fact that Java has been around 3 or 4 times longer than .NET is going to mean it has more depth. Being newer isn't a design flaw.
.NET, not so much, so you made the best decision given your skill set.
As far as your personal project is concerned, you shouldn't count the time you screwed up as time you spent on C#. It also sounds like you know Java well and
Yes, as in "strong and promotes growth."
Unit conversions are invertible functions. It simply doesn't matter which units you use as the low-level representation.
You're missing something more basic: magnitudes form the basis of an algebra that's isomorphic to algebra on the real numbers. That's the whole reason that it's possible to use operations on numbers as a surrogate for operations with magnitudes: e.g., you can find out how long two pieces of wood placed end-to-end would be by adding numbers that stand in the correct relation to the magnitude of their lengths.
The number 1 doesn't have any special properties in this connection. It's just another real number. (0 is another story, of course, because it's the identity.)
This is really a static type analysis problem. It's possible to do some of this in languages with really powerful type systems, like Haskell; here is a link to a Haskell library that performs compile-time dimensional checking.
Are you adequate?
Ada is back.
You can defy gravity... for a short time
I'd really like to see "fuzzy" values next. Particularly fuzzy values for dates.
Almost every application out there stores absolute times. But very often you don't know the exact date and time and you'd like the computer to be able to still record, display (in localised form) and sort it according to what precision you do have - sorting "January 6, 2007" before "Some time in summer 2007". Free text fields and ad-hoc date notations suck.
I read the PDF, looks very interesting. I don't feel qualified to comment on the scientific suitability, but I have one suggestion with regards to naming:
:)
SystemOfUnits - would it be possible to rename it to UnitSystem? Easier to write, and especially easier to say in a conversation, which one sounds better if you are talking to colleagues during a code review? For instance -
"Here I've used the SI UnitSystem, but perhaps another UnitSystem would be preferable?"
vs
"Here I've used the SI SystemOfUnits, but perhaps another SystemOfUnits would be preferable?
On the other hand, to avoid confusion the SystemUnit class would then have to be renamed to something else - USUnit maybe, which looks ugly, or UnitSystemUnit which is both ugly and awkward. Hmm, difficult choice. Maybe SystemOfUnits isn't that bad after all.
Cheers,
Lars
Being bitter is drinking poison and hoping someone else will die
I know upgrading is not always desired or possible with 3rd party app-servers etc, but in the case of 1.6 you seriously need to consider the move. 1.6 will boost your performance considerably, while you need to change virtually nothing. It also brings along some bugfixes (which, granted, also can result in behavior changes that need to be re-tested, but you have test suites, right?) and platform improvements.
Seriously.
With great power comes great electricity bills.
To use the units of measurement easily it would be helpful if
...
Java had user definable operators or at least operator overloading.
That way a more "natural" notation of formulas would be possible.
Abstract data types would also help with measurement units
Greetings Thomas Mertes
Seed7 Homepage: http://seed7.sourceforge.net/
User defined statements and operators, abstract
data types, templates without special syntax,
OO with interfaces and multiple dispatch.
I was actually trying to create a parody of a riduculously-strongly-typed language, which I was going to call "Rosie" (something else you can have a cup of, see
reset h
h/feet = 3
h/feet/inch=3.370007
leaves h/inch equal to 39.370007 and h equal to 1. I never finished coding up the interpreter, though
Je fume. Tu fumes. Nous fûmes!
Shut up! ;)
PS: My sig is a Verizon-related pun
My 0.02 cents
Not using templates - templates weren't even reliable in G++ in those days. I did try using them, but it quickly became unmaintainable.
I used an Emacs Lisp program to generate C++ classes for every dimensional combination in our programs, and operator overloading to combine them.
For example, we had "Velocity", "Speed", "Time_Interval", "Absolute_Time", "Position", "Acceleration" and several other classes, which could only be combined in certain ways. We had different types for different numbers of dimensions, too - 1d, 2d, 3d.
When compiled it all came down to simple arithmetic - nicely optimised. But any mismatch in dimensions showed up as a reasonably clear compile error. It worked really well. And it was reasonably maintainable with the Lisp code generator.