Two women and one man working together in the meeting room.
31.07.2024
Kirsi Vatanen

How to create an outstanding user experience on your website

Why does your company’s website exist? The question might sound trivial at first, as it’s clear in today’s world that if a business isn’t online, it might as well not exist. Consumers are online, and online interactions are only increasing. But is your web service truly customer-centric? Does it serve your customers more than it serves your business?

Most companies believe they offer a good customer experience, but rarely is the perspective genuinely customer-focused.

If you want your site to be more than just a mundane business card with basic info, promotional talk, and contact details, it must deliver value to your customers. And to provide value, you need to understand what your target audience values and needs.

From the company’s perspective, a good web service reaches the right people, and visitors find what they’re looking for and perform the desired actions.

From the visitor’s perspective, however, it’s more emotional: a good web service not only provides value but also feels pleasant and effortless to use. If it doesn’t, the customer is easily lost.

So how is a good user experience created online? These five steps will take you a long way.

1. Involve the users in the designing process

Too often, user needs are overlooked when building web services. It’s essential to utilize user testing and surveys during the design process. This ensures that the information is presented to users in the way they expect to receive it.

2. Ensure good usability

Users appreciate quick and effortless transactions. At its best, a web service is so easy to use that navigation is intuitive.

The service’s functionalities are clarified with visual elements, and users are gently but clearly guided along the path towards the desired action.

3. Provide truly useful content

It’s important to consider the entire customer journey rather than just a single purchase event. How can you help the visitor when they are just beginning to look for a solution to their problem? How can you serve the customer after the purchase? How can you encourage the customer to return?

Forget about your product and focus on solving the problems users face at different stages of their journey. Meaningful content that engages the customer is key here, whether it’s a thought-provoking blog post, guide, video, discussion forum, or even a recipe bank.

4. Make an impact with visuality

The appearance of the site should reflect your company’s message. A significant part of the first impression is formed based on the visual style of the site. The visual style is one of the most important tools a company has to convince the customer and build trust.

5. Invest in scalability

As your business grows, the user experience of the web service must scale smoothly with it. For the user, it’s important that the service operates consistently and that they don’t have to learn new things as the system expands.


A good user experience is a significant competitive advantage, and its importance for business success is constantly growing. It’s about serving customers and creating customer satisfaction.

Your website should be seen as a tool for building and maintaining customer relationships. At its best, your service not only supports your business but becomes a profitable business model in itself, delighting customers—so much so that they keep coming back and recommend it to others.

If you want to improve your website or have questions about its user experience, feel free to get in touch.

The blog post was originally published in 2017.

Author

Kirsi Vatanen

Marketing Manager
Mies käyttää ruudunlukijaa
15.05.2024
Simo Hellsten

Fix accessibility problems at the (open) source

Accessibility is an important topic for people responsible for the profits and expenses of the web world – somewhat dependent on the nature of the actor. A lot of web commerce sites would do well welcoming the money from those clients who benefit from improved accessibility, while the public sector, that has no direct income, is bound by the law to provide accessible services. Faced with ever-tightening budget constraints, decision-makers may wonder about the most effective ways to improve accessibility. The easy answer is of course – have someone else do it, and for free.

The content of the internet today consists of a multitude of services, platforms and frameworks. While there are several strictly commercial companies with successful products, the majority of the internet we see today has its base on open source software. About two thirds of all the websites are built on open source software content management systems (CMS). The overwhelmingly biggest player in the field is WordPress, while Drupal is a strong second for large and complex sites.

Open source code is free to distribute and modify within the limits of it’s license. This has usually resulted in the software being developed and maintained by online communities. And the communities take the accessibility of their products seriously.

In the recent past I myself have spoken at both WordPress and Drupal developer community events and Drupal is a CMS where I contribute to accessibility and usability regularly. At Drupal’s chat forum the accessibility channel has 1560 participants ranging from developers interested in accessibility to hard-core accessibility professionals – some of whom are currently also working on the next generation of the international web content accessibility guidelines, WCAG 3. Drupal has also a monthly live online meeting on accessibility where one can present issues or ask questions. This is one of the ways to share accessibility knowledge in the community.

A typical website, depending on the complexity, has a development team of just a few people. While a lot of developers today have some level of accessibility skills, not all projects have an actual accessibility specialist in their team. This is where the community shows its power. Accessibility is always easier when done right from the beginning, instead of fixing afterwards based on testing the otherwise ready product. When the CMS of choice has gone through accessibility testing before being released as an installable distribution. A lot of the work has already been done by the community. And if (or more likely when) new issues arise during the individual site’s development, the community is available for advice on best practices and fixing newly found issues.

The community will help you to fix accessibility, but it is a two way road. When working on a project, every once in a while you come up with big or small accessibility issues that can be fixed at the source. These can be for example administration theme issues or maybe even some core JavaScript. When you or your team fix such an issue on your production site, make sure to give your code back to the CMS project core – or if the finding was about a contributed open source module to its source code. This way the effect of your finding will have a much bigger impact all over the Internet.

