Posts Tagged ‘Google’
[KotlinConf2017] Kotlin Static Analysis with Android Lint
Lecturer
Tor Norbye is the technical lead for Android Studio at Google, where he has driven the development of numerous IDE features, including Android Lint, a static code analysis tool. With a deep background in software development and tooling, Tor is the primary author of Android Lint, which integrates with Android Studio, IntelliJ IDEA, and Gradle to enhance code quality. His expertise in static analysis and IDE development has made significant contributions to the Android ecosystem, supporting developers in building robust applications.
Abstract
Static code analysis is critical for ensuring the reliability and quality of Android applications. This article analyzes Tor Norbye’s presentation at KotlinConf 2017, which explores Android Lint’s support for Kotlin and its capabilities for custom lint checks. It examines the context of static analysis in Android development, the methodology of leveraging Lint’s Universal Abstract Syntax Tree (UAST) for Kotlin, the implementation of custom checks, and the implications for enhancing code quality. Tor’s insights highlight how Android Lint empowers developers to enforce best practices and maintain robust Kotlin-based applications.
Context of Static Analysis in Android
At KotlinConf 2017, Tor Norbye presented Android Lint as a cornerstone of code quality in Android development, particularly with the rise of Kotlin as a first-class language. Introduced in 2011, Android Lint is an open-source static analyzer integrated into Android Studio, IntelliJ IDEA, and Gradle, offering over 315 checks to identify bugs without executing code. As Kotlin gained traction in 2017, ensuring its compatibility with Lint became essential to support Android developers transitioning from Java. Tor’s presentation addressed this need, focusing on Lint’s ability to analyze Kotlin code and extend its functionality through custom checks.
The context of Tor’s talk reflects the challenges of maintaining code quality in dynamic, large-scale Android projects. Static analysis mitigates issues like null pointer exceptions, resource leaks, and API misuse, which are critical in mobile development where performance and reliability are paramount. By supporting Kotlin, Lint enables developers to leverage the language’s type-safe features while ensuring adherence to Android best practices, fostering a robust development ecosystem.
Methodology of Android Lint with Kotlin
Tor’s methodology centers on Android Lint’s use of the Universal Abstract Syntax Tree (UAST) to analyze Kotlin code. UAST provides a unified representation of code across Java and Kotlin, enabling Lint to apply checks consistently. Tor explained how Lint examines code statically, identifying potential bugs like incorrect API usage or performance issues without runtime execution. The tool’s philosophy prioritizes caution, surfacing potential issues even if they risk false positives, with suppression mechanisms to dismiss irrelevant warnings.
A key focus was custom lint checks, which allow developers to extend Lint’s functionality for library-specific rules. Tor demonstrated writing a custom check for Kotlin, leveraging UAST to inspect code structures and implement quickfixes that integrate with the IDE. For example, a check might enforce proper usage of a library’s API, offering automated corrections via code completion. This methodology ensures that developers can tailor Lint to project-specific needs, enhancing code quality and maintainability in Kotlin-based Android applications.
Implementing Custom Lint Checks
Implementing custom lint checks involves defining rules that analyze UAST nodes to detect issues and provide fixes. Tor showcased a practical example, creating a check to validate Kotlin code patterns, such as ensuring proper handling of nullable types. The process involves registering checks with Lint’s infrastructure, which loads them dynamically from libraries. These checks can inspect method calls, variable declarations, or other code constructs, flagging violations and suggesting corrections that appear in Android Studio’s UI.
Tor emphasized the importance of clean APIs for custom checks, noting plans to enhance Lint’s configurability with an options API. This would allow developers to customize check parameters (e.g., string patterns or ranges) directly from build.gradle or IDE interfaces, simplifying configuration. The methodology’s integration with Gradle and IntelliJ ensures seamless adoption, enabling developers to enforce project-specific standards without relying on external tools or complex setups.
Future Directions and Community Engagement
Tor outlined future enhancements for Android Lint, including improved support for Kotlin script files (.kts) in Gradle builds and advanced call graph analysis for whole-program insights. These improvements aim to address limitations in current checks, such as incomplete Gradle file support, and enhance Lint’s ability to perform comprehensive static analysis. Plans to transition from Java-centric APIs to UAST-focused ones promise a more stable, Kotlin-friendly interface, reducing compatibility issues and simplifying check development.
Community engagement is a cornerstone of Lint’s evolution. Tor encouraged developers to contribute checks to the open-source project, sharing benefits with the broader Android community. The emphasis on community-driven development ensures that Lint evolves to meet real-world needs, from small-scale apps to enterprise projects. By fostering collaboration, Tor’s vision positions Lint as a vital tool for maintaining code quality in Kotlin’s growing ecosystem.
Conclusion
Tor Norbye’s presentation at KotlinConf 2017 highlighted Android Lint’s pivotal role in ensuring code quality for Kotlin-based Android applications. By leveraging UAST for static analysis and supporting custom lint checks, Lint empowers developers to enforce best practices and adapt to project-specific requirements. The methodology’s integration with Android Studio and Gradle, coupled with plans for enhanced configurability and community contributions, strengthens Kotlin’s appeal in Android development. As Kotlin continues to shape the Android ecosystem, Lint’s innovations ensure robust, reliable applications, reinforcing its importance in modern software development.
Links
[KotlinConf2017] Understand Every Line of Your Codebase
Lecturer
Victoria Gonda is a software developer at Collective Idea, specializing in Android and web applications with a focus on improving user experiences through technology. With a background in Computer Science and Dance, Victoria combines technical expertise with creative problem-solving, contributing to projects that enhance accessibility and engagement. Boris Farber is a Senior Partner Engineer at Google, focusing on Android binary analysis and performance optimization. As the lead of ClassyShark, an open-source tool for browsing Android and Java executables, Boris brings deep expertise in understanding compiled code.
- Collective Idea company website
- Google company website
- Victoria Gonda on LinkedIn
- Boris Farber on LinkedIn
Abstract
Understanding the compiled output of Kotlin code is essential for optimizing performance and debugging complex applications. This article analyzes Victoria Gonda and Boris Farber’s presentation at KotlinConf 2017, which explores how Kotlin and Java code compiles to class files and introduces tools for inspecting compiled code. It examines the context of Kotlin’s compilation pipeline, the methodology of analyzing bytecode, the use of inspection tools like ClassyShark, and the implications for developers seeking deeper insights into their codebases. The analysis highlights how these tools empower developers to make informed optimization decisions.
Context of Kotlin’s Compilation Pipeline
At KotlinConf 2017, Victoria Gonda and Boris Farber addressed the challenge of understanding Kotlin’s compiled output, a critical aspect for developers transitioning from Java or optimizing performance-critical applications. Kotlin’s concise and expressive syntax, while enhancing productivity, raises questions about its compiled form, particularly when compared to Java. As Kotlin gained traction in Android and server-side development, developers needed tools to inspect how their code translates to bytecode, ensuring performance and compatibility with JVM-based systems.
Victoria and Boris’s presentation provided a timely exploration of Kotlin’s build pipeline, focusing on its similarities and differences with Java. By demystifying the compilation process, they aimed to equip developers with the knowledge to analyze and optimize their code. The context of their talk reflects Kotlin’s growing adoption and the need for transparency in how its features, such as lambdas and inline functions, impact compiled output, particularly in performance-sensitive scenarios like Android’s drawing loops or database operations.
Methodology of Bytecode Analysis
The methodology presented by Victoria and Boris centers on dissecting Kotlin’s compilation to class files, using tools like ClassyShark to inspect bytecode. They explained how Kotlin’s compiler transforms high-level constructs, such as lambdas and inline functions, into JVM-compatible bytecode. Inline functions, for instance, copy their code directly into the call site, reducing overhead but potentially increasing code size. The presenters demonstrated decompiling class files to reveal metadata used by the Kotlin runtime, such as type information for generics, providing insights into how Kotlin maintains type safety at runtime.
ClassyShark, led by Boris, serves as a key tool for this analysis, allowing developers to browse Android and Java executables and understand their structure. The methodology involves writing Kotlin code, compiling it, and inspecting the resulting class files to identify performance implications, such as method count increases from lambdas. Victoria and Boris emphasized a pragmatic approach: analyze code before optimizing, ensuring that performance tweaks target actual bottlenecks rather than speculative issues, particularly in mission-critical contexts like Android rendering.
Practical Applications and Optimization
The practical applications of bytecode analysis lie in optimizing performance and debugging complex issues. Victoria and Boris showcased how tools like ClassyShark reveal the impact of Kotlin’s features, such as inline functions adding methods to class files. For Android developers, this is critical, as method count limits can affect app size and performance. By inspecting decompiled classes, developers can identify unnecessary object allocations or inefficient constructs, optimizing code for scenarios like drawing loops or database operations where performance is paramount.
The presenters also addressed the trade-offs of inline functions, noting that while they reduce call overhead, excessive use can inflate code size. Their methodology encourages developers to test performance impacts before applying optimizations, using tools to measure method counts and object allocations. This approach ensures that optimizations are data-driven, avoiding premature changes that may not yield significant benefits. The open-source nature of ClassyShark further enables developers to customize their analysis, tailoring inspections to specific project needs.
Implications for Developers
The insights from Victoria and Boris’s presentation have significant implications for Kotlin developers. Understanding the compiled output of Kotlin code empowers developers to make informed decisions about performance and compatibility, particularly in Android development where resource constraints are critical. Tools like ClassyShark democratize bytecode analysis, enabling developers to debug issues that arise from complex features like generics or lambdas. This transparency fosters confidence in adopting Kotlin for performance-sensitive applications, bridging the gap between its high-level syntax and low-level execution.
For the broader Kotlin ecosystem, the presentation underscores the importance of tooling in supporting the language’s growth. By providing accessible methods to inspect and optimize code, Victoria and Boris contribute to a culture of informed development, encouraging developers to explore Kotlin’s internals without fear of hidden costs. Their emphasis on community engagement, through questions and open-source tools, ensures that these insights evolve with developer feedback, strengthening Kotlin’s position as a reliable, performance-oriented language.
Conclusion
Victoria Gonda and Boris Farber’s presentation at KotlinConf 2017 provided a comprehensive guide to understanding Kotlin’s compiled output, leveraging tools like ClassyShark to demystify the build pipeline. By analyzing bytecode and addressing optimization trade-offs, they empowered developers to make data-driven decisions for performance-critical applications. The methodology’s focus on practical analysis and accessible tooling enhances Kotlin’s appeal, particularly for Android developers navigating resource constraints. As Kotlin’s adoption grows, such insights ensure that developers can harness its expressive power while maintaining control over performance and compatibility.
Links
[DevoxxUS2017] Creating a Connected Home by Kevin and Andy Nilson
At DevoxxUS2017, Kevin Nilson, a Java Champion and lead of the Chromecast Technical Solutions Engineer team at Google, joined forces with his 12-year-old son, Andy Nilson, to present a captivating live coding demo on building a connected home. Their session showcased how voice and mobile controls can interact with smart devices, leveraging platforms like Google Home. Kevin and Andy’s collaborative approach highlighted the accessibility of IoT development, blending technical expertise with educational outreach. This post examines the key themes of their presentation, emphasizing the fusion of innovation and learning.
Building a Smart Home Ecosystem
Kevin Nilson and Andy Nilson began by demonstrating a connected home setup, where lights, fans, and music systems respond to voice commands via Google Home. Kevin explained the architecture, integrating devices like Philips Hue and Nest thermostats through APIs. Andy, showcasing his coding skills, contributed to the demo by writing scripts to control devices, illustrating how accessible IoT programming can be, even for young developers. Their work reflected Google’s commitment to seamless smart home integration.
Voice Control and Device Integration
The duo delved into voice-activated controls, showing how Google Home processes commands like “turn on the lights.” Kevin highlighted the use of OAuth for secure device linking, ensuring commands are tied to user accounts. Andy demonstrated triggering actions, such as activating a fan, by coding simple integrations. Their live demo, despite network challenges, showcased practical IoT applications, emphasizing ease of use and real-time interaction with smart devices.
Inspiring the Next Generation
Kevin and Andy emphasized the educational potential of their project, drawing from their involvement in Devoxx4Kids and JavaOne Kids Day. Andy’s participation, rooted in his experience coding since childhood, inspired attendees to engage young learners in technology. Kevin shared resources for learning IoT, recommending starting with specific problems and exploring community solutions, such as hackathon projects like the Febreze air freshener integration, to spark creativity.
Fostering Community and Collaboration
Concluding, Kevin encouraged developers to explore IoT through open-source communities and hackathons, sharing his experience as a Silicon Valley JUG leader. Andy’s enthusiasm for coding underscored the session’s goal of making technology accessible. Their call to action invited attendees to contribute to smart home projects, leveraging platforms like Google Home to build innovative, user-friendly solutions for connected living.
Links:
[DevoxxBE2013] Riddle Me This, Android Puzzlers
Stephan Linzner and Richard Hyndman, Google Android Developer Advocates, unravel enigmatic Android behaviors through interactive puzzles. Stephan, an automation aficionado and runner, teams with Richard, a 12-year mobile veteran from startups to operators, to probe component lifecycles, UI quirks, and KitKat novelties. Their session, blending polls and demos, spotlights content providers’ primacy, ViewStub pitfalls, and screen recording tools, arming developers with debugging savvy.
Android’s intricacies, they reveal, demand vigilance: from process spawning to WebView debugging. Live polls engage the audience, transforming head-scratchers into teachable moments.
Component Creation Order and Lifecycle
Stephan kicks off with a poll: which component initializes first post-process spawn? Hands favor activities, but content providers lead—crucial for data bootstrapping.
Richard demos service lifecycles, warning against onCreate leaks; broadcasts’ unregistered crashes underscore registration discipline.
UI Rendering Quirks and Optimizations
ViewStub inflation puzzles Stephan: pre-inflate for speed, but beware null children post-inflation. Richard explores ListView recycling, ensuring adapters populate recycled views correctly to avoid visual glitches.
These gotchas, they stress, demand profiler scrutiny for fluid UIs.
KitKat Innovations and Debugging Aids
KitKat’s screen recording, Richard unveils, captures high-res videos sans root—ideal for demos or Play Store assets. Stephan spotlights WebView debugging: Chrome DevTools inspect remote views, editing CSS live.
Monkey tool’s seeded crashes aid reproducible testing, simulating user chaos.
Interactive Polls and Community Insights
Polls gauge familiarity with overscan modes and transition animations, fostering engagement. The duo fields queries on SurfaceView security and WebView copies, clarifying limitations.
This collaborative format, they conclude, equips developers to conquer Android’s riddles.
Links:
[DevoxxBE2012] Re-imagining the Browser with AngularJS
Misko Hevery and Igor Minar, Google engineers and AngularJS co-leads, re-envisioned client-side development. Misko, an Agile coach with open-source contributions, partnered with Igor, focused on developer tools, to showcase AngularJS’s approach to simplifying web apps.
They posited extending the browser with declarative HTML and JavaScript, reducing code while enhancing readability. AngularJS bridges to future standards like web components and model-driven views.
Misko demonstrated data binding, where models sync with views automatically, eliminating manual DOM manipulation. Directives extend HTML, creating custom elements for reusability.
Igor highlighted dependency injection for modularity, and services for shared logic. Routing enables single-page apps, with controllers managing scopes.
They emphasized testability, with built-in mocking and end-to-end testing.
Declarative UI and Data Binding
Misko illustrated two-way binding: changes in models update views, and vice versa, without boilerplate. This declarative paradigm contrasts imperative jQuery-style coding.
Directives like ng-repeat generate lists dynamically, while filters format data.
Modularity and Dependency Management
Igor explained modules encapsulating functionality, injected via DI. This promotes clean, testable code.
Services, factories, and providers offer flexible creation patterns.
Routing and Application Structure
NgRoute handles navigation, loading templates and controllers. Scopes isolate data, with inheritance for hierarchy.
Testing and Future Alignment
Angular’s design facilitates unit and e2e tests, using Karma and Protractor.
They previewed alignment with web components, where directives become custom tags.
In Q&A, they compared to Knockout.js, noting Angular’s framework scope versus library focus.
Misko and Igor’s presentation framed AngularJS as transformative, anticipating browser evolutions while delivering immediate productivity.
Links:
[DevoxxBE2012] The Chrome Dev Tools Can Do THAT
Ilya Grigorik, a Google web performance engineer and developer advocate, unveiled advanced capabilities of Chrome Developer Tools. Ilya, focused on accelerating the web, overwhelmed attendees with tips, dividing into inspection/debugging and performance analysis.
He encouraged hands-on exploration via online slides, emphasizing tools’ instrumentation for pinpointing bottlenecks.
Starting with basics, Ilya showed inspecting elements, modifying DOM/CSS live, and using console for JavaScript evaluation.
Advanced features included remote debugging for mobile, connecting devices to desktops for inspection.
Inspection and Debugging Essentials
Ilya demonstrated breakpoints on DOM changes, XHR requests, and events, pausing execution for analysis.
Color pickers, shadow DOM inspection, and computed styles aid UI debugging.
Console utilities like $0 for selected elements, querySelector, and table formatting enhance interactivity.
JavaScript Profiling and Optimization
CPU profilers capture call stacks, revealing hot spots. Ilya profiled loops, identifying inefficiencies.
Heap snapshots detect memory leaks by comparing allocations.
Source maps map minified code to originals, with pretty-printing for readability.
Network and Resource Analysis
Network panel details requests, with filters and timelines. Ilya explained columns like status, size, showing compression benefits.
WebSocket and SPDY inspectors provide low-level insights.
HAR exports enable sharing traces.
Timeline and Rendering Insights
Timeline records events, offering frame-by-frame analysis of layouts, paints.
Ilya used it to optimize animations, enabling GPU acceleration.
CSS selectors profile identifies slow rules.
Auditing and Best Practices
Audits suggest optimizations like minification, unused CSS removal.
Extensions customize tools further.
Low-Level Tracing and Customization
Chrome Tracing visualizes browser internals, instrumentable with console.time for custom metrics.
Ilya’s session equipped developers with powerful diagnostics for performant, debuggable applications.
Links:
Windows Mobile 6.1: which browser?
Here is a short comparative of webbrowsers available on Windows Mobile 6.1. I used them on a Acer X960 on French VirginMobile network.
| Browser | Pros | Cons | WebSite |
|---|---|---|---|
| Internet Explorer 5 |
|
|
|
| Mozilla Fennec 1.0a1 |
|
|
http://www.mozilla.org/projects/fennec/1.0a1/releasenotes/ |
| Opera Mobile 10 |
|
|
http://www.opera.com/ |
| SkyFire 1.5 |
|
|
http://get.skyfire.com |
As a conclusion, what do I do?
- In most cases, I use Opera, for its speedness and tabs.
- When I need watch a video
- my Acer X960 displays YouTube videos in a specific player
- on other websites, I use SkyFire.
- For Google applications (GMail, Reader, Docs, etc.), I use SkyFire, too.