Categories
ai artificialintelligence code development

Learning to think in code

After I posted my thinking in code post, I had an interesting discussion over on my Google+ page.

It’s a difficult mindset to cultivate. When you get it and are in the zone, it’s effortless in a way that is hard to explain. It basically feels no different than writing in proper English.
When you don’t have it, it’s like trying to speak in a different language. Which makes sense, but it isn’t quite exact.

I’ve been coding for so long, thinking in code is second nature, but I liken it to when I learned to drive. At first I was very bad, I made a lot of mistakes and it really knocked my confidence, but I stuck at it because I lived in the country and had no choice, I was still nervous after passing my test, and it took about another 2 years before I got to the point where I wasn’t consciously thinking about the mechanics of driving, the meaning of each marking and road sign, and how to react to different conditions.

A lot of people I’ve mentored get scared when they lose confidence, but that’s an important step, and it always takes a long time to get past the conscious thinking stage, where they’re switching between the customer domain and the coding domain rather than thinking in the customer domain and writing in the coding domain.

Switching to Haskell got me back to newb mode again. It’s less like programming and more like magic. I can see how it works, and it does things as expected, but intuition tells me it shouldn’t work.

That’s how I felt when I started with node.js – first time I’ve really dug into the guts of JavaScript. I’ve done first-order functions and callbacks in other languages, but the way JavaScript does it, compared to C# or Python, forces me to think about what I’m doing.

I know some of the problems are addressed in ES6, but prototypes rather than the OO I’ve used elsewhere is a massive shift for me, and I definitely don’t think in JavaScript yet.

https://plus.google.com/+CraigNicolGeek/posts/dPLRZFbHsn1

And then I read Code rant: Learn To Code, It’s Harder Than You Think, and it got me thinking about the AI Gods, and how unnatural it is to think in code. And that’s important. When you talk to users and customers, and when you talk to managers, they look at all the information saying coding is easy and then ask why it’s taking so long, or why you can’t just put that number there, and then switch off when you try to explain. Indeed, you can end up in a meeting like this one:

The expert : https://www.youtube.com/watch?v=BKorP55Aqvg

So it’s important for people to understand that code is hard, and it is a specialist skill, whilst still trying to encourage people to take up software, because we need a new generation of AI gods, and they need the time, and the inclination to grok coding.

I grew up in the 8-bit days, with the MSX, and coding was an integrated part of the experience. The command line was the programming language, and all the magazines has type-ins, so there was a lot of opportunity to practice typing, as well as coding, which is a valuable subsidiary skill. There’s a similar modern experience with the Raspberry Pi, but the industry as a whole has moved on so much, that the days of spending a few hours typing to get something that has the same surface quality as the games in the shops, are mainly behind us, at least as far as the big box games, rather than the casual field. And it will be about games, because who is going to write a tax auditing application for fun?

How do I learn?

So if you’re just starting out, and you want to write software, or you want to be the next AI God, what do you need?

Here’s what I think is most important:

  • Teach yourself. Attend classes if it helps, but if you’re not self-motivated to learn and keep up to date, you will quickly fall behind.
  • Crave simplicity. Challenge yourself to cut complexity, to streamline. The less code you have to write, the easier it is to work with. Always seek new ways to simplify what you do.
  • Practice the basics. Use the many programming exercises to capture branching, modularisation, testing. Find examples you like, either smaller exercises, or complex Mandelbrot calculations and keep reworking them to understand new languages, or to challenge yourself to understand that basics. Can you write a program without if statements, or can you throw away the tests and rewrite the code?
  • Practice often. Spend 20 hours writing code. Then reflect, understand what you know, and write more. The more you write, the more you’ll understand what you don’t know.
  • Read code. And think about it. Just because it exists, doesn’t necessarily mean it’s good, but think about how you would solve the same problem. Understand what decisions were made and why.
  • Understand principles deeply, technologies less so. Know what it means to be Object Oriented, or Event Driven, or Functional. Understand what they are and how to use them. It doesn’t matter whether you’re using C# or Python or VB or Java or Haskell or The Next Big Thing. If you understand the principles, you can apply them with whatever syntax your current language provides, and you can understand what to use when.
  • Think in code, but talk in human. If you can’t explain what you’re doing to your users or your manager, you don’t understand it enough. Crave simplicity in your communication as well as your code.
  • Talk publicly. Present, blog, chat. Find a local user group and connect. If you’re enthusiastic, you’ll be welcome. If you’re shy, everyone will understand. We’ve all been there.
  • Simplicity doesn’t mean brevity. Be as brief as possible, but don’t lose context, or nuance. Be clear.

