Java (and Similar Languages) Missing Objects 2 - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Java (and Similar Languages) Missing Objects 2 (778 Views)
1 Reply
| Java (and Similar Languages) Missing Objects 2 by fallguy(op): 12:37am On Dec 12, 2012 |
sequel to a previous post. this one is wilder and more speculative. 1.) smart variables ----------------------- i dont see any direct application of this concept, but then many 'nice-to-have' concepts that were implemented did find some practical use in the future. the idea is that a variable once reassigned should be able to remember its previous value. this can help in debugging. for example - in imperative programming, if var is a variable, var = A; var now points to A. var = B, var has lost memory of its previous value . a smart variable would consume memory and be inefficient and all that but then its all about - being able to recall,and i would reflect real world scenarios. in a phone conversation that got interrupted or when a speaker digresses, they can backtrack and get back on track often by asking "what was it i/we were talking about b4 i got interrupted/rambled off" 2.) more realistic generics ------------------------------ the whole generic concepts as taught in textbooks is built around restricting acceptance of objects into a container, but sometimes one may want to valid objects to belong to a set, instead of being just one type. anyone that belongs to the set can then make it thru instead of getting bounced. presently a list that accepts only integers could be defined as: List<Integer> what if i want a list that accepts any of Integer,String,Employee. I could be wrong here but the explanation on generics is pretty loosey and i'll have to create different signatures for this. the work around is to create your own data structure and create a registrar and bouncer - but the idea is that there should be only 1 signature- . 3. Exception throwing should be switchable ----------------------------------------------- like it is in c++ ,that crappy language. but it helps sometimes that a constructor that throws exceptions , shouldnt throw it- e.g when instances of the type are to be created as static final members in a nother class, before the enclosing class' constructor is called. wrapping the final constants in try/catch block to handle the exception that they may throw but (wont') is impossible!! 4.) 2 way regular expression pattern object ------------------------------------------------ again, i dont use regular expressions- its ugly and i always promise that i'll get around to learning them so this piont could be wrong- but the idea here is - that regular expressions match strings , a pattern is specified and a string argument is matched against the pattern. pretty flat. idea is, specify a pattern, and if a string matches the pattern, the string could be split into the components of the pattern. how could this be useful. for those string parsing programs - and believe me - string parsing is one huge body of programming work. say, a string pattern is to match - (Numbers)(Operators)(Numbers)... (for a calculator app) the regular expression could split the arguments into an array of string matching the pattern. in the said calculator app,this will save the programmer writing the tokenizer, this could be used to split credit cards,zip etc. bye bye redundant tokenization. 5.) more meta capabilities imbued in class object ------------------------------------------------------ For now any meta functionality in java/c sharp is relegated to the reflections package. but because java classes make reflections work so cumbersome, the programmer has to do meta tasks manually, how? he runs javap , or runs the javadoc -- to see which method exists in a parent , if one is programming a class, he cant say - if method X exists in parent, //do this its just not possible. so java programmer has to live in a bloated IDE or juggle btw javadoc and code he's writting- the more meta capabilities that ar primitive to a class, the more a programmer can do with less. another scenario is that , when a class is created, its super classes are constructed and the methods are hard-wired into the parent, but if the methods are stored in a mapping structure, then faster programs can be created if programmer can deliberately empty all the super classes hashmap and the program only loads super methods as needed!! but there maybe some caching scheme in place but point be , methods are too hard wired to classes. languages like Io have gone back to the simpler way of just treating methods as hashmap objects. 6.) accessing program data at runtime ---------------------------------------- I think this may have been solved. but i'm not sure- early beginners in programming often fall into the trap of wanting to use not the value of a variable but it name programatically. e.g int x = 10. what is x,can be determined easily but - getting the name of all integer variables whose value is 10, is hard. the data in the program is not easily accessible , this could be justified but it can be limiting and frustrating. programmers want full access full knowledge- no restrictions. 7.) modifiable software at runtime ------------------------------------------ I think this will he preserve of AI systems for programs that can modify themselves when running, this will required that 6. above become reality, and that the program come with its compiler, luckily this is a reality. modern java comes with a compiler interface, though its documentation is horrible and pathetic. |
Live Question And Answer Section For Android, Java And Php From 7-10 Pm Everyday • Difference Between Java And Javascript • Re: Java And Biometrics • 2 • 3 • 4
Mobile Computing/application/development: Where To Start. • Do U Read Terms And Condition Of Websites Before Signing Up • Vb.net And Java