Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

Tech Guides

851 Articles
article-image-all-hail-our-robot-overlords
Owen Roberts
23 Mar 2016
3 min read
Save for later

All hail our robot overlords?

Owen Roberts
23 Mar 2016
3 min read
Imagine for a second that the year is 20XX. The remnants of humanity eke out a limited existence in the shadow of the ruins of Neo New London. For years the new ruling class, the machines, have ruled over the planet with a cold mechanical grip; hunting stragglers with ruthless tactics and superior Go playing strategies. Sounds horrible doesn’t it? Even worse, according to most news articles you might have read over the last few weeks we’re just a few years off this grimdark reality. Just two weeks ago Google’s AlphaGo won 4 out of 5 games against Lee Sedol, one of the greatest Go players currently in the world (Sedol won the 4th match). It’s an interesting look at how far we’ve come in the world of AI as well as how far we’ve still got to go – the turning point in the 4th match, for instance, was when AlphaGo made a mistake and did not realize it for 10 whole turns. But most of the reports that talked about the event didn’t really touch on the gravitas of the match for the world of AI and how far we’ve come without realizing it, mostly focusing on the nightmare of a robot ruled future. What was truly special about this match? We had previously thought we were 5 years away from this actually happening. AI has had a long history of hype and disappointment. Alan Turing predicted that machines would be able to successfully imitate humans by the year 2000, and 16 years later than that deadline we’ve finally gotten them to master on of the most complex games ever created. It shows just how skill Google’s team is at solving such a complex problem, and shows us a look at the practical use AI can have in the immediate future. When it comes to AI we’ve either always thought too big about what it can do or too small but in actuality the reality, especially right now, is somewhat in-between. Currently one of the best uses of AI and deep learning is with Google’s reverse image search function – finding sources based on matching key areas of an image. It’s a small feature in the grand scheme of things, but shows how far reaching AI can be when applied to old problems. The implications AI will have on products like voice assistants, search engines, chat bots, 3D scanners, language translators, automobiles, drones, medical imaging systems, and more is going to be huge. Sure, we’ll eventually get around to mass producing robots that can accurately adapt to the job they’re given but that’s a long way away at this stage. Right now the focus on AI should not be on reaching the pop culture future we’ve dreamed of for years but on specific applications that make our lives easier. The more data that is collected by our current AI means the better products we can create. This will cause a circular effect where more users jump on these better products, in turn giving our AI more data to work with to create EVEN BETTER products for even more users to jump on. So all in all, the immediate future of AI is going to be much smaller and less deadly than killer machines and human batteries. And even if I’m wrong and the worst happens we can at least have peace of mind that the Great Robot War will be pretty cool.
Read more
  • 0
  • 0
  • 1464

article-image-bridging-gap-between-data-science-and-devops
Richard Gall
23 Mar 2016
5 min read
Save for later

Bridging the gap between data science and DevOps with DataOps

Richard Gall
23 Mar 2016
5 min read
What’s the real value of data science? Hailed as the sexiest job of the 21st century just a few years ago, there are rumors that it’s not quite proving its worth. Gianmario Spacagna, a data scientist for Barclays bank in London, told Computing magazine at Spark Summit Europe in October 2015 that, in many instances, there’s not enough impact from data science teams – “It’s not a playground. It’s not academic” he said. His solution sounds simple. We need to build a bridge between data science and DevOps - and DataOps is perhaps the answer. He says: "If you're a start-up, the smartest person you want to hire is your DevOps guy, not a data scientist. And you need engineers, machine learning specialists, mathematicians, statisticians, agile experts. You need to cover everything otherwise you have a very hard time to actually create proper applications that bring value." This idea makes a lot of sense. It’s become clear over the past few years that ‘data’ itself isn’t enough; it might even be distracting for some organizations. Sometimes too much time is spent in spreadsheets and not enough time is spent actually doing stuff. Making decisions, building relationships, building things – that’s where real value comes from. What Spacagna has identified is ultimately a strategic flaw within how data science is used in many organizations. There’s often too much focus on what data we have and what we can get, rather than who can access it and what they can do with it. If data science isn’t joining the dots, DevOps can help. True, a large part of the problem is strategic, but DevOps engineers can also provide practical solutions by building dashboards and creating APIs. These sort of things immediately give data additional value by making they make it more accessible and, put simply, more usable. Even for a modest medium sized business, data scientists and analysts will have minimal impact if they are not successfully integrated into the wider culture. While it’s true that many organizations still struggle with this, Airbnb demonstrate how to do it incredibly effectively. Take a look at their Airbnb Engineering and Data Science publication on Medium. In this post, they talk about the importance of scaling knowledge effectively. Although they don’t specifically refer to DevOps, it’s clear that DevOps thinking has informed their approach. In the products they’ve built to scale knowledge, for example, the team demonstrate a very real concern for accessibility and efficiency. What they build is created so people can do exactly what they want and get what they need from data. It’s a form of strict discipline that is underpinned by a desire for greater freedom. If you keep reading Airbnb’s publication, another aspect of ‘DevOps thinking’ emerges: a relentless focus on customer experience. By this, I don’t simply mean that the work done by the Airbnb engineers is specifically informed by a desire to improve customer experiences; that’s obvious. Instead, it’s the sense that tools through which internal collaboration and decision making take place should actually be similar to a customer experience. They need to be elegant, engaging, and intuitive. This doesn’t mean seeing every relationship as purely transactional, based on some perverse logic of self-interest, but rather having a deeper respect for how people interact and share ideas. If DevOps is an agile methodology that bridges the gap between development and operations, it can also help to bridge the gap between data and operations. DataOps - bringing DevOps and data science together This isn’t a new idea. As much as I’d like to, I can’t claim credit for inventing ‘DataOps’. But there’s not really much point in asserting that distinction. DataOps is simply another buzzword for the managerial class. And while some buzzwords have value, I’m not so sure that we need another one. More importantly, why create another gap between Data and Development? That gap doesn’t make sense in the world we’re building with software today. Even for web developers and designers, the products they are creating are so driven by data that separating the data from the dev is absurd. Perhaps then, it’s not enough to just ask more from our data science as Gianmario Spacagna does. DevOps offers a solution, but we’re going to miss out on the bigger picture if we start asking for more DevOps engineers and some space for them to sit next to the data team. We also need to ask how data science can inform DevOps too. It’s about opening up a dialogue between these different elements. While DevOps evangelists might argue that DevOps has already started that, the way forward is to push for more dialogue, more integration and more collaboration. As we look towards the future, with the API economy becoming more and more important to the success of both startups and huge corporations, the relationships between all these different areas are going to become more and more complex. If we want to build better and build smarter we’re going to have to talk more. DevOps and DataOps both offer us a good place to start the conversation, but it’s important to remember it’s just the start.
Read more
  • 0
  • 0
  • 7482

article-image-android-your-mobile-platform-choice
Richard Gall
21 Mar 2016
2 min read
Save for later

Android: Your Mobile Platform of Choice