Just this spring my team, in which we develop and maintain a small number of university services, two of which use Drupal 10, identified three small accessibility issues that were part of the Drupal core. As we fixed the accessibility for our sites I made merge requests to Drupal core. This way we not only contributed to Drupal development but also got additional review for the code and even some advice on how to best implement the solutions proposed by our team’s web accessibility specialist in the Drupal core context. I even learned how to write my first Nightwatch.js test for the feature – something I probably wouldn’t have ended up doing if we had only fixed the issue on our own projects.

Now that our three small accessibility fixes have been merged to Drupal core, by the time sites have updated to the latest bug fix releases, we have contributed to one in eight enterprise web sites around the world. In small steps, we can make the world a better place. This is open source at its best.


Simo is member of Drupal UX team and following accessibility issues. He is also member of W3C Cognitive Accessibility Community Group, W3C Nordic Accessibility Group and IAAP.

Author

Simo Hellsten

Full Stack Developer
A view from hotel window in Davos
17.04.2024
Toni Nissinen

Mountain Highs: My unforgettable experience at Mountain Camp Davos

This year, I had the fantastic opportunity to attend Mountain Camp in Davos, Switzerland. It marked several firsts for me: my first Drupal Camp outside Finland, my first visit to Switzerland, and my first work-related conference trip. I’m excited to share my experiences with you in this blog post.

The experience overall was just awesome! The Drupal community is so welcoming and supportive. Immediately I felt welcomed to the community and didn’t hesitate to be myself and ask questions. We went skiing, some of us on multiple days, had dinner together and a couple of drinks along the way. Chill atmosphere all the way for the whole week.

Group photo of Mountain Camp attendees. Photo Patrick Itten.

I met many wonderful and inspiring people around the world. I couldn’t be happier to meet all of you, a special shout-out to those who were there for the pre-event days! It was so exciting to hear all the stories about how people do their work and how they participate with both the global and local Drupal communities. Even though there are many companies doing similar things with Drupal, we should not fear collaborating with each other over the companies and sharing knowledge with each other. Something you have been struggling with recently could be a piece of cake for someone else and vice versa. This is the essence of community: helping each other succeed. What we contribute benefits not just ourselves but also others within the community.

The event was packed full of useful information and the session topics, with sessions covering a wide range of topics from Drupal security practices to card games about hardware and software. Some topics were about how we could develop a software solution with a customer and some were about developing a smart watch application. The variety of topics was astonishing as I thought that all the topics will be strictly Drupal, especially the nerdy code stuff, though there were also those kinds of topics. I wish I could participate in every session as there were so many interesting and inspiring speakers and topics.

Toni Nissinen etualalla parvekkeella. Taustalla näky yAlpit

I made numerous global contacts, and I feel these connections will extend beyond simple LinkedIn additions. They are fellow professionals I can reach out to for advice and support, which I value immensely. I look forward to meeting many of them again at future events and hope to connect with new people.

The sessions in Drupal Camp were really interesting and some of the topics were not that technical Drupal development topics (the nerdy code stuff) so in addition to developers and people working around Drupal, people who use Drupal based solutions and who are interested in maybe making a switch to using Drupal can get invaluable information. In general if you work in a team developing a software solution, even if it’s not Drupal, you might find something useful in these kinds of events.

I highly recommend participating in Drupal Camps and Cons in general. The next opportunity to join is at DrupalCamp Helsinki + Baltics on April 26th! Be sure to check the website for schedule and registration, by the way it’s FREE!

I’ll be there, too and if you have any questions, or if you just want to chat, please feel free to say hi!

Photos: Toni Nissinen and Patrick Itten.

Author

Toni Nissinen

Drupal Developer
A pile of colorful Lego bricks with some of the bricks being assembled into an unfinished house. The house should be partially built, showing an incom Large.
29.02.2024
Tuukka Turu

Building Blocks of Modern Web Development – Web Components

The rapid pace of web development demands continuous innovation and efficiency. Developers are actively seeking new ways to streamline their workflow and enhance user experience. A significant step forward has been the emergence of web components. These compact and versatile elements offer developers a fresh approach to building web applications and a powerful toolkit for creating modular and maintainable user interfaces.

What are web components?

At their core, web components are a set of standardized technologies that enable developers to define their own HTML elements. Comprising three main technologies – Custom Elements, Shadow DOM, and HTML Templates – web components allow for the creation of encapsulated, reusable components that can be seamlessly integrated into almost any web application.

How are web components created?

At its simplest, custom elements can be created with Vanilla JavaScript. However, this is not the most efficient or appealing way to create components. Fortunately, there are libraries available that enable an efficient and user-friendly way to create components.

Lit.dev, supported by Google, is gaining popularity and offers an excellent starting point for developing your own components. StencilJS, developed by the Ionic organization, is another library for web component development.

Where can web components be used?

Web components can be used in many different contexts, from simple websites to complex single-page applications (SPAs). They are particularly useful in situations where modular, reusable elements are needed across different parts of an application or when building component libraries for widespread use.

Web components and design systems

