Tag Archives: javascript

  • Choosing a JavaScript Framework

    shutterstock_112692424

    In software development, choosing the right technology for the right job is (arguably) the most important decision a developer can make. But it’s also something easier said than done: For example, you can use many different general-purpose programming languages for the same job, and it’s not clear which one is the most suitable. At other times, a project has particular needs that only a handful of technologies or platforms can provide.

    With all that in mind, let’s talk about the differences between some JavaScript frameworks, focusing in particular on how to choose the right one for the right project.

    As JavaScript has grown, people have created different libraries to expand its utility in Web development. Some of those libraries, such as AngularJS and Ember, are incredibly popular. Unless you’ve actually built a few applications with each one, it’s hard to get a feel for their respective strengths and weaknesses. (I’ve met a lot of Web developers who picked what they thought was the best one, used it for a year, and then, while deep into their project with no turning back, decided they had made a mistake.)

    Know What the Features Mean

    Before you can really understand what the frameworks offer, you need to understand what the different features even mean. MVC? MVVC? One-way or two-way binding? And so on. We’ll get into those briefly, but before that, let’s consider a most important point:

    Focus on the Final Product

    When choosing a framework, focus on what you’re trying to accomplish. How sophisticated is your Web application’s front end? Will you be doing a lot of JavaScript number-crunching, and thus need easy access to the data? Or will you be creating a beautiful front end that is user-oriented but doesn’t have a lot of data manipulation?

    The strength of your coding skills is still another factor in framework selection. Different frameworks allow you more leeway and freedom—but with that freedom comes the need to do more actual coding.

    Some frameworks are considerably larger than others, and lock you into specific architectures. AngularJS is a good example; it’s difficult to stray outside of the suggested architecture, but the architecture comes with a long list of features that automatically take care of problems for you, which means less coding.

    Compare that to a framework such as Knockout, which gives you much more flexibility, but you also have to do a lot of rolling your own to figure out what works best for you. (Ember falls in the middle, although some people might disagree.)

    Models, Views, and Controllers

    Most of the frameworks take different approaches regarding models, views, and controllers. The model is your data. The view is what your users see on the screen; treat it as a representation of your data. The controller is the code that manages the data.

    Frameworks differ in how the models, views, and controllers are architected. A lot of developers have found a need to separate the model into two different types of data: one is the actual data stored in the database, and the other is the temporary data that assists in what the user sees on the screen. The “real” data exists in one format, but to be presented on screen, it needs to be in a slightly different “shape” in order to be manipulated by the user interface.

    This need has resulted in an addition to the Model-View-Controller (MVC) architecture, with a fourth component, the Viewmodel. I found some great explanations of the difference between MVC and Model View ViewModel (MVVM) on Stack Overflow and one blog. (I will usually put additional data inside the viewmodel that isn’t part of the main data, such as a list of countries needed to populate a dropdown list.)

    Data Binding

    Next comes data binding. Before these frameworks existed, you had to put your controls in your HTML, and then use jQuery to read the data out. If you wanted to gather up data to be sent to a server through AJAX, you had to gather the values from your different controls; or if you were reading data from the server, you had to go through the data and populate your controls. This was a headache.

    Data binding refers to copying the data values between your model and your controls on the screen. Thus, if your model has a user object containing a first name and last name, the framework will put the first name and last name on the screen automatically for you. With two-way binding, as the user modifies the first name and last name inside a control, your data automatically updates.

    People have differing opinions about whether two-way binding is a good thing or not, and whether a library should allow it. Regardless of those opinions, different libraries do allow it; and if you need it, you obviously want a library that supports it.

    Here’s a great video and slideshow that explains how our three libraries, Ember, knockout, and AngularJS compare on two-way binding. (Despite that support, developers have still found themselves in messy situations, particularly with AngularJS and Ember; consider carefully the implications of one- or two-way binding before going down either road.)

    Examples

    In all of these frameworks, you’re going to be writing code. (If you’re not comfortable writing JavaScript code, now is the time to start learning it.)

    With the below example, I’m focusing on Knockout because that’s the one I’ve been using lately (which is not to say it’s always the best one for the job). Suppose you have a model that includes first name, last name, and home country, like so:

    
    var model = {
    
    firstName: 'George',
    
    lastName: 'Washington',
    
    country: 'USA'
    
    }
    
    

    In order to use two-way binding, you have to wrap functions around each item, using what are called observables:

    
    var modelObs = {
    
    firstName: ko.observable('George'),
    
    lastName: ko.observable('Washington'),
    
    country: ko.observable('USA')
    
    }
    
    

    You can learn the details on how this works on the Knockout website. For now, I want to point out that if you bind each member to an input box on a page, the value will immediately change in your model in response to the user’s input. If the user types “Thomas” in the first name field, you’ll get a different value when you check the firstName function:

    
    console.log(modelObs.firstName());
    
    

    will show ‘Thomas’.

    Or, if you change model, like so:

    
    modelObs.firstName('Ben');
    
    

    then the input box on the screen will immediately change. That’s what two-way binding is all about. (As an exercise, think about why you need a function to set the value, rather than a simple assignment, as least with old versions of JavaScript.)

    Conclusion

    There are many more frameworks out there that you’ll want to explore. If you’re looking for work as a Web developer and trying to decide which framework to learn, you should look at the requirements of the jobs that interest you. If you’ve been focusing on Ember but seeing only AngularJS in job postings of note, then perhaps it’s a good idea to explore AngularJS. That’s what will ultimately help you decide which frameworks to learn.

    The post Choosing a JavaScript Framework appeared first on Dice Insights.

  • JavaScript You Need to Know For a Job

    shutterstock_130719125

    JavaScript is a programming language that’s easy to pick up, but extremely difficult to master. Even some of its beginner-level functions are decidedly not beginner-friendly. When you land your first JavaScript job, you’re going to want to know as much as possible, if only so you can navigate through some of the language’s trickier aspects without needing to ask for help.

    Below is the bare minimum of what you’ll need to know to work with JavaScript (beyond the absolute basics such as variables, functions, the difference between null and undefined, and so on). For those who have some JavaScript knowledge, the following list might miss some specific elements you think belong there; but the idea here is that, if beginners are at a level where they understand the presented items, they probably understand the language enough to operate effectively.

    Check out the latest JavaScript-developer jobs.

    The Beginner’s List

    • Know what a prototype is, what the “this” variable does, and how to use both.
    • Know the difference between a list and an object (and how a list is technically both, and can be used as both).
    • Know that functions are objects that can be passed as parameters into other functions and returned from other functions.
    • Know what closures are and how to use them. This might seem like an advanced topic, but when working with functions returning functions, it’s easy to introduce bugs if you’re not careful.
    • Know how to use functions such as the list’s map and filter functions. With this in mind, I encourage you to read this specification and learn the methods available on all types of objects.
    • Know your way around the developer command line and debugger. All the major browsers provide these now.

    Slightly More Advanced (Document Object Model)

    The DOM (Document Object Model) is the browser’s representation of a Web page. The DOM isn’t technically part of JavaScript, but it’s a big part of browser programming with JavaScript. As such, most employers are going to expect you to know your way around the DOM if you’re applying for a JavaScript job. Vital aspects include:

    • Accessing the DOM directly from JavaScript. For example, know how to locate elements through calls such as getElementById, getElementsByClassName, getElementsByTagName, and so on. Also know how to use the newer selector methods: querySelector, querySelectorAll.
    • Accessing the DOM using jQuery. Again, jQuery isn’t part of JavaScript, but a lot of employers expect you to know it. Know the difference between $(‘a’) and $(‘.a’). A simple dot changes everything.
    • Understand the global object, how the browser provides the global object, and how you access it through your JavaScript programming. (Answer: The browser provides the window object (lowercase w) as the global object.) Understand why the browser is the service implementing the global object and what happens when you move JavaScript code outside of the browser, such as to Node.js.

    A lot of documentation presents the DOM API using what looks like C-language interfaces. That’s because under the hood, the objects likely are C objects. You access these objects through your JavaScript code. For example, when you call getElementById, you get back an element. But under the hood, that object is a C object with properties and methods.

    This page on the Mozilla Developer Network shows you the different properties and methods available. An element is descended from a node, which means, if you have an element, you can call any of the properties and methods available on this page for a node. Try it right now—press F12 and open up the console. Here’s how you get an element:

    
    e1 = document.getElementsByClassName('header-bar')[0]
    
    

    …and then a child of that element:

    
    e2 = e1.querySelector('.container')
    
    

    And then remove that second element. The interface for the node class tells us there’s a removeChild function, so here you go:

    
    e1.removeChild(e2)
    
    

    And watch the top bar on this page you’re reading disappear. Done. (Refresh the page to bring it back.)

    In addition to the DOM, there’s much more you’ll want to study regarding Web pages and how they fit together with JavaScript. You must know how to add events to elements and how to handle the events. Know both the pure JavaScript way,

    e1.addEventListener('click', function(e) {
    
       console.log('CLICK!'); }, false);
    
    

    as well as the jQuery way:

    
    $(e1).on('click', function() { console.log('CLICK 2!'); } )
    
    

    Spend some time exploring the HTML5 features, such as how to save to local storage and manipulate a canvas element. Again, these are not technically features of JavaScript; they’re APIs provided by the browser. But if you’re trying to land a job writing code that runs in the browser, you’ll want to know how they work.

    And then there’s the biggie, Ajax. You must know what Ajax is—a way to make calls back to the server—and how to use it.

    Even More Advanced

    Now take your JavaScript programming to the next level. The more you know, the better. As before, here’s a sampling of things to know:

    • Know how to call bind and apply on a function, what the differences are, and why you would need to use them.
    • Know the different ways to create objects, including Object.create, and when you’ll need the hasOwnProperty method:
    
    x = {a:1, b:2};
    
    x.toString(); // prints out [object Object]
    
    x.hasOwnProperty('a'); // returns true
    
    x.hasOwnProperty('toString'); // returns false
    
    

    compared to:

    
    x = Object.create(null);
    
    x.toString // is undefined
    
    
    • Know the different ways of implementing object-oriented programming, especially inheritance.
    • Know what promises are, and learn two important asynchronous libraries: async and Q. They’re used a great deal in server-side Node.js programming, but can also be a huge benefit in browser programming.
    • Learn server-side Node.js programming. It will really force you to become a JavaScript guru.

    Conclusion: Even Further

    If you know the material in the third section, you’re in great shape. But there’s always more to learn. Want to take it even further? Learn about ES5 and the newest features of JavaScript that might not be present in all browsers. Learn the different frameworks, such as Backbone, Ember, Angular, and Knockout. The more you know, the more likely you’ll land that job.

    The post JavaScript You Need to Know For a Job appeared first on Dice Insights.

  • JavaScript Tops Popular Languages, As Swift Rises

    RedMonk

    Developers assume that Swift, Apple’s newish programming language for iOS and Mac OS X apps, will become extremely popular over the next few years. According to new data from RedMonk, a tech-industry analyst firm, Swift could reach that apex of popularity sooner rather than later.

    While the usual stalwarts—including JavaScript, Java, PHP, Python, C#, C++, and Ruby—top RedMonk’s list of the most-used languages, Swift has, well, swiftly ascended 46 spots in the six months since the firm’s last update, from 68th to 22nd.

    Check out the latest developer jobs.

    “When we see dramatic growth from a language it typically has jumped somewhere between 5 and 10 spots, and the closer the language gets to the Top 20 or within it, the more difficult growth is to come by,” RedMonk wrote in an accompanying blog posting. “Given this dramatic ascension, it seems reasonable to expect that the Q3 rankings this year will see Swift as a Top 20 language.”

    RedMonk pulls data from GitHub and Stack Overflow to create its rankings, due to those sites’ respective sizes and the public nature of their data. While its top-ranked languages don’t trade positions much between reports, there’s a fair amount of churn at the lower end of the rankings. Among those “smaller” languages, R has enjoyed stable popularity over the past six months, Rust and Julia continue to climb, and Go has exploded upwards—although CoffeeScript, often sited as a language to watch, has seen its support crumble a bit.

    Here are RedMonk’s top 20 languages:

    1. JavaScript
    2. Java
    3. PHP
    4. Python
    5. C#
    5. C++
    5. Ruby
    8. CSS
    9. C
    10. Objective-C
    11. Perl
    11. Shell
    13. R
    14. Scala
    15. Haskell
    16. MATLAB
    17. Go
    17. Visual Basic
    19. Clojure
    19. Groovy

    A more intensive look at RedMonk’s data is available on its blog.

    Upload Your ResumeEmployers want candidates like you. Upload your resume. Show them you’re awesome.

    Related Articles

    Image: RedMonk

    The post JavaScript Tops Popular Languages, As Swift Rises appeared first on Dice News.

  • Which Programming Language Pays the Best?

    shutterstock_Lightboxx

    What programming language will earn you the biggest salary over the long run?

    According to Quartz, which relied partially on data compiled by employment-analytics firm Burning Glass and a Brookings Institution economist, Ruby on Rails, Objective-C, and Python are all programming skills that will earn you more than $100,000 per year. Java, C++, JavaScript, C, and R also topped the list, routinely racking up salaries of $90,000 and above.

    Click here to find programming jobs.

    “The dataset isn’t perfect, it’s missing newer but increasingly popular languages like Erlang and Haskell, likely because they don’t turn up all that frequently on job ads and resumes,” Quartz explained in the accompanying article. “A large number of the ads also don’t list salary.”

    But salary doesn’t necessarily correlate with popularity. Earlier this year, for example, tech-industry analyst firm RedMonk produced its latest ranking of the most-used languages, and Java/JavaScript topped the list, followed by PHP, Python, C#, and C++/Ruby. RedMonk predicted that new languages such as Apple’s Swift and Google’s Go, while ranked very low at the moment, will also climb into more prominent positions over the next few years.

    Meanwhile, Python was the one programming language to appear on Dice’s recent list of the fastest-growing tech skills, which is assembled from mentions in Dice job postings. Python is a staple language in college-level computer-science courses, and has repeatedly topped the lists of popular programming languages as compiled by TIOBE Software and others. (In addition to Python, other popular languages in college intro courses include Java, MATLAB, C++, C, Scheme, and Scratch.)

    “The best programming language may well be the one that is most likely to help you consistently find a job, not necessarily the one that pays best,” is how Matt Asay described, in a recent ReadWrite column, the dilemma facing today’s programmers.

    In other words, pursuing a language because of the six-figure salary, while tempting, might not prove your best option in all circumstances.

    Upload Your ResumeEmployers want candidates like you. Upload your resume. Show them you’re awesome.

    Related Articles

    Image: Lightboxx/Shutterstock.com

    The post Which Programming Language Pays the Best? appeared first on Dice News.

  • What the Next 18 Months Holds for Software Careers

    It’s easy to put your head down and focus on the work that you have to do today. To think about the job you’re doing now. To think about the technology you know already. To understand the team structure you’re currently in. That’s what’s now. But what’s next? Let’s take a walk through the next 18 months and see where engineering is going. Focus on Learning H iring managers have figured out that tomorrow’s skills won’t be today’s skills, so they’re looking for learners. With the time and productivity crunch managers face — not to mention their desire to sweeten the pot for qualified talent — they’re going to be more inclined to support your ideas for training. More and more companies are creating training budgets that employees can use any way they want. What to Expect: In interviews and reviews, expect to start seeing more emphasis on how you learn, how quickly you learn and what you learn. The good news is that it means you’re also more likely to get an interview even if you only have 80 percent of the job’s matching skills. It also means that you’re going to be more responsible for identifying your own training opportunities such as online courses , podcast subscriptions and conferences to name a few. How to Handle It: Take charge of your own training, whether you’re working or between jobs. Ask your manager what projects are coming up, do some research and suggest training options that make sense. Make your learning projects public even if they’re for personal use, and don’t be afraid to ask for feedback. Write a summary of how you went about learning so you have a good story to tell at your next performance review or job interview. Mobile First and Mobile Only What’s Going On: Apps are everywhere. Smartphones are everywhere. According to IDC, PC sales are dropping and will continue to do so through 2018. At the same time, global smartphone sales are up 46 percent, a solid mix of Android and iOS . How to Handle It: Software developers and the companies they work for need to reach people where they are: on their phones. That means more apps, more mobile websites and more emphasis on semi-connected use. If you’re a PC application developer , it’s time to figure out how to build mobile apps . If you’re a Web developer , make sure you’re up to date on responsive design and mobile constraints. If you’re a server developer , there’s good news: All those apps still need servers. You’ll be building a lot of REST APIs . Focus any outside-of-work learning you do on technologies that are mobile-friendly. Volunteer for any mobile projects your company is starting so you can start to learn. Rise of JavaScript Frameworks What’s Going On: The pendulum is swinging back from thin clients to thick clients, but now the browser is the thick client. To support that, JavaScript is taking on characteristics of server-side programming: encapsulation, light object-orientation, MVC support. The odds are high that your next Web application will use Ember , Angular or something similar. Backbone — the granddaddy of the JavaScript frameworks — has lost momentum but will remain prevalent for a year or so. How to Handle It: If you’re a Web developer, get your hands on a JavaScript framework tutorial and start learning. It doesn’t matter which framework you choose, but this is a tool you’ll need in your arsenal soon. Testing Integration What’s going on: The future isn’t bright for manual testers. More and more teams are focusing on “whole team testing,” which usually translates to automated testing by developers and “acceptance” or light manual testing by business users or customers. Dedicated testers are turning into specialists, particularly in performance, load and security-related testing. How to handle it: If you’re a manual tester, you’ll need to find a niche ( automation , performance , security , etc.) or you’ll have an increasingly hard time finding a job. If you’re a developer, expect to start testing your own code, usually with existing test frameworks. All engineers should expect to spend more time with interested business users and to start explaining features and bugs to a wider audience. Conclusion Technologies, techniques, patterns and team dynamics are all places where today’s solutions won’t solve tomorrow’s problems. The onus is on you to keep up so that your career today is a career you can continue tomorrow. Fortunately, you have some notice, so you can be ready. The post What the Next 18 Months Holds for Software Careers appeared first on Dice News .

  • Demand for IT Engineers Shows in Salaries

    IT engineers continue to be in demand, and the proof is in their salaries, according to the 2013–2014 PayScale College Salary report . Their roles accounted for a sizable chunk of the top 10 salaries across all industries when measured by median pay for graduates with at least 10 years of experience. Computer engineering majors, sharing sixth place with electrical engineering majors, had an annual median salary of $106,000 for those at the mid-career level. When starting out – with five years’ experience or less– they earned $65,300 a year, compared to the slightly lower $64,300 for electrical engineers. Meanwhile, mid-career computer science graduates also earned six figures. Their median salaries stood at $102,000. Within computer science degrees, the five top jobs in terms of demand are software architecture and development , mobile app development , Big Data analytics , healthcare IT and video game design . Skills that are particularly in demand include . NET development , Java , JavaScript , C# , C++ , HTML5 and ASP.NET . Mechanical engineering majors round out the top 10 list, with mid-career professionals earning a median salary of $99,700. Demand for these jobs should continue strong, as well. According to the American Society of Mechanical Engineers in its 2013 salary report , “As the world’s population increases, so will the demands on the next generation of engineers to provide solutions for global challenges. Mechanical engineers will be at the forefront of solving these problems.” Over the past 10 years, there seems to have been a renewal of interest in mechanical engineering degrees, says Tom Perry, ASME’s director of engineering education. The number of students seeking bachelor’s degrees in the subject or related fields increased by 43 percent — to 130,000 — in 2012, he notes. He attributes this interest to the wide range of applications for mechanical engineering, from the long-held traditional use of control systems found in robotics to embedded systems used in sustainable energy smart systems. “It’s not just about mechanical engineering anymore,” Perry says. “This is not your grandfather’s mechanical engineering.” The post Demand for IT Engineers Shows in Salaries appeared first on Dice News .