I realize I’m in a minority here, but don’t lump me in with people who fear and hate operator overloading, and its lack is perhaps the single biggest wart the Java language has. Multiplication on vectors and matrices is multiplication, dammit, and I’m not going to have some hand-wringing dweeb tell me that the proper notation for it is just too powerful for me to be trusted with.
The problem was never that exactly… it was that any Tom Dick or Harry would choose any number of daft co-opted ASCII symbols to do all manner of daft things with all manner of daft objects and the result is… well, C++. You know how that looks.
If vecmath were built in intrinsically into Java (and honestly there’s no real reason why complex numbers and tuples/matrices/vecmath couldn’t be built in now) they could do some official operator overloading for it and thus solve 95% of everyone’s issues over it (like they did with + and String). Let’s face it complex numbers and tuples/matrices/vecmath are the only real use cases. Maybe. I’m not a maths nerd
Cas
The same arguments have been made against OOP and polymorphism in particular: “It looks like a function call, but you just don’t know what it’s actually doing! Madness!”
Whatever. This particular holy war has no end, so I’ll just leave it where it is. We have lots of language choices on the JVM alone, so it’s not like we need a One True Syntax.
interoperability is currently to difficult. Using language A as DSL for UI, language B for maths and java as system language all running on the same might be interesting but maintaining the interface in a polylingual project is currently a problem.
Doing this on-way is usually not that difficult, e.g generating accessors for OpenCL kernels with jocl or stuff like this. But having groovy, scala and java in the same project is horror.
[quote=“princec,post:35,topic:37289”]
There are compilers available for compiling C#, Java, BASIC, Prolog, Python, Ruby, PHP, Pascal to JavaScript. That is not including languages which only target JS, such as CoffeeScript, OMeta and my own Quby language.
If you leverage Silverlight, then you can even use all the .NET languages in the browser for scripting, with very little hassle. Even the dynamic ones, such as IronPython and IronRuby. You can also do similar with applets, but it typically require several megabytes of .jars, per-language (and all the problems with running applets, such as those freezes).
What is really nice about JS, is that for the most part, it’s pretty damn easy to target. Simple things are a direct translation (like ‘int i = 5+5’ becomes ‘var i = 5+5’), whilst high-level abstractions such as closures, generators, Ruby blocks, modules and classes are all trivial to fake.
There are also movements to make this easier, such as Google’s recently leaked Dash/Dart project.
Not true, unless you use the same ‘generic’ number type as JS in your source language. Otherwise for integer types you have to emulate it, sometimes it’s just simple usage of AND operator, sometimes complete emulation (longs). Also JS lacks goto which complicates things for control structures as things are not directly convertible to JS control structures (eg. in case of converting from Java bytecode or other intermediate representation). Though there are labeled loops that can be used instead in most cases, but it’s not as straightforward as goto.
goto? are you talking about spaghetti code?
My problem with this kind of thinking is: they “already” can write awful code. Nothing you can do will prevent that. Properly used syntax sugar in the vein of operator overloading greatly improves readability and maintainablity. Without it the simplest of equations are near impossible to read. Besides with modern tools like Eclipse an overloaded operator could be decorated differently than the default and a simple cntrl-click takes you to the defining method. So in summary, you penalize everyone without really gaining anything and the “problems” of badly used are no where near as what it used to be (is that overloaded?? Where is it defined?? Arghh!!).
Just for game programming I’d have a much longer list. And the problem is that any given implemenation would only statisfy as small percentage of any potential users. Personally I think this would be a worse soultion than not support it at all. But I get annoyed everytime I see a String concat with the plus sign (and it’s worse if I’m the one typing it).
Same thing. There’s nothing wrong with gotos. There are code sequences (like interpretors and stream processing) which are greatly hindered by a lack of a goto statement. Keep in mind that break and continue are simply structured gotos.
Hey don’t get me wrong, I was all for introducing operators to Java (Just using legal method names rather than crazy symbols. Eg. public static operator dot(a, b) … a dot b kinda thing)
Cas
I have no real problem with a high level language leaving out goto – I guess even I have a “nanny state” attitude toward some language features. Heck, Scala doesn’t even have break/continue in loops (but it has delimited continuations, so you could implement them pretty trivially).
The real problem is, javascript is increasingly being used as something it was never intended to be: a compiler target. The lack of an unconditional jump makes it a fairly awkward target, though that’s hardly the only thing. Personally I’d rather see a more appropriate compiler target, along the lines of PNaCl, rather than trying to shoehorn everything into a hacked up high level language.
static imports not enough?
Problem with static-imports if that you don’t have infix-notation: dot(a, b) <-> a dot b, and that you don’t have operator precendence.
It’d be a relatively simple language change I think. Still… hm.
On the subject of imports wouldn’t it be nice to alias imports? I think C# has this feature. Some of the extremely daft classnames people choose in external libraries are a right fingerful to type.
Cas
Imports? I haven’t seen them since I discovered Ctrl+Shift+O on Eclipse :DDD
I never use labelled gotos, I avoid using “break” and “continue”. These things are not a part of structured programming. Maybe you feel comfortable with them but they aren’t necessary (it had been proven about thirty years ago).
Occasionally there are some time-saving things I’d like to do which just involving one set of source code referring to certain things with a consistent name. Or more usually it’s when two identical classes have the same name and I end up having to fully.qualify.the.whole.name.all.over which looks hideous. Wouldn’t it be nice to:
import com.something.longwinded.Util as LWUtil;
import com.someothercompany.library.Util as SOUtil;
again, a trivial syntactic change that’d make my code look lovelier here and there.
Cas
They’re part of my structured programming… and they’re really easy to understand. It’s just how C style code looks. Or really we might as well be using Oberon or Modula or something.
Cas
Just yesterday I used a named outer loop and a break to save me an hour of thinking. It was a good day
Hey don’t get me wrong, I was all for introducing operators to Java (Just using legal method names rather than crazy symbols. Eg. public static operator dot(a, b) … a dot b kinda thing)
Stop! Stop! You’re killing me! a dot b
. Change that to a dot: b
and you have Smalltalk. Seriously I don’t think introducing a whole new sytatic style would be a good idea and IHMO the readablity isn’t really improved.
I have no real problem with a high level language leaving out goto – I guess even I have a “nanny state” attitude toward some language features.
Let me clarify. I’m not claiming that HL languages should include an unstructured goto statement. (Although very very handy for high performance state machine like processing) My issue is with the argument that it (or any other feature) should be excluded because some people would write bad code with it. That battle is lost the instance you decide to create a language. Stuff like: It’s too marginal to be worthwhile, it complicates basic blocks and therefore the backend, it syntatically doesn’t fit or even I don’t want it. These are all reasonable arguments.
I never use labelled gotos, I avoid using “break” and “continue”. These things are not a part of structured programming.
That’s just silly. If this stems from someones advice…stop listening to them. Note that ‘if’ blocks are also structured gotos (method calls, etc. etc.)
Maybe you feel comfortable with them but they aren’t necessary (it had been proven about thirty years ago).
In 1936 Turing described the operations “required” for any computer algorithm to be able to run. A goto (or equivalent) is required. So, from Turing everything beyond a minimal set of ops which are Turing complete is unnecessary…and pretty much describes virtually all features of any high-level language.
I’d guess that you’re refering to Edsger Dijkstra’s paper from 1968 titled “Go To Statement Considered Harmful”. The argument is against the excessive usage of goto’s that was happening at the time and that programming languages needed move toward a structured style (a.k.a convert unstructured gotos into structured ones)
Not using unstructure gotos (when available) I can almost understand…attempting to avoid structured versions is crazy man, crazy!
In 1936 Turing described the operations “required” for any computer algorithm to be able to run. A goto (or equivalent) is required. So, from Turing everything beyond a minimal set of ops which are Turing complete is unnecessary…and pretty much describes virtually all features of any high-level language.
I’d guess that you’re refering to Edsger Dijkstra’s paper from 1968 titled “Go To Statement Considered Harmful”. The argument is against the excessive usage of goto’s that was happening at the time and that programming languages needed move toward a structured style (a.k.a convert unstructured gotos into structured ones)
Not using unstructure gotos (when available) I can almost understand…attempting to avoid structured versions is crazy man, crazy!
Yes I was refering to this paper. The use of labels, “break” and “continue” is forbidden in some kinds of programs, especially in safe softwares (softwares critical for human beings, used in airplanes, during operations in hospitals, etc…). Programs written without these things are easier to prove, they are closer to their mathematical equivalents, I can easily find the entry and the exit of the methods.