Design systems have gained popularity among larger organizations, where the need for a consistent visual style across multiple services is important. Web components offer an ideal tool for their implementation.

Design systems are a collection of defined components, styles, and guidelines that enable a consistent appearance and behavior across all parts of an application.

Web components fit naturally into design systems, offering clear, modular, and easily reusable building blocks that support the correct visual style and, most importantly, are functional and accessible elements. In this way, they promote consistency and efficient design implementation in different use cases. Additionally, the use of web components allows for effortless updating and maintenance of components, making design systems more dynamic and flexible.

Why use web components?

There are several compelling reasons to adopt web components in modern web development:

  • Reusability: Web components enable the creation of reusable elements, reducing unnecessary repetition and promoting code efficiency.
  • Modularity: Encapsulating functionality in separate components allows for greater modularity, making code management and maintenance easier.
  • Compatibility: Web components are compatible with different framework and library environments, offering flexibility and compatibility in various development contexts.
  • Encapsulation: Shadow DOM ensures encapsulation, preventing style and behavior conflicts between components and the surrounding page.
  • Standardization: As a W3C standard, web components enjoy broad support in modern browsers, ensuring consistency and reliability in web development projects.

What challenges might arise?

While web components offer numerous advantages, they also come with challenges:

  • Browser support: Although support for web components is extensive, older browsers may lack full compatibility, requiring polyfills or alternative arrangements.
  • Complexity: Developing and managing web components can be complex, especially for teams not yet fully familiar with the technology.
  • Performance load: Depending on implementation, web components can cause performance load, particularly in large component counts.
  • Potential SEO challenges: Depending on the implementation approach, SEO can be a challenge. Search engine crawlers may have difficulty reading Shadow DOM elements, as they require JavaScript processing. However, this challenge can often be resolved, for example, through server-side rendering if the application architecture allows it.

Advantages and Disadvantages of Web Components

Advantages:

  • Reusability and modularity promote code efficiency.
  • Compatibility ensures application functionality across different framework and library environments.
  • Encapsulation prevents style and behavior conflicts.
  • Standardization promotes consistency and reliability.

Disadvantages:

  • Browser support may vary, requiring polyfills or alternative arrangements.
  • Development and management can be complex, especially for beginners.
  • Performance at the browser level can pose challenges in extensive setups.

This is a concise, high-level overview of web components. In the next part, we will delve deeper and examine the more technical side.

Author

Tuukka Turu

Front-end Developer
Woman working with her laptop, analytic elements on screen
09.01.2024
Erika Vanhala

What insights can Matomo Analytics provide?

Matomo is an open-source tool that allows you to track and analyze the traffic on your website. It provides insights into various aspects of your website’s performance, such as the number of visitors, traffic sources, page views, and user behaviour.

Matomo analytics can tell you how many visitors your website has had during a specific time period and where these visitors are coming from. The data also reveals user behavior across different devices, locations, and even purchase transactions. Additionally, you can gain insights into how effectively different social media channels drive traffic to your website.

With Matomo analytics, you can uncover which pages your visitors are navigating to, how long they spend on each page, and their overall journey through your site. This valuable information enables you to enhance the user experience on your website, making it more appealing to your audience.

Data Analytics: The backbone of your online service’s development

With analytics, you’ll know where your site’s visitors come from, allowing you to tailor your marketing to those sources. Heatmap data visualises where on the page users exit and which links they click, providing concrete information on how to make your content more engaging. You can also create different versions of headlines, texts, or images, and determine the most effective version through A/B testing.

Tracking the effectiveness of marketing campaigns is easy, as you can see how many visitors your campaign brought to your website and how many of them performed the desired action, such as purchasing a product or subscribing to a newsletter.

Matomo’s reports are user-friendly, customisable to fit your needs, and informative even for internal stakeholders.

In my opinion, Matomo analytics is a powerful tool that provides valuable insights into your website’s traffic. It allows you to target your marketing accurately, enhance your website’s user experience, and make it more attractive to visitors, all while ensuring the protection of user privacy.

Matomo is a smart solution for organisations that want to safely track and optimise their website’s performance while owning their data.

Interested in how Matomo could fit into your website?

Contact us

  • Send us a message

  • This field is for validation purposes and should be left unchanged.

Author

Erika Vanhala

Project Manager
Woman and man looking at Matomo Analytics dashboard on laptop screen.
23.11.2023
Erika Vanhala

Data-responsible Matomo Analytics

Matomo is a web and site analytics tool particularly favored by public organisations, known for its GDPR-friendly features. Matomo Analytics provides a versatile and effective solution that helps understand the efficiency of your website and the behavior of visitors. In this blog post, we explore the benefits and possibilities of Matomo analytics.

Full data ownership and privacy

One of Matomo analytics’ greatest strengths is the complete ownership it offers over collected data. Unlike many other analytics solutions, Matomo does not share your data with third parties, nor does it utilise it for marketing purposes.

By using Matomo for site analytics, you communicate to your customers that you respect their right to privacy, without the concern of compatibility with international agreements. Matomo can be used either in a GDPR-compliant cloud service or installed entirely on your own servers.

