|
When I read that Swift to JavaScript comparison[^]... I had quite a big laugh!
Apple wanted a language that would be modern, fast and safe. To anyone who has done a bit of Objective-C in the past, hearing the term “modern” should be music to his or her ears. Apple has delivered in that regard, with adding plenty of syntactic sugar onto the language. It is evident that they were inspired by modern scripting languages such as Ruby, Python, Groovy and of course JavaScript.
Well, if that if where they get their inspiration for a "modern" language, I can be forgiven for ignoring Swift then, I guess!
(PS: I do Xamarin, long live C# )
|
|
|
|
|
I am not a Swift fan, but it has some advantages as I learned in the recent WWDC Videos as great type safety, optimization while compiling and linking and purity by coding. So Swift isnt really a scripting language but the successor of Objective-C.
I have written some C# for years and it is fine, but never Xamarin. But I think cant do all iOS stuff on Xamarin and the performance isnt too great.
Code in Swift has often only few lines of code: that scaries me.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I like how "the bad" isn't actually bad, but how a proper language should work. Like type-safety and none of that weird (and unpredictable) truthy falsey stuff
Edsger Dijkstra once said "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." I guess the same is true for JavaScript
|
|
|
|
|
I particularly liked his example of something "bad":
var myValue = "FOO";
myValue = 5;
WTF - why would you do that?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
I had a JavaScript function (concocted by some coworkers) that I had to use. It was quite a big function and I wasn't very familiar with the domain, so I looked up a usage example, applied that to my own code, inspected the return value, processed it and tested some more. So after weeks of development my code suddenly broke. I had hit an edge case where the function suddenly returned something completely different (most of the time it would return an object with some values, but this time an array with completely other objects was returned)
WHYYYYY!?!?!?!?
|
|
|
|
|
Those cow-orkers were complete idiots.
And JavaScript is a back-asswards language that needs to be replaced with something that actually makes sense.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Not hard to beat JavaScript. One of the worse languages developed. Too many weird things that have to be understood. Looks like C but not anything like any other C style syntax language. Then it is used for Web stuff, and it became more ridiculous. Does not play nice with XML and yet different. If it had played nice with HTML I would have said fine. By that I mean being able to just put code in the middle and not having to do any special formatting fixing to make it work. We have been stuck with this abomination way to long.
|
|
|
|
|
Foo foo = null;
for(Foo bar: Foobars){
foo = bar;
}
if(foo == null){
return someErroR;
}
Then also:
int i = 0;
for(String s : stringArray){
if(i > 0){
stringArray[i] = joinCharacter + stringArray[i];
}
i++;
}
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
The second one would fall flat on its face in C#. Does it actually work in Java? If it does, that's a huge WTF.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Are you talking about the foreach syntax?
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
No, the modification of the collection while looping it.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Brisingr Aerowing wrote: No, the modification of the collection while looping it. I've had issues trying to remove elements from a collection while looping but I have not had an issue just changing a value of the collection items, have you?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I believe Brisingr is thinking of when you iterate through a enumerable and you attempt to update the ienumerable item.
Like the following:
for(String s : stringArray){
if(i > 0){
s = joinCharacter + stringArray[i];
}
i++;
}
It's fine to update the other referenced collection (stringArray[i]).
Brisingr probably was just thinking about that. Not trying to start a battle by speaking for him though.
|
|
|
|
|
Hate to say it, but that should work just fine, even in a C# foreach.
It's just the product of a deranged mind.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I've had code like that crash several times. It seemed kinda hit or miss. Never figured out what happened.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I'm trying to figure out how some code wires up, but it's a spider web. I'll leave all the goodness out and just get right to the point - I'm cruising around through files and notice, upon going to definition, there's an empty interface. I'm in the habbit of cleaning up code, so I remove it. Compilation error. Why ? Because all this stuff implements this interface for no other reason then to be passed around "generically" through the code.......
Elephant elephant elephant, sunshine sunshine sunshine
modified 19-Jul-16 14:52pm.
|
|
|
|
|
|
AVOID using marker interfaces (interfaces with no members).
If you need to mark a class as having a specific characteristic (marker), in general, use a custom attribute rather than an interface.
But who cares about the framework design guidelines?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Except marker interface can be used as constraints in generics...attributes can't.
|
|
|
|
|
yeah, what good does it do, to constrain on empty interface?!
|
|
|
|
|
I think something like Serializable has a meaning to it, so that is a different case. Needing an empty interface just so you can write generic code makes your code base stank. Since these are using in multi-thousand line files, I guess it's only one bit of the problem, but I did say that I was going to skip all the particulars and get strait to the point.
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
I once used a marker interface for some third party component.
The component COULD edit, save, cancel, delete, etc. (through a method named DoAction(string)). If an action was supported was decided by some method ActionSupported(string) or some such.
I created an empty marker interface IThirdPartyComponent, and then interfaces like ISave (with Save method), IEdit (with Edit method) etc. that all inherited IThirdPartyComponent.
That worked a lot better than DoAction(string) and ActionSupported(string), especially since I was able to built some strong typed additional tooling around it
|
|
|
|
|
I think I short circuited my own post by "I'll leave out the goodness and just get to the point". It's possible that this is the marker pattern, although it's not - it's more likely it wasn't intentionally any pattern, just something thrown in to get it working. It's hard to tell though, in the multi-thousand line code files that I'm digging through.
Also, the marker pattern seems to imply[^]
I would argue first-off that Serializable and Cloneable are bad examples of marker interfaces. Sure, they're interfaces with methods, but they imply methods, such as writeObject(ObjectOutputStream). (The compiler will create a writeObject(ObjectOutputStream) method for you if you don't override it, and all objects already have clone(), but the compiler will again create a real clone() method for you but with caveats. Both of these are weird edge cases that really aren't good design examples.)
something like meta-data[^] or methods in many cases.
1) Looking carefully on marker interface in Java e.g. Serializable, Clonnable and Remote it looks they are used to indicate something to compiler or JVM. So if JVM sees a Class is Serializable it done some special operation on it, similar way if JVM sees one Class is implement Clonnable it performs some operation to support cloning. Same is true for RMI and Remote interface. So in short Marker interface indicate, signal or a command to Compiler or JVM.
Read more: http://javarevisited.blogspot.com/2012/01/what-is-marker-interfaces-in-java-and.html#ixzz4Esj4dLCe
I don't feel like what was done here is a good use for that, especially in the junk it's tied up in. If it was intentional, it was done to avoid a good refactor in a steaming pile.
Elephant elephant elephant, sunshine sunshine sunshine
|
|
|
|
|
What component? That single DoAction method is a horrible design, and any component that uses such patterns goes straight into the trash, never to be looked at or used again.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
It was part of the DevExpress WinForms controls.
It's really not THAT horrible as you have little choice but to use string codes for your UI.
So basically there was this button bar and whenever you clicked a button some component would raise DoAction(string).
I simply wrote a custom component that translated DoAction(string) to Save, Edit, etc.
|
|
|
|