2024 State of Marketing Report – by HubspotMarius Sescu
https://www.hubspot.com/state-of-marketing
· Scaling relationships and proving ROI
· Social media is the place for search, sales, and service
· Authentic influencer partnerships fuel brand growth
· The strongest connections happen via call, click, chat, and camera.
· Time saved with AI leads to more creative work
· Seeking: A single source of truth
· TLDR; Get on social, try AI, and align your systems.
· More human marketing, powered by robots
ChatGPT is a revolutionary addition to the world since its introduction in 2022. A big shift in the sector of information gathering and processing happened because of this chatbot. What is the story of ChatGPT? How is the bot responding to prompts and generating contents? Swipe through these slides prepared by Expeed Software, a web development company regarding the development and technical intricacies of ChatGPT!
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
The realm of product design is a constantly changing environment where technology and style intersect. Every year introduces fresh challenges and exciting trends that mold the future of this captivating art form. In this piece, we delve into the significant trends set to influence the look and functionality of product design in the year 2024.
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
Mental health has been in the news quite a bit lately. Dozens of U.S. states are currently suing Meta for contributing to the youth mental health crisis by inserting addictive features into their products, while the U.S. Surgeon General is touring the nation to bring awareness to the growing epidemic of loneliness and isolation. The country has endured periods of low national morale, such as in the 1970s when high inflation and the energy crisis worsened public sentiment following the Vietnam War. The current mood, however, feels different. Gallup recently reported that national mental health is at an all-time low, with few bright spots to lift spirits.
To better understand how Americans are feeling and their attitudes towards mental health in general, ThinkNow conducted a nationally representative quantitative survey of 1,500 respondents and found some interesting differences among ethnic, age and gender groups.
Technology
For example, 52% agree that technology and social media have a negative impact on mental health, but when broken out by race, 61% of Whites felt technology had a negative effect, and only 48% of Hispanics thought it did.
While technology has helped us keep in touch with friends and family in faraway places, it appears to have degraded our ability to connect in person. Staying connected online is a double-edged sword since the same news feed that brings us pictures of the grandkids and fluffy kittens also feeds us news about the wars in Israel and Ukraine, the dysfunction in Washington, the latest mass shooting and the climate crisis.
Hispanics may have a built-in defense against the isolation technology breeds, owing to their large, multigenerational households, strong social support systems, and tendency to use social media to stay connected with relatives abroad.
Age and Gender
When asked how individuals rate their mental health, men rate it higher than women by 11 percentage points, and Baby Boomers rank it highest at 83%, saying it’s good or excellent vs. 57% of Gen Z saying the same.
Gen Z spends the most amount of time on social media, so the notion that social media negatively affects mental health appears to be correlated. Unfortunately, Gen Z is also the generation that’s least comfortable discussing mental health concerns with healthcare professionals. Only 40% of them state they’re comfortable discussing their issues with a professional compared to 60% of Millennials and 65% of Boomers.
Race Affects Attitudes
As seen in previous research conducted by ThinkNow, Asian Americans lag other groups when it comes to awareness of mental health issues. Twenty-four percent of Asian Americans believe that having a mental health issue is a sign of weakness compared to the 16% average for all groups. Asians are also considerably less likely to be aware of mental health services in their communities (42% vs. 55%) and most likely to seek out information on social media (51% vs. 35%).
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
This article is all about what AI trends will emerge in the field of creative operations in 2024. All the marketers and brand builders should be aware of these trends for their further use and save themselves some time!
A report by thenetworkone and Kurio.
The contributing experts and agencies are (in an alphabetical order): Sylwia Rytel, Social Media Supervisor, 180heartbeats + JUNG v MATT (PL), Sharlene Jenner, Vice President - Director of Engagement Strategy, Abelson Taylor (USA), Alex Casanovas, Digital Director, Atrevia (ES), Dora Beilin, Senior Social Strategist, Barrett Hoffher (USA), Min Seo, Campaign Director, Brand New Agency (KR), Deshé M. Gully, Associate Strategist, Day One Agency (USA), Francesca Trevisan, Strategist, Different (IT), Trevor Crossman, CX and Digital Transformation Director; Olivia Hussey, Strategic Planner; Simi Srinarula, Social Media Manager, The Hallway (AUS), James Hebbert, Managing Director, Hylink (CN / UK), Mundy Álvarez, Planning Director; Pedro Rojas, Social Media Manager; Pancho González, CCO, Inbrax (CH), Oana Oprea, Head of Digital Planning, Jam Session Agency (RO), Amy Bottrill, Social Account Director, Launch (UK), Gaby Arriaga, Founder, Leonardo1452 (MX), Shantesh S Row, Creative Director, Liwa (UAE), Rajesh Mehta, Chief Strategy Officer; Dhruv Gaur, Digital Planning Lead; Leonie Mergulhao, Account Supervisor - Social Media & PR, Medulla (IN), Aurelija Plioplytė, Head of Digital & Social, Not Perfect (LI), Daiana Khaidargaliyeva, Account Manager, Osaka Labs (UK / USA), Stefanie Söhnchen, Vice President Digital, PIABO Communications (DE), Elisabeth Winiartati, Managing Consultant, Head of Global Integrated Communications; Lydia Aprina, Account Manager, Integrated Marketing and Communications; Nita Prabowo, Account Manager, Integrated Marketing and Communications; Okhi, Web Developer, PNTR Group (ID), Kei Obusan, Insights Director; Daffi Ranandi, Insights Manager, Radarr (SG), Gautam Reghunath, Co-founder & CEO, Talented (IN), Donagh Humphreys, Head of Social and Digital Innovation, THINKHOUSE (IRE), Sarah Yim, Strategy Director, Zulu Alpha Kilo (CA).
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
The search marketing landscape is evolving rapidly with new technologies, and professionals, like you, rely on innovative paid search strategies to meet changing demands.
It’s important that you’re ready to implement new strategies in 2024.
Check this out and learn the top trends in paid search advertising that are expected to gain traction, so you can drive higher ROI more efficiently in 2024.
You’ll learn:
- The latest trends in AI and automation, and what this means for an evolving paid search ecosystem.
- New developments in privacy and data regulation.
- Emerging ad formats that are expected to make an impact next year.
Watch Sreekant Lanka from iQuanti and Irina Klein from OneMain Financial as they dive into the future of paid search and explore the trends, strategies, and technologies that will shape the search marketing landscape.
If you’re looking to assess your paid search strategy and design an industry-aligned plan for 2024, then this webinar is for you.
5 Public speaking tips from TED - Visualized summarySpeakerHub
From their humble beginnings in 1984, TED has grown into the world’s most powerful amplifier for speakers and thought-leaders to share their ideas. They have over 2,400 filmed talks (not including the 30,000+ TEDx videos) freely available online, and have hosted over 17,500 events around the world.
With over one billion views in a year, it’s no wonder that so many speakers are looking to TED for ideas on how to share their message more effectively.
The article “5 Public-Speaking Tips TED Gives Its Speakers”, by Carmine Gallo for Forbes, gives speakers five practical ways to connect with their audience, and effectively share their ideas on stage.
Whether you are gearing up to get on a TED stage yourself, or just want to master the skills that so many of their speakers possess, these tips and quotes from Chris Anderson, the TED Talks Curator, will encourage you to make the most impactful impression on your audience.
See the full article and more summaries like this on SpeakerHub here: https://speakerhub.com/blog/5-presentation-tips-ted-gives-its-speakers
See the original article on Forbes here:
http://www.forbes.com/forbes/welcome/?toURL=http://www.forbes.com/sites/carminegallo/2016/05/06/5-public-speaking-tips-ted-gives-its-speakers/&refURL=&referrer=#5c07a8221d9b
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
Everyone is in agreement that ChatGPT (and other generative AI tools) will shape the future of work. Yet there is little consensus on exactly how, when, and to what extent this technology will change our world.
Businesses that extract maximum value from ChatGPT will use it as a collaborative tool for everything from brainstorming to technical maintenance.
For individuals, now is the time to pinpoint the skills the future professional will need to thrive in the AI age.
Check out this presentation to understand what ChatGPT is, how it will shape the future of work, and how you can prepare to take advantage.
A brief introduction to DataScience with explaining of the concepts, algorithms, machine learning, supervised and unsupervised learning, clustering, statistics, data preprocessing, real-world applications etc.
It's part of a Data Science Corner Campaign where I will be discussing the fundamentals of DataScience, AIML, Statistics etc.
Time Management & Productivity - Best PracticesVit Horky
Here's my presentation on by proven best practices how to manage your work time effectively and how to improve your productivity. It includes practical tips and how to use tools such as Slack, Google Apps, Hubspot, Google Calendar, Gmail and others.
The six step guide to practical project managementMindGenius
The six step guide to practical project management
If you think managing projects is too difficult, think again.
We’ve stripped back project management processes to the
basics – to make it quicker and easier, without sacrificing
the vital ingredients for success.
“If you’re looking for some real-world guidance, then The Six Step Guide to Practical Project Management will help.”
Dr Andrew Makar, Tactical Project Management
2024 State of Marketing Report – by HubspotMarius Sescu
https://www.hubspot.com/state-of-marketing
· Scaling relationships and proving ROI
· Social media is the place for search, sales, and service
· Authentic influencer partnerships fuel brand growth
· The strongest connections happen via call, click, chat, and camera.
· Time saved with AI leads to more creative work
· Seeking: A single source of truth
· TLDR; Get on social, try AI, and align your systems.
· More human marketing, powered by robots
ChatGPT is a revolutionary addition to the world since its introduction in 2022. A big shift in the sector of information gathering and processing happened because of this chatbot. What is the story of ChatGPT? How is the bot responding to prompts and generating contents? Swipe through these slides prepared by Expeed Software, a web development company regarding the development and technical intricacies of ChatGPT!
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
The realm of product design is a constantly changing environment where technology and style intersect. Every year introduces fresh challenges and exciting trends that mold the future of this captivating art form. In this piece, we delve into the significant trends set to influence the look and functionality of product design in the year 2024.
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
Mental health has been in the news quite a bit lately. Dozens of U.S. states are currently suing Meta for contributing to the youth mental health crisis by inserting addictive features into their products, while the U.S. Surgeon General is touring the nation to bring awareness to the growing epidemic of loneliness and isolation. The country has endured periods of low national morale, such as in the 1970s when high inflation and the energy crisis worsened public sentiment following the Vietnam War. The current mood, however, feels different. Gallup recently reported that national mental health is at an all-time low, with few bright spots to lift spirits.
To better understand how Americans are feeling and their attitudes towards mental health in general, ThinkNow conducted a nationally representative quantitative survey of 1,500 respondents and found some interesting differences among ethnic, age and gender groups.
Technology
For example, 52% agree that technology and social media have a negative impact on mental health, but when broken out by race, 61% of Whites felt technology had a negative effect, and only 48% of Hispanics thought it did.
While technology has helped us keep in touch with friends and family in faraway places, it appears to have degraded our ability to connect in person. Staying connected online is a double-edged sword since the same news feed that brings us pictures of the grandkids and fluffy kittens also feeds us news about the wars in Israel and Ukraine, the dysfunction in Washington, the latest mass shooting and the climate crisis.
Hispanics may have a built-in defense against the isolation technology breeds, owing to their large, multigenerational households, strong social support systems, and tendency to use social media to stay connected with relatives abroad.
Age and Gender
When asked how individuals rate their mental health, men rate it higher than women by 11 percentage points, and Baby Boomers rank it highest at 83%, saying it’s good or excellent vs. 57% of Gen Z saying the same.
Gen Z spends the most amount of time on social media, so the notion that social media negatively affects mental health appears to be correlated. Unfortunately, Gen Z is also the generation that’s least comfortable discussing mental health concerns with healthcare professionals. Only 40% of them state they’re comfortable discussing their issues with a professional compared to 60% of Millennials and 65% of Boomers.
Race Affects Attitudes
As seen in previous research conducted by ThinkNow, Asian Americans lag other groups when it comes to awareness of mental health issues. Twenty-four percent of Asian Americans believe that having a mental health issue is a sign of weakness compared to the 16% average for all groups. Asians are also considerably less likely to be aware of mental health services in their communities (42% vs. 55%) and most likely to seek out information on social media (51% vs. 35%).
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
This article is all about what AI trends will emerge in the field of creative operations in 2024. All the marketers and brand builders should be aware of these trends for their further use and save themselves some time!
A report by thenetworkone and Kurio.
The contributing experts and agencies are (in an alphabetical order): Sylwia Rytel, Social Media Supervisor, 180heartbeats + JUNG v MATT (PL), Sharlene Jenner, Vice President - Director of Engagement Strategy, Abelson Taylor (USA), Alex Casanovas, Digital Director, Atrevia (ES), Dora Beilin, Senior Social Strategist, Barrett Hoffher (USA), Min Seo, Campaign Director, Brand New Agency (KR), Deshé M. Gully, Associate Strategist, Day One Agency (USA), Francesca Trevisan, Strategist, Different (IT), Trevor Crossman, CX and Digital Transformation Director; Olivia Hussey, Strategic Planner; Simi Srinarula, Social Media Manager, The Hallway (AUS), James Hebbert, Managing Director, Hylink (CN / UK), Mundy Álvarez, Planning Director; Pedro Rojas, Social Media Manager; Pancho González, CCO, Inbrax (CH), Oana Oprea, Head of Digital Planning, Jam Session Agency (RO), Amy Bottrill, Social Account Director, Launch (UK), Gaby Arriaga, Founder, Leonardo1452 (MX), Shantesh S Row, Creative Director, Liwa (UAE), Rajesh Mehta, Chief Strategy Officer; Dhruv Gaur, Digital Planning Lead; Leonie Mergulhao, Account Supervisor - Social Media & PR, Medulla (IN), Aurelija Plioplytė, Head of Digital & Social, Not Perfect (LI), Daiana Khaidargaliyeva, Account Manager, Osaka Labs (UK / USA), Stefanie Söhnchen, Vice President Digital, PIABO Communications (DE), Elisabeth Winiartati, Managing Consultant, Head of Global Integrated Communications; Lydia Aprina, Account Manager, Integrated Marketing and Communications; Nita Prabowo, Account Manager, Integrated Marketing and Communications; Okhi, Web Developer, PNTR Group (ID), Kei Obusan, Insights Director; Daffi Ranandi, Insights Manager, Radarr (SG), Gautam Reghunath, Co-founder & CEO, Talented (IN), Donagh Humphreys, Head of Social and Digital Innovation, THINKHOUSE (IRE), Sarah Yim, Strategy Director, Zulu Alpha Kilo (CA).
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
The search marketing landscape is evolving rapidly with new technologies, and professionals, like you, rely on innovative paid search strategies to meet changing demands.
It’s important that you’re ready to implement new strategies in 2024.
Check this out and learn the top trends in paid search advertising that are expected to gain traction, so you can drive higher ROI more efficiently in 2024.
You’ll learn:
- The latest trends in AI and automation, and what this means for an evolving paid search ecosystem.
- New developments in privacy and data regulation.
- Emerging ad formats that are expected to make an impact next year.
Watch Sreekant Lanka from iQuanti and Irina Klein from OneMain Financial as they dive into the future of paid search and explore the trends, strategies, and technologies that will shape the search marketing landscape.
If you’re looking to assess your paid search strategy and design an industry-aligned plan for 2024, then this webinar is for you.
5 Public speaking tips from TED - Visualized summarySpeakerHub
From their humble beginnings in 1984, TED has grown into the world’s most powerful amplifier for speakers and thought-leaders to share their ideas. They have over 2,400 filmed talks (not including the 30,000+ TEDx videos) freely available online, and have hosted over 17,500 events around the world.
With over one billion views in a year, it’s no wonder that so many speakers are looking to TED for ideas on how to share their message more effectively.
The article “5 Public-Speaking Tips TED Gives Its Speakers”, by Carmine Gallo for Forbes, gives speakers five practical ways to connect with their audience, and effectively share their ideas on stage.
Whether you are gearing up to get on a TED stage yourself, or just want to master the skills that so many of their speakers possess, these tips and quotes from Chris Anderson, the TED Talks Curator, will encourage you to make the most impactful impression on your audience.
See the full article and more summaries like this on SpeakerHub here: https://speakerhub.com/blog/5-presentation-tips-ted-gives-its-speakers
See the original article on Forbes here:
http://www.forbes.com/forbes/welcome/?toURL=http://www.forbes.com/sites/carminegallo/2016/05/06/5-public-speaking-tips-ted-gives-its-speakers/&refURL=&referrer=#5c07a8221d9b
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
Everyone is in agreement that ChatGPT (and other generative AI tools) will shape the future of work. Yet there is little consensus on exactly how, when, and to what extent this technology will change our world.
Businesses that extract maximum value from ChatGPT will use it as a collaborative tool for everything from brainstorming to technical maintenance.
For individuals, now is the time to pinpoint the skills the future professional will need to thrive in the AI age.
Check out this presentation to understand what ChatGPT is, how it will shape the future of work, and how you can prepare to take advantage.
A brief introduction to DataScience with explaining of the concepts, algorithms, machine learning, supervised and unsupervised learning, clustering, statistics, data preprocessing, real-world applications etc.
It's part of a Data Science Corner Campaign where I will be discussing the fundamentals of DataScience, AIML, Statistics etc.
Time Management & Productivity - Best PracticesVit Horky
Here's my presentation on by proven best practices how to manage your work time effectively and how to improve your productivity. It includes practical tips and how to use tools such as Slack, Google Apps, Hubspot, Google Calendar, Gmail and others.
The six step guide to practical project managementMindGenius
The six step guide to practical project management
If you think managing projects is too difficult, think again.
We’ve stripped back project management processes to the
basics – to make it quicker and easier, without sacrificing
the vital ingredients for success.
“If you’re looking for some real-world guidance, then The Six Step Guide to Practical Project Management will help.”
Dr Andrew Makar, Tactical Project Management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Scala
1. Wstęp
O języku
Przykłady
BIWAK Scali
czyli Scala w domu i zagrodzie
Krzysztof Goj
Koło Naukowe Informatyków BIT
3 grudnia 2008
Krzysztof Goj BIWAK Scali
2. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala – flame
Lepsza Java
Haskell dla ludzi
Ruby, który nie muli
Procesy Erlanga na JVM
Krzysztof Goj BIWAK Scali
3. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala – flame
Lepsza Java
Haskell dla ludzi
Ruby, który nie muli
Procesy Erlanga na JVM
Krzysztof Goj BIWAK Scali
4. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala – flame
Lepsza Java
Haskell dla ludzi
Ruby, który nie muli
Procesy Erlanga na JVM
Krzysztof Goj BIWAK Scali
5. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala – flame
Lepsza Java
Haskell dla ludzi
Ruby, który nie muli
Procesy Erlanga na JVM
Krzysztof Goj BIWAK Scali
6. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala
Nazwa i logo
Obiektowo-funkcyjny język programowania wysokiego
poziomu i ogólnego przeznaczenia.
Zgodność z Javą, wersja na .NET
Elastyczna składnia pozwala na tworzenie DSL-i
Stworzona przez Martina Oderskiego (EPFL)
http://www.scala-lang.org
Krzysztof Goj BIWAK Scali
7. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala
Nazwa i logo
Obiektowo-funkcyjny język programowania wysokiego
poziomu i ogólnego przeznaczenia.
Zgodność z Javą, wersja na .NET
Elastyczna składnia pozwala na tworzenie DSL-i
Stworzona przez Martina Oderskiego (EPFL)
http://www.scala-lang.org
Krzysztof Goj BIWAK Scali
8. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala
Nazwa i logo
Obiektowo-funkcyjny język programowania wysokiego
poziomu i ogólnego przeznaczenia.
Zgodność z Javą, wersja na .NET
Elastyczna składnia pozwala na tworzenie DSL-i
Stworzona przez Martina Oderskiego (EPFL)
http://www.scala-lang.org
Krzysztof Goj BIWAK Scali
9. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala
Nazwa i logo
Obiektowo-funkcyjny język programowania wysokiego
poziomu i ogólnego przeznaczenia.
Zgodność z Javą, wersja na .NET
Elastyczna składnia pozwala na tworzenie DSL-i
Stworzona przez Martina Oderskiego (EPFL)
http://www.scala-lang.org
Krzysztof Goj BIWAK Scali
10. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala
Nazwa i logo
Obiektowo-funkcyjny język programowania wysokiego
poziomu i ogólnego przeznaczenia.
Zgodność z Javą, wersja na .NET
Elastyczna składnia pozwala na tworzenie DSL-i
Stworzona przez Martina Oderskiego (EPFL)
http://www.scala-lang.org
Krzysztof Goj BIWAK Scali
11. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
Czym jest Scala
Nazwa i logo
Obiektowo-funkcyjny język programowania wysokiego
poziomu i ogólnego przeznaczenia.
Zgodność z Javą, wersja na .NET
Elastyczna składnia pozwala na tworzenie DSL-i
Stworzona przez Martina Oderskiego (EPFL)
http://www.scala-lang.org
Krzysztof Goj BIWAK Scali
12. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” w shellu
Najprościej Scalę zmusić do mówienia pisząc w shellu.
shell
goj@abulafia ∼ % scala
Welcome to Scala version 2.7.1.final [...]
Type in expressions to have them evaluated.
Type :help for more information.
scala> println(quot;Hello, World!quot;)
Hello, World!
Krzysztof Goj BIWAK Scali
13. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” w shellu
Najprościej Scalę zmusić do mówienia pisząc w shellu.
shell
goj@abulafia ∼ % scala
Welcome to Scala version 2.7.1.final [...]
Type in expressions to have them evaluated.
Type :help for more information.
scala> println(quot;Hello, World!quot;)
Hello, World!
Krzysztof Goj BIWAK Scali
14. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” w shellu
Najprościej Scalę zmusić do mówienia pisząc w shellu.
shell
goj@abulafia ∼ % scala
Welcome to Scala version 2.7.1.final [...]
Type in expressions to have them evaluated.
Type :help for more information.
scala> println(quot;Hello, World!quot;)
Hello, World!
Krzysztof Goj BIWAK Scali
15. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” w shellu
Najprościej Scalę zmusić do mówienia pisząc w shellu.
shell
goj@abulafia ∼ % scala
Welcome to Scala version 2.7.1.final [...]
Type in expressions to have them evaluated.
Type :help for more information.
scala> println(quot;Hello, World!quot;)
Hello, World!
Krzysztof Goj BIWAK Scali
16. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” w shellu
Najprościej Scalę zmusić do mówienia pisząc w shellu.
shell
goj@abulafia ∼ % scala
Welcome to Scala version 2.7.1.final [...]
Type in expressions to have them evaluated.
Type :help for more information.
scala> println(quot;Hello, World!quot;)
Hello, World!
Krzysztof Goj BIWAK Scali
17. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” w shellu
Najprościej Scalę zmusić do mówienia pisząc w shellu.
shell
goj@abulafia ∼ % scala
Welcome to Scala version 2.7.1.final [...]
Type in expressions to have them evaluated.
Type :help for more information.
scala> println(quot;Hello, World!quot;)
Hello, World!
Krzysztof Goj BIWAK Scali
18. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
19. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
20. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
21. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
22. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
23. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
24. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
25. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
26. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
27. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
28. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako osobny program
najczęściej pisze się tak. . .
hello.scala
object HelloWorld extends Application {
println(quot;Hello, world!quot;)
}
shell
goj@abulafia ∼ % scalac hello.scala
goj@abulafia ∼ % ls
Hello.class Hello$.class hello.scala
goj@abulafia ∼ % scala -cp . Hello
Hello, World!
goj@abulafia ∼ % java -cp .:$SCALA_HOME/lib/scala-library.jar Hello
Hello, World!
Krzysztof Goj BIWAK Scali
29. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako skrypt
. . . można też pisać skrypty
script.sh
#!/bin/sh
exec scala quot;$0quot; quot;$¨
!#
object HelloWorld {
def main(args: Array[String]) {
println(quot;Hello, World!quot;)
}
}
HelloWorld.main(args)
shell
goj@abulafia ∼ % chmod +x script.sh
goj@abulafia ∼ % ./script.sh
Hello, World!
Krzysztof Goj BIWAK Scali
30. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako skrypt
. . . można też pisać skrypty
script.sh
#!/bin/sh
exec scala quot;$0quot; quot;$¨
!#
object HelloWorld {
def main(args: Array[String]) {
println(quot;Hello, World!quot;)
}
}
HelloWorld.main(args)
shell
goj@abulafia ∼ % chmod +x script.sh
goj@abulafia ∼ % ./script.sh
Hello, World!
Krzysztof Goj BIWAK Scali
31. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako skrypt
. . . można też pisać skrypty
script.sh
#!/bin/sh
exec scala quot;$0quot; quot;$¨
!#
object HelloWorld {
def main(args: Array[String]) {
println(quot;Hello, World!quot;)
}
}
HelloWorld.main(args)
shell
goj@abulafia ∼ % chmod +x script.sh
goj@abulafia ∼ % ./script.sh
Hello, World!
Krzysztof Goj BIWAK Scali
32. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako skrypt
. . . można też pisać skrypty
script.sh
#!/bin/sh
exec scala quot;$0quot; quot;$¨
!#
object HelloWorld {
def main(args: Array[String]) {
println(quot;Hello, World!quot;)
}
}
HelloWorld.main(args)
shell
goj@abulafia ∼ % chmod +x script.sh
goj@abulafia ∼ % ./script.sh
Hello, World!
Krzysztof Goj BIWAK Scali
33. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako skrypt
. . . można też pisać skrypty
script.sh
#!/bin/sh
exec scala quot;$0quot; quot;$¨
!#
object HelloWorld {
def main(args: Array[String]) {
println(quot;Hello, World!quot;)
}
}
HelloWorld.main(args)
shell
goj@abulafia ∼ % chmod +x script.sh
goj@abulafia ∼ % ./script.sh
Hello, World!
Krzysztof Goj BIWAK Scali
34. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako skrypt
. . . można też pisać skrypty
script.sh
#!/bin/sh
exec scala quot;$0quot; quot;$¨
!#
object HelloWorld {
def main(args: Array[String]) {
println(quot;Hello, World!quot;)
}
}
HelloWorld.main(args)
shell
goj@abulafia ∼ % chmod +x script.sh
goj@abulafia ∼ % ./script.sh
Hello, World!
Krzysztof Goj BIWAK Scali
35. Wstęp
Czym jest Scala
O języku
Hello, World!
Przykłady
“Hello, World!” jako skrypt
. . . można też pisać skrypty
script.sh
#!/bin/sh
exec scala quot;$0quot; quot;$¨
!#
object HelloWorld {
def main(args: Array[String]) {
println(quot;Hello, World!quot;)
}
}
HelloWorld.main(args)
shell
goj@abulafia ∼ % chmod +x script.sh
goj@abulafia ∼ % ./script.sh
Hello, World!
Krzysztof Goj BIWAK Scali
36. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Fundamenty programowania funkcyjnego
Funkcje to zwykłe obiekty
• Można je przekazywać jako argumenty do funkcji
• Mogą być zwracane przez inne funkcje
• Programujemy składając je na różne sposoby
Izolowanie efektów ubocznych
• Niezmienność (immutability)
• Programujemy tworząc nowe obiekty na podstawie starych,
a nie zmieniając istniejące
Krzysztof Goj BIWAK Scali
37. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Fundamenty programowania funkcyjnego
Funkcje to zwykłe obiekty
• Można je przekazywać jako argumenty do funkcji
• Mogą być zwracane przez inne funkcje
• Programujemy składając je na różne sposoby
Izolowanie efektów ubocznych
• Niezmienność (immutability)
• Programujemy tworząc nowe obiekty na podstawie starych,
a nie zmieniając istniejące
Krzysztof Goj BIWAK Scali
38. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Fundamenty programowania funkcyjnego
Funkcje to zwykłe obiekty
• Można je przekazywać jako argumenty do funkcji
• Mogą być zwracane przez inne funkcje
• Programujemy składając je na różne sposoby
Izolowanie efektów ubocznych
• Niezmienność (immutability)
• Programujemy tworząc nowe obiekty na podstawie starych,
a nie zmieniając istniejące
Krzysztof Goj BIWAK Scali
39. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Fundamenty programowania funkcyjnego
Funkcje to zwykłe obiekty
• Można je przekazywać jako argumenty do funkcji
• Mogą być zwracane przez inne funkcje
• Programujemy składając je na różne sposoby
Izolowanie efektów ubocznych
• Niezmienność (immutability)
• Programujemy tworząc nowe obiekty na podstawie starych,
a nie zmieniając istniejące
Krzysztof Goj BIWAK Scali
40. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Fundamenty programowania funkcyjnego
Funkcje to zwykłe obiekty
• Można je przekazywać jako argumenty do funkcji
• Mogą być zwracane przez inne funkcje
• Programujemy składając je na różne sposoby
Izolowanie efektów ubocznych
• Niezmienność (immutability)
• Programujemy tworząc nowe obiekty na podstawie
starych, a nie zmieniając istniejące
Krzysztof Goj BIWAK Scali
41. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Fundamenty programowania funkcyjnego
Funkcje to zwykłe obiekty
• Można je przekazywać jako argumenty do funkcji
• Mogą być zwracane przez inne funkcje
• Programujemy składając je na różne sposoby
Izolowanie efektów ubocznych
• Niezmienność (immutability)
• Programujemy tworząc nowe obiekty na podstawie starych,
a nie zmieniając istniejące
Krzysztof Goj BIWAK Scali
42. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Fundamenty programowania funkcyjnego
Funkcje to zwykłe obiekty
• Można je przekazywać jako argumenty do funkcji
• Mogą być zwracane przez inne funkcje
• Programujemy składając je na różne sposoby
Izolowanie efektów ubocznych
• Niezmienność (immutability)
• Programujemy tworząc nowe obiekty na podstawie
starych, a nie zmieniając istniejące
Krzysztof Goj BIWAK Scali
43. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Zalety programowania funkcyjnego
Skalowalność
Zwięzłość
Naturalny sposób opisu wielu problemów
Jest trędi–dżezi, kul, na topie
Krzysztof Goj BIWAK Scali
44. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Zalety programowania funkcyjnego
Skalowalność
Zwięzłość
Naturalny sposób opisu wielu problemów
Jest trędi–dżezi, kul, na topie
Krzysztof Goj BIWAK Scali
45. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Zalety programowania funkcyjnego
Skalowalność
Zwięzłość
Naturalny sposób opisu wielu problemów
Jest trędi–dżezi, kul, na topie
Krzysztof Goj BIWAK Scali
46. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Zalety programowania funkcyjnego
Skalowalność
Zwięzłość
Naturalny sposób opisu wielu problemów
Jest trędi–dżezi, kul, na topie
Krzysztof Goj BIWAK Scali
47. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Co to jest DSL?
Domain Specific Languages
Zewnętrzne (np. Make)
Wewnętrzne (np. Rake)
Krzysztof Goj BIWAK Scali
48. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Co to jest DSL?
Domain Specific Languages
Zewnętrzne (np. Make)
Wewnętrzne (np. Rake)
Krzysztof Goj BIWAK Scali
49. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Co to jest DSL?
Domain Specific Languages
Zewnętrzne (np. Make)
Wewnętrzne (np. Rake)
Krzysztof Goj BIWAK Scali
50. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Co to jest DSL?
Wewnętrzny DSL w Scali — Specs
object helloWorld extends Specification {
quot;’Hello, World!’ has 13 charactersquot; in {
quot;Hello, World!quot;.size mustEqual 13
}
quot;’Hello, World!’ matches /H.*W.*d.?/ regexpquot; in {
quot;Hello, World!quot; must beMatching(quot;H.*W.*d.?quot;)
}
}
Krzysztof Goj BIWAK Scali
51. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Scala a współbieżność
scala.actors
scala.concurrent
• scala.concurrent.pilib – rachunek π
• scala.concurrent.jolib – join calculus
• Lock, SyncChannel
Scala-STM (poza biblioteką standardową)
Krzysztof Goj BIWAK Scali
52. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Scala a współbieżność
scala.actors
scala.concurrent
• scala.concurrent.pilib – rachunek π
• scala.concurrent.jolib – join calculus
• Lock, SyncChannel
Scala-STM (poza biblioteką standardową)
Krzysztof Goj BIWAK Scali
53. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Scala a współbieżność
scala.actors
scala.concurrent
• scala.concurrent.pilib – rachunek π
• scala.concurrent.jolib – join calculus
• Lock, SyncChannel
Scala-STM (poza biblioteką standardową)
Krzysztof Goj BIWAK Scali
54. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Scala a współbieżność
scala.actors
scala.concurrent
• scala.concurrent.pilib – rachunek π
• scala.concurrent.jolib – join calculus
• Lock, SyncChannel
Scala-STM (poza biblioteką standardową)
Krzysztof Goj BIWAK Scali
55. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Scala a współbieżność
scala.actors
scala.concurrent
• scala.concurrent.pilib – rachunek π
• scala.concurrent.jolib – join calculus
• Lock, SyncChannel
Scala-STM (poza biblioteką standardową)
Krzysztof Goj BIWAK Scali
56. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
Scala a współbieżność
scala.actors
scala.concurrent
• scala.concurrent.pilib – rachunek π
• scala.concurrent.jolib – join calculus
• Lock, SyncChannel
Scala-STM (poza biblioteką standardową)
Krzysztof Goj BIWAK Scali
57. Wstęp Programowanie funkcyjne
O języku Elastyczna Składnia
Przykłady Inne
traity
pattern matching
składnia dla XML-a
inferencja typów
domknięcia funkcyjne
funkcje anonimowe
implicit conversions
implicit parameters
for comprehensions i monady
elastyczny system typów
Krzysztof Goj BIWAK Scali
58. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Przykłady
Krzysztof Goj BIWAK Scali
59. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
Haskell
map (1+) [1, 2, 3]
Ruby
[1, 2, 3].map {|i| i+1}
Scheme (Lisp)
(map (lambda (n) (1+ n)) ’(1 2 3))
Python
[n+1 for n in [1, 2, 3]]
Erlang
lists:map(fun(N) -> N+1 end, [1, 2, 3]).
Krzysztof Goj BIWAK Scali
60. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
Java
import java.util.List;
import java.util.ArrayList;
import static java.util.Arrays.asList;
interface Function<Result, Arg> {
public Result execute(Arg arg);
}
public class MapExample {
public static<Result, Arg> List<Result> map(Function<Result, Arg> fn, Iterable<Arg> iter) {
List<Result> result = new ArrayList<Result>();
for (Arg i: iter)
result.add(fn.execute(i));
return result;
}
public static void main(String[] args) {
map(new Function<Integer, Integer>() {
public Integer execute(Integer i) {
return i + 1;
}
}, asList(1, 2, 3));
}
}
Krzysztof Goj BIWAK Scali
61. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
Scala
object MapExample extends Application {
def increase(n: Int): Int = {
return n + 1;
}
Array(1, 2, 3).map(increase);
}
Scala — którka funkcja
object MapExample extends Application {
def increase(n: Int): Int = n + 1;
Array(1, 2, 3).map(increase);
}
Scala — inferencja typów
object MapExample extends Application {
def increase(n: Int) = n + 1;
Array(1, 2, 3).map(increase);
}
Krzysztof Goj BIWAK Scali
62. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
Scala
object MapExample extends Application {
def increase(n: Int): Int = {
return n + 1;
}
Array(1, 2, 3).map(increase);
}
Scala — którka funkcja
object MapExample extends Application {
def increase(n: Int): Int = n + 1;
Array(1, 2, 3).map(increase);
}
Scala — inferencja typów
object MapExample extends Application {
def increase(n: Int) = n + 1;
Array(1, 2, 3).map(increase);
}
Krzysztof Goj BIWAK Scali
63. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
Scala
object MapExample extends Application {
def increase(n: Int): Int = {
return n + 1;
}
Array(1, 2, 3).map(increase);
}
Scala — którka funkcja
object MapExample extends Application {
def increase(n: Int): Int = n + 1;
Array(1, 2, 3).map(increase);
}
Scala — inferencja typów
object MapExample extends Application {
def increase(n: Int) = n + 1;
Array(1, 2, 3).map(increase);
}
Krzysztof Goj BIWAK Scali
64. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
to samo, co na poprzednim slajdzie
def increase(n: Int) = n + 1;
Array(1, 2, 3).map(increase);
funkcja anonimowa
Array(1, 2, 3).map((n: Int) => n + 1);
dalsza inferencja typów
Array(1, 2, 3).map(n => n + 1);
anonimowy argument
Array(1, 2, 3).map(_ + 1);
wygodna składnia
Array(1, 2, 3) map (_ + 1)
Krzysztof Goj BIWAK Scali
65. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
to samo, co na poprzednim slajdzie
def increase(n: Int) = n + 1;
Array(1, 2, 3).map(increase);
funkcja anonimowa
Array(1, 2, 3).map((n: Int) => n + 1);
dalsza inferencja typów
Array(1, 2, 3).map(n => n + 1);
anonimowy argument
Array(1, 2, 3).map(_ + 1);
wygodna składnia
Array(1, 2, 3) map (_ + 1)
Krzysztof Goj BIWAK Scali
66. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
to samo, co na poprzednim slajdzie
def increase(n: Int) = n + 1;
Array(1, 2, 3).map(increase);
funkcja anonimowa
Array(1, 2, 3).map((n: Int) => n + 1);
dalsza inferencja typów
Array(1, 2, 3).map(n => n + 1);
anonimowy argument
Array(1, 2, 3).map(_ + 1);
wygodna składnia
Array(1, 2, 3) map (_ + 1)
Krzysztof Goj BIWAK Scali
67. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
to samo, co na poprzednim slajdzie
def increase(n: Int) = n + 1;
Array(1, 2, 3).map(increase);
funkcja anonimowa
Array(1, 2, 3).map((n: Int) => n + 1);
dalsza inferencja typów
Array(1, 2, 3).map(n => n + 1);
anonimowy argument
Array(1, 2, 3).map(_ + 1);
wygodna składnia
Array(1, 2, 3) map (_ + 1)
Krzysztof Goj BIWAK Scali
68. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Na rozgrzewkę - map
to samo, co na poprzednim slajdzie
def increase(n: Int) = n + 1;
Array(1, 2, 3).map(increase);
funkcja anonimowa
Array(1, 2, 3).map((n: Int) => n + 1);
dalsza inferencja typów
Array(1, 2, 3).map(n => n + 1);
anonimowy argument
Array(1, 2, 3).map(_ + 1);
wygodna składnia
Array(1, 2, 3) map (_ + 1)
Krzysztof Goj BIWAK Scali
69. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
takaSkładnia.setJestBrzydka(true)
Settery i gettery
class DateError extends Exception
class TimeOfDayVar {
private var h, m, s: Int = 0
def hours = h
def hours_= (h: Int) =
if (0 <= h && h < 24) this.h = h
else throw new DateError()
// ...
}
def main(args: Array[String]) {
val d = new TimeOfDayVar
d.hours = 8; d.minutes = 30; d.seconds = 0
d.hours = 25 // throws a DateError exception
}
Krzysztof Goj BIWAK Scali
70. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Implicit Conversions
silnia
def fact(n: Int): BigInt = if (n > 0) BigInt(n) * fact(n-1) else 1
implicit def enrich(n: Int) = new {
def !(): BigInt = fact(n)
}
println(42!)
1405006117752879898543142606244511569936384000000000
Krzysztof Goj BIWAK Scali
71. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Implicit Conversions
silnia
def fact(n: Int): BigInt = if (n > 0) BigInt(n) * fact(n-1) else 1
implicit def enrich(n: Int) = new {
def !(): BigInt = fact(n)
}
println(42!)
1405006117752879898543142606244511569936384000000000
Krzysztof Goj BIWAK Scali
72. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
For Comprehensions
sprytne pętle
for (i <- 1 to 100 by 7) println(i)
for (i <- 1 to 100 by 7 if i % 3 == 0) println(i)
val numbers = for (i <- 1 to 100 by 7 if i % 3 == 0) yield i-1
odcukrzamy
(1).to(100).by(7).foreach(println)
(1).to(100).by(7).filter(_ % 3 == 0).foreach(println)
val numbers = (1).to(100).by(7).filter(_ % 3 == 0).map(_-1)
Krzysztof Goj BIWAK Scali
73. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
For Comprehensions
sprytne pętle
for (i <- 1 to 100 by 7) println(i)
for (i <- 1 to 100 by 7 if i % 3 == 0) println(i)
val numbers = for (i <- 1 to 100 by 7 if i % 3 == 0) yield i-1
odcukrzamy
(1).to(100).by(7).foreach(println)
(1).to(100).by(7).filter(_ % 3 == 0).foreach(println)
val numbers = (1).to(100).by(7).filter(_ % 3 == 0).map(_-1)
Krzysztof Goj BIWAK Scali
74. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
For Comprehensions
sprytne pętle
for (i <- 1 to 100 by 7) println(i)
for (i <- 1 to 100 by 7 if i % 3 == 0) println(i)
val numbers = for (i <- 1 to 100 by 7 if i % 3 == 0) yield i-1
odcukrzamy
(1).to(100).by(7).foreach(println)
(1).to(100).by(7).filter(_ % 3 == 0).foreach(println)
val numbers = (1).to(100).by(7).filter(_ % 3 == 0).map(_-1)
Krzysztof Goj BIWAK Scali
75. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
For Comprehensions
sprytne pętle
for (i <- 1 to 100 by 7) println(i)
for (i <- 1 to 100 by 7 if i % 3 == 0) println(i)
val numbers = for (i <- 1 to 100 by 7 if i % 3 == 0) yield i-1
odcukrzamy
(1).to(100).by(7).foreach(println)
(1).to(100).by(7).filter(_ % 3 == 0).foreach(println)
val numbers = (1).to(100).by(7).filter(_ % 3 == 0).map(_-1)
Krzysztof Goj BIWAK Scali
76. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Opcje
Opcje
import scala.collection.mutable.HashMap
val numbers = HashMap(0 -> quot;nicquot;, 1 -> quot;jednoquot;, 2 -> quot;dwaquot;)
val rnd = new Random
numbers get rnd.nextInt(7) match {
case Some(name) => println(quot;To quot; + name)
case None => println(quot;Dużoquot;)
}
println(numbers get rnd.nextInt(7) map {_.capitalize + quot;!quot;}
getOrElse quot;DUŻO!!!quot;)
Krzysztof Goj BIWAK Scali
77. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
ScalaCheck — QuickCheck i więcej
ScalaCheck
import org.scalacheck._
object StringSpecification extends Properties(quot;Stringquot;) {
specify(quot;startsWithquot;, (a: String, b: String) => (a+b).startsWith(a))
specify(quot;endsWithquot;, (a: String, b: String) => (a+b).endsWith(b))
// Is this really always true?
specify(quot;concatquot;, (a: String, b: String) =>
(a+b).length > a.length && (a+b).length > b.length
)
specify(quot;substringquot;, (a: String, b: String) =>
(a+b).substring(a.length) == b
)
specify(quot;substringquot;, (a: String, b: String, c: String) =>
(a+b+c).substring(a.length, a.length+b.length) == b
)
}
Krzysztof Goj BIWAK Scali
78. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Traity
Trait ordered
trait Ordered[A] {
def compare(that: A): Int
def < (that: A): Boolean = (this compare that) < 0
def > (that: A): Boolean = (this compare that) > 0
def <= (that: A): Boolean = (this compare that) <= 0
def >= (that: A): Boolean = (this compare that) >= 0
def compareTo(that: A): Int = compare(that)
}
Użycie
class Sth(val a: Int) extends Ordered[Sth] {
override def compare(other: Sth) = {
val b = other.a
(a*a) compare (b*b)
}
}
val rnd = new Random
println(if (new Sth(-3) < new Sth(rnd nextInt 5)) quot;Yesquot; else quot;Noquot;)
Krzysztof Goj BIWAK Scali
79. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Traity
Trait ordered
trait Ordered[A] {
def compare(that: A): Int
def < (that: A): Boolean = (this compare that) < 0
def > (that: A): Boolean = (this compare that) > 0
def <= (that: A): Boolean = (this compare that) <= 0
def >= (that: A): Boolean = (this compare that) >= 0
def compareTo(that: A): Int = compare(that)
}
Użycie
class Sth(val a: Int) extends Ordered[Sth] {
override def compare(other: Sth) = {
val b = other.a
(a*a) compare (b*b)
}
}
val rnd = new Random
println(if (new Sth(-3) < new Sth(rnd nextInt 5)) quot;Yesquot; else quot;Noquot;)
Krzysztof Goj BIWAK Scali
80. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Domknięcia
Zapis
var counter = 0
def bump_up() {
counter += 1
}
Odczyt
def outer(a: Int): Int = {
def helper(b: Int) = a * a - b
helper(4) + helper(a-1)
}
Krzysztof Goj BIWAK Scali
81. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Domknięcia
Zapis
var counter = 0
def bump_up() {
counter += 1
}
Odczyt
def outer(a: Int): Int = {
def helper(b: Int) = a * a - b
helper(4) + helper(a-1)
}
Krzysztof Goj BIWAK Scali
82. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Domknięcia
Licznik — patologicznik
def mkCounter() = {
var soFar = 0
def counter(n: Int) = {
soFar += n
soFar
}
counter _
}
val cnt1 = mkCounter()
val cnt2 = mkCounter()
cnt1(1); cnt1(30)
println(cnt1(11))
println(cnt2(7))
wypisze 42 i 7
Krzysztof Goj BIWAK Scali
83. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
XML – tworzenie
XML
case class Person(name: String, age: Int)
class AddressBook(a: Person*) {
private val people: List[Person] = a.toList
def toXHTML =
<table class=quot;XMLquot;>
<tr>
<th>Last Name</th>
<th>First Name</th>
</tr>
{ for (val p <- people) yield
<tr>
<td>{ p.name }</td>
<td>{ p.age.toString }</td>
</tr>
}
</table>;
}
Krzysztof Goj BIWAK Scali
84. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
XML – wyszukiwanie 1/3
XML
def understandFakt(note: scala.xml.Node): String = note match {
case <murder>
<criminal>
<name>{murdererName}</name>
<age>{murderAge}</age>
</criminal>
<victim><name>{victimName}</name>{_*}</victim>
</murder> => quot;ZBRODNIA! quot; + murderAge + quot;-letni quot; +
murderAge + quot; zabił quot; + quot; quot; + victimName
case <advert>{content}</advert> => quot;Kupuj quot; + content
case _ => quot;prognoza pogody: będzie padaćquot;
}
Krzysztof Goj BIWAK Scali
85. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
XML – wyszukiwanie 2/3
XML
val stuff =
<badStuff>
<newspapers>
<newspaper title=quot;Nasz Dziennikquot;>...</newspaper>
<newspaper title=quot;NIEquot;>...</newspaper>
<newspaper title=quot;Faktquot;>
<frontPage>
<advert>Fakt</advert>
<pogoda/>
</frontPage>
</newspaper>
</newspapers>
</badStuff>
Krzysztof Goj BIWAK Scali
86. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
XML – wyszukiwanie 3/3
XML
for {
val paper <- stuff quot;newspapersquot; quot;newspaperquot;
paper.attributes(quot;titlequot;) == quot;Faktquot;
val frontPage <- paper quot;frontPagequot;
val article <- frontPage child
} println(understandFakt(article))
Krzysztof Goj BIWAK Scali
87. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – definicja
class Stack[+A] {
def push[B >: A](elem: B): Stack[B] = new Stack[B] {
override def top: B = elem
override def pop: Stack[B] = Stack.this
override def toString() = Stack.this.toString() +
quot; quot; + elem.toString()
}
def top: A = error(quot;no element on stackquot;)
def pop: Stack[A] = error(quot;no element on stackquot;)
override def toString() = quot;quot;
}
hierarchia klas
Krzysztof Goj BIWAK Scali
88. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
89. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
90. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
91. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
92. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
93. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
94. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
95. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
96. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
97. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
98. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Kowariancja i dolna granica typu
Stos – użycie
scala> :load examples/stack.scala
Loading examples/stack.scala...
defined class Stack
scala> new Stack
res0: Stack[Nothing] =
scala> res0 push quot;Alaquot; push quot;maquot; push quot;kotaquot;
res1: Stack[java.lang.String] = Ala ma kota
scala> res1 pop
res2: Stack[java.lang.String] = Ala ma
scala> res2 push 0
res3: Stack[Any] = Ala ma 0
Krzysztof Goj BIWAK Scali
99. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Hierarchia typów
stack.scala
Krzysztof Goj BIWAK Scali
100. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Funkcja
trait Function1[-T1, +R]
Krzysztof Goj BIWAK Scali
101. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Implicit Parameters
Powtórka z algebry
abstract class SemiGroup[A] {
def add(x: A, y: A): A
}
abstract class Monoid[A] extends SemiGroup[A] {
def unit: A
}
implicit object StringMonoid extends Monoid[String] {
def add(x: String, y: String): String = x concat y
def unit: String = quot;quot;
}
implicit object IntMonoid extends Monoid[int] {
def add(x: Int, y: Int): Int = x + y
def unit: Int = 0
}
def sum[A](xs: List[A])(implicit m: Monoid[A]): A = (m.unit /: xs)(m.add)
println(sum(List(1, 2, 3)))
println(sum(List(quot;aquot;, quot;bquot;, quot;cquot;)))
Krzysztof Goj BIWAK Scali
102. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Parser Combinators
Prosty Kalkulator
import scala.util.parsing.combinator.lexical.StdLexical
import scala.util.parsing.combinator.syntactical.StdTokenParsers
object arithmeticParser extends StdTokenParsers {
type Tokens = StdLexical ; val lexical = new StdLexical
lexical.delimiters ++= List(quot;(quot;, quot;)quot;, quot;+quot;, quot;-quot;, quot;*quot;, quot;/quot;)
lazy val expr = term*(quot;+quot; ^^^ {(x: Int, y: Int) => x + y}
| quot;-quot; ^^^ {(x: Int, y: Int) => x - y})
lazy val term = factor*(quot;*quot; ^^^ {(x: Int, y: Int) => x * y}
| quot;/quot; ^^^ {(x: Int, y: Int) => x / y})
lazy val factor: Parser[Int] = quot;(quot; ~> expr <~ quot;)quot; |
numericLit ^^ (_.toInt)
def eval(str: String) = expr(new lexical.Scanner(str))
}
println(arithmeticParser.eval(quot;4 * (5+5) + 8/4quot;).get)
Krzysztof Goj BIWAK Scali
103. Wstęp rozgrzewka
O języku ciekawsze
Przykłady przerażające
Parser Combinators
Prosty Kalkulator
import scala.util.parsing.combinator.lexical.StdLexical
import scala.util.parsing.combinator.syntactical.StdTokenParsers
object arithmeticParser extends StdTokenParsers {
type Tokens = StdLexical ; val lexical = new StdLexical
lexical.delimiters ++= List(quot;(quot;, quot;)quot;, quot;+quot;, quot;-quot;, quot;*quot;, quot;/quot;)
lazy val expr = term*(quot;+quot; ^^^ {(x: Int, y: Int) => x + y}
| quot;-quot; ^^^ {(x: Int, y: Int) => x - y})
lazy val term = factor*(quot;*quot; ^^^ {(x: Int, y: Int) => x * y}
| quot;/quot; ^^^ {(x: Int, y: Int) => x / y})
lazy val factor: Parser[Int] = quot;(quot; ~> expr <~ quot;)quot; |
numericLit ^^ (_.toInt)
def eval(str: String) = expr(new lexical.Scanner(str))
}
println(arithmeticParser.eval(quot;4 * (5+5) + 8/4quot;).get)
Krzysztof Goj BIWAK Scali
104. Do poczytania
Zakończenie
Dziękuję
Do poczytania
http://www.scala-lang.org
Blog Martina Oderskiego
Blog Daniela Spiewaka
Blog Jamesa Iry-ego
http://scala-blogs.org/
#scala na freenode
Slajdy (z linkami) będą na
http://biwak-agh.blogspot.com/
Krzysztof Goj BIWAK Scali
105. Do poczytania
Zakończenie
Dziękuję
Do poczytania
http://www.scala-lang.org
Blog Martina Oderskiego
Blog Daniela Spiewaka
Blog Jamesa Iry-ego
http://scala-blogs.org/
#scala na freenode
Slajdy (z linkami) będą na
http://biwak-agh.blogspot.com/
Krzysztof Goj BIWAK Scali
106. Do poczytania
Zakończenie
Dziękuję
Do poczytania
http://www.scala-lang.org
Blog Martina Oderskiego
Blog Daniela Spiewaka
Blog Jamesa Iry-ego
http://scala-blogs.org/
#scala na freenode
Slajdy (z linkami) będą na
http://biwak-agh.blogspot.com/
Krzysztof Goj BIWAK Scali
107. Do poczytania
Zakończenie
Dziękuję
Do poczytania
http://www.scala-lang.org
Blog Martina Oderskiego
Blog Daniela Spiewaka
Blog Jamesa Iry-ego
http://scala-blogs.org/
#scala na freenode
Slajdy (z linkami) będą na
http://biwak-agh.blogspot.com/
Krzysztof Goj BIWAK Scali
108. Do poczytania
Zakończenie
Dziękuję
Do poczytania
http://www.scala-lang.org
Blog Martina Oderskiego
Blog Daniela Spiewaka
Blog Jamesa Iry-ego
http://scala-blogs.org/
#scala na freenode
Slajdy (z linkami) będą na
http://biwak-agh.blogspot.com/
Krzysztof Goj BIWAK Scali
109. Do poczytania
Zakończenie
Dziękuję
Do poczytania
http://www.scala-lang.org
Blog Martina Oderskiego
Blog Daniela Spiewaka
Blog Jamesa Iry-ego
http://scala-blogs.org/
#scala na freenode
Slajdy (z linkami) będą na
http://biwak-agh.blogspot.com/
Krzysztof Goj BIWAK Scali
110. Do poczytania
Zakończenie
Dziękuję
Do poczytania
http://www.scala-lang.org
Blog Martina Oderskiego
Blog Daniela Spiewaka
Blog Jamesa Iry-ego
http://scala-blogs.org/
#scala na freenode
Slajdy (z linkami) będą na
http://biwak-agh.blogspot.com/
Krzysztof Goj BIWAK Scali