Cookie-free tracking

With Matomo analytics, you can decide whether your website uses cookies. Opting for cookie-free tracking provides a better user experience by eliminating the need for visitors to click through cookie banners.

Cookie-free tracking relies on actual website visits, and visitors cannot be profiled as returning users. However, you can still track popular pages, user actions, and on-site purchases. Matomo avoids data sampling, collecting data equally from each visitor, ensuring reliable conclusions.

Customisable reports and user-friendly interface

Matomo includes all essential metrics for evaluating your website’s effectiveness. You can easily monitor page views, visitor origins, conversions such as form submissions, and much more. Reports can be visualised according to your needs. Reporting is intuitive, making data analysis effortless.

Open source and community support

As an open-source analytics solution, Matomo is freely available and customizable to suit your needs. Additionally, Matomo boasts a global, active community providing support and continuous solution development. You automatically receive all the latest updates.

Compliance with strict data laws

Matomo analytics is designed to adhere to the strictest privacy standards, including the EU’s GDPR, the U.S. HIPAA, and the UK’s PECR. Matomo enables legal data collection while respecting user privacy.

Matomo scales according to your needs, making it a smart choice for organizations with specific data processing requirements, such as the public sector, healthcare entities, banks, and insurance companies.

Interested in integrating Matomo into your solution? Contact us.

Author

Erika Vanhala

Project Manager
View for Mautic marketing report
19.10.2023
Kirsi Vatanen

Mautic is an easy-to-use and efficient marketing automation system

Mautic is a versatile open-source marketing automation system that’s both user-friendly and scalable. With Mautic, you can streamline your marketing processes, deliver the right actions to the right audience at the right time, and effortlessly measure the impact of your efforts.

Mautic offers a comprehensive set of features designed to enhance your marketing efficiency, including:

Contact Management: Easily gather and manage contact information, such as email addresses, mailing addresses, and phone numbers.

Segmentation: Create custom contact segments based on criteria like interests or website behavior. This allows you to precisely target actions and adjust your strategy on the fly for improved marketing effectiveness.

Campaign Management: Create and manage multi-channel marketing campaigns, including emails and text messages, landing pages, and social media activities.

Automation: Automate tasks like email sends, landing page creation, and contact tracking, freeing up time and resources for other crucial tasks.

Lead Scoring: Assign numerical values to contact actions and profile data collected on your website. Leverage this data for lead nurturing and personalized campaigns, offering valuable insights for your sales team and internal stakeholders.

Reporting: Easily evaluate campaign effectiveness with customizable reports.

Four examples of using Mautic:

Building brand awareness: Craft personalized campaigns tailored to contacts at various stages of the buying journey, delivering engaging content that resonates.

Lead Generation: Utilize email forms and landing pages to collect registrations and engage interested contacts, generating leads and facilitating inquiries.

Sales Enablement: Design email campaigns to guide marketing leads into the sales funnel, ensuring alignment between marketing and sales objectives.

Enhanced Customer Service: Automate customer service processes, from managing customer data to responding to queries. Provide content that empowers customers to maximize their investment.

Mautic’s marketing automation system is a powerful tool for achieving your marketing objectives, adaptable to even the most demanding needs. Plus, it seamlessly integrates with Drupal solutions.

“Mautic is an excellent choice for clients who want to maintain control of their data, prefer open-source solutions, or work with a high volume of leads. The cost structure in a client-owned system is distinct from platforms like HubSpot,” says our CEO, Mikko Hämäläinen.


Would you like to learn more? Contact Mikko!

Author

Kirsi Vatanen

Marketing Manager
Shopping carts, ostoskärryjä jonossa
24.10.2022


Drupal Commerce – when is it the best choice for an e-commerce platform?

The competition between different e-commerce platforms is getting more and more frantic, since digitalization is pushing companies to take their business over to the internet. Many a business developer may feel a bit overwhelmed when facing the multitude of choices being offered. How can you tell the best platform for your own business? What should be taken into account when making the choice?

It’s clear that you should use your business needs and goals as a starting point. What is the role of e-commerce for your company now and in the future? How much time and money can you invest in developing e-commerce? What about your customers? What are their expectations when they do business with you? How can those expectations be met and even exceeded? When you’ve done the groundwork, you will have a clear idea about your e-commerce concept, and mapping out suitable platforms gets considerably easier. 

For instance, traditional product retail probably benefits most out of highly productized solutions like Magento and hosted SaaS solutions like Shopify. For more marketing-driven commerce with an emphasis on content, the best choices are solutions based on a content management system like Drupal Commerce, WooCommerce for WordPress or Optimizely Commerce. Then there are the really heavy weight systems like the products from IBM, SAP and Oracle that are only used by very large companies in Finland.

Drupal Commerce

Since Druid has its roots in Drupal development, we have some input on Drupal Commerce in particular.

Drupal Commerce stands out with its customizability and strong features for content marketing and digital commerce. Explore the capabilities of Drupal Commerce.

Commerce can be seamlessly integrated into the Drupal content management system, enabling agile and unified management of both the online store and the website.