Richard Gall
21 Mar 2016
2 min read
It’s been a long week of argument and debate, strong words and opinions – and that’s just in the Packt office. But, now the votes have been counted we can announce that Android is the Packt customer’s mobile platform of choice. Across oour website poll and our Twitter poll, Android was the clear winner. Throughout the week, it also proved to be the most popular platform with customers, with sales of our Android eBooks exceeding those for iOS.  As you can see, our Twitter poll, delivered a particularly significant win for Android. Clearly there was a lot of love for Android. But what we really loved about the week was hearing some interesting perspectives from mobile developers around the world. This tweet in particular summed up why we think Android dominated the vote: Fundamentally, it’s all about customization – with Android you have more freedom as a developer, which, for many developers is central to the sheer pleasure of the development experience. Of course, the freedom you get with Android is only a certain type of freedom – and there are, of course trade-offs if you want the openness of such a platform. This article from October 2015 suggested that Android development is ‘30% more expensive than iOS development’ due to the longer amount of time Android projects take – the writers estimate that, on average, you write 40% more code when working with Android over iOS. But with new tools on the horizon likely to make Android development even more efficient (after all, think about what it was like to build for Android back in 2013!), it’s unsurprising that it should prove so popular with many developers. We’re celebrating Android’s win with an additional week of offers – which means you’ve now got another week to pick up our very best Android titles and get ready for a bright and exciting future in the mobile development world!
Read more
  • 0
  • 0
  • 1716

article-image-swift-2016
Owen Roberts
16 Mar 2016
4 min read
Save for later

Swift in 2016

Owen Roberts
16 Mar 2016
4 min read
It’s only been 2 years since Swift was first released to the public and it’s amazing how quickly it has been adopted by iOS developers all over. Seen as a great jumping point for many people and a perfect alternative to Objective-C with some of the best modern language features built in, like tuples and generics; being Open Source is the icing on the cake for tinker-happy devs looking to make the language their own. Swift is in an interesting position though; despite it being one of the fastest languages being picked up right now, do you know how many apps made by Apple actually use it in iOS 9.2? Only 1. Calculator. It’s not a huge surprise when you think about it – the language is new and constantly evolving, and we can safely assume that Calculator’s use of Swift is to test the water as the features and workings of the language settle down. Maybe in the next 2-3 years Apple will have finally moved to a pure Swift world, but other developers? They’re really jumping into the language. IBM, for example, uses Swift for all its iOS apps. What does this mean for you? It means that, as a developer, you have the ability to help shape a young language that rarely happens on today’s web. So here are a few reasons you should take the plunge and get deeper into Swift in 2016, and if you haven’t started yet, then there’s no better time! Swift 3 is coming What better time to get even deeper into the language when it’s about to add a host of great new features? Swift 3.0 is currently scheduled to launch around the tail end of 2016 and Apple aren’t keeping what they want to include close to their chest. The biggest additions are looking to be stabilizing the ABI, refining the language even more with added resilience to changes, and further increasing portability. All these changes have been on the wishlists of Swift devs for ages and now that we’re finally going to get them there’s sure to be more professional projects made purely in Swift. 3.0 looks to be the edition of Swift that you can use for your customers without worry, so if you haven’t gotten into the language yet, this is the version you should be prepping for! It’s no longer an iOS only language Probably the biggest change to happen to Swift since it became Open Source is that the language is now available on Ubuntu officially, while dedicated fans are also currently creating an Android port of all things. What does this mean for you as a developer? Well, the potential for a greater number of platforms your apps can be deployed on has grown; and one of Swift’s main complaints, that it’s an iOS only language, is rendered moot. It’s getting easier to learn and use In the last 2 years we’ve seen a variety of different tools and package managers for those looking to get more out of Swift. If you’re already using Swift it’s most likely you’re using Xcode to write apps. However, if you’re looking to try something new or just don’t like Xcode then there’s now a host of options for you. Testing frameworks like Quick are starting to appear on the market and alternatives such as AppCode look to build on the feedback the community gives to Xcode and fill in the gaps with what it’s missing. Suggestions as you type and decent project monitoring are becoming more commonplace with these new environments, and there are more environments around if you look, so why not jump on them and see which one suits your style of development? The Swift job market is expanding Last year the Swift job market expanded by an incredible 600%, and that was in its first year alone. With Apple giving Swift its full support and the community having grown so quickly, companies are beginning to take notice. Many companies who produce iOS apps are looking for the benefits that Swift offers over Objective-C and having that language as part of your skillset is something that is beginning to set iOS developers apart from one another… With everything happening with Spring this year it looks to be one of the best times to jump on board or dig deeper into the language. If you’re looking to get started building your Swift skills then be sure to check out our iOS tech page, it has all our most popular iOS books for you to explore along with the list of upcoming titles for you to preorder, Swift included.
Read more
  • 0
  • 0
  • 2438

article-image-reactive-programming-swift
Milton Moura
16 Mar 2016
6 min read
Save for later

Reactive Programming in Swift

