Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Why does Java not include enough useful utilities ?

 
Ranch Hand
Posts: 143
6
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many utility functions which could be useful for a large number of people, but Java either does not provide them at all or provides them too late. For example, get the sub-string between two strings that occur in a given string - https://stackoverflow.com/questions/16597303/extract-string-between-two-strings-in-java. Other examples - Joda time library, Lombok (no more boilerplate code for getters and setters !). Google first provided the libraries needed for functional programming with lambdas. But, Java only provided that starting with version 8. I am sure there must be more examples like these.

Why does Java provide such utilities so late or simply never provide them ?
 
Rancher
Posts: 527
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if there were lambdas before java 8.  I'm guessing they'd rather focus on big helpful changes, like lambdas, or referencing with val, instead of adding simple functions that a small library can provide.
 
Marshal
Posts: 25927
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One man's "useful utility" is another man's "useless cruft". There may be people who need to find the string which sits between two substrings, but in my opinion there can't be very many of them. I certainly wouldn't expect to find that in the standard API, not unless there were several dozen other similar but not the same methods. And it's about four lines of code if you don't use regex, so you'd think it would take most of those people about one minute to write the code.
 
Saloon Keeper
Posts: 6625
161
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's only so much you can include and maintain. Java was made extensible for that reason, and 3rd party libraries for all kinds of stuff duly turned up. Sounds good to me.
 
Sheriff
Posts: 4889
317
IntelliJ IDE Python Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tom Joe wrote:Lombok (no more boilerplate code for getters and setters !)


I have a special dislike / distrust of project lombok. To be honest I have a baseline skepticism / distrust of most 3rd party libraries, in fact I don't really like some of the really mainline ones such as Spring and don't get me started on Hibernate.
 
Marshal
Posts: 70598
287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What made you think Java® doesn't provide Joda time?
 
Rancher
Posts: 912
22
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO... because Java is not C#.  Sun did not want to get into a pissing contest with MS after kicking their butts on the Java law suite.  It took Oracle to adopt the MS assembly line type of release schedule that MS has enjoyed and been blasted for all these many years I've been in programming, and rush to become C# like.  BTW: I have on several occasions been employed by MS partner corporations and consulting firms... it has not increased my opinion of them, but rather, has diminished my exuberance for their products as I became all too familiar with them.

Tom Joe wrote:There are many utility functions which could be useful for a large number of people, but Java either does not provide them at all or provides them too late. For example, get the sub-string between two strings that occur in a given string - https://stackoverflow.com/questions/16597303/extract-string-between-two-strings-in-java. Other examples - Joda time library, Lombok (no more boilerplate code for getters and setters !). Google first provided the libraries needed for functional programming with lambdas. But, Java only provided that starting with version 8. I am sure there must be more examples like these.