Drupal Commerce is used on over 80,000 websites.

The most customizable of them all

Drupal is often said to be capable of doing anything: everything is possible, and there’s a module for everything. This is true, as Drupal Commerce, being thoroughly modular, can be tailored to fit any business model.

Drupal Commerce is the most flexible e-commerce solution on the market, offering the necessary functionalities for all kinds of online sales without compromising freedom: the interface, system management tools, and design can be crafted exactly the way you want. The system is easy to use and doesn’t require technical expertise.

Sounds great, doesn’t it? Especially experienced e-vendors, who already know that ready-made solutions will not support their specific requirements, will most likely appreciate the flexibility Drupal has to offer. But customizability in and of itself doesn’t necessarily give value to a client, if the client doesn’t know what they want or need. That’s why we have drawn up some basic guidelines for you to compare with your company’s business development needs to see if Drupal is a match for you.

Why choose Drupal Commerce and when?

Drupal Commerce is worth considering as an e-commerce platform in the following cases:

You want a completely consistent user experience for both your webstore and your website.
Drupal Commerce is the only e-commerce platform that has been built on top of an enterprise level content management system. When you choose Drupal, you get a one-stop solution for a content management system and a webstore, which are seamlessly integrated together. You can manage the website and the webstore on a single system. For example, Magento doesn’t offer this: it uses partners for content management capabilities, and the domains for your webstore and your website are just linked together.

You want to emphasize content, not products.
When you’re not just about straightforward product sales but want to utilize marketing content to support sales, a content management system that includes an e-commerce system is a must. Drupal Commerce connects different sorts of content and products seamlessly together thanks to its versatile content marketing tools. Highly productized e-commerce solutions can’t manage this.

You want your webstore to be integratable with various background systems.
Drupal Commerce can integrate your webstore with virtually any system, for example marketing automation, product information management or customer relationship management systems.

Your company does digital commerce.
For instance, it could be a membership service or a subscription channel – any digital product. Compared to its competitors, Drupal Commerce offers more advanced tools to meet these needs, for example when it comes to managing licenses or files.

You have a large webstore and your budget nears six figures.
Drupal Commerce might not be the best tool for building small or simple webstores. Of course it works fine as a platform for more traditional webstores, but most of its true potential will be left untapped and it probably won’t be a cost effective solution. As a versatile and flexible system, Drupal Commerce can be used to implement the most complex of commercial intricacies and to create rich user experiences by combining commerce with content.

You want an open source solution.
When you choose Drupal Commerce, you won’t have to pay for license fees and you are not married to a single vendor. Open source allows for cost effective development and versatile extension possibilities. Thanks to its huge developer community, the system is of very high quality, very reliable and very secure. Closed systems are typically more limited when it comes to customizability, extensibility as well as layout.

You want a long term solution, which will grow and develop alongside your business.
You need to think about the future when choosing your platform. Precisely due to its flexibility, Drupal Commerce adapts to the changing requirements of your web service or business, be they new kinds of content, new ways of doing business, customer-specific customizations or an increase in volume.

Just like the founder and leader of the Drupal project Dries Buytaert noted in his State of Drupal speech in September: “Drupal is for ambitious digital experiences. It isn’t about how big you start, it’s about how you hope to grow.” 

Text is updated Aug 19, 2024.

Would you like to know more about Drupal Commerce? Contact us and we’ll see how it could serve the needs of your business!

17.11.2021

My experience coming from C++ to JavaScript

Having been with C++ for a long time, I’d become comfortable with it. I’d use it both as a scripting language and for building complex desktop applications. Adding Qt gave me powerful tools for creating user interfaces; and I had access to OpenCL for accelerated computing, OpenGL for real-time graphics, OpenCV for image processing, etc. For my needs, this ecosystem worked very well for a long time.

But over time, pressure mounted for me to expand into the web development sphere. So I started learning JavaScript.

In this post, I’ll go over some of the experiences I had coming from C++ to JavaScript, including some of the things that went well and some that didn’t. I’ll try to give a few pointers to people who’re planning to do the same, and hopefully some perspectives to JavaScript developers who might be interested in C++.

First impressions

I had some prior familiarity with HTML and CSS from using them to style Qt components and from dabbling in simple web pages, but I’d never done anything with JavaScript. By this time the language was a couple decades old; the specification was up to about ES9.

JavaScript’s syntax is very similar to C++, to the point that the differences feel dialectal. You get your familiar statements like if, for, and switch; you define functions much the same way (just with dynamic typing); and especially if you’ve written C++ in a procedural style, your program flow may be very similar.

But although the syntactic similarity can ease the transitioning from one language to the other, it’s in some ways a hinderance: things can appear familiar but end up working in an unexpected way, quickly landing you in one of the pitfalls of JavaScript.

The initial pitfalls

There were three notable pitfalls I got to experience when getting started with JavaScript:

  1. Behavior of array indices
  2. Deep vs. shallow copies
  3. The ‘this’ keyword

They all had to do with what on the syntactic level looked like familiar concepts from C++ but in practice turned out to work quite differently.