Milton Moura
16 Mar 2016
6 min read
In this post we will learn how to use some of Swift's functional features to write more concise and expressive code using RxSwift, a reactive programming framework, to manage application states and concurrent tasks. Swift and its functional features Swift can be described as a modern object-oriented language with native support for generic programming. Although it is not a functional language, it has some features that allows us to program using a functional approach, like closures, functions as first-class types, and immutable value types. Nevertheless, Cocoa Touch is an object-oriented framework and bares the constraints that this paradigm enforces. Typical issues that arise in software development projects include managing shared application state and concurrent asynchronous tasks that compete for the data that resides there. Functional programming solves these problems by privileging the immutable state and defining application logic as expressions that do not change during the application's lifecycle. By defining self-contained functions, computations can be easily parallelized and concurrency issues minimized. The Reactive Model The reactive programming model has its roots in FRP (functional reactive programming), which shifts the paradigm from discrete, imperative, command-driven programming to a series of transformations that can be applied to a stream of inputs continously over time. While that might sound like a mouthful, there's nothing quite like a simple example to get a feel for what this means. Expressing a relationship between variables Let's say you have two variables (A and B) whose value changes over the running time of an application, and a third one (C) that derives its own value based on the previous two. 1. var A = 10 2. var B = 20 3. let C = A * 2 + B 4. 5. // Current Values 6. // A = 10, B = 20, C = 40 7. 8. A = 0 9. 10. // Current Values 11. // A = 0, B = 20, C = 40 The definition of C with regards to A and B is evaluated only once, when the assignment operation is executed. The relationship between them is lost immediatly after that. Changing A or B from then on will have no effect on the value of C. At any given moment, to evaluate that expression you must reassign the value of C and calculate it once again, based on the current values of A and B. How would we do this in a reactive programming approach? In the reactive model, we would create two streams that propagate changes in the values of either A or B over time. Each value change is represented as a signal in its corresponding stream. We then combine both streams and assign a transformation that we want to perform on each signal emitted, thus creating a new stream that will emit only transformed values. The usual way to demonstrate this is using Marbles Diagrams, where each line represents the continuity of time and each marble an event that occurs at a determined point in time: Reacting in Cocoa Touch To address this in Cocoa Touch, you could use Key-Value Observing to add observers to the changing variables and handle them when the KVO system notifies you: self.addObserver(self, forKeyPath:"valueA", options: .New, context: nil) self.addObserver(self, forKeyPath:"valueB", options: .New, context: nil) override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) { let C = valueA * 2 + valueB } If your variables are tied to the user interface, in UIKit you could define a handler that is invoked when change events are triggered: sliderA.addTarget(self, action: "update", forControlEvents: UIControlEvents.ValueChanged) sliderB.addTarget(self, action: "update", forControlEvents: UIControlEvents.ValueChanged) func update() { let C = sliderA.value * 2 + sliderB.value } But none of these approaches define a persistent and explicit relationship between the variables involved, their lifecycle, and the events that change their value. We can overcome this with a reactive programming model. There are a couple of different implementations currently available for OS X and iOS development such as RxSwift and ReactiveCocoa. We will focus on RxSwift but the basic concepts we address are similar in both frameworks. RxSwift RxSwift extends the Observer pattern to simulate asynchronous streams of data flowing out of your Cocoa Touch objects as if they were typical collections. By extending some of Cocoa Touch's classes with observable streams, you are able to subscribe to their output and use them with composable operations, such as filter(), merge(), map(), reduce(), and others. Returning to our previous example, let's say we have an iOS application with two sliders (sliderA and sliderB) and we wish to continously update a label (labelC) with the same expression we used before (A * 2 + B): 1. combineLatest(sliderA.rx_value, sliderB.rx_value) { 2. $0 * 2 + $1 3. }.map { 4. "Sum of slider values is ($0)" 5. }.bindTo(labelC.rx_text)  We take advantage of the rx_value extension of the UISlider class that transforms the slider's value property into an observable type that emits an item when its value changes. By applying the combineLatest() operation on both slider's observable types, we create a new observable type that emits items whenever any of its source streams emits an item. The resulting emission is a tuple with both slider's values that can be transformed in the operation callback (line 2). Then, we map the transformed value into an informative string (line 4) and bind its value to our label (line 5). By composing three independent operations (combineLatest(), map() and bindTo()) we were able to concisely express a relationship between three objects and continuously update our application's UI, reacting accordingly to changes in the application state. What's next? We are only scratching the surface on what you can do with RxSwift. In the sample source code, you will find an example on how to download online resources using chainable asynchronous tasks. Be sure to check it out if this article sparked your curiosity. Then take some time to read the documentation and learn about the several other API extensions that will help you develop iOS apps in a more functional and expressive way. Discover how patterns in Swift can help you to deal with a large number of similar objects in our article Using the Flyweight Pattern. About the author Milton Moura (@mgcm) is a freelance iOS developer based in Portugal. He has worked professionally in several industries, from aviation to telecommunications and energy and is now fully dedicated to creating amazing applications using Apple technologies. With a passion for design and user interaction, he is also very interested in new approaches to software development. You can find out more at http://defaultbreak.com
Read more
  • 0
  • 0
  • 5674

article-image-swift-missing-pieces-surviving-change
Nicholas Maccharoli
14 Mar 2016
5 min read
Save for later

Swift: Missing Pieces & Surviving Change

Nicholas Maccharoli
14 Mar 2016
5 min read
Change Swift is still a young language when compared to other languages like C, C++, Objective-C, Ruby, and Python. Therefore it is subject to major changes that will often result in code breaking for simple operations like calculating the length of a string. Packaging functionality that is prone to change into operators, functions or computed properties may make dealing with these transitions easier. It will also reduce the number of lines of code that need to be repaired every time Swift undergoes an update. Case study: String Length A great example of something breaking between language updates is the task of getting a string’s character length. In versions of Swift prior to 1.2, the way to calculate the length of a native string was countElements(myString), but then in version 1.2 it became just count(myString). Later at WWDC 2015 Apple announced that many functions that were previously global –such as count - were now implemented as protocol extensions. This resulted in once again having to rewrite parts of existing code as myString.characters.count. So how can one make these code repairs between updates more manageable? With a little help from our friends Computed Properties of course! Say we were to write a line like this every time we wanted to get the length of a string: let length = count(myString) And then all of a sudden this method becomes invalid in the next major release and we have unfortunately calculated the length of our strings this way in, say, over fifty places. Fixing this would require a code change in all fifty places. But could this have been mitigated? Yes, we could have used a computed property on the string called length right from the start: extension String { var length : Int { return self.characters.count } } Had our Swift code originally been written like this, all that would be required is a one line change. This is because the other fifty places would still be receiving a valid Int from the call myString.length. Missing Pieces Swift has some great shorthand and built in operators for things like combining strings - let fileName = fileName + ".txt" - and appending to arrays - waveForms += ["Triangle", "Sawtooth"]. So what about adding one dictionary to another? //Won't work let languageBirthdays = ["C" : 1972, "Objective-C": 1983] + ["python" : 1991, "ruby" : 1995] But it works out of the box in Ruby: compiled = { "C" => 1972, "Objective-C" => 1983 } interpreted = { "Ruby" => 1995, "Python" => 1991 } programming_languages = compiled.merge(interpreted) And Python does not put up much of a fuss either: compiled = {"C":1972, 'Objective-C': 1983} interpreted = {"Ruby":1995, "Python": 1991} programming_languages = compiled.update(interpreted) So how can we make appending one dictionary to another go as smoothly as it does with other container types like arrays in Swift? By overloading the + and += operators to work with dictionaries of course! func + <Key, Value> (var lhs: Dictionary<Key, Value>, rhs: Dictionary<Key, Value>) -> Dictionary<Key, Value> { rhs.forEach { lhs[$0] = $1 } return lhs } func += <Key, Value> (inout lhs: Dictionary<Key, Value>, rhs: Dictionary<Key, Value>) -> Dictionary<Key, Value> { lhs = lhs + rhs return lhs } With a light application of generics and operator overloading we can make the syntax for dictionary addition the same as the syntax for array addition. Operators FTW: Regex Shorthand One thing that you may have encountered during your time with Swift is the lack of support for regular expressions. At the time of writing, Swift is currently at version 2.1.1 and there is no Regular Expression support in the Swift Standard Library. The next best thing to do is to rely on a third party library or Foundation Framework's NSRegularExpression. The issue is that writing code to use NSRegularExpression to find a simple match is a bit long winded every time you wish to check for a match. Putting it into a function is not a bad idea either, but defining an operator may make our code a bit more compact. Taking inspiration from Ruby's =~ regex operator, let’s make a simple version returning a bool representing if there was a match: infix operator =~ { associativity left precedence 140 } func =~ (lhs: String, rhs: String) -> Bool { if let regex = try? NSRegularExpression(pattern: rhs, options: NSRegularExpressionOptions.CaseInsensitive) { let matches = regex.matchesInString(lhs, options: NSMatchingOptions.ReportCompletion, range: NSMakeRange(0, lhs.length)) return matches.count > 0 } else { return false } } (Take note of our trusty length computed property springing to action.) This time around there is no operator as of Swift 2.1 called =~. Therefore, we need to first define the symbol telling the Swift compiler that it is an operator that is infix taking objects on the left and right side, with a precedence of 140, and its associativity is left. Associativity and precedence only matter when there are multiple operators chained together, but I imagine most uses of this operator being something like: guard testStatus =~ "TEST SUCCEEDED" else { reportFailure() } Have fun but be courteous It would be wise to observe The Law of the Instrument and not treat everything as a nail just because you have a hammer in arm’s reach. When making the decision to wrap functionality into an operator or use a computed property in place of the canonical way of coding something explicitly, first ask yourself if this is really improving readability. It could be that you’re just reducing the amount of typing – think about how easily the next person reading your code could adapt. If you want to create even better Swift apps then check out our article to make the most of the Flyweight pattern in Swift - perfect when you need a large number of similar objects! About the author Nick Maccharoli is an iOS / Backend developer and Open Source enthusiast working at a startup in Tokyo and enjoying the current development scene. You can see what he is up to at @din0sr or github.com/nirma
Read more
  • 0
  • 0
  • 1718
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €14.99/month. Cancel anytime
article-image-why-android-will-rule-our-future
Sam Wood
11 Mar 2016
5 min read
Save for later