For those of you with experience, what else would you add?

Categories
ai artificialintelligence c++ code development programming search

Updated slides on Genetic Algorithms

I had the opportunity at work to revisit my Generic Algorithm talk, to refactor it with a bit more time to hopefully make it clearer. I also ported the C++ template code to Python to make it easier to demo. I’ll be talking about the implementation differences in a future post but I’ve included the links for the talk below for public consumption.

Categories
ai artificialintelligence code programming

Why AI doesn’t scare me

Tripod Machine
The chances of anything coming from Mars are a million to one…

You may have heard about a letter going about where a lot of people say they’re scared of AI and autonomous weapons. There are some very interesting signatories on the list. As someone who studied AI, and knows a couple of people on that list from my course, the letter interested me greatly.

I’ll discuss the implications of autonomous weapons in a future post, but a lot of the reporting and comments about the letter talked about fear of AI itself. As if smarter machines in and of themselves are the greater threat to humanity, without considering whether or not these smarter machines are designed to kill. This fear appears to be unrelated to whether the machines are smarter than us, just about being smart enough to be a threat (although I want to discuss the singularity in a later post too).

Perhaps for a small minority, the fear comes from the same place as fear of other humans. The ignorance breeding fear that someone or something smarter or different from you will be threat to your way of life, or your life itself. There’s legitimate fears within that, linked back through history to the luddites whose jobs were at risk from automated machines.

It’s clear that jobs will replace humans with machines, and the better machines get, the further up the pay scale the threat will come, just as globalization pushed low paid jobs to other countries. It’s a real problem that needs to be addressed politically via training, diversification of the economy, and other tactics, but I don’t want this to be a political blog, so decide for yourself how jobs can be created.

If your fear comes from not being the smartest person in the room – get over yourself. Success builds on success, and humanity’s greatest achievements have come from those who stand on the shoulders of giants. These days, these may be iron giants. AI that is smarter than us already exists, machines are better than us at Chess, Jeopardy, code breaking, and calculating Sine tables.

AI is already all around us – it does fraud detection, voice recognition and a bunch of other things – Once it works, it’s not AI any more (as .Net Rocks reiterates), and it will get better.

If you want to know more, the following article and video are definitely worth a look.

<How safe is AI : http://www.bbc.co.uk/news/science-environment-34249500 >

<How smart is today’s AI : https://www.youtube.com/watch?v=poLZqn2_dv4 >

Categories
ai artificialintelligence development

AI and I

My degree was in Computer Science and Artificial Intelligence. Unfortunately, AI was a tough field to get a job in when I graduated, so I concentrated on the Computer Science part in the main. However, AI still fascinates me, and a lot of the “Big Data” movement is actually appropriating techniques from AI to filter and transform data, because of the fields in AI that study pattern recognition, feedback and learning, and application of structure onto data (think classifying pictures by their content, or detecting spam from a collection of email).

There’s a few news stories recently that I want to talk about over a series of posts, but first of all, I want to direct folk to this nice summary from Wired, which perfectly demonstrates an old truth in AI – that AI is the stuff we haven’t figured out yet. Once we understand it, it becomes Computer Science. The Three Breakthroughs That Have Finally Unleashed AI on the World | WIRED

The article, is some ways, is many years too late, fraud detection systems are almost as old as credit cards, we’ve had spam filters for years, most humans are easily defeated by chess computers. Many of the things we used to hold as either evidence for intelligence, or super hard problems for computers to solve, have been solved. Those thresholds have passed, and our world is building of smart, learning systems, adapting to you, learning more about each of us to provide more tailored experiences, either for our benefit, or for the benefit of marketers.

There’s still plenty to learn, and it’s still an exciting field, but we’re no longer in a world where AI is “just around the corner”. Computers are smarter than us in many ways. General intelligence may still be unsolved, but practical intelligence is now part of the fabric of our lives. AI is not something to be scared of. It’s here, and it’s helping us. But like any technology, the ethical concerns are still a matter to be discussed.

Categories
ai artificialintelligence data development search

The UX of Big Data

