1. JAVA: The Good Parts
자바 언어의 특징과 활용 방안의 주관적인 탐구
박성철 / SK Planet
2. 이야기의 시작...
“프로그래밍 언어들을 한 문장으로 소개”
http://npcode.com/blog/archives/124
Perl
: Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information
Python
: Python is an interpreted, interactive, object-oriented programming language that combines remarkable power with very clear syntax.
Ruby
: Ruby is an interpreted scripting language for quick and easy object oriented programming.
PHP
: PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
3. C++
: C++ is a general purpose programming language with a bias towards systems programming that
* is a better C
* supports data abstraction
* supports object-oriented programming
* supports generic programming
J
: J is a modern, high-level, general-purpose, high-performance programming language.
Lisp
: Lisp is a programmable programming language.
Java?
자바는 공신력 있고 설득력 있는 한문장 소개를 찾지 못했다. C++ 보다도 정체성이 불분명한 녀석이다.
!
4. 이야기의 시작...
“프로그래밍 언어들을 한 문장으로 소개”
http://npcode.com/blog/archives/124
Perl
: Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information
Python
: Python is an interpreted, interactive, object-oriented programming language that combines remarkable power with very clear syntax.
Ruby
: Ruby is an interpreted scripting language for quick and easy object oriented programming.
PHP
: PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
기종기종?? 검종검종??
6. @자바 백서
자바의 설계 목표
1. 단순함, 객체중심, 친숙함
2. 견고하고 안전한
3. 아키텍처 중림성과 이식성
4. 고성능
5. 인터프리터, 쓰레드, 동적
http://www.oracle.com/technetwork/java/index-136113.html
May 1996
James Gosling
Henry McGilton
언어
VM
8. 단순함, 친숙함
2.2.1 No More Typedefs, Defines, or Preprocessor
2.2.2 No More Structures or Unions
2.2.3 No Enums
2.2.4 No More Functions
2.2.5 No More Multiple Inheritance
2.2.6 No More Goto Statements
2.2.7 No More Operator Overloading
2.2.8 No More Automatic Coercions
2.2.9 No More Pointers
Java = C/C++ - WTF
9. 견고하고 안전한...
견고성 = 정적static 타입
컴파일러가 타입을 확인
안전성 = 엄격한strong 타입
실행 중에 타입 확인
10. Unit testing isn't enough. You need static typing too.
http://evanfarrer.blogspot.ca/2012/06/unit-testing-isnt-enough-you-need.html
말하길...
1. 정적 타이핑은 버그를 탐지하기엔 불충분하며, 단위 테스트를 해야 한다.
2. 단위 테스트를 장착하고 나면, 정적 타입 확인은 과잉이다.
3. 정적 타이핑은 유효한 프로그램을 오류로 분류하기도 하므로 해롭다.
사용자가 많고 테스트가 잘 장착되어 있는 파이선 오픈소스 프로젝트 네 가지를 하스켈로 1:1 포팅했더니...
The Python NMEA Toolkit: 9 오류
MIDIUtil: 2 오류
GrapeFruit: 0 오류
PyFontInfo: 6 오류
16. 인터페이스Interface
Alan kay
OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme` late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.
시뮬라 67 : 범용 언어 = 알고리듬 표현 + 코드 분해
프로그램을 작은 독립된 프로그램의 조합으로 보자
레고 블럭
스몰토크 : 메시징
생물의 세포
17. 패키지Package
디렉토리
이름 영역Namespace
모듈 : 응집의 단위
기본 가시성
이름이 없어 잊혀진 존재
package-private (또는 package-protected)
public < protected < package-private < private
캔트백Kent Beck과 에릭 감마Erich Gamma의 가시성 토론
은익 정보 단위 테스트
18. 내부 클래스Inner Class
클래스 = 파일 원칙 위배 (자바 1.1에서 추가)
패키지
클래스
내부 클래스
메서드
블럭
19. 열거형Enum
C++에서 일부러 가지고 오지 않았던 특징
Java Enum = Class = Type Safe
이름 영역Namespace이 기본 제공
설계 패턴 중 상태 패턴State Pattern 적용 가능
지네릭Generics
C++(template)에서 유보한 특징
알고리듬이 처리할 타입을 사용시에 지정
코드 재사용 기술
Object는 안녕
하지만 복잡한 상황이 생기기도...
20. By Jean-Michel BAUD (CC BY-NC-SA 3.0)
http://images.cdn.fotopedia.com/7dctrd1a20m9m-hiXb-5pBiH4-hd.jpg
JVM
3. 아키텍처 중림성과 이식성
4. 고성능
5. 인터프리터, 쓰레드, 동적
21. 인터프리터Interpreter
자바는 인터프리터 언어
아키텍처 중립성, 이식성
동적 로딩 & 바인딩 : 클래스 로더
파이선과 유사한 실행 구조
.java → .class → JVM
.py → .pyc(or .pyo) → PVM
UCSD Pascal(UCSD p-System, 1978)이 모델
자동 메모리 관리Garbage Collector
Lisp에서 나온 개념
신뢰성 향상
클래스와 메모리 관리 분리 - 순수한 객체
메모리 누수 문제 경감
성능 혁신의 핵심
22. 리플렉션
코드의 메타데이터를 다루는 기술
메타데이터 : java.lang.Class, java.lang.reflect.Constructor, java.lang.reflect.Field,
java.lang.reflect.Method
interface Walkable { void walk(); }
interface Swimmable { void swim(); }
interface Quackable { void quack(); }
…
as(Walkable.class, p).walk(); //OK, person has walk() method
as(Swimmable.class, p).swim(); //OK, person has swim() method
as(Quackable.class, p).quack(); //Runtime Error, person does not have quack() method
...
static <T> T as(Class<T> t, final Object obj) {
return (T) Proxy.newProxyInstance(t.getClassLoader(), new Class[] {t},
new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
return obj.getClass().getMethod(method.getName(), method.getParameterTypes())
.invoke(obj, args);
} catch (NoSuchMethodException nsme) { throw new NoSuchMethodError(nsme.getMessage());
} catch (InvocationTargetException ite) { throw ite.getTargetException(); }
}
});
}
Java duck type 예:
- 위키 백과 에서
23. 메타 프로그래밍Meta Programming
다른 프로그램을 생성하거나 조작하는 프로그램을 작성하는 행위
* 선행 처리
예) AspectJ
* 컴파일러 확장
APT(Annotation Procession Tool) &
Pluggable Annotation Processing API (JSR 269)
예) Lombok
* 리플렉션 | 바이트 코드 생성/조작
예) Spring Framework DI + AOP
“It is about programming at the meta level, that is about changing your interpreter or changing how code is compiled”
- 랄프 존슨Ralph Johnson
24. 다 언어 프로그래밍Polyglot
JVM은 Java만의 VM이 아니다.
Byte code라면 원천을 따지지 않고 실행
80:20 (또는 80:10:10) & 도구의 법칙
DSL
위키 백과 JVM 언어 목록
http://en.wikipedia.org/wiki/List_of_JVM_languages
Clojure, Groovy, Scala, Kotlin, JRuby, Jython, Rhino 등 90여개
Java 공식 지원
JSR 292: Supporting Dynamically Typed Languages on the Java Platform
JSR 232: Scripting for the JavaTM Platform
"It's not the progress I mind, it's the change I don't like".
- 마크 트웨인Mark Twain
27. 자바는 관리자가 좋아하는 언어?
There are heavier-weight object-oriented languages and the elephant in the room is sort of Java, you can't really make a list of modern languages without talking about it. Java is sort of the Cobalt of the 21st century, I think. It's kind of heavyweight, verbose, and everyone loves to hate it, though not everyone will admit that. But managers kind of like it because it looks like you're getting a lot done, you know, if 100 lines of Java code accomplish a task, then it looks like you've written 100 lines, even though in a different language, it might only take 5 lines. You know, it's like, you know, you can eat a 1-pound steak or you can eat, you know, 100 pounds of shoe leather and you feel a greater sense of accomplishment after the shoe leather, but, you know, maybe they're some downsides
- 래리 웰Larry Wall
30. 언어 확장 : Library
자바는 언어적 한계를 설계로 해결하도록 합니다. 그래서 좀 수다스럽고 번거롭지만 지금까지는 21세기의 코볼 역할을 잘 하고 있어요. - 박성철
Calendar now = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Set<Calendar> set = new LinkedHashSet<Calendar>();
for (String element : list) {
if (element != null) {
try {
date = dateFormat1.parse(element);
} catch (ParseException e) {
throw new SomeException(e);
}
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(date.getTime());
if (!calendar.after(now)) {
set.add(calendar);
}
}
}
Set<Calendar> set = Op.on(list).toSet().forEach().exec(FnString.toCalendar("dd/MM/yyyy")).get();
막 코딩
OP4j 사용
31. 구조 재사용 : 프레임워크
투기성 개발에 지나치게 빠지면 소프트웨어 건강에는 해롭다. 최악의 형태가 프레임워크다! 원래 나쁜 의도였던 건 아니지만, 투기성 개발의 병증을 분명히 보여주는 존재다. 자바는 다른 어떤 언어보다 특히 병세가 심하다. - 닐 포드Neal Ford
프레임워크의 진화
1. 프레임워크는 실제로 애플리케이션을 구축하기 위해 반복적으로 적용 가능해야 한다.
2. 성공적인 프레임워크를 만들기 위한 최선의 접근 방법은 프레임워크를 염두에 두지 않는 것이다.
3. 프레임워크의 추상 클래스 및 인터페이스의 목록, 이들 간의 관계는 사전 설계가 아닌 경험을 기반으로 해야 한다.
http://aeternum.egloos.com/2640343
Spring Framework!!!
Don Roberts, Ralph Johnson
32. 내게 자바는?
이일민(Toby)
“객체지향으로 인도하는 언어? (딴짓 못하게 다 막고...)”
이상민(집필좋아)
“자바는 계속 진화하는 언어다” & “자바는 밥벌이다?”
차민창(Min Cha)
“자바란 단순하고 깔끔한 언어라고 생각합니다. 단순함과 깔끔함이 장점이지만 한편으로 한계일 수도 있는 것 같기도 하네요.”
황장호(rath)
“엔터프라이즈 환경 (아니 뭐 꼭 기업이라기보다 뭐 좀 진지하게 뭐좀 해보려는) 에서 무난하게 쓸 수 있는 언어중에 제일 자료도 많고 툴도 많고 쉽고 제일 쉬운게 자바같아요.”
“로우레벨도 아니고 하이레벨도 아닌데, 어쩌다보니 현실에선 로우레벨이 된... 좀 로우한 감이 많아서 노동은 많지만, 그래도 "그러한" 요구사항들을 충족하면서도 쉬운.”
김해영(geekinside)
“딸을 유치원에 보내주는 고마운 언어”
33. 공식 자바 정의?
The Java programming language is a general-purpose concurrent class-based object-oriented programming language, specifically designed to have as few implementation dependencies as possible.
자바 프로그래밍 언어는 범용 병행 클래스 기반 객체 중심 프로그래밍 언어다. 특히 가능한 별다른 조건 없이 다양한 환경에서 동작하도록 설계 되었다.