Why Android Will Rule Our Future

Sam Wood
11 Mar 2016
5 min read
We've been joking for years that in the future we'll be ruled by Android Overlords - we just didn't think it would be an operating system. In 2015, it's predicted that Android shipped over one billion devices - a share of the mobile market equating to almost 80%. In our 2015 Skill Up survey, we also discovered that Android developers were by far the highest paid of mobile application developers. Android dominates our present - so why is it likely going to be vital to the world of tomorrow too? IoT Will Run On Android (Probably) Ask any group of developers what the Next Big Thing will be, and I bet you that more than one of them is going to say Internet of Things. In 2015, Google announced Android stepping into the ring of IoT operating systems when it showed us Brillo. Based on the Android kernal but 'scrubbed down by a Brillo pad', Brillo offers the possibility of a Google-backed cohesive platform for IoT - something potentially vital to a tech innovation increasingly marred by small companies attempting to blaze their own trail off in different directions. If IoT needs to be standardized, what better solution than with Android, the operating system that's already the go-to choice for open-source mobile devices? We've already got Smart Fridges running on Android, smart cars running on Android, and tons of smart-watches running on Android - the rest of the Internet of Things is likely just around the corner. Android is Colonizing Desktop Microsoft is still the King of Desktop, and Windows isn't going anywhere any time soon. However, its attempts to enter the mobile space have been miserable-at-best - a 2.8% share of the mobile market in 2015. What has been more successful is the idea of hybridizing the desktop and the mobile, in particular with the successful line of Surface laptops-come-tablets. But is the reverse likely to happen? Just like we're seeing Android moving from being a mobile OS to being used for IoT, we're also seeing the rise of ideas of Android Desktop. The Remix OS for PC operating system is created by former Google developers, and promises an "Android for PC" experience. Google-proper's own experiments in desktop are currently all based on the Chrome OS - which is growing fast in its market share, particularly among the education and student sectors. I'm an enthusiastic Chromebook owner and user, and when it falls short of meeting the full requirements of a major desktop OS, I'll often turn to my Android device to bridge the gap. According to the Wall Street journal, Google may be thinking similar and is considering folding Chrome OS and Android into one product. Consider the general praise that Microsoft received for Windows 10 mobile, and the successful unification of their platforms under a single OS. It's easy to imagine the integration of Google's mobile and desktop projects into a similar single user experience - and that this hybrid-Android would make a serious impact in the marketplace. For Apple, the Only Way Is Down Apple has banked on being the market in luxury for its mobile devices - and that might spell its doom. The pool of new buyers in the smartphone market is shrinking, and those late adopters are more likely to be price-conscious and enamored with the cheaper options available on Android. (After all, if your grandmother still complains about how much milk costs these days, is she really going to want to shell out $650 for an iPhone?) If Apple wants a bigger share of the market, it's going to need to consider a 'budget option' - and as any brand consultant will tell you, nothing damages the image of luxury like the idea that there's a 'cheap version'. Apple is aware of this, and has historically protested that it's never happening. But in 2015, we saw the number people switching from Android to iOS fall from from 13% to 11%. Even larger, the number of first-time smartphone buyers contributing to Apple's overall sales went from 20% to 11% over the same period. Those are worrying figures - especially when it also looks like more people switched from iOS to Android, than switched from Android to iOS. Apple may be a little damned-if-it-does, damned-if-it-doesn't in the face of Android. You can get a lot for your money if you're willing to buy something which doesn't carry an Apple logo. It's easy to see Android's many producers creating high-powered luxury devices; it's harder to see Apple succeeding by doing the opposite. And are we really ever going to see something like the iFridge? Android's Strength is its Ubiquity Principal to Android's success in the future is its ubiquity. In just six years, it's gone from being a new and experimental venture to over a billion downloads and being used across almost every kind of smart device out there. As an open source OS, the possibilities of Android are only going to get wider. When Androids rule our future, it may be on far more than just our phones. Dive into developing for Android all this week with our exclusive Android Week deals! Get 50% off selected titles, or build your own bundle of any five promoted Android books for only $50.
Read more
  • 0
  • 0
  • 2527

article-image-angularjs-nodejs-and-firebase-startup-web-developers-toolkit
Erik Kappelman
09 Mar 2016
7 min read
Save for later

Angular.js, Node.js, and Firebase: the startup web developer's toolkit

