20 ms·
Is there a snippet of example code to look at? I browsed the pharo.org website, but couldn't find an example to give me a taste. I even tried googling "pharo ex
by edmundhuber 9y ago
Is there a snippet of example code to look at? I browsed the pharo.org website, but couldn't find an example to give me a taste. I even tried googling "pharo example" and with a brief look at the results didn't find an example.
Today, there are hundreds of programming languages competing for attention. It is in your interest to put an example front and center of why one should spend time looking into yet another programming language.
- protomyth 9y agoYou can download whole books with Pharo examples http://files.pharo.org/books/ http://files.pharo.org/books/
- Y_Y 9y agoMaybe a whole book is overkill. When I'm checking out a new language I like to see a couple of short, accessible examples to get a feel for the language. Like this clock[0]: Time now asValueHolder in: [ :clock | [ [ 1 second asDelay wait. clock value: Time now ] repeat ] fork. clock inspect ] [0] https://medium.com/concerning-pharo/elegant-pharo-code-bb590f0856d0 https://medium.com/concerning-pharo/elegant-pharo-code-bb590...
- SomeHacker44 9y agoI have found that O'Reilly's "Nutshell" books tell me everything I need to know when learning most new languages, and then some. For some languages, though, they have features that might make this sort of overview challenging if you do not understand the core paradigms (such as Rust's ownership concepts).
- IshKebab 9y agoNot really: https://rustbyexample.com/ https://rustbyexample.com/ There's no excuse for not having any examples of a programming language on that programming language's home page. Here are some languages that do it right: https://ceylon-lang.org/ https://ceylon-lang.org/ https://www.dartlang.org/ https://www.dartlang.org/ https://golang.org/ https://golang.org/ https://www.rust-lang.org/en-US/ https://www.rust-lang.org/en-US/ Notice there at least one example (often executable!) on the home page of each site. I'm actually pleasantly surprised how well all those sites do. Most smaller programming languages get this bit horribly wrong.
- igouy 9y ago> There's no excuse for not having any examples of a programming language… https://pharo.org/ https://pharo.org/ I see examples on their home page.
- tom_mellior 9y agoThere is an image showing many IDE windows, one of which does actually show code you would find if you already knew what the code you were looking for looked like. You could still not copy and paste it. Then there is a textual example consisting of two lines of Posix shell, embedded in which is indeed a tiny Pharo program in a string. The parent's point mostly stands. (Oh, and there is a frickin' popup for a frickin' email newsletter hiding the content.)
- igouy 9y ago> You could still not copy and paste it. Why would you copy and paste code before you'd done anything more than glance at a language home page? Perhaps the better comparison is with some other languge IDE: https://www.jetbrains.com/go/ https://www.jetbrains.com/go/
- IshKebab 9y agoYeah maybe if Pharo was just a Smalltalk IDE, but apparently it is a distinct language.
- igouy 9y agoMore like a distinct Smalltalk language implementation. For decades, different Smalltalk language implementations have introduced novel things while still being recognizably implementations of Smalltalk. I haven't been able to find a clear statement of language differences between Pharo and other Smalltalks. The closest thing I've come across is this statement of intent: "We want to stress the fact that Pharo will certainly derive from ANSI and other Smalltalks. We will not change for the sake of change. What we want to say is that if there is something that can be improved but does not conform the ANSI Smalltalk, we will do it anyway." Perhaps a Pharo expert can clarify?
- deleted 9y ago[deleted]
- otakucode 9y agoI've always found the 'image' environment to be far more interesting than the language of Smalltalk itself. If you do find just code snippets, you're missing out on what I, at least, see as the most significant feature of the whole thing. The way it goes about defining the code is clunky, but the overall structure of 'images' and the workflow involved with them is fascinating. I could easily see something similar being the future of containerization when implemented in some other language.
- jhbadger 9y agoLots of other languages work/worked that way. System images were a common feature of many Lisp systems and some Forth systems in the 1980s.
- agumonkey 9y agoAlso self
- deleted 9y ago[deleted]
- throwaway7645 9y agoThe image is just one reason why compiling an SBCL executable results in such a large file. It has state as well...or so I've read.
- deleted 9y ago[deleted]
- flavio81 9y agoWhen you load Lisp files, they get compiled; this compilation is saved as binary files (often, "fast load files"), that do what it says on the tin: They allow you to, next time, load your program really quickly. Now, your program also has state. If you want, you can also save the state of the program (i.e. by using the "save-lisp-and-die" command). This can create large files, because this allows you not only to quickly "run" the program again, but to also run it with the same state that it had when you did the save.
- tom_mellior 9y agoThe language is a dialect of Smalltalk, so looking for Smalltalk examples might be more productive. There are some useful examples at http://wiki.c2.com/?SmalltalkExamples http://wiki.c2.com/?SmalltalkExamples, such as (double quotes are comments): " this sends a message to the transcript " Transcript show: 'hello world '. " compute 10 factorial and send the result to the Transcript " Transcript show: 10 factorial. " now, try this: " Transcript show: 100 factorial. " a loop (the timesRepeat-method evaluates its argument n-times)" 10 timesRepeat: [ Transcript show:'hello'. Transcript cr. ]. " another loop " 1 to: 10 do:[ :i | Transcript show:i. Transcript show:' '. Transcript show:i sqt. Transcript cr. ]. " looping over a collection " #('a' 'b' 'c' ) do:[:each | Transcript show: each. Transcript cr. ].
- nobleach 9y agoI always find LearnXinYminutes to be a cool "quick look" at a language syntax: https://learnxinyminutes.com/docs/smalltalk/ https://learnxinyminutes.com/docs/smalltalk/
- bulutsuzku 9y agoThe real experience is using the tools in the image for a couple of days... only then you'll have eureka moment
- mbil 9y agoHere's a "Pharo Cheat Sheet" PDF from pharo.org http://files.pharo.org/media/pharoCheatSheet.pdf http://files.pharo.org/media/pharoCheatSheet.pdf
- gnaritas 9y agoSmalltalk is not "yet another programming language"; Smalltalk is the language all those other OO programming languages copied. You should look into it because it is the source of the object oriented paradigm and it'll make you a better OO programmer in all of those other languages.
- lucozade 9y agoSorry to be that guy but a lot of what we've come to know as OO is more directly descended from Simula because that was a big inspiration for Bjarne. As such, C++, Java and C#, which constitute a significant chunk of OO programming, are probably better thought of as descended from Simula (and C). There's a clearer lineage to the likes of Ruby and Objective-C, and to a lesser extent Javascript and Python. I would definitely concur regarding looking into it, it definitely makes you think about things in a different way. Whether or not it makes one a better programmer, I can't say. I only programmed professionally in it for a relatively brief time and it was a hugely frustrating experience. I was glad to get out of it. In the sense that it made me understand that a programming environment has a big influence on how well a codebase can scale then, yes, I learnt loads. But that was because it really wasn't very good at scaling without an awful lot of TLC. I moved onto a Java application which was bliss by comparison (ironically, given its reputation for classpath hell etc). This was some years ago mind so the state of the art of Smalltalk has, I'm sure, moved on.
- e12e 9y ago> what we've come to know as OO is more directly descended from Simula True, what is often called object oriented is often more about classes and inheritance, and less about (instantiated) objects communicating via messages. It's really rather odd how Smalltalk, Strongtalk and Self could be major influences behind the jvm, jre and java - when you look at were java ended up... [ed: on the other hand if you start with Self and add Algol syntax you get javascript - maybe it makes sense that Strongtalk and Algol makes java...]
- gnaritas 9y agoWell, I'll be that guy, I don't care what inspired Bjarne, Simula created the idea of an object, but it wasn't until Smalltalk that object orientation became a paradigm: Smalltalk created OO, not Simula. Object != Object Orientation, Simula was and is a procedural language with objects bolted on after the fact. C# is a Java clone so I need only address your Java misstatement, Java was far more influenced by Objective C and Smalltalk than by C++ as far as OO goes; it looked to C++ only for syntax. Java is semantically a direct descendant of Smalltalk and was inspired directly by Smalltalk as both of its creators knew Smalltalk and Objective C (another Smalltalk derivative). [1] Direct from the co-creator of java not to mention that Gosling himself was a Smalltalker. So no, what we know as modern OO came directly from Smalltalk. [1] https://cs.gmu.edu/~sean/stuff/java-objc.html https://cs.gmu.edu/~sean/stuff/java-objc.html
- shalabhc 9y agoThis may not be immediately apparent, but I discovered that Smalltalk did not fit into the 'programming language' concepts in my head. I think of a typical bytecode VM language as [source code] -> [interpreter] -> [running program] Instead Smalltalk is more like [running program] + [auto persistence] + [editing tools] So you don't modify large gobs of source code files, you modify the running program from within - aka live editing. The running program consists of a network of interconnected objects. You use the textual syntax also - but only to modify parts of the already live program (e.g. you could 'install' a new method on an existing class object). You inspect the running program using graphical browsers (typically also part of the same program) - and everything you modify is live immediately. The syntax of Smalltlak is interesting (can be seen here https://en.wikipedia.org/wiki/Smalltalk#Syntax https://en.wikipedia.org/wiki/Smalltalk#Syntax). But the more interesting aspects of the experience are the live editing, working with network of objects, hybrid text/non-text ways of modifying these objects, etc.
- vvdcect 9y ago> [running program] + [auto persistence] + [editing tools] How do you use TDD when coding like this?
- stcredzero 9y agoHow do you use TDD when coding like this? There were some utilities that let you run the tests at the push of a button.
- bertfreudenberg 9y agoKent Beck invented TDD while programming in Smalltalk. You first extend the environment with tests, then add the code to make them green. All without ever having to restart the "program".
- e12e 9y agoI admit the question made me smile, but it's a great question. I found these short videos, that are maybe the shortest possible answer (less than 3 minutes, I just watched them w/o sound, auto-captioned): Pharo: https://youtu.be/ymITEeAOtEA https://youtu.be/ymITEeAOtEA Cinecom Smalltalk: https://youtu.be/mXoxfmcDDJM https://youtu.be/mXoxfmcDDJM
- throwaway7645 9y agoI've asked the same things many times, but that's largely irrelevant. Smalltalk is just different. I'm more of a Vim/Awk/Python guy, but Smalltalk is quite beautiful in it's own way and images are really cool.
- notduncansmith 9y agoI love this site for quick syntax intros: https://learnxinyminutes.com/docs/smalltalk/ https://learnxinyminutes.com/docs/smalltalk/