Behavior of array indices

On the surface, indexing arrays works the same way in C++ and JavaScript: given an array array, you can access its elements with array[0...n]. And this indeed holds true if you only use (positive) integers for the array index. But as soon as you do something like array[x / 2], you’ll run into divergent behavior.

In C++, the result of x / 2 – where x is an integer – is an integer. When you write array[3 / 2], you’ll be getting array[1], and you’re probably very used to it being this way.

In JavaScript, different rules apply. First, the language has no integers, only floating-point numbers. Second, array indices are converted into strings. That means 3 / 2 produces the floating-point value 1.5, which means array[3 / 2] gives you array["1.5"], which in turn will equal undefined in the likely case that the array has no element with the key “1.5”.

For example, in C++:

const std::array array = {10, 11, 12};
// array[1] == 11
// array[3 / 2] == array[1] == 11

In JavaScript:

const array = [10, 11, 12];
// array[1] === array["1"] === 11
// array[3 / 2] === array["1.5"] === undefined (oops)

This isn’t a big problem at the end of the day because you can coax the index value into an integer (e.g. array[Math.floor(3 / 2)] === array["1"]). However, unlike a C++ compiler, a JavaScript engine probably won’t warn you about using a floating-point value as an array index, so until you notice it manually, you’ll get a silent NaN propagating in your program from what at first glance looks to be well-behaved code.

Read more about arrays in JavaScript here.

Deep vs. shallow copies

In C++, I had gotten used to being able to deeply copy plain structs with direct assignment:

struct pod_structure
{
    int array[3];
};

pod_structure object = {10, 11, 12};

// This copies by value, i.e. makes a deep copy.
pod_structure objectCopy = object;

// Since the copy is deep, modifying it doesn't modify the original.
objectCopy.array[0] = 99;
// object.array[0] == 10
// objectCopy.array[0] == 99

This didn’t translate well to JavaScript, where objects are copied by reference:

function data_structure(array) {
    return {
        array: [...array]
    }
};

const object = data_structure([10, 11, 12]);

// This copies by reference, i.e. makes a shallow copy.
const objectCopy = object;

// The copy is shallow, so modifying it modifies the original.
objectCopy.array[0] = 99;
// object.array[0] === 99
// objectCopy.array[0] === 99

I remember being somewhat stunned when I first ported a piece of C++ code to JavaScript and saw that making a deep copy of a plain data structure was actually a bit of a rabbit’s hole. Direct assignment typically but not always copies by reference (JavaScript makes no syntactic distinction between data and reference, so you’ll need to know the spec), certain methods like Object.assign() create copies that are partially deep and partially shallow, and semi-official deep-copying kludges like objectCopy = JSON.parse(JSON.stringify(object)) also have their pitfalls (e.g. JSON.stringify() will silently omit JSON-incompatible data).

One way to get around this issue – a way I ended up favoring – is to use immutable objects, so that you don’t need to care whether a copy is a reference. If you want to modify an object, you create a new immutable object with those modifications, and references to the original object remain as they were. The downside is that this isn’t fully straightforward to accomplish either – you could use the standard Object.freeze() method to make an object immutable, but since it doesn’t freeze nested objects, you’d have to go an extra mile to ensure true immutability down the whole property tree.

(As of late 2021, although the landscape of deep copying in JavaScript remains somewhat messy, support for a standard structuredClone() method has begun to land in browsers.)

The ‘this’ keyword

C++ and JavaScript both provide a this keyword, and in both languages it represents a reference to a particular context. But the mechanics of it can differ in painful ways.

In C++, this evaluates to a pointer that refers to an instance of the class (or struct) in which it’s used:

struct object
{
    object* self()
    {
        return this;
    }
};

object instance;
// instance.self() == &instance == 0x...

// Can't use 'this' outside of a class context.
std::cout << this;
// Compiler: ^~~~ error: invalid use of 'this' in non-member function

In JavaScript, this refers to an execution context and has a much broader domain both functionally and in what values it can represent:

function say_this() {
    console.log(this);
}

const object = {
    initial_this: this,
    say_this: function(){console.log(this)},
    say_this_arrow: ()=>console.log(this)
};

console.log(this);
// "Window {...}"

console.log(object.initial_this);
// "Window {...}"

object.say_this();
// "{initial_this: Window, say_this: f, ...}"

object.say_this_arrow();
// "Window {...}"

say_this();
// "undefined" (in strict mode) or "Window {...}"

new say_this();
// "say_this {}"

say_this.call(document.head);
// "<head>...</head>"

The this of C++ is semantically telling you, “this instance of the class”. The this of JavaScript likewise appears to say, “this context that I’m in”, but means to say, “this branch of execution”, which in turn depends on factors that aren’t visible in the local semantic context. So if you use this inside an object in JavaScript, you might expect it to refer to the object itself, but in reality it may refer to (a) the object, (b) nothing, or (c) anything, depending on how the object is being accessed. For this reason, especially if you’re used to how it works in C++, it’s very easy to mess up this in JavaScript.