Erik Kappelman
09 Mar 2016
7 min read
So, you’ve started a web company. You’ve even attracted one or two solid clients. But now you have to produce, and you have to produce fast. If you’ve been in this situation, then we have something in common. This is where I found myself a few months ago. A caveat: I am a self-taught web developer in an absolute sense. Self-taught or not, in August of 2015 I found myself charged with creating a fully functional blogging app for an author. Needless to say, I was in over my head. I was aware of Node.js, because that had been the backend for the very simple static content site my company had produced first. I was aware of database concepts and I did know a reasonable amount of JavaScript, but I felt ill prepared to pull of these tools together in a cohesive fashion. Luckily for me it was 2015 and not 1998. Today, web developers are blessed with tools that make the development of websites and web apps a breeze. After some research, I decided to use Angular.js to control the frontend behavior of the website, Node.js with Express.js as the backend, and Firebase to hold the data. Let me walk you through the steps I used to get started. First of all, if you aren’t using Express.js on top of Node.js for your backend in development you should start. Node.js was written in C, C++ and JavaScript by Ryan Dahl in 2009. This multiplatform runtime environment for JavaScript is fast, open-source, and easy to learn, because odds are you already know JavaScript. Using Express.js and the Express-Generator in congress with Node.js makes development quite simple. Express.js is Node middleware. In simple terms, Express.js makes your life a whole lot easier by doing most of the work for you. So, let’s build our backend. First, install Node.js and NPM on your system. There are a variety of online resources to complete this step. Then, using NPM, install the Express application generator. $ npm install express-generator -g Once we have Node.js and the Express generator installed, get to your development folder and execute the following commands to build the skeleton of your web app’s backend: $ express app-name –e I use the –e flag to set the middleware to use ejs files instead of the default jade files. I prefer ejs to jade but you might not. This command will produce a subdirectory called app-name in your current directory. If you navigate into this directory and type the commands $ npm install $ npm start and then navigate in a browser to http://localhost:3000 you will see the basic welcome page auto generated by Express. There are thousands of great things about Node.js and Express.js and I will leave them to be discovered by you as you continue to use these tools. Right now, we are going to get Firebase connected to our server. This can serve as general instructions for installing and using Node modules as well. Head over to firebase.com and create a free account. If you end up using Firebase for a commercial app you will probably want to upgrade to a paid account, but for now the starter account should be fine. Once you get your Firebase account setup, create a Firebase instance using their online interface. Once this is done get back to your backend code to connect the Firebase to your server. First install the Firebase Node module. $ npm install firebase --save Make sure to use the --save flag because this puts a new line in your packages.json file located in the root of the web server. This means that if you type npm install, as you did earlier, NPM will know that you added firebase to your webserver and install it if it is not already present. Now open the index.js file in the routes folder in the root of your Node app. At the top of this folder, put in the line var Firebase = require(‘firebase’); This pulls the Firebase module you installed into your code. Then to create a connection to the account you just created on Firebase[MA1]  ,put in the following line of code: var FirebaseRef = new Firebase("https://APP-NAME.firebaseio.com/"); Now, to take a snapshot in JSON of your Firebase and store it in an object, include the following lines var FirebaseContent = {}; FirebaseRef.on("value", function(snapshot) { FirebaseContent = snapshot.val(); }, function(errorObject) { console.log("The read failed: " + errorObject.code); }); FirebaseContent is now a JavaScript object containing your complete Firebase data. Now let’s get Angular.js hooked up to the frontend of the website and then it’s time for you to start developing. Head over to angularjs.org and download the source code or get the CDN. We will be using the CDN. Open the file index.ejs in the views directory in your Node app’s root. Modify the <head> tag, adding the CDN. <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.1/angular.min.js"></script> </head> This allows you to use the Angular.js tools. Angular.js uses controllers to control your app. Let’s make your angular app and connect a controller. Create a file called myapp.js in your public/javascripts directory. In myapp.js include the following angular.module(“myApp”,[]); This file will grow but for now this is all you need. Now create a file in the same directory called myController.js and put this code into it. Angular.module(“myApp”).controller(‘myController’,['$scope',function($scope){ $scope.jsVariable = 'Controller is working'; }]) Now modify the index.ejs file again. <html ng-app=“myApp”> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.1/angular.min.js"></script> <script src="/javascripts/myApp.js"></script> <script src="/javascripts/myController.js"></script> </head> <body ng-controller= “myController”> <h1> {{jsVariable}} </h1> </body> </html> If you start your app again and go back to http://localhost:3000 you should see that your controller is now controlling the contents of the first heading. This is just a basic setup and there is much more you will learn along the way. Speaking from experience, taking the time to learn these tools and put them into use will make your development faster and easier and your results will be of much higher quality. About the Author Erik was born and raised in Missoula, Montana. He attended the University of Montana and received a degree in economics. Along the way, he discovered the value of technology in our modern world, especially to businesses. He is currently seeking a master's degree in economics from the University of Montana and his research focuses on the economics of gender empowerment in the developing world. During his professional life, he has worn many hats – from cashier, to barista, to community organizer. He feels that Montana offers a unique business environment that is often best understood by local businesses. He started his company, Duplovici, with his friends in an effort to meet the unique needs of Montana businesses, non-profits, and individuals. He believes technology is not simply an answer to profit maximization for businesses: by using internet technologies we can unleash human creativity through collective action and the arts, as well as business ventures. He is also the proud father of two girls and has a special place in his heart for getting girls involved with technology and business.
Read more
  • 0
  • 1
  • 7306

article-image-solving-day-7-advent-code-using-swift
Nicky Gerritsen
07 Mar 2016
7 min read
Save for later

Solving Day 7 of Advent of Code using Swift

Nicky Gerritsen
07 Mar 2016
7 min read
Eric Wastl created the website Advent of Code, a website that published a new programming exercise from the first of December until Christmas. I came across this website somewhere in the first few days of December and as I participated in the ACM ICPC in the past, I expected I should be able to solve these problems. I decided it would be a good idea to use Swift to write these solutions. While solving the problems, I came across one problem that I was able to do really well in Swift and I'd like to explain that one in this post. Introduction After reading the problem, I immediately noticed some interesting points: We can model the input as a graph, where each wire is a vertex and each connection in the circuit connects some vertices to another vertex. For example x AND y -> z connect both x and y to vertex z. The example input is ordered in such a way that you can just iterate over the lines from top to bottom and apply the changes. However, the real input does not have this ordering. To get the real input in the correct ordering, one should note that the input is basically a DAG. Or at least it should be, otherwise it cannot be solved. This means we can use topological sorting to sort the vertices of the graph in the order we should walk them. Although in the example input, it seems that AND, OR, NOT, LSHIFT and RSHFT always operated on a wire, this is not the case. They can also operate on a constant value. Implementation Note that I replaced some guard lines with forced unwrapping here. The source code linked at the end contains the original code. First off, we define a Source, which is an element of an operation, i.e. in x AND y both x and y are a Source: enum Source { case Vertex(String) case Constant(UInt16) func valueForGraph(graph: Graph) -> UInt16 { switch self { case let .Vertex(vertex): return graph.vertices[vertex]!.value! case let .Constant(val): return val } } var vertex: String? { switch self { case let .Vertex(v): return v case .Constant(_): return nil } } static func parse(s: String) -> Source { if let i = UInt16(s) { return .Constant(i) } else { return .Vertex(s) } } } A Source is either a Vertex (i.e. a wire) and then it has a corresponding string as identifier, or it is a constant and then it contains some value. We define a function that will return the value for this Source given a Graph (more on this later). For a constant source the whole graph does not matter, but for a wire we should look up the value in the graph. The second function is used to extract the identifier of the vertex of the source, if any. Finally we also have a function that helps us parse a string or integer into a Source. Next up we have an Operation enumeration, which holds all information about one line of input: enum Operation { case Assign(Source) case And(Source, Source) case Or(Source, Source) case Not(Source) case LeftShift(Source, UInt16) case RightShift(Source, UInt16) func applytoGraph(graph: Graph, vertex: String) { let v = graph.vertices[vertex]! switch self { case let .Assign(source1): v.value = source1.valueForGraph(graph) case let .And(source1, source2): v.value = source1.valueForGraph(graph) & source2.valueForGraph(graph) /* etc for other cases */ case let .RightShift(source1, bits): v.value = source1.valueForGraph(graph) >> bits } } static func parseOperation(input: String) -> Operation { if let and = input.rangeOfString(" AND ") { let before = input.substringToIndex(and.startIndex) let after = input.substringFromIndex(and.endIndex) return .And(Source.parse(before), Source.parse(after)) } /* etc for other options */ var sourceVertices: [String] { /* code that switches on self and extracts vertex from each source */ } The operation enum has a static function that allows us to parse a line from the input into an Operation and a function that will allow us to apply it to a graph. Furthermore, it has a computed variable that returns all source vertices for the operation. Now a Vertex is an easy class: class Vertex { var idx: String var outgoing: Set<String> var incoming: Set<String> var operations: [Operation] var value: UInt16? init(idx: String) { self.idx = idx self.outgoing = [] self.incoming = [] self.operations = [] } } It has an ID and keeps track of a set of incoming and outgoing edges (we need both for topological sorting). Furthermore, it has a value (which is initially not set) and a list of operations that has this vertex as target. Because we want to store vertices in a set, we need to let it conform to Equatable and Hashable. Because we have a unique string identifier for each vertex, this is easy: extension Vertex: Equatable {} func ==(lhs: Vertex, rhs: Vertex) -> Bool { return lhs.idx == rhs.idx } extension Vertex: Hashable { var hashValue: Int { return self.idx.hashValue } } The last structure we need is a graph, which basically hold a list of all vertices: class Graph { var vertices: [String: Vertex] init() { self.vertices = [:] } func addVertexIfNotExists(idx: String) { if let _ = self.vertices[idx] { return } self.vertices[idx] = Vertex(idx: idx) } func addOperation(operation: Operation, target: String) { // Add an operation for a given target to this graph self.addVertexIfNotExists(target) self.vertices[target]?.operations.append(operation) let sourceVertices = operation.sourceVertices for v in sourceVertices { self.addVertexIfNotExists(v) self.vertices[target]?.incoming.insert(v) self.vertices[v]?.outgoing.insert(target) } } } We define a helper function that ads a vertex if not already added. We then use this function to define a function that can add operation to the graph, together with all required vertices and edges. Now we need to be able to topologically sort the vertices of the graph, which can be done using Kahn's Algorithm[MA6] . This[MA7]  can be done in Swift almost exactly using the pseudo-code explained there: extension Graph { func topologicalOrder() -> [Vertex] { var L: [Vertex] = [] var S: Set<Vertex> = Set(vertices.values.filter { $0.incoming.count == 0 }) while S.count > 0 { guard let n = S.first else { fatalError("No more nodes in S") } S.remove(n) L.append(n) for midx in n.outgoing { guard let m = self.vertices[midx] else { fatalError("Can not find vertex") } n.outgoing.remove(m.idx) m.incoming.remove(n.idx) if m.incoming.count == 0 { S.insert(m) } } } return L } } Now we are basically done, as we can now write up a function that calculates the value of a given wire in a graph: func getFinalValueInGraph(graph: Graph, vertex: String) -> UInt16? { let topo = graph.topologicalOrder() for vertex in topo { for op in v.operations { op.applytoGraph(graph, vertex: vertex.idx) } } return graph.vertices[vertex]?.value } Conclusions This post (hopefully) gave you some insight intohow I solved one of the bigger Advent of Code problems. As you can see Swift has some really nice features that help in this case, like enums with types and functional methods like filter. If you like these kinds of problems I suggest you go to the Advent of Code website and start solving the problems. There are quite a few that are really easy to get started. The complete code for this blogpost can be found at my GitHub account. About the author Nicky Gerritsen is currently a Software Architect at StreamOne, a small Dutch company specialized in video streaming and storage. In his spare time he loves to code on Swift projects and learn about new things Swift. He can be found on Twitter @nickygerritsen and on GitHub: https://github.com/nickygerritsen/.
Read more
  • 0
  • 0
  • 4479

