Re: [Pharo-users] type checking in Smalltalk
On Thu, Mar 30, 2017 at 5:04 PM Marc Hanisch via Pharo-users < pharo-users@lists.pharo.org> wrote:
Hello,
I have a question which is more related to software engineering than to Pharo, but I hope that someone can give me an useful hint ;-)
Thanks for any advice :-) Marc
There are three schools of thought Static programming , Dynamic programming and Hybrid Programming *School of Static Programming * The school of Static Programming which has been originating from compiled languages (turn code from source code to machine code before execution) it follows a static approach to the code. This means everything is clearly predefined, planned ahead and follows strict rules. *Pros: * 1) because compilers have specific code that its intentions are clear its much easier for them to optimize performance, hence code tends to run much faster eg C code tends to be 100s to 1000s times faster than Python code 2) Certain bugs can be captured at compile time which makes code safer to deploy to client. The compiler usually can capture such bugs and display relevant warning and errors again because the compiler is more strict to what goes in and what gets out. *Cons:* 1) Changing code on the fly, while the code runs can be notorious hard to do because of these restrictions. This means it does not work well with coders that love to experiment and try new ideas on the fly. 2) Finding bugs also can be harder because of these restrictions, the coder cannot easily change code on the fly on execution and generally the programming language is much less forgiving not only when coding but also when trying to inspect code and debug it. 3) Overall design can be quite ugly in the shake of increased performance and safety and that may affect the design of code as well *School of Dynamic Programming* The school of Dynamic Programming originates from interpreted languages , though modern implementations have compilers that compile source code to byte code and an interpreter that converts byte code to machine code on execution. There is no need for planning ahead in dynamic coding, instead dynamic coding works on the basis of abstractions and its proud to be the father and mother of OOP. OOP is an abstraction based , dynamic coding workflow that dominates dynamic language and even modern statically compiled languages. *Pros:* 1) Code can change on the fly making coding much easier and beginner friendly 2) No need to plan ahead 3) more dynamic workflow also when debugging code that allows to interact and communicate with code real time *Cons:* 1) Performance is sacrificed, thats not obvious for code that executes at once but for code that repeats thousands to millions of times the slow downs depending on the implementation of the language can be anywhere between 10s of times to 1000s of times slower that a static language 2) Using the wrong data / object will not be easily reported beforehand and at times it can be hard to detect such problems. Other bugs can also be hard to be detected even under the use of helping tools that examine and evaluate code because of the generic nature of the code. *Hybrid Programming* Even though static languages give us static programming outside the box and dynamic languages give us dynamic programming outside the box, modern implementation allow for repetitively easily to mix these two workflows. Its also possible for the coder to implement his/her own features with a language. For example C language does not support OOP outside the box, but OOP implementations for C do exist most popular being GObjects used by the GTK+ library C++ and Java although statically typed languages support also more dynamic types through the use of templates and generics Dynamic languages also can come with a variety of tools that perform checks during runtime or even compile time. Also test driven development is very popular for performing this task allowing the coder to create code , launch with a single command thousands of tests and make sure his code passes even more strict guidelines than an average compiler for a statically compiled language. The catch however is that in both cases there are compromises, sub standard implementations and plain weird behavior. *Summary:* *There is no right and wrong, whether we talk about types or other features whether you will follow the dynamic school or the static school is up to you and you preferences.* Both approaches have pros and cons and both will make you waste time while coding. The future however looks more bright and promising for the dynamic school with the rise of AI. Compilers and developer tools in the future may be smarter not only detecting errors and common bugs but actually analyzing coder intentions and even coding philosophies. AI is already used for code analysis but its still on early stage but is none the less our very close future. Funny irony: The most popular scenario for future technology is quantum computing. Hardware by nature is "static" , you have to design it before hand and make sure it works almost perfectly before selling it. This is reflected to the basis of digital architecture where the smaller unit is bit which is always a number and always either 1 or 0. But with quantum computing the bit can inherit quantum properties and be both 1 and 0 at the same time. This will allow in the future for more flexible design of "dynamic" hardware allowing for hardware to also deal with abstractions directly.
if you copy/paste something you should give a reference
On 31 Mar 2017, at 16:40, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
On Thu, Mar 30, 2017 at 5:04 PM Marc Hanisch via Pharo-users <pharo-users@lists.pharo.org> wrote: Hello,
I have a question which is more related to software engineering than to Pharo, but I hope that someone can give me an useful hint ;-)
Thanks for any advice :-) Marc
There are three schools of thought Static programming , Dynamic programming and Hybrid Programming
School of Static Programming
The school of Static Programming which has been originating from compiled languages (turn code from source code to machine code before execution) it follows a static approach to the code. This means everything is clearly predefined, planned ahead and follows strict rules.
Pros:
1) because compilers have specific code that its intentions are clear its much easier for them to optimize performance, hence code tends to run much faster eg C code tends to be 100s to 1000s times faster than Python code
2) Certain bugs can be captured at compile time which makes code safer to deploy to client. The compiler usually can capture such bugs and display relevant warning and errors again because the compiler is more strict to what goes in and what gets out.
Cons:
1) Changing code on the fly, while the code runs can be notorious hard to do because of these restrictions. This means it does not work well with coders that love to experiment and try new ideas on the fly.
2) Finding bugs also can be harder because of these restrictions, the coder cannot easily change code on the fly on execution and generally the programming language is much less forgiving not only when coding but also when trying to inspect code and debug it.
3) Overall design can be quite ugly in the shake of increased performance and safety and that may affect the design of code as well
School of Dynamic Programming
The school of Dynamic Programming originates from interpreted languages , though modern implementations have compilers that compile source code to byte code and an interpreter that converts byte code to machine code on execution. There is no need for planning ahead in dynamic coding, instead dynamic coding works on the basis of abstractions and its proud to be the father and mother of OOP. OOP is an abstraction based , dynamic coding workflow that dominates dynamic language and even modern statically compiled languages.
Pros: 1) Code can change on the fly making coding much easier and beginner friendly 2) No need to plan ahead 3) more dynamic workflow also when debugging code that allows to interact and communicate with code real time
Cons:
1) Performance is sacrificed, thats not obvious for code that executes at once but for code that repeats thousands to millions of times the slow downs depending on the implementation of the language can be anywhere between 10s of times to 1000s of times slower that a static language
2) Using the wrong data / object will not be easily reported beforehand and at times it can be hard to detect such problems. Other bugs can also be hard to be detected even under the use of helping tools that examine and evaluate code because of the generic nature of the code.
Hybrid Programming
Even though static languages give us static programming outside the box and dynamic languages give us dynamic programming outside the box, modern implementation allow for repetitively easily to mix these two workflows. Its also possible for the coder to implement his/her own features with a language.
For example C language does not support OOP outside the box, but OOP implementations for C do exist most popular being GObjects used by the GTK+ library
C++ and Java although statically typed languages support also more dynamic types through the use of templates and generics
Dynamic languages also can come with a variety of tools that perform checks during runtime or even compile time. Also test driven development is very popular for performing this task allowing the coder to create code , launch with a single command thousands of tests and make sure his code passes even more strict guidelines than an average compiler for a statically compiled language.
The catch however is that in both cases there are compromises, sub standard implementations and plain weird behavior.
Summary:
There is no right and wrong, whether we talk about types or other features whether you will follow the dynamic school or the static school is up to you and you preferences. Both approaches have pros and cons and both will make you waste time while coding.
The future however looks more bright and promising for the dynamic school with the rise of AI. Compilers and developer tools in the future may be smarter not only detecting errors and common bugs but actually analyzing coder intentions and even coding philosophies. AI is already used for code analysis but its still on early stage but is none the less our very close future.
Funny irony:
The most popular scenario for future technology is quantum computing. Hardware by nature is "static" , you have to design it before hand and make sure it works almost perfectly before selling it. This is reflected to the basis of digital architecture where the smaller unit is bit which is always a number and always either 1 or 0. But with quantum computing the bit can inherit quantum properties and be both 1 and 0 at the same time. This will allow in the future for more flexible design of "dynamic" hardware allowing for hardware to also deal with abstractions directly.
On 31 Mar 2017, at 19:38, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
On Fri, 31 Mar 2017 at 19:13, Sven Van Caekenberghe <sven@stfx.eu> wrote: if you copy/paste something you should give a reference
I did not copy paste anything, 100 % mine. What part you think it's copy ?
Ah, sorry then, the formatting seemed to suggest it came from somewhere else. BTW, I don't think the hybrid part is a real thing. Although I understand that static typed languages like C, C++, Java and so many others have their place and use, people in those languages spend an awful amount of time and code dealing with the types they love so much. The modern static languages with all their magic are even worse. And even in a nice static typed program that compiles with no warnings, there are still dynamic errors lurking everywhere. The world cannot be defined in a static way. The dynamic type errors that you get in Pharo during development are 95% plain logic errors, once you fix those and write some unit tests, a Pharo program is just as stable and reliable as anything else that is well written, tested and debugged. And I love Igor's "Don't ask, tell" idea - right on target. Anyway, that is my personal opinion, I don't want to convince you. Sven
Hehe yeah I love nice formatting :) You don't need to convince me , I prefer coding dynamically Ironically enough is the static that is not a real thing anymore. I am coding C++ and Unreal uses templates for pretty much everything. Templates the equivalent of dynamic types, kinda. However when performance is concerned anything dynamic must go, which in C++ means templates and smart pointers. One for dynamic types and the other for dynamic memory management. Generally however templates and generics are super popular and coders are frowned upon if they do not use them because falling back to pure static coding is considered bad coding practice. C++ is on route of becoming even more hybrid, the new hot potato being modules a replacement to header files , similar to Python modules. It was to be included in the next iteration of C++ but was postponed. Probably will get included in the one after the next. In Python a module is a source code file that is treated as an object. So a global variable is equivalent to class variable, the source file being the class. If the module is a package (file folder) then it's class variables are the sub modules. Nowadays people use static languages not because they want to but because the have to for legacy code and performance reasons. Still modern projects usually mix dynamic with static languages. The static plays the role of the kernel providing high performance the dynamic the role of easy to use , beginner friendly, scripting interface. Java and C# support out of the box any dynamic language out there. So the lines nowadays are extremely blurry. It's 2017 , great time to live in when you can choose among so many choices. On Fri, 31 Mar 2017 at 21:35, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 31 Mar 2017, at 19:38, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
On Fri, 31 Mar 2017 at 19:13, Sven Van Caekenberghe <sven@stfx.eu> wrote: if you copy/paste something you should give a reference
I did not copy paste anything, 100 % mine. What part you think it's copy ?
Ah, sorry then, the formatting seemed to suggest it came from somewhere else.
BTW, I don't think the hybrid part is a real thing.
Although I understand that static typed languages like C, C++, Java and so many others have their place and use, people in those languages spend an awful amount of time and code dealing with the types they love so much. The modern static languages with all their magic are even worse. And even in a nice static typed program that compiles with no warnings, there are still dynamic errors lurking everywhere. The world cannot be defined in a static way.
The dynamic type errors that you get in Pharo during development are 95% plain logic errors, once you fix those and write some unit tests, a Pharo program is just as stable and reliable as anything else that is well written, tested and debugged.
And I love Igor's "Don't ask, tell" idea - right on target.
Anyway, that is my personal opinion, I don't want to convince you.
Sven
On Sat, Apr 1, 2017 at 2:34 AM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 31 Mar 2017, at 19:38, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
On Fri, 31 Mar 2017 at 19:13, Sven Van Caekenberghe <sven@stfx.eu> wrote: if you copy/paste something you should give a reference
I did not copy paste anything, 100 % mine. What part you think it's copy ?
Ah, sorry then, the formatting seemed to suggest it came from somewhere else.
BTW, I don't think the hybrid part is a real thing.
Although I understand that static typed languages like C, C++, Java and so many others have their place and use, people in those languages spend an awful amount of time and code dealing with the types they love so much. The modern static languages with all their magic are even worse. And even in a nice static typed program that compiles with no warnings, there are still dynamic errors lurking everywhere. The world cannot be defined in a static way.
The dynamic type errors that you get in Pharo during development are 95% plain logic errors, once you fix those and write some unit tests, a Pharo program is just as stable and reliable as anything else that is well written, tested and debugged.
And I love Igor's "Don't ask, tell" idea - right on target.
This would make a good name for a book on OO. cheers -ben
Anyway, that is my personal opinion, I don't want to convince you.
Sven
On 31 March 2017 at 21:34, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 31 Mar 2017, at 19:38, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
On Fri, 31 Mar 2017 at 19:13, Sven Van Caekenberghe <sven@stfx.eu> wrote: if you copy/paste something you should give a reference
I did not copy paste anything, 100 % mine. What part you think it's copy ?
Ah, sorry then, the formatting seemed to suggest it came from somewhere else.
BTW, I don't think the hybrid part is a real thing.
Although I understand that static typed languages like C, C++, Java and so many others have their place and use, people in those languages spend an awful amount of time and code dealing with the types they love so much. The modern static languages with all their magic are even worse. And even in a nice static typed program that compiles with no warnings, there are still dynamic errors lurking everywhere. The world cannot be defined in a static way.
The dynamic type errors that you get in Pharo during development are 95% plain logic errors, once you fix those and write some unit tests, a Pharo program is just as stable and reliable as anything else that is well written, tested and debugged.
And I love Igor's "Don't ask, tell" idea - right on target.
Hey, hey.. These words, originally, definitely are not mine.. It is something i learned, being among wise people of smalltalk family.
Anyway, that is my personal opinion, I don't want to convince you.
Sven
-- Best regards, Igor Stasenko.
participants (4)
-
Ben Coman -
Dimitris Chloupis -
Igor Stasenko -
Sven Van Caekenberghe