I’d recommend ignoring what you know about C++ in this regard and even to avoid using JavaScript’s this altogether until you’re sure you understand what it would do – and why so – in the particular situation you’d use it in. Otherwise it’s too easy to be creating fragile, hard to understand code.

Read more about JavaScript’s this keyword here.

Time to refactor?

After a while of building things with JavaScript, I’d become settled into certain patterns, some of which I later felt best to move away from and some that I chose to keep. Among those patterns have been:

  1. C++-isms
  2. Compensating for the lack of static typing
  3. Easing into the messy package ecosystem

C++-isms

One of the things I most often have found myself refactoring in my early JavaScript code are its in-code interfaces. Often they’ve had a contextually unpleasant C++ tinge to them; they’ve felt clunky or out of place in JavaScript.

For example, since C++ doesn’t allow named function arguments, you only declare paremeter names in the function signature and then call the function without re-declaring the names:

int sum(const std::vector<int> &numbers = {}, const int initialValue = 0)
{
    // ...
}

sum({1, 2, 3}, 5);

I’d port code like that to JavaScript almost verbatim:

function sum(numbers = [], initialValue = 0) {
    // ...
}

sum([1, 2, 3], 5);

The result isn’t outright bad, but in neither case does the call to sum() tell the reader what the arguments mean. The person could assume that the list of values provides the numbers to be summed, and maybe by convention that 5 is the sum’s initial value. But they’d need to look up the function signature to be sure.

By finagling with JavaScript’s syntax (in this case, object destructuring) you can have named arguments:

function sum({numbers = [], initialValue = 0} = {}) {
    // ...
}

sum({numbers: [1, 2, 3], initialValue: 5});

I think the call to sum() now looks and feels more like JavaScript. Even if you disagree or prefer the C++-like way, you’ll probably agree that the C++-style call is more obscure about intent. Besides being more explicit, the destructured version is more flexible to call: you can re-arrange the arguments, and default value initialization doesn’t require a certain argument order either.

Compensating for the lack of static typing

I’d been in the habit of using assertions in C++ to ensure – among other things – the validity of arguments passed to functions. Since JavaScript doesn’t support static typing like C++ does, my asserting extended naturally to checking arguments’ types as well. Something like this:

function func(arg) {
    console.assert(typeof arg == "number", "'arg' must be of type 'number'");
}

Sometimes I’d feel I was being overly pedantic writing type checks in a language made to be dynamically typed. Not to mention each assertion took up more lines of code, required more time to write, and needed to be maintained when the intended type of an argument was changed. Maybe it was an anti-pattern?

Well, I’ve so far decided not to refactor away assertions from my JavaScript code. In fact, I still keep adding them to new code. Consider the following:

function func(arg) {
    console.assert(typeof arg == "number", "'arg' must be of type 'number'");
}

const array = [1, 2, 3];

func(array[1]);
// Runs OK (arg === 2, which is fine)

func(array[1 / 2]);
// Assertion failure (arg === undefined, the array has no key "0.5")

func("1");
// Assertion failure (arg is not a number by strict comparison)

The second call to func() makes the mistake of assuming that integer division in JavaScript results in an integer. The assertion immediately catches the mistake.

The third call to func() is OK in the sense that the function could probably implicitly cast the string into a number and then execute correctly. But still, the function expects a number, so its receiving a string indicates that some other part of the codebase is misbehaving (maybe it’s passing along a stringified number directly from a network response). In my opinion it’s probably better for the long-term reliability of the application that you’re alerted to this.

That said, these assertions are just a roundabout way of shoehorning in a kind of static typing. A more elegant way might be to use TypeScript, which provides an additional syntax layer over JavaScript that includes native-like static types. With TypeScript, we could leave out the manual type assertions and let the TypeScript compiler handle type checking:

// The argument is now of a TypeScript-specific 'number' type.
function func(arg: number) {}

const array = [1, 2, 3];

func(array[1]);
// No errors from TypeScript (the call is OK)

func(array[1 / 2]);
// No errors from TypeScript (but the index bug goes undetected)

func("1");
// TypeScript error: Argument of type 'string' is not assignable to parameter of type 'number'

I’ve used TypeScript for only a short while, but so far my impressions of it are mixed. Introducing static typing can increase the reliability and readability of your code, and TypeScript’s interface system may get you to think about and define your in-code interfaces more clearly. On the other hand, its type system doesn’t always feel solidly integrated with JavaScript, and from what I’ve seen it can add considerable complexity and/or compatibility issues to your build process.

Easing into the messy package ecosystem

Among the biggest elephants in the room has to be JavaScript’s sprawling package ecosystem.

As a C++ developer, I was used to working at low level, carefully managing the dependencies of my applications and often introducing no dependencies at all besides the standard library. By contrast, JavaScript is a high-level language where a typical project may depend on hundreds or thousands of external packages, and whose developer base seems more accepting of abstracting away the lower-level details behind those external dependencies.

When learning React, it’s typically recommended to use the create-react-app project bootstrapper. It sets up a React development environment in an automated way, saving you the trouble of manually doing the boilerplate. The downside is that it also makes your development environment dependent on over 1,500 extra packages.