article-image-developmentworkflow-two-approaches-automate-livereloading
Timo Weiss
04 Mar 2016
5 min read
Save for later

Development/Workflow: Two approaches to automate livereloading

Timo Weiss
04 Mar 2016
5 min read
A good workflow and development environment should support you being productive. Great tooling becomes more and more important the larger your application becomes. There are mainly two big players for your build and automation environment in the node ecosystem out there: GruntJs and GulpJs. Both can automate tasks you usually have to do manually such as running your tests or minifying and concatenating your files. While Grunt aims to define the tasks via configuration, Gulp uses a programmatic approach. Since we're working with an interpreted language, which doesn't need to be compiled, the only thing we have to do to make our changes visible, is reloading the page. If you come to a point where you make changes very frequently, you might get annoyed by always reloading it manually. For this reason, we want to have a look at some existing solutions we could make use of. Livereloading We are going to show you two different approaches to automate the process of reloading the page, which will be referred to as livereloading. The first one will fit into your gulp environment. The second will be defined in your code itself and has no dependency on any other buildsystem. Using Gulp In the following we will learn how to set up a very vanilla gulp method: If you haven't already done so, run npm install --save-dev gulp. This will fetch the latest version of gulp. The --save-dev flag will add an entry to your devDependencies property in your package.json. Then head over to your existing gulpfile.js or create a new one. After requiring the module gulp, we want to define a new task and we name it livereload: var gulp = require('gulp'); gulp.task('livereload', function () { if (location && location.reload) { location.reload(); } }); // attach the watcher gulp.watch(['app/**/*'], ['livereload']); Gulp provides a function called task. As you would probably expect, it is used to define a new task. As a first parameter, it takes the name of the task you want to create. The second parameter can be a callback function or an array with strings of depending tasks, which needs to be resolved first. gulp.task(name[, deps], fn) Note: The tasks in the array will be executed before your new task will run. They will run with maximum concurrency. The gulp.watch() function lets you declare files that should being watched. The function can be used in two different versions: gulp.watch(glob [, opts], tasks) or gulp.watch(glob [, opts, cb]). Both will return an EventEmitter that emits change-events which can be listened on. Livereload without buildsystem Sometimes installing a buildsystem for a small app or prototype might be too time intensive. If you want to use only the livereloading, you can afford this without gulp and grunt. Programmatically A solution which is independent of any third-party modules can be achieved by using nodes fs.watch: var fs = require('fs'); fs.watch('index.js', function(event, filename) { if (location) { location.reload(); } }); Here, we attach a file watcher to the index.js and trigger the reload if the file has changed or renamed. You can also watch for directories and subdirectories. Unfortunately watching subdirectories only works on OSX: var fs = require('fs'); fs.watch('./', { recursive: true } function(event, filename) { if (location) { location.reload(); } }); By passing an option object with {recursive: true}, subdirectories are also being watched. If your development machine is working with other platforms than OSX, you can consider using a third party module to be able to watch subdirectories. chokidar One solution is chokidar. It is a wrapper around nodes fs.watch and fs.watchFile and supports many additional features such as excluding files by name or regex and many additional events. To install chokidar run npm install chokidar. var chokidar = require('chokidar'); chokidar.watch('./').on('all', function(event, path) { if (location) { location.reload(); } }); As a first parameter you can pass a filename, directory or even glob. To see extended examples and the full documentation visit the GitHub repository of chokidar. gaze Another solution is gaze. This is the module which powers gulp. It has a little different API as chokidar. It provides consistent events across Windows, Linux, and OSX. Installation can be done by npm install gaze. A simple reloading example looks like the following: var gaze = require('gaze'); gaze('**/*.js', function(err, watcher) { this.on('all', function(event, filepath) { if(location) { location.reload(); } }); }); Here, the variable gaze is a function which takes as a first parameter a filename, directory or glob. You can also pass an array with multiple filenames, directories, or globs. The all event gets emitted if a file gets changed, added, or deleted. Also here, to see extended examples and the full documentation visit the GitHub repository of gaze. Save up to 70% on some of our top web development products from 11th to 18th April. From Flask to Angular 2, we've got everything to keep the modern web developer ahead of the game. Find them here. About the Author Timo Weiss is a hybrid mobile application and Norrrde.js back-end developer. He can be found on Github @timoweiss.
Read more
  • 0
  • 0
  • 1262
article-image-packt-explains-deep-learning-in-90-seconds
Packt Publishing
01 Mar 2016
1 min read
Save for later

Packt Explains... Deep Learning in 90 seconds

Packt Publishing
01 Mar 2016
1 min read
If you've been looking into the world of Machine Learning lately you might have heard about a mysterious thing called “Deep Learning”. But just what is Deep Learning, and what does it mean for the world of Machine Learning as a whole? Take less than two minutes out of your day to find out and fully realize the awesome potential Deep Learning has with this video today.
Read more
  • 0
  • 0
  • 2396

article-image-packt-explains-deep-learning
Packt Publishing
29 Feb 2016
1 min read
Save for later

Packt Explains... Deep Learning

Packt Publishing
29 Feb 2016
1 min read
If you've been looking into the world of Machine Learning lately you might have heard about a mysterious thing called “Deep Learning”. But just what is Deep Learning, and what does it mean for the world of Machine Learning as a whole? Take less than two minutes out of your day to find out and fully realize the awesome potential Deep Learning has with this video today. Plus, if you’re already in love with Deep Learning, or want to finally start your Deep Learning journey then be sure to pick up one of our recommendations below and get started right now.
Read more
  • 0
  • 0
  • 1336

article-image-tic-tac-oop
Liz Tom
26 Feb 2016
5 min read
Save for later

Tic-Tac-OOP

Liz Tom
26 Feb 2016
5 min read
Hi there, if you're like me, you might have struggled with the idea behind object-oriented programming using JavaScript. I had no idea what I was doing! And while reading up about OOP helps, for me, the thing that really solidifies a new concept in my head is to build something. So, today we're going to build Tic Tac Toe. First Things First First, let's think about various classes we might need to make this simple game. Well, if we break down the components of a game there's a board, players, and the actual game itself. JavaScript is a prototype based language. This means that instead of writing classes and having objects instantited from the class, you directly write objects. Let's get started with building out Tic Tac Toe and hopefully you'll be able to see some differences. Ready Player One So Tic Tac Toe generally has two players, X and O. We can achieve this by creating a Player object. What types of things do players have? Players have names, if they are an X or an O, and maybe they have how many games they've won. There are few ways to approach this. You can make an object literal: playerOne = { name: 'Wonder Woman', marker: 'X' }; Use the constructor pattern: var Player = function(name, marker) { this.name = name; this.marker = marker; } var playerOne = new Player('Wonder Woman', 'X'); Or we can add each method and property directly to the prototype: function Player () { Player.prototype.name = 'Wonder Woman'; Player.prototype.marker = 'X'; }; var playerOne = new Player(); Now you can see updating properties on the last one might not be a great experience. I don't really want all my instances of Player to be Wonder Woman. I like to set my properties using the constructor method (so they're easy to update when I create new instances) and like to add methods by adding them to the object's prototype. While you can declare functions when you use the constructor pattern, what ends up happening is that you recreate that method every time you declare a new instance of the object. Putting methods on the prototype has you declaring a method only once but allows you access to it. People smarter than me say it helps keep memory usage lower. Anyway, back to the task at hand. We've made a player object and an instance of a player. Player One (aka Wonder Woman) is ready to go! But sadly Wonder Woman has nowhere to go. Building the Game So what else do you need in a tic tac toe game? Perhaps a board? Some spaces to populate that board? A game? These all sound great to me! A game probably needs to keep track of who is playing and what board they're playing on. A board might keep track of the various spaces. Spaces probably need to know where they are located. var Game = function(playerOne, playerTwo) { this.playerOne = playerOne; this.playerTwo = playerTwo; this.board = new Board(); this.currentPlayer = playerOne; }; var Board = function() { this.spaces = []; for(var x = 0; x < 3; x++){ for(var y = 0; y < 3; y++){ this.spaces.push(new Space(x, y)); } } }; var Space = function(xCoord, yCoord) { this.xCoord = xCoord; this.yCoord = yCoord; }; Ok, so we have our objects. We've put some properties on those objects . Now it's time for some functionality. There are some basic things I want to be able to do with tic tac toe. So let's say I'm Wonder Woman. What are the kinds of questions I'm going to ask myself to play this game? Is it my turn? Can I use this space? Did I win? These questions are going to be the basic methods we're going to add to our awesome objects. First up: Is it my turn? So we need a way to keep track of turns. Easy Peasy. Game.prototype = { switchPlayer: function(){ if( this.turn === 2 ) { this.turn = 1; this.currentPlayer = this.playerOne; return this.playerTwo; } else { this.turn = 2; this.currentPlayer = this.playerTwo; return this.playerOne; } } } Now we need to know, can a player even use that space and also who is occupying that space? Space.prototype = { markSpace: function(player){ if( !this.marked ) { this.marked = player; return true; } } } Did the player win? Board.prototype = { winner: function(player){ var coords = []; this.spaces.map(function(space){ if(space.marked === player) { coords.push({x: space.xCoord, y: space.yCoord}); } }); if(checkThree(coords)) return true; if(checkDiagonal(coords)) return true; } } var checkThree = function(coords){ // winning game logic here! } var checkDiagonal = function(coords) { // more winning game logic here! or you can combine the two into one function } I'll let you come up with the winning game logic. I put my logic in a function that my winner method called. If you'd like to check out this game in action, you can go here. Thanks for joining me on this exciting journey. If you end up making a sweet tic tac toe game, I'd love to see it! Tweet at me: @lizzletom If you’re interested in learning more about the world of OOP in JavaScript check out our Introduction to Object-Oriented Programming using Python, JavaScript, and C#, a perfect jumping point to using OOP for any situation. About the author Liz Tom is a Software Developer at Pop Art, Inc in Portland, OR.  Liz’s passion for full stack development and digital media makes her a natural fit at Pop Art.  When she’s not in the office, you can find Liz attempting parkour and going to check out interactive displays at museums.
Read more
  • 0
  • 0
  • 3686
article-image-5-engines-build-games-without-coding
Sam Wood
17 Feb 2016
4 min read
Save for later

5 engines to build games without coding

Sam Wood
17 Feb 2016
4 min read
Let's start with a disclaimer - if you want to make a video game the best it can be, you're going to need to learn how to code. But you can build games without coding. So, if the prospect of grinding C++ in order to make the next Minecraft doesn't quite appeal to you here are 5 accessible tools to help you get into game development without writing a single line of code. GameMaker - drag and drop game development GameMaker is one of the premier engines that offers users the chance to make complete mobile games just with using a drag-and-drop interface. Specifically designed so that novice computer programmers would be able to make computer games without much programming knowledge, it's an excellent choice for anyone looking to make cross-platform game app without reams of code. In addition, GameMaker boasts its own language for when you want to add extra custom features and refine your game experience. Unreal Engine - AAA game development without writing code Unreal Engine is a AAA engine, used to make some of the biggest names out there. If you're just getting into games development and are unsure about coding, you might be surprised to see it on this list. What UE4 offers to beginners and non-coders, though, is the power of its Blueprints visual scripting. With Blueprints, you can create (reasonably) complex games all without typing a single line of C++. Based on the concept of using a node-based interface, Blueprints allows non-programmers access to gameplay elements including camera control, player input, items and triggers, and more. Unity - the definitive game engine and a good place to begin Unity is the tool of pro-game developers; in our 2015 Skill Up Survey, it was revealed as the tech that was most important for earning the top salaries in the industry. Unity has no built-in visual scripting like Unreal - but what it does have is a massive community, and a huge supply of code snippets and assets available for almost every requirement. You can do a lot in its editor just by dragging scripts onto in-game objects. Whilst (like Unreal) you'll want to pick up some coding skills when you start to make your games more complex, you can get quite a way standing on the shoulders of your fellow developers. If that's not working for you, though, why not check out PlayMaker? This visual scripting plugin for Unity offers a whole new arrange of options for when you want something a little more custom. GameSalad - an amazing behavior library Much like GameMaker, GameSalad is an intuitive drag-and-drop interface game creator. What makes GameSalad stand out from the crowd though is its amazing behavior library. This library lets developers implement really complex behaviors, of a kind that would be challenging or even impossible for someone to muddle through without a knowledge of coding. There a thousands of successful games on Google Play and the App Store built with GameSalad - why not add yours to their number? Lumberyard Okay, so I lied a bit in the title of this blog - currently, there's nothing to suggest that Amazon's new game engine will be particularly friendly to non-coders. So what is Lumberyard? Why is it on here? Lumberyard is Amazon's new game engine, derived from CryENGINE. It's built to get people deploying their games to Amazon Web Services (AWS) but is otherwise free to use. What's interesting about Lumberyard is its visual scripting tool supposedly made for designers and engineers with little to no backend experience to add cloud-connected features to a game. These features can include a "community news feed, daily gifts, or server-side combat resolution" - added within minutes through drag-and-drop visual scripting. Lumberyard is still super new, so we'll have to wait and see if it delivers on its promises - but we may well find ourselves with a serious contender to the likes of Unity and Unreal. Check out other related posts: Construct Game Development: Platformer Revisited, a 2D Shooter C++, SFML, Visual Studio, and Starting the first game  
Read more
  • 0
  • 2
  • 50068

article-image-tic-tac-toe-es6
Liz Tom
17 Feb 2016
5 min read
Save for later

Tic Tac Toe in ES6

Liz Tom
17 Feb 2016
5 min read
First off, what is ES6? If you're unsure of what ES6 is, it's the new release of JavaScript and comes with some features. Most likely you're using ES5 JavaScript. ES6 makes the first major update to the language since 2009 so you can imagine some people are very excited. There are plenty of things to get super excited about with release of ES6, but one thing I'd like to cover today is the introduction of Classes! If you want to try ES6 out, you can try out Babel. Babel compiles your ES6 code for you so you can see all your neat ES6 stuff without worrying about browser support. I'm not going to go through the entire tutorial on how to build Tic Tac Toe, but will focus on ES6. Some Background So I've heard a lot of folks describe JavaScript object oriented programming to me and the word prototypal or prototype always comes up. I know that I use the word prototype to create objects but what does that really mean? I think Mozilla does a great job at describing JavaScript so I'm going to go with their explanation: Prototype-based programming is an OOP model that doesn't use classes, but rather it first accomplishes the behavior of any class and then reuses it (equivalent to inheritance in class-based languages) by decorating (or expanding upon) existing prototype objects. (Also called classless, prototype-oriented, or instance-based programming.) Here’s Mozilla’s introduction to OOP in JavaScript. The word prototype always threw me off so I had a really hard time grasping the idea of object oriented programming when I was first introduced to it. After taking a little break from JavaScript and learning OOP principles in another language, I came back and suddenly had a much better understanding of what was happening. Classes The new keyword Class is really just syntactial sugar over the protype syntax in previous releases of JavaScript. Classes make object oriented programming in JavaScript easier to read. It doesn't change the fact that JavaScript uses a prototype based object oriented programming model. Tic Tac Toe We're going to write a super basic version of Tic Tac Toe with ES6 just so you can see some of the differences in syntax. So in Tic Tac Toe there are several elements that we need. A board, a game, some players and spaces. In ES5 when I wanted to make a player object I did the following: var Player = function(name, marker){ this.name = name; this.marker = marker; }; In ES6 the same thing looks like this: class Player { constructor(options) { this.name = options.name; this.marker = options.marker; } } Cool! So far, there's no big difference and I'm actually writing more code using ES6 than I would if I was using ES5. You'll see a bigger difference when writing methods. So let's make a space next. In ES5 I would have made a space like this: var Space = function(xCoord, yCoord){ this.xCoord = xCoord; this.yCoord = yCoord; }; Space.prototype = { markSpace: function(player){ if( !this.marked ) { this.marked = player; return true; } } }; The same thing in ES6 looks like this: class Space { constructor(options) { this.xCoord = options.xCoord; this.yCoord = options.yCoord; } markSpace(player) { if ( !this.marked ) { this.marked = player; return true; } } } When we want to make an instance of a class in ES6 it's the same as ES5. let player1 = new Player('Liz', 'X') Pretty cool, right? Subclassing Another neat feature of ES6 is that you can subclass very easily. Let's say we have another type of space that we'd like to implement. A FancyPlayer! In ES5 you'd have to that by: var Player = function(name, marker){ this.name = name; this.marker = marker; }; Player.prototype.playerInfo = function() { return 'Player Name: ' + this.name + ' Player Marker: ' + this.marker; } function FancyPlayer(xCoord, yCoord, fancyPlayerProperty) { Space.call(this, xCoord, yCoord); this.fancyPlayerProperty = fancyPlayerProperty; } FancyPlayer.prototype = Object.create(Space.prototype); FancyPlayer.prototype.constructor = FancyPlayer; FancyPlayer.prototype.playerInfo = function (player) { return Player.prototype.playerInfo.call(this) + ' Fancy: ' + this.fancyPlayerProperty; }; With ES6 you can subclass like this: class FancyPlayer extends Player { constructor(xCoord, yCoord, fancyPlayerProperty) { super(xCoord, yCoord); this.fancyPlayerProperty = fancyPlayerProperty; } describe() { return super.playerInfo() + ' Fancy: ' + this.fancyPlayerProperty; } } Conclusion ES6 is adding a lot of great things and making syntax a lot cleaner. The class keyword doesn't change much but will hopefully make your code cleaner to read and maybe make it easier for those who are struggling with object oriented programming in JavaScript to have an easier time. I know when I was first learning object oriented principles, the JavaScript syntax really confused me. So hopefully you have fun trying out ES6 syntax! To learn more about the world of OOP check out our Introduction to Object-Oriented Programming using Python, JavaScript, and C# - a perfect jumping point to using OOP for any situation. About the author Liz Tom is a Software Developer at Pop Art, Inc in Portland, OR.  Liz’s passion for full stack development and digital media makes her a natural fit at Pop Art.  When she’s not in the office, you can find Liz attempting parkour and going to check out interactive displays at museums.
Read more
  • 0
  • 0
  • 2109