Following on from my Dangers of Big Data talk at DunDDD, I’ve been thinking about what a good user experience for data analytics would look like, imagining the business user presented with useful, actionable information rather than notepad and a copy of the R or Python cookbook. I want something deceptively simple like the Google search box, rather than deceptively complex like Excel.

Excel, and R and Python, put a lot of tools at your disposal, and you could use any of them to construct an answer, but the secret to analytics relies on getting a valid, useful answer. The first is a matter of restricting the answer space to that which can be supported by the data (for example, disallowing multiplication of time-based input streams, or aggregating when there is no statistical basis for it), the second is a matter of allowing the user to explore the space so they can determine (and where appropriate, train the system to recognise) which factors are most important, how they affect the desired outcome, and how changes to the environment affect these factors.

Then the question becomes, how much should the software take over. Do we have a duty to protect users from themselves by preventing invalid analysis where we can detect it, or do we have to accept that the frustration that will cause leads to alienation and users will be less likely to respond well to further corrections. Even nudging had its possible, as anyone who had been frustrated by grammar checkers can attest. But at least nudging helps the user to understand, rather than putting up roadblocks. Nudging encourages learning, roadblocks encourage switching to another way.

How would you encourage users to handle analysis appropriately?

Categories
ai artificialintelligence c++ code development geneticalrorithms programming

Genetic Algorithms

I wanted to post a new blog here via Flock, but Flock and Blogger won’t play together 😦 this post is also available here.

I had a great time at the Tech MeetUp (@techmeetup) in Glasgow this week. If you want to meet up with other tech minded folk in Scotland, it’s definitely worth checking out. See the details at the end of this post.

At the meeting this week, I got talking to a few folk (including John Gallagher who gave a great talk) about AI and Genetic Algorithms. This inspired me to dig out my old experimental code for doing GAs using C++ Templates. The code’s very rough and ready, and it was written long before I discovered TDD or subversion, but it should be standards-compliant, and it compiles in the latest GCC (I can’t vouch for other compilers, if you try it, let me know). As it’s a source-code library, you’ll have to compile it yourself, but if you don’t know how to use a compiler, you’re probably reading the wrong blog anyway. I will be tidying up the code and creating a wish list as I get the chance, but I’m throwing it out there in case it’s useful to anyone.

If you’re interested, check it out at the link below and let me know what you think.

Genetic Algorithm Templates (edit : changed link to github)

If you’re interested in Tech MeetUp, you can see videos from previous talks at their website

The Tech MeetUp is the informal opportunity to meet other developers and tech companies, to showcase your hacks or projects, and to find out what’s happening around us. Help build the tech community – set up a profile and come along to a Tech MeetUp.

Home – Techmeetup

You can find out about upcoming meetings on their mailing list

Description: An easily accessible and friendly community of tech minds, skills and startups around Scotland and Northern UK.


Tech Meetup | Google Groups

Categories
ai artificialintelligence c++ code development geneticalrorithms programming

Genetic Algorithm Templates

I had a great time at the Tech MeetUp (@techmeetup) in Glasgow this week. If you want to meet up with other tech minded folk in Scotland, it’s definitely worth checking out. See the details at the end of this post.

At the meeting this week, I got talking to a few folk (including John Gallagher who gave a great talk) about AI and Genetic Algorithms. This inspired me to dig out my old experimental code for doing GAs using C++ Templates. The code’s very rough and ready, and it was written long before I discovered TDD or subversion, but it should be standards-compliant, and it compiles in the latest GCC (I can’t vouch for other compilers, if you try it, let me know). As it’s a source-code library, you’ll have to compile it yourself, but if you don’t know how to use a compiler, you’re probably reading the wrong blog anyway. I will be tidying up the code and creating a wish list as I get the chance, but I’m throwing it out there in case it’s useful to anyone.

If you’re interested, check it out at the link below and let me know what you think.

Genetic Algorithm Templates (edit : changed link to github)

If you’re interested in Tech MeetUp, you can see videos from previous talks at their website

The Tech MeetUp is the informal opportunity to meet other developers and tech companies, to showcase your hacks or projects, and to find out what’s happening around us. Help build the tech community – set up a profile and come along to a Tech MeetUp.

Home – Techmeetup

You can find out about upcoming meetings on their mailing list

Description: An easily accessible and friendly community of tech minds, skills and startups around Scotland and Northern UK.


Tech Meetup | Google Groups

Blogged with the Flock Browser