When I started learning React (I was still fairly new to JavaScript overall), I thought the amount dependencies introduced by create-react-app was absolutely nuts. Why would a hello-world app need hundreds of miscellaneous dependencies? I chose to go against the grain of every React tutorial and learn it without packages or package managers:

<div id="react-container"></div>
<script src="react.development.js"></script>
<script src="react-dom.development.js"></script>
<script>
    const container = document.getElementById("react-container");
    const component = React.createElement("span", {}, "Hello world");
    ReactDOM.render(component, container);
</script>

In this vein, there are no extra packages required, and I didn’t even need to install a package manager. I could build full React apps this way, and they’d be lighter-weight and potentially more secure (or not). But I’d also be missing out on quality-of-life improvements like…

// Creating a nested element with plain React.
divWithChild =
    React.createElement("div", {},
        React.createElement("span", {className: "label"}, "Hello world")
    );

// Creating the same element with JSX syntax (dependent on a transpiler).
divWithChild = (
    <div>
        <span className="label">
            Hello world
        </span>
    </div>
);

…not to mention I’d perpetually be working uphill and against the grain, because create-react-app and the like make things much easier, and most fellow JavaScript developers will be of that opinion.

I think easing into the apparent craziness of the JavaScript package ecosystem was the hardest part about transitioning from C++ to JavaScript. It meant no longer understanding certain aspects of my programs at lower levels. On the other hand, I wasn’t supposed to be working at low level with a high-level language to begin with, and I could be more productive by accepting that.

Future outlook

In my opinion, having first learnt C++ can give you an edge in becoming proficient in JavaScript. C++ offers a lot of freedom but requires a lot of responsibility; it motivates you to try to write well-behaving code because the alternative is a compromised application (or worse). If the motivation to build reliable code carries into JavaScript, it can elevate your work above some of the quirks of the language that might otherwise negatively affect the quality of your work – or at least you might get bitten by those quirks less often.

But experience of C++ can also be major baggage. You might be used to having lower-level control over your programs – for instance, insisting that dependencies be kept to a minimum. In the higher-level JavaScript this may become an anti-pattern that holds you back from being as effective of a developer as you could be.

I personally still use both languages. C++ gives me high performance, syntactic power, and few restrictions. JavaScript gives me first-class networking, a huge platform to distribute on, and a powerful GUI system in the triad of HTML5/CSS3/JavaScript; it can be an expressive, creative language and I often have fun using it.

01.11.2021

Working at Druid, according to Druids

In the spring of 2021, we asked our people how they feel about working at Druid, what they value in work, and how they see themselves and their co-workers. Here comes a summary of the answers. Hopefully this will give you an idea of what it’s like to work with us.

Most of the Druids, over 70%, work with software development, the rest with something else such as sales or project management. So in general we can say that Druid is a very developer-oriented company packed with deep knowledge of software development. People really enjoy problem solving and finding solutions.

How is work and management at Druid?

We have a lot of long-term employees a low turnover. Why is that? What makes people stay? Not surprisingly, the answer lies in our culture. Freedom and flexibility, a relaxed atmosphere with nice and helpful co-workers, interesting projects and opportunities – for us, these are the ingredients that make up an attractive workplace. This may sound clichéd, since so many companies are advocating these things nowadays, but our greatest strength is our culture, which actively nurtures these values.

Quite logically, our people consider company culture to be the most important factor at work, along with flexible working hours. Other important factors for us are professional development, the possibility to work remotely, our team and colleagues, and the impact of our work – doing work that matters.

Druid is a self-organized company and we are exploring the Teal philosophy. In practice this means that we have a high level of autonomy and we are accountable for coordinating work with each other. Decisions affecting the whole company are made in swarms that anyone can join or set up. Currently we have over 10 active swarms ranging from tech to strategy, from billing to recruitment. Outside the swarms, any individual can make a decision to fix an issue or complete a task by first seeking advice from others.

What are we Druids like?

We describe ourselves and our co-workers as relaxed and easy-going, skilled and talented people who are passionate about what they do. It also seems that we have two types of people at Druid: those who want to focus purely on coding and don’t want to be disturbed, and those who want to be involved in developing the company and really value Teal and what it represents. And both are totally ok.

Druids have a wide range of hobbies and personal interests. The most popular free time activities seem to be making and listening to music, gaming and coding as well as spending time with family and friends. And the list goes on. We have people who are into art, baking, cars, carpentry, climbing, cooking, fishing, hiking, gym and sports in general, Japanese culture and martial arts, motorcycling, movies, travelling, reading, sailing, walking and yoga.

When we go deep into what really matters in life, our people value honesty and integrity, freedom, fairness, equality, and family. These are the values that unite all of us Druids as human beings.

Edit: Our CTO Marko would like to add that ice hockey belongs to our hobby list as well 😀

If you feel that you can relate to these thoughts and could see yourself working with us, don’t hesitate to get in touch. We are always interested in getting to know new colleagues!

Author