Declarative Programming in Java

Discussions

News: Declarative Programming in Java

  1. Declarative Programming in Java (25 messages)

    Many developers are excited for the world of metadata. The wave hits with JDK 1.5, and this article discusses JSR 175 in some depth. The basics of annotations are discussed, examples given, a comparison to .NET attributes, and finally areas where we may see this metadata pop-up.

    Conclusion
    Every new release of Java has introduced new features, but few warrant a new way of thinking to realize their full potential. Using annotations effectively to simplify programming in Java requires a shift in our thought processes. Even though we use declarative programming languages such as SQL and XSLT most frequently, it may take some time for us to understand how to use declarative and imperative programming together.

    Here are a few things you could do with annotations to simplify or empower your programming:

    • Develop code generators using annotations.
    • Develop a new unit-testing framework using annotations, such as NUnit.
    • Think about ways to extend the compiler using custom annotation handlers.
    • Think about annotation's role in defining AOP extensions to Java.
    Read Declarative Programming in Java

    Threaded Messages (25)

  2. Declarative Programming in Java[ Go to top ]

    I didn't get very far and ...

    "An EJB only implements the business logic". [Sirens and Flashing lights go off]
  3. Declarative Programming in Java[ Go to top ]

    "Many developers are excited for the world of metadata"

    Many developers are also exited about "grammatics" ;-)
  4. Declarative Programming in Java[ Go to top ]

    "Many developers are excited for the world of metadata"Many developers are also exited about "grammatics" ;-)
     
    Yes, han, many developers may have exited the world of metadata, but I am more excited to hear about the 'grammatic' structure of earlier your post ;-).

    excite -- excited
    exit -- exited
  5. Declarative Programming in Java[ Go to top ]

    Yes, alok, they have exited grammar. Don't you get it?
  6. Men your are just to bad :-)

    But, as a developer, what makes me really excited is a nice beer, a nice blond, and nothing else to worry about.
  7. Metadata![ Go to top ]

    Man - the NUnit and web services structure in .NET rocks. I can't wait until we have some stuff like this in java with an IDE to support it!

    Better late than never I guess.
  8. Metadata![ Go to top ]

    Man - the NUnit and web services structure in .NET rocks. I can't wait until we have some stuff like this in java with an IDE to support it!Better late than never I guess.
    Thats odd, cause my Java IDE does. Now the stuff talked about in this article ... . Its cool and all but I am still trying to get the normal developer to understand the "basics" (in both Java and C#).

    Kinda funny - I thought the exact sort of thing when I went from doing VB6 to Java\VAJ. Even more funny - most of the things I need still are not in VS.Net. Would be nice though to have the new stuff in Eclipse, etc. Give them a week or so ... .
  9. ?[ Go to top ]

    Is it just me or did anyone else come away more confused? Doesn't seem as simple and as Attributes in C#.
  10. Declarative Programming in Java[ Go to top ]

    Maybe I'm jaded, I don't see much value in this article, all it does is describe JSR 175 and its API without actually taking time to reflect on what it makes possible.
    A declaration cannot have multiple annotations for the same annotation type.
    This is not quite correct, you simply use an array of those when you need multiple annotations to be present.

    Also, saying that SQL is a declarative language takes the cake.

    Disappointing.

    --
    Cedric
    http://beust.com/weblog
  11. Maybe I'm jaded, I don't see much value in this article, all it does is describe JSR 175 and its API without actually taking time to reflect on what it makes possible.
    So true. Actually, there is no good material on the web that look deep into the limitations of JDK 1.5 metadata annotations and available workarounds based on real life usage.
    I'm fed up with Hello World samples.
  12. Maybe I'm jaded, I don't see much value in this article, all it does is describe JSR 175 and its API without actually taking time to reflect on what it makes possible.
    So true. Actually, there is no good material on the web that look deep into the limitations of JDK 1.5 metadata annotations and available workarounds based on real life usage.I'm fed up with Hello World samples.
    Well, since you called me on it, I decided to do something about it :-)

    I posted a few thoughts here. Comments welcome.

    --
    Cedric
  13. DBC using MetaTag[ Go to top ]

    We can extend the language to include invariant expressions for classes and modules, and pre- and post-condition expressions for functions and methods. With this Java will support 'Design by Contract', beyond "a simple assertion facility" look at: http://developer.java.sun.com/developer/bugParade/bugs/4449383.html
  14. DBC using MetaTag[ Go to top ]

    We can extend the language to include invariant expressions for classes and modules, and pre- and post-condition expressions for functions and methods. With this Java will support 'Design by Contract'...
    Luscious! Now you're talkin' high quality software, the kind of software I can trust. The possibility of DBC encoded as metadata proves to me that Java annotations is a great concept. Annotations provide the most extensibility to Java, in a way very similar to XML. And an XML document can be the content of a Java annotation.

    I checked the BugParade 4449383, and Sun's evaluation of it says that DBC depends on JSR-199, which aims to publicize the javac package's entry point. Sun's evaluation doesn't consider metadata! Elsewhere on the bug ticket, an astute surfer added a remarking about this missed opportunity. Sun should jump on metadata for DBC instead of creating Java keywords. If you have a spare bug vote, visit it's ticket.
  15. Starting a campaign[ Go to top ]

    Anyone knows how to start a campaign to put DBC in Java using metadata (jsr 175)? We should vote in 4449383 ( 'Design by Contract', beyond a simple assertion)?

    Whe sould use JCP? How we can submit this idea to JCP?

    This link is provided as additional resources for voting in the bug : http://developer.java.sun.com/developer/bugParade/bugs/4449383.html
  16. Starting a campaign[ Go to top ]

    Anyone knows how to start a campaign to put DBC in Java using metadata (jsr 175)?
    Annotated DBC deserves its own JSR. Until then maybe someone wants to start a SourceForge project?
  17. SQL is declarative[ Go to top ]

    Also, saying that SQL is a declarative language takes the cake.
    SQL /is/ a declarative language.....


    Can I have my cake now?


    :)
  18. SQL is declarative[ Go to top ]

    Also, saying that SQL is a declarative language takes the cake.
    SQL /is/ a declarative language.....Can I have my cake now?:)
    Nope, your assignment is to read up on Prolog and then check back here again :-)

    --
    Cedric
  19. SQL is declarative[ Go to top ]

    FYI

    http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?query=Declarative

    "...A general term for a >>>relational<<< language or a functional language, ..."
  20. SQL is declarative[ Go to top ]

    A SQL statement is a specification of "what data I need". It does not specify the actual mechanism for accessing that data. It is the job of the query optimizer to choose an execution plan from the space of all possible execution plans that could satisy that specification.

    When I write a SQL statement, I don't tell my database "do a full table scan on A, then nested loops join from A to B using an index scan on B". I just tell it: "I want rows from A and B that satisfy this join condition".
  21. SQL is declarative[ Go to top ]

    Okay let's not engage in a language war because we all know where this path leads, but just a quick comment on your definition:
    A SQL statement is a specification of "what data I need". It does not specify the actual mechanism for accessing that data. It is the job of the query optimizer to choose an execution plan from the space of all possible execution plans that could satisy that specification.When I write a SQL statement, I don't tell my database "do a full table scan on A, then nested loops join from A to B using an index scan on B". I just tell it: "I want rows from A and B that satisfy this join condition".
    By this definition, you could say that C is a declarative language because when I write "t[i]", I am just telling it what data I need and I don't care if it involves dereferencing a memory location to get it...

    Anyway. Back to the thread.

    --
    Cedric
    http://beust.com/weblog
  22. SQL is declarative[ Go to top ]

    I was curious and for whatever it is worth various sources indicate SQL is classified as a declarative language e.g. http://en.wikipedia.org/wiki/Declarative_programming_language
  23. AOP as a consumer[ Go to top ]

    This has been reposted from my BLOG So comment there too if you like. Anyways.....

    I've been saying this over and over again, but I'll say it again. AOP is a perfrect consumer for annotations. Combine the two and you practically have pluggable Java keywords. We have a number of annotated aspects within JBoss AOP that take advantage of this feature. JBoss AOP currently has proprietary support for annotation-like tags. YOu can define doclet tags, annotations are described in XML, and then attached to your classes. The upside to this is that it works in JDK 1.4. Downside is that it is untyped.

    BUT.....

    Currently we're working on following for JBoss AOP:
    * Javassist 3.0, our bytecode manipulation framework, has support for adding, modifying, creating, and removing JDK 1.5 annotations from existing Java class files. This is finished in CVS, but not released yet.
    * JBoss AOP also has JDK 1.5 annotation support as well within CVS.
    * Currently I'm working on an annotation compiler that will generate and embed annotations into Java classes from doclet and make them available through JDK 1.4. JDK 1.4 class file format is compatible with annotations. This should be committed soon. An abstraction will be provided so that you can have the same code that works for JDK 1.4 and JDK 1.5.
    * JBoss AOP will also provide annotation introductions so that you can introduce annotations to any Java class.

    A new version of Javassist and JBoss AOP will be out in a week or two so you can play with these features. If you can't wait, you can grab this stuff out of our CVS and try it out. Just navigate to www.jboss.org for more info.

    Bill
  24. AOP as a consumer[ Go to top ]

    I think Metadata will make a lot of things possible. Development will look much different in Java 5 years from now. I can't wait.

    Steve
  25. Ya know, all of this is very interesting but, I see it a distraction. It encourages the development community to focus on the technology instead of providing solutions to real problems.

    Wait, but it is really cool. That doesn't cut it in the developing large scale enterprise solutions where you have to deal with some many different variables. I think I'll wait until I can see some real concrete advantages.

    Because its is cool isn't Good enough.
  26. Contrary to imperative programming, declarative programming is a programming paradigm by giving specification rather than the algorithm of how to find out the solution. On another word, you are the boss: you tell what to do, and the interpreter figures how to do.

    Apparently SQL is declarative - you tell how the data relates to each other but not how to find the data out of the database, unlike the good old network database. Logic programming is also declarative, e.g. given the relation parent(X,Y), I can define what the relation ancestor(X,Y) is like this:

    ancestor(X,Y) :- parent(X,Y).
    ancestor(X,Z) :- ancestor(X,Y), parent(Y,Z).

    which reads somebody’s parents are his ancestor and his ancestor’s parents are still his ancestors. You figure out what ancestor is, and the logic programming systems will find all ancestors for you.

    You see, the above examples are of semantics and that is what declarative programming really cares about. Without semantics, every body can tell different stories of the given information. This is just like <table> tag of html file. Some think of it as a tabular containing data, but others may think of it as a positioning element for better layout.

    So the annotation of Java code is by no means any sort of declarative programming. It just gives some information to the source code but not the semantics. You cannot tell what the source code is really about. For example, if a annotate that a class method is about finding out all the solutions of the famous eight queen puzzle but the source code I wrote is buggy and found only 80 solutions amongst the 94 solutions, is that really declarative?