This statement is VERY valid - well so often we need to jump over OO loop optimizing and adapting out code in situations where OO approach is completely and totally useless and result can be achieved much faster and by far more efficient without OO rubbish. And B4A as Java related language is very prone to such problem.........optimized or otherwise adapted to an object-oriented approach.....
interesting: can you provide a sample?so often we need to jump over OO loop optimizing and adapting out code in situations where OO approach is completely and totally useless and result can be achieved much faster and by far more efficient without OO rubbish.
I understand what you are suggesting. But do you really need it? A programme will not run twice as fast because of this.well so often we need to jump over OO loop optimizing and adapting out code in situations where OO approach is completely and totally useless and result can be achieved much faster and by far more efficient without OO rubbish.
I do not understand what you referring to GOTO or OO? having or not having GOTO does not impact speed of final code nor restrict logic anyhow. It is mere convenient tool that allow from time to time create more elegant code. This is about it. OO and especially Java with all those Virtual Java Machines severely slow final code and we afloat only because we have enormously powerful processors multiplied on fast and practically unlimited memory nowadays. Even VB with stupid conversion of everything (even integer!!!!) before multiplication and division to ugly Variant (that never meant to be exists, IMHO) and then converting it back to whatever it was another real killer of speed of final code....A programme will not run twice as fast because of this....
I have to dig my code to give you practical example and I am too lazy to do so. One notorious example that I remember I need to manipulate with string and string method was unable to do what I want, so I have to declare another structure that I use for nothing but just achieve requested functionality. Incredibly ugly and incredibly non-obvious, much more so than using GOTO. Plus continuous requirement to convert strings back and forth if you need to use them outside B4A. Ugly and unproductive in both writing code and speed of execution.interesting: can you provide a sample?
This is purely wrong. Java and the JVM are extremely fast. The compiler optimizes many things and all kinds of preoptimizations are simply a waste of time.OO and especially Java with all those Virtual Java Machines severely slow final code
Hard to say anything without an example.One notorious example that I remember I need to manipulate with string and string method was unable to do what I want, so I have to declare another structure that I use for nothing but just achieve requested functionality. Incredibly ugly and incredibly non-obvious, much more so than using GOTO.
???Plus continuous requirement to convert strings back and forth if you need to use them outside B4A
The compiled output is very fast, believe me.Java with all those Virtual Java Machines severely slow final code and we afloat only because we have enormously powerful processors multiplied on fast and practically unlimited memory nowadays
Erel, with all respect there is no person in whole Universe that potentially could convince me that interpreter (JVM) will be as fast as direct optimized code. I am in this business from middle 80-s.This is purely wrong. Java and the JVM are extremely fast. The compiler optimizes many things and all kinds of preoptimizations are simply a waste of time.
Hard to say anything without an example.
???
By definition pseudo-code run by JVM cannot be faster (and even cannot have the same speed) as native code to processor. I was searching for converter Java to native code and I did not succeed - all of them restricted in this or that way. Believe me it seems to you fast enough purely because nowadays we have enormously fast hardware.The compiled output is very fast, believe me.
If it too fast for you you always can put few dummy cycles. But you cannot make it faster than processor's abilities....Who is in need of that speed?
It would be correct if you talking about true compiler with optimizer. And it would be incorrect for JavaA well-written programme hardly makes any difference to a pure machine programme in terms of processing speed after compilation.
Come on! Firstly there is C that allow you to write fast code that almost directly translates into machine code. And secondly leave untouched program written in C and in Java and try to modify it after 10-15 years. Chances are that competent programmer in C will do it with easy while in Java you will face whole lot of new methods and structures and half of method in original program will be depricated and unknown to new generation of programmers. This is if it will work on "updated" JVM altogether.As a rule, the programme waits for input from a user at some point anyway. Of course, there are also applications that are very time-critical (weather forecasting and climate research, the calculation of corresponding models). But these are very specialised and there are more specialised high-level languages and more sophisticated compilers for them. The processing speed of today's processors is so high that the effort of processor-orientated programming is simply not worth it. Programming costs a lot of money and trying to write a complex programme in today's machine language is simply futile and uneconomical. Who, for example, is supposed to maintain this code and adapt it to constantly changing conditions? In my opinion, it is a hopeless battle. In addition, there are a large number of sophisticated processor architectures that are constantly changing, and it is nowhere near as easy as it used to be to write the code for at least one processor family.
Disagree. More often then not it not dictated by "evolution" but rather by fashion and desire to create new business opportunities. Heck, VB6 is still alive and everyone excited about TwinBasic. C is still here and even Assembler (though for very special stuff). And yet Fortran is still here among scientific community. And how many new and "progressive" technologies sank to the bottom of Mariana Trench in last 3 decades? Java in my eyes has only one advantage - theoretical possibility to run everywhere. Theoretical because you cannot have universal classes that could work on absolutely any device. And who ever going to run my application written specifically for Android bar-code gun on Oracle Solaris??????????? It was born because of specific device and it will die once device disappears. No portability ever required for such applications.Many programming principles (such as lazy loading) lead to further increases in speed and make sense.
If you use such techniques, I personally see no reason to go back to the roots. That would no longer work in today's fast-moving world.
Of course you can also implement new commands in an established high-level language, why not if it makes sense. But times, technology and programming techniques have changed. They have actually developed in an evolutionary way, unproductive stuff has fallen by the wayside and largely died out. A lot of money is at stake.
JVM is not an interpreter. However more importantly, I'm fine with people having different opinions, even if I know that they are wrongErel, with all respect there is no person in whole Universe that potentially could convince me that interpreter (JVM) will be as fast as direct optimized code.
Well, some of your considerations are understandable, but simply cannot be economical. It's highly theoretical. True, but no way to make it work as you want. What is your problem with the string functions? It is precisely these functions that can be wonderfully replaced via the substring functions. You no longer need LEFT, MID, RIGHT, you can easily search for substrings or replace them. Only the syntax has changed.I never understand what is wrong with functions for string manipulation and why I have to use ugly inconvenient and cumbersome methods. In B4A (read in Java) all string manipulation is nightmare comparing to VB6 where string manipulation very inconvenient comparing to C.
This or that JVM is additional layer that consume computer resources that otherwise could be funneled to do main task. Again with modern super-fast hardware, multicore processors and real life considerations like awaiting for user input difference is so small that sometimes special methods required to measure it and from practical POV speed pretty much the same. However it does not mean that when using properly compiled machine code that can utilize modern hardware features program will run faster.JVM is not an interpreter. However more importantly, I'm fine with people having different opinions, even if I know that they are wrong
Honestly I do not understand your post....But how fast is fast enough in your opinion?...
How I can edit my posts? Last sentence should be like this:This or that JVM is additional layer that consume computer resources that otherwise could be funneled to do main task. Again with modern super-fast hardware, multicore processors and real life considerations like awaiting for user input difference is so small that sometimes special methods required to measure it and from practical POV speed pretty much the same. However it does not mean that when using properly compiled machine code that can utilize modern hardware features program will run faster.
This is another very valid point. Because of absent of pre-processor (or in-line functions) and absent of GOTO it is well so often one need to duplicate code everywhere with danger to forget changing all duplication when necessarily. Or otherwise create swamp of global variables that could be difficult to trace especially in massive project.There are certain situations where I have found GOSUB/RETURN very useful and much more readable.
Specifically I have had some complicated routines with a lot of local variables where all or most of the branches have some common code.
B4X requires that I either duplicate all of that common code or make all of the local variables not local. Not very readable unless I create a separate module for just that Sub.
Sometimes aggregate numerous local variables that used for totally different reasons into one structure not practical at all. Plus everywhere outside C passing parameters by val or by reference is obscure and not straightforward at all to extend that ages ago I developed habits not to change anything that passed into sub ultimately treating all parameters as passed by value.or gather together all of the local variables into a custom type variable (or, at least, all the local variables used by the common code), and then pass that custom type variable as a parameter to the common code sub. Any changes made to the "local variables" inside the custom type variable, are seen by the caller when the common code sub returns.
Has advantage over "make all of the local variables not local" in that it makes the Sub re-entrant, ie each call to the sub with local variables, has its own set of local variables.
You can do likewise with Arrays, Lists and Maps: they all get passed by reference too.
Still a bit awkward, but not as awkward as making local variables global where they are at risk of being trashed by other invocations of the sub.
I see that everyone has its own idea about jumps. For me, in some cases, Jumps (goto) simplify greatly my code maintenance.Unconditional jump instructions like GOTO are considered deprecated for several reasons:
In modern programming, many languages have removed or significantly restricted the use of GOTO to encourage safer and more structured programming practices. However, in certain very specific and controlled cases, some languages still support similar constructs.
- Complexity of control flow: Using GOTO makes program control flow much more complex and less clear, leading to code that is difficult to read, understand, and maintain over time.
- Debugging difficulties: GOTO can make debugging harder since unconditional jumps can complicate tracking program execution in a linear fashion.
- Lack of structured programming: The use of GOTO violates the principles of structured programming, which promotes control flow constructs like if-else statements, loops, and subroutines to improve code readability and maintainability.
- Potential errors: Overuse of GOTO can easily lead to programming errors, such as infinite loops or situations where parts of the code are not executed as expected.
One of the most famous critics of GOTO was Edsger Dijkstra, a pioneer in computer science. In his famous 1968 article titled "Go To Statement Considered Harmful", published in the Communications of the ACM journal, Dijkstra strongly criticized the indiscriminate use of GOTO, emphasizing how it can compromise code clarity and debugging ease. This article had a significant impact on the widespread adoption of structured programming practices.
In summary, abandoning GOTO has been an important step toward writing clearer, safer, and more maintainable code in modern programming languages.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?