Why does Java provide such utilities so late or simply never provide them ?

 
Saloon Keeper
Posts: 12402
269
  • Likes 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les, I work in a software company that builds solutions that tightly integrate with many different Microsoft products. Over the past 5 years I've made two primary observations:

  • Microsoft has made great steps in becoming more open-source, and becoming less evil in general.
  • Microsoft still employs mainly shit programmers and it's horrible to write software that interfaces with their products.
  •  
    Tim Cooke
    Sheriff
    Posts: 4889
    317
    IntelliJ IDE Python Java Linux
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Stephan van Hulst wrote:Microsoft still employs mainly shit programmers and it's horrible to write software that interfaces with their products.


    This actually made me audibly laugh. I think our glorious leader Paul Wheaton will also be amused by it, he has a special dislike of Microsoft.
     
    Saloon Keeper
    Posts: 22630
    153
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Likes 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Getting a string from between two strings is a stock task using Regular Expressions. Or, if you'd rather keep your sanity, it can be made into your very own personal utility method by stringing common substring/find functions together. But actually I rarely do that particular operation, and when I do, it's usually something I do with command-line file utilities, not part of an application. Not a good example of Java lacking "useful utilities".

    Java has one of the richest utility compendiums around and, as I'm at the moment having to deal with a much-poorer but venerable alternative language, I miss that stuff.

    As for dumping on Microsoft programmers, that's what happens in large corporations. They get hordes of cheap developers so that they can save money to blow on overpriced and often-useless business systems and consultants.

    The main problem with Microsoft at the moment is a serious lack of quality control. It's been nearly a year since Windows was even trustworthy at the mediocre level that we expect from big-name software products. Every new fix release since then has come with a free game: the "What essential function breaks and renders Windows unbootable?" game.

    I don't think Microsoft loves Windows anymore.
     
    Les Morgan
    Rancher
    Posts: 912
    22
    Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Stephan,

    I used work for a Microsoft partner firm and one day we had the MS Engineers down explaining the ins and outs of OLE, object linking and embedding, and it went something like this:

    We have a standard that says you will expose your proprietary interfaces to the view of the world, including all of your competitors, so that we can have a standard that works really nice across all compatible products.

    The engineer then smiled and said: not everyone is forthcoming with their full interface and not everyone gives all of the interface points to make everything work perfectly because after all, business is always trying to get one over on their competition. (my little thoughts here: MS always does that with its partners--keeps them in the dark as much as possible, while exploiting whatever they can from their agreements.

    Les

    BTW: MS's move to be more open, which is a good thing, is self-preservation.  Back when I started MS had about 85%+ of the web, but after Linux and Apache hit the market that soon reversed where everyone else had 85%+ of the market and MS was picking over 15% or less.  It took them a long time to see the writing on the wall that they either had to become more agile across platforms and products or people were jumping ship.  IMO: if the user population, our end-users in business, didn't have the inherent knowledge available from MS release to MS release, which they really messed up in 8 and completely made 9 disappear, Ubuntu would be on all the desktops and MS would be a token in the history of computers.

    Stephan van Hulst wrote:Les, I work in a software company that builds solutions that tightly integrate with many different Microsoft products. Over the past 5 years I've made two primary observations:

  • Microsoft has made great steps in becoming more open-source, and becoming less evil in general.
  • Microsoft still employs mainly shit programmers and it's horrible to write software that interfaces with their products.
  •  
    Ranch Hand
    Posts: 127
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Tom Joe wrote:There are many utility functions which could be useful for a large number of people, but Java either does not provide them at all or provides them too late. For example, get the sub-string between two strings that occur in a given string - https://stackoverflow.com/questions/16597303/extract-string-between-two-strings-in-java. Other examples - Joda time library, Lombok (no more boilerplate code for getters and setters !). Google first provided the libraries needed for functional programming with lambdas. But, Java only provided that starting with version 8. I am sure there must be more examples like these.

    Why does Java provide such utilities so late or simply never provide them ?


    RegEx are a part of SE API since 1.4 wich was released in early 2002, only about 8 years after initial 1.0 release in 1996. And although I don't know I guess there was some lib pretty early on to do such tasks - and then RegEx showed up in 2002.
    RegEx under the hood work no different than searching and substring and splitting and checking for equality. So, if you ask if it was possible to split up a String to get data inside of tags before Java introduced RegEx - sure it was, it just required you to write all what a RegEx does yourself - and the given example would only require a loop for search for the start tag, then for the end tag, and then just substring between the indexes. With some ugly unreadable code this can even be a one-liner. So, in fact, using RegEx is more complex than not for this sample task.
     
    Ranch Hand
    Posts: 33
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Stephan van Hulst wrote:Les, I work in a software company that builds solutions that tightly integrate with many different Microsoft products. Over the past 5 years I've made two primary observations:

  • Microsoft has made great steps in becoming more open-source, and becoming less evil in general.
  • Microsoft still employs mainly shit programmers and it's horrible to write software that interfaces with their products.


  • Can Microsoft make more money by making it hard to interface with their products ? I mean, like being a dominant car maker & designing your cars to require frequent maintenance from authorized repair shops ? If yes, then it is a good strategy until good alternatives start showing up. One can always dip into the huge pile of cash from the good days. Perhaps even do charity with some of that cash.
     
    Greenhorn
    Posts: 8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Stephan van Hulst wrote:Les, I work in a software company that builds solutions that tightly integrate with many different Microsoft products. Over the past 5 years I've made two primary observations:

  • Microsoft has made great steps in becoming more open-source, and becoming less evil in general.
  • Microsoft still employs mainly shit programmers and it's horrible to write software that interfaces with their products.


  • That is absolutely true things and I am also thinking the Lambda is the only things which is introduced in Java 8.
     
    Tim Holloway
    Saloon Keeper
    Posts: 22630
    153
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    When Java was initially designed, Gosling and his crew looked carefully at the features available from other programming languages, especially C++. The goal was to produce a portable, standardized and efficient language environment designed from the ground up for object-oriented design, for security, and for reliability.

    This meant discarding pointers and multiple inheritance, limiting casts, runtime overhead that strained the processors of the day and a lot of other decisions. Some of which have been since regretted. But Java is a living language and its design has been impacted by its usage, by influences from other ecosystems and by advances in understanding. Lambdas, for example, are such a fundamental part of LISP that parameterized functions are almost an afterthought - they're built on lambdas, But traditional procedural and OOP languages rarely implemented lambdas. One of the primary reasons why Java finally adopted lambdas was that in the absence of explicit C-style pointer-based callbacks, a rather clunky mechanism of anonymous inner classes had become necessary to achieve many goals - Swing in particular made heavy use of that mechanism. Lambdas make the process much cleaner.

    Java will continue to grow and evolve. Some ideas are not yet ripe. There is also the need to avoid throwing in every possible concept into the language lest it become cumbersome and hard to learn and use. Like most successful products, it is "good enough", and better than many of its alternatives, and it will continue to address needs as they arise.
     
    Greenhorn
    Posts: 18
    3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There's a lot of history behind Java now - 25 years or more - so things have evolved a great deal, as Tim points out.

    Also, there are key philosophical differences in how different language communities treat these questions.

  • Python was always intended as a "batteries included" language, with a comprehensive set of standard functions implemented (mostly) in a consistent  "Pythonic" style. The idea is that people should be able to pick up Python quickly and starting achieving their goals as quickly as possible.
  • Scala was also largely intended to provide a lot of functionality in the standard libraries (especially the Collections), although the Scala community has at times resisted the full "batteries included" approach. Scala is also a "big" language with a complex type system, which adds to the challenge of getting started with Scala (although you can just ignore a lot of the fancy stuff).
  • Java started out as a very small language (unlike Scala) with a minimal set of libraries (unlike Python) and a tendency to leave it up to individual developers to roll their own functionality for particular purposes.  My experience is that this led to a lot of re-inventing the wheel, multiple competing libraries to do basic things, and glaring gaps and inconsistencies e.g. why did it take 20 years to clean up the mess around dates and times in Java?

  • So it's also a question of what the original goals of the language were and what the community around that language sees as a priority.
     
    Campbell Ritchie
    Marshal
    Posts: 70598
    287
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Christopher Webster wrote:. . . . why did it take 20 years to clean up the mess around dates and times in Java?  . . .

    And why did it take that long to get Objects#equals() and similar methods?
     
    Tim Holloway
    Saloon Keeper
    Posts: 22630
    153
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    My impression actually is that Java started out richer than Python.

    Java has been since its earliest design an Object-Oriented language. That made it virtually mandatory that it should have a certain bare minimum set of classes to function effectively. So the JavaDoc for the core JVM shows lots of classes and methods and many of them date all the way back.

    Python, on the other hand, started out as a procedural language. Procedural languages tend to be minimalistic. In fact, you can largely blame C and its evolved standard function libraries for setting what basic requirements that successor languages do have.

    Python, however, did gain a lot of functionality from a more or less centralized resource ("the cheese shop"), whereas Java had several independent big-name interests, including the Apache project, codehaus, and CollabNet, to name just a few. While these days, almost everything is hosted on GitHub, back then the closest approximation was SourceForge, and it was not as universal. A lot of Python's libraries are relatively new, and especially anything OOP-related, since that's not Python's original paradigm, and thus they are more prone to be centrally-locatable.
     
    Christopher Webster
    Greenhorn
    Posts: 18
    3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Interesting points, Tim.  

    My own experience with Java started in 1996, when the JDK offered what seemed to me like a minimal set of functionality and I struggled to think of anything I could usefully do with it. Maybe a failure of imagination on my part, but it certainly felt like a bare-bones language to me at least. OTOH it was a heck of a lot easier to get started with than C...

    I started with Python later in its life-cycle, when the "batteries included"philosophy already felt like a core element of the language and it certainly felt a lot richer than core Java did, but I guess I missed the pre-history here.

    I think Campbell's point about object equality also relates to C's legacy, the idea that we would care more about whether an object reference refers to the same location than whether two instances of Person contain the same attribute values.  Another reason why I prefer Scala and its nice friendly case classes!
     
    Tim Holloway
    Saloon Keeper
    Posts: 22630
    153
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Christopher Webster wrote:
    I think Campbell's point about object equality also relates to C's legacy, the idea that we would care more about whether an object reference refers to the same location than whether two instances of Person contain the same attribute values.



    That gets into interesting territory. On the one hand, nothing about an object "reference" says that said reference has to be a memory address pointer. In fact, I believe that machines have been built with no addressable memory at all. The classical Turing Machine doesn't require addressable memory as I recall. On the other hand, there's also nothing in the abstract spec that says that the same object reference is constrained to actually reference the same object implementation so long as all implementations meet the "==" operator test. That has implications on VMs with possibly distributed internals and/or partitioned address spaces.

    Then there's the equals() method. I think most of us have discovered that, for example, two identical Strings might not satisfy the "==" operation. But conversely, two "equal" objects might have different property values. That, in fact, is an essential characteristics of the Java Persistence Architecture, where you can have 2 instances of an object, one freshly fetched from the database and one fetched earlier with field modification. The thing that makes these object "equal" is that they have identical database key values, even though they are 2 separate and distinct objects.

    Self-defined languages - especially OOP languages like Java often have introspective capabilities. But Java has probably leveraged them more than most languages. And we've learned much about what introspective methods are most convenient (or even essential). So it's not surprising that occasionally the language environment gets periodic improvements. Plus Java is not 100% pure OOP. In Smalltalk, if memory serves, you can redefine 9 as "gary" and no problem (until you try to do arithmetic with it!). In Java, there are the binary primitives and the corresponding boxing objects. And then there's null, which is not an object and thus cannot be used as the referent for object methods such as "if null.equals(someObject)".

    So Java is full of kinks and kludges, and that's what recent updates have been trying to go back and paper over.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic