The Lone C++ Coder's Blog from The Lone C++ Coder's Blog
First, a confession - I actually occasionally call myself a coder, but in a tongue in cheek, post-modern and ironic way. Heck, it does make for a good blog title and license plate. Nevertheless, with all the recent “coding schools” cropping up all over the place - at least if you are in the Bay Area - it does seem that being able to code in the context of a reasonably sought after web technology without much further formal training is the path to new, fulfilling careers and of course untold riches in an economy where recent graduates in all fields have problems finding work.Subclassing Objective-C classes in Swift and the perils of Initializers
Pete Barber from C#, C++, Windows & other ramblings
--- Begin update1. The post below applies to Xcode 6 Beta 2. With Beta 3 & 4 the relationships between the Swift and Objective-C regarding the calling of super class initializers has been formalized.
1a. A Swift class can have multiple non-convenience initializers but in this case they must all property initialize any properties. Also, a non-convenience initializer cannot invoke another initializer, i.e. it cannot call self.init(...)
1b. When calling an Objective-C any initializer can be called but unlike what happened in Beta 2 if the initializer invoked is not the Objective-C 'designated' initializer and thus calls it this DOES NOT now result in a virtual like call to an initializer with that signature in the subclass, i.e. the main problem that led to the writing of this blog post.
2. If you want to subclass an SKSpriteNote in Beta 4 the following StackOverflow post shows how.
3. It seems that for some OS classes, in my case SpriteKit either Apple directly or some Xcode magic now provides a shim Swift wrapper of the Objective-C interface (the one for SKSpriteNode has a comment with a date of 2011 but when attempting to "show in Finder" nothing happens). As such all the initializers for SKSpriteNode are marked as convenience except for the 'designated' initializer, e.g.
class MySpriteNode : SKSpriteNode {}
3a. This is now essentially a Swift only project with the MySpriteNode now deriving from SKSpriteNode which is a Swift class. As such the Swift rules must be followed. This means that any convenience initializers in MySpriteNode can only call non-convenience initializers for MySpriteNode and these MUST in turn call a non-convenience initializers in the superclass. In the case of SKSpriteNode there is a only a single designated initializer which is:
--- End update
As a way to learn Swift I decided to have a play with Sprite Kit. One of the first things I did was to create a subclass of SKSpriteNode. This has a very handy initializer:
init(imageNamed name: string) (in Swift)
-(instanceType)initWithImageNamed:(NString*)name (in Objective-C)
I then derived from this resulting in:
class Ball : SKSpriteNode
{
init()
{
super.init(imageNamed: "Ball")
}
}
and added it to my scene as follows:
var ball = Ball()
ball.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame))
self.addChild(ball)
ball.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame))
self.addChild(ball)
Time for some experiments
init(value value:Int, AndAnother value1:Int)
Subclassing Objective-C from Swift
Time for another experiment but this time using a base class written in Objective-C:Conclusion
Initial thoughts on Swift
The Lone C++ Coder's Blog from The Lone C++ Coder's Blog
Like pretty much every other programmer with a Mac, I’m currently looking at Swift. Will I write anything but toy programs in it? I don’t know yet - I don’t really write any Mac-ish software on my Mac, just unix-ish programs. If Swift doesn’t escape the OS X and iOS ecosystems it’ll be a nice exercise in a neat language that’s not really that relevant to the world at large, or at least to my part of the world at large.Videos from C++ track on NDC 2014
olvemaudal from Geektalk
As the chair for the C++ track on NDC Oslo, I am happy to report that the C++ track was a huge and massive success! The C++ community in Norway is rather small so even if NDC is a big annual conference for programmers (~1600 geeks) and even with names like Nico, Scott and Andrei as headliners for the track, I was not sure how many people would actually turn up for the C++ talks. I was positively surprised. The first three sessions was packed with people (it was of course a cheap trick to make the three first sessions general/introductory on popular topics). All the other talks were also well attended. The NDC organizers have already confirmed that they want to do this next year as well.
NDC Oslo is an annual five day event. First two days of pre-conference workshops (Andrei did 2 days of Scalable design and implementation using C++) and then 9 tracks of talks for three full days. As usual, NDC records all the talks and generously share all the videos with the world (there are 150+ talks, kudos to NDC!).
I have listed the videos from the C++ track this year. I will also put out a link to the slides when I get them. Enjoy!
Day 1, June 4, 2014
- C++14, Nico Josuttis (video)
- Effective Modern C++, Scott Meyers (video)
- Error Handling in C++, Andrei Alexandrescu (video)
- Move, noexcept, and push_back(), Nico Josuttis (video)
- C++ Type Deduction and Why You Care, Scott Meyers (video)
- Generic and Generative Programming in C++, Andrei Alexandrescu (video)
Day 2, June 5, 2014
- C++ – where are we headed?, Hubert Matthews (video)
- Three Cool Things about D, Andrei Alexandrescu (video)
- The C++ memory model, Mike Long (video, slides)
- C++ for small devices, Isak Styf (video)
- Brief tour of Clang, Ismail Pazarbasi (video)
- Insecure coding in C and C++, Olve Maudal (video, slides)
- So you think you can int? (C++), Anders Knatten (video)
With this great lineup I hope that NDC Oslo in June has established itself as a significant annual C++ event in Europe together with Meeting C++ Berlin in December and ACCU Bristol in April.
Save the date for NDC next year, June 15-19, 2015. I can already promise you a really strong C++ track at NDC Oslo 2015.
A final note: Make sure you stay tuned on isocpp.org for global news about C++.
Someone is building a BBC Micro emulator in Javascript
The Lone C++ Coder's Blog from The Lone C++ Coder's Blog
For those of us who remember when the BBC Micro was the home computer with the fastest Basic implementation available, a long time ago, and was pretty legendary in home computing circles in Europe. It didn’t sell that much outside of the UK, mostly because of its price. It was also the target system for the original implementation of Elite. Matt Godbolt is building an emulator in JavaScript. First post of his series can be found here.