Nope, sorry. Python is an easy, good language. Basic was not popular because it was easy, or even good, it was popular because it was everywhere. JavaScript, for all its warts and foibles, is the new basic. It's easy enough, and it's everywhere.
Python, fwiw, is a better BASIC. It includes a built-in Turtle graphics system and a decent IDE. You can teach loops and draw graphics in just a few lines of code:
And so on. That initial experience has been one of the easiest to teach kids outside of a visual environment like Scratch. Some friends of mine have tried teaching Javascript but it's just frustrating: you have to teach looping with intermediate values and mutation, you have to teach the DOM, and if you want to get turtle graphics... well you have to scour the net for a poor implementation that barely works and teach the <script> tag... you get the idea. It's painful.
The ubiquitousness is a huge advantage. Installing Python on a Windows machine and running programs is not as easy as "just being there." And being able to share your programs with a URL has so much potential... potential I feel is wasted by the walled-garden nature of code and presentation in modern browsers, crappy developer tools, and a lack of usable built-in batteries.
Python will never be as ubiquitous as Javascript. But it's pretty close: OS X includes a Python distribution as do most Linux distributions. Windows is the place where it hurts. I don't know if it could be, "the new BASIC," but it could certainly be a better one.
(This coming from someone who has fond memories of BASIC on the Apple IIc and Amiga 500).
The justifications you give for that make it seem like JavaScript is the new BASIC while Python is a better Logo (less ubiquitous language that is structurally better for pedagogy, though disadvantaged simply by being less ubiquitous.)
> Windows is the place where it hurts.
And still the dominant desktop platform. Which would be less important, as mobile eclipses desktop, if mobile environments included a standard, bundled interpreter that users could easily access for tinkering, but that's very much not the case.
> The justifications you give for that make it seem like JavaScript is the new BASIC while Python is a better Logo (less ubiquitous language that is structurally better for pedagogy, though disadvantaged simply by being less ubiquitous.)
You quoted me -- I said Python is a better BASIC; implying that while Javascript might be the new BASIC, Python is better at being one. Let that be clear!
The turtle graphics module is only one example. Python ships with plenty of other useful libraries and tools that make it great for experimenting and learning.
Let's not sell BASIC short -- its success wasn't just about ubiquity. It was designed by John G. Kemeny and Thomas E. Kurtz to help Dartmouth students write programs to do work. They thought it was a shame more people didn't know how to program computers. I think they succeeded with their original goals[0].
Python has the advantage of being invented some twenty-five-ish-odd years later. After a couple decades of development it has grown into a language and system that far surpasses BASIC in its ability to teach people how to write programs and be productive right away. It's better than BASIC and teaching more people how to program, imho.
Javascript is definitely more ubiquitous. I wish it was easier to use and came with better libraries and things in the browsers. It's everywhere but it's not easier to use than Python. And Python's not as obscure as you'd think... don't discount the market share of Apple + Linux systems combined. If Windows jumps on board and packages a Python distribution: watch out (as if, but hey).
The new BASIC... jury is still out for me. I like both languages just fine. Javascript is a little bit more ubiquitous but it's not any easier to get into in my experience; at least not with modern browsers hiding the web console and providing little in the way of built-in code editors (and to say nothing of the DOM getting in the way of everything from drawing graphics to the screen to accessing the keyboard).
> Frankly i fear that the tech world is getting less and less tinker friendly decade by decade.
That's kind of a constant in the tech world with every technology; I remember as a kid old timers making that complaint about radios. For a long time, its been made about cars. And, yeah, more recently, personal computers.
With radios it has been that moving for tubes to transistors to ICs has upped the minimum tools needed to get anything done.
With cars emission laws and such had introduced something similar via computerized injection etc.
But with computers etc the complexity was there for the start, but the tinker hostility has, IMO, come from a change in business from selling hardware to the hardware being a terminal for "content". Thus the tinkering hostility comes from propping up DRM under the guise of "security".
Well well, thats nifty. I recall playing with something similar on a old school computer using basics.
BTW, a team at Intel put Python into GRUB recently. And IMO they produced something that strongly reminded me of firing up something akin to the C64 and be greeted with a basic prompt.
Also, i swear i recently read about someone making a python enabled shell. Meaning that you could mix shell commands and python code on the same input. Had some small issues where python syntax overlapped with command switches or something.
I didn't start learning to program because I wanted to program, I learned to program because I saw a file called GORILLA.BAS in one of the folders on my MS-DOS machine.
Once I figured out I could open it in QBASIC and just press F5.... that was it... I would be a programmer for my next 20+ years and counting.
EDIT:
I would also like to point out how important the QBASIC IDE was as well. F5 to run. Put your cursor over any function and press F1 and it gave you a full description. It fixed your syntax (somewhat) as you coded too. It would highlight the line where the error happened. It literally held your hand through creating whatever you could dream up at the time.
My experience almost exactly mirrors yours. When I was in grade school, there was a shared computer in the hallway outside the eighth-grade classroom, and if the teachers trusted you enough, you could stay in and use it instead of going outside for recess. A few buddies and I would congregate around the PC and play Gorillas. And once we figured out how to edit the source code and do weird things with gravity, or cause tremendous banana explosions, we were hooked! (And, I think several of us went on to become programmers.) It was kind of like the thrill you'd get when you used Game Genie on an NES game for the first time.
I think that's the best way to get kids into coding, not some forcefed programming gui, but "Hey, here's a game you can play in class!" and then just give suggestive nods towards the source code and "what happens if you change this?" Next thing you know, kids are all trying to one up each other's programming, pulling apart the source and putting it back together without realizing that they're programming. I got into electronics by pulling apart toys and looking what makes them tick, there's no reason the same couldn't be done for code.
Yes, thank you, I almost forgot about how it really began with tweaking the code for the game itself! Great memories. Reminds me of how so many old games had .dat files (or something similar) that you could mess with initial settings or screw with the sounds.
This gives me a good idea for teaching my kids to program. Why start from scratch? I'm going to give them a game like this, with code, and see if they can do something crazy with it!
P.S. For me, I became the computer lab teacher's assistant in order to skip recesses or other activities in middle school. Fixed printers, made .bat file menus, good times.
I recall a friend doing something similar with mobs for Quake 1. The game used its own dialect of C, iirc. And it was possible to decompile the relevant files. So after some time he started modifying mods.
That Quake 2 and later required Visual-C++ and such kinda took the spark out of the creative mods, as the entry price became too high.
For instance Quake 1 had a "flight sim" of sorts that was basically done by one guy using Quake-C and some simple, freeware, modeling tools.
There was an attempt at making a successor for it in Quake 2, but even with a larger team etc it basically ran out of steam thanks to the complexities involved etc.
Basic was popular because that was all you had. It was everywhere because computers shipped with it and other programming languages were simply prohibitively expensive. And so many of those working with computers at the time would roll their own assemblers to escape from BASIC (slow, inefficient use of memory).
Agreed that Javascript is the new BASIC, Python needs to be installed, just like BASIC javascript is already present on your computer whether you like it or not.
> BASIC was the de facto operating system for most personal computers.
The de facto OS shell for most personal computers before IBM compatibles and DOS took over (it still came with BASIC, but it was no longer in a shell-equivalent role.)
Agreed. Callback hell in JavaScript is reminiscent of the GOTO-hell we used to suffer as BASIC programs grew larger. Like you said, with all its problems it was still ubiquitous and practical. So is JavaScript.
console.log("Hello") is not more complicated than print("Hello").
For the callbacks it is actually possible to not use them. See how to: http://www.xul.fr/javascript/no-callback.php (and it is even very simple). That is just a matter of style.
JavaScript is great because it is so versatile. You can make command-line programs (using node), server programs (node) and even native apps (using react native) using JavaScript. However JavaScript is not a well-designed language and for that reason it is not a good first language. That's why things like TypeScript exist and it makes OOP easier among other things. ES6 is a big improvement too. In the long run I think JavaScript will win because it is being improved and has huge momentum, but right now Python is the better first language.
If I were a beginner, I'd take BASIC over most of those. BASIC does have warts and having it ubiquitous did help its adoption, but the language itself was "easy to use" for its day. (Perl is pretty good, but BASIC had a two decade head start on it.)
I would definitely agree with you now, but this article was written in 2008. Maybe the landscape was a little different then? But I guess even then, Python wasn't really 'everywhere'.
As a Data Visualization enthusiast, I can say that Processing [0] is a great candidate for an introductory language to introduce programming (and computer science in general).
It is a less verbose subset and superset of Java at the same time, has a solid IDE providing great visual feedback as the code changes and you can introduce real, physical world concepts through classes, polymorphism and what not in a way that doesn't look too abstract. In fact, many visual arts courses have successfully introduced programming to an audience of designers and artists that are usually not fond of it.
Installing it is a 100MB download away and you can even make use of the universal aspect of javascript through ProcessingJS [1] or p5.js [2], or even through Python [3].
+1 For Processing. I was talking to a friend about that the other day and used this very same phrase "Processing is the new Basic".
You can't talk about the joy of learning computers without having a very, very easy way to produce simple graphics. Processing delivers on that, it doesn't even require a main().
Imagine introducing programming to kids at the same time they learn the cartesian coordinate system, or allowing them to grasp f(x) = sin(x) visually through experimentation. And pointed somewhere else on this thread, you can publish your work using the HTML exporter - no need for other people to install languages, open the console, etc, etc...
As much as I love python now for scripting and other simple tasks now, Processing was the first "real" programming platform I encountered (after learning the forgive the pun basics with BASIC on my trusty TI-89). It was simple to use, and introduced me to OOP, which blew my mind coming from TI-BASIC. I would recommend Processing to anyone that asks about getting started in programming.
Yesterday I had to explain to my 9-year-old daughter that the bug in her Python script was due to the fact that she indented with a tab and not four spaces. Trying to publish her program so that her friends could use it was a nightmare (it's a console app).
It's 2015 and we have the brightest minds working on this stuff and it's all shit.
There are linters to handle syntax issues like tabs for spaces. Furthermore every text editor I've ever used has supported automatic handling of tabs/spaces and how many to indent.
Not sure on publishing but maybe try packaging it properly (I believe python apps can be wrapped into .exe files) and putting the package into something like dropbox folder?
That there are right and wrong editors for Python is exactly the point. A 9-year-old could understand BASIC 30 years ago without having to worry about choosing the "right" editor to handle different types of blank space.
All is needed is to have editor that can show white spaces (i.e. show tabs differently than spaces, after all those are two different characters).
With that the whole issue with tabs and spaces no longer exists.
BTW if you are copying snippets of code from website "as is" in any language you will have to reformat it to fit your structure. Also if you copy code so often that this is becoming an issue I'm not sure I would want someone like that working for me.
Professional developers are permanently scarred by software environment configuration tooling. It's to the point that when I decide to pick up a new language or technology stack, I dread researching or even picking a way to get my environment set up, dependencies resolved, and my code built and deployed. And it's not because the tooling is bad, but just that there is so much of it, and it's continually being re-written to add marginally new value.
Beginners benefit from there being a single way of doing things. Competing tooling just leads new developers to waste time early in their careers writing even more tooling, or writing a bunch of scripts and blogs to talk about how they dealt with tooling.
Tooling in JS is going to discourage some potential developers. It's not that bad in Python.
Anecdotally, I recently went back and did some QuickBasic 4.5 programming, and was surprised how decent the experience actually was. I was on a retro kick, and was working backward/up to to doing some IBM PCjr hardware cartridge programming/ROM design. I still have a stack of old programming books from the mid 80's and early 90's and it was great to dust them off and re-read them with a fresh/older set of eyes.
I ended up doing some simple graphics programming on an old 386sx. Using QB for high-level code, and interfacting with some ASM for lower level graphics and data processing, it was actually quite pleasant.
But then, the reference PCjr that I was targeting/experimenting on finally gave up the ghost and died, and I lost interest in hunting down a new one... Poor little guy.
What I took away from the experience is while the tools were more primitive, it wasn't the languages that sucked when I was learning to program in the mid 80's and early 90's as a kid; it was me. I sucked at programming.
Retro programming can be great fun. I dive into it - a little - every now and then. E.g. Turbo Pascal 3, Turbo C 2, Icon, Forth, BASIC even. I think I still have a copy of Delphi 1 on CD - it came as a promo with a UK computer magazine I bought at a roadside newsstand. And used it to write some small apps. Surprisingly the apps worked even on much later versions of Windows than were current when Delphi 1 was released, though of course the widgets looked old-style.
Also fun is exploring offbeat languages (that are not retro). Pike and ElastiC come to mind as ones I've checked out, and there are others.
seems pretty simple. Sure, when you get into async it might confuse young kids (or experienced programmers), but most beginner stuff won't need callbacks.
True, though there are some inconsistencies in the language. For first language it probably makes most sense to use a language that seems to be carefully designed.
When my friends ask me what language they should get started in when they want to learn to program without a specific application in mind, I usually suggest Python for all the reasons the article so convincingly presents. So certainly in one sense it's a good modern BASIC equivalent.
However, I don't think that what made BASIC so magical was just that it was easy -- it was easy and you could make the computer do the things you were interested in. And while the capabilities of Python are vastly greater than BASIC of yore, I think a beginner's expectations of what they should be able to do have grown even more quickly.
These days, typically someone who wants to learn to program wants to do one of two things: (1) make a website or (2) create an app. For a lot of types of sites Python is still a great choice (Flask is definitely one of the easiest frameworks out there to pick up, and I'm actually teaching my wife to program by making a basic Flask app with her). However, for other interests Javascript or even Java or Swift may be more appropriate first languages.
I guess that what I'm trying to say is that the best first language is the one that ignites your imagination with its possibilities, rather than the one that's the absolute easiest to learn.
Very true. It probably can't happen for various reasons, but I would love if windows just folded python 3.2 in as part of the default install.
Python certainly feels, to me, like the most similar language to the old QBasic. Simple syntax, with advanced features that you can use, or not use, pretty robust standard library, not great, but usable IDE built-in (I assume IDLE still comes in the install?)
One of the really cool things about QBasic was that it had support for doing such a wide spectrum of things natively, and easily. In my first semester-long high-school course, we went from Hello World, to doing VGA graphics with the different SCREEN modes and FILL, LINE, etc, making programs that could play christmas carols using the built-in MIDI commands, and doing some animations that relied on some of the old-school page-flipping techniques that we take for granted with modern hardware and APIs.
I don't know of another language that makes it as easy to do all that now. Python with pygame would be a start, but it's still much more complicated to get a window created that you can draw in than it was with QBasic.
>we went from Hello World, to doing VGA graphics with the different SCREEN modes and FILL, LINE, etc, making programs that could play christmas carols using the built-in MIDI commands
I miss these in the new generation of languages. You could do so much cool stuff with swithcing to graphics mode and using pixel, line and circle commands. I was able to write a (1) shooter where you shoot down a plane that moves horizontally across the screen and the projectile was subject to 'gravity'. (2) A program that 'morphs' one outline to another. (3) A wireframe/3d space shooter.
I was able to build all this without the internet, with plain high school math and physics. And I wonder if I was a kid who grew up in todays environment, I would have been able to build the same. I have the internet, but I doubt I would be enticed into making stuff like that, like I was enticed by QBasic. I mean, one minute you are printing multiplication tables, the next minute you are turning individual pixels on/off on the screen. I remember it being a very empowering feeling.
Maybe Python has all these qualities, but it is - different -. If you learn programming with Python, you have to relearn it again to use any other common language, Java, C#, JavaScript etc...
Articles like this remind me of a quote from the German philosopher Arthur Schopenhauer[1] (in the context of Python's great success and proliferation):
To truth only a brief celebration of victory is allowed
between the two long periods during which it is condemned
as paradoxical, or disparaged as trivial.
I remember trying to program some BASIC back in 1st grade, which was 31 years ago. I was terrible at it, but I was hooked.
Fast forward to today: my 4th grader asked me the other day which language he should learn, and I was stumped. I ran through the languages I know well in my head: Java, PHP, Perl, Python, Ruby, Javascript, Go, Swift... Wasn't sure what to tell him. His expectations are fairly high, due to Minecraft and video games and whatever.
So, on one level I agree with the author: Python (or Ruby) is probably the closest to the original feel of BASIC. You can dive into simple statements without wrapping it in a class. You don't need to worry about functional vs. OOP or methods or functions. You can just write some code.
But, as I thought about it, I realized my son already _is_ programming. He's just using Minecraft's red stones. It isn't turing complete, but it has basic input and output.
What I'd love to see is something like Minecraft, but with a more accessible programming environment. There are a few tools out there that do it, but the gap between the visual building experience and the programming experience is way to wide. I want him to click on a block and write 3 lines of code to change the color and give it some behavior.
tl;dr - Minecraft is the new BASIC for most kids today. It just isn't a very good BASIC.
I'd suggest processing for kids starting out. It gives them the visual feedback they need to get hooked. I got a 14yo to build a particle system in < 4hrs and after that he was hooked.
>EDIT: When I say that Python is the new BASIC, I mean it as a compliment, to say that Python is in the best position to become a lingua franca for non-programmers to learn programming.
I think it is much more common for novice non-programmers to look at some HTML/Javascript that they're curious about and then tweak the javascript a little to change the behavior of the webpage. The tweaking may come from copying a stackoverflow.com answer without unerstanding the underlying principles (aka "cargo cult"). However, these humble beginnings act as the gateway to more systematic learning (.e.g read "Java - The Good Parts by D Crockford", etc).
Because of Javascript's pervasiveness[1], it is much more likely for a beginner to hack around with others' Javascript and then eventually write their own .js rather than download Python and start writing .py files.
Those are my personal observations. Do others see total more beginners downloading Python rather than dipping their toes into Javascript?
[1]
google.com search "get started Javascript" ~211 million hits:
I think Python is a great first language to learn. It is well designed and is widely supported, for example Visual Studio 2015 comes with it. The only trouble with Python is the Python 2 vs. 3 situation. Both these versions are being improved. Python 3 is the newer and better language, but a lot of libraries are only available for Python 2. The wxpython library, referenced in this article, is an example.
No, I don't think so. I was going to write a long and detailed post but I have a really full schedule this morning.
I'll just point out that Python suffers from a deployment issue. Getting a web project up and running can be a nightmare (no, using Heroku merely hides the problem...it's still there). Even on the desktop it can get really cryptic and confusing for a newbie. And, of course, releasing and sharing your app is --from the vantage point of a newbie-- just about impossible.
On something like VisualBasic you can package-up and create an installer for your app with one click. Anyone can then install it and end-up with an icon on the desktop they can click and run the app. The "path to exe" is simple.
Again, I don't have time to dig deeper. We love Python and use it extensively for our web (with Django) and desktop work professionally. And, yes, I am teaching my kids programming with Python. But, no, I don't think Python is the new Basic, on more than one front.
I learned Visual Basic 6 as my first language. I appreciated that my application could for the most part run on any Windows machine without a massive framework as a requirement. Don't get me wrong though, I love .NET entirely! I just enjoyed Visual Basic 6, because it felt native, and to some degree was. I still wish there was a native solution with a RAD environment like that, Delphi is nice but the syntax is quite friction filled for a beginner. Nowdays C# is the clear winner, although not yet a native solution and not yet multiplatform without friction.
Edit:
More on topic:
My personal opinion is that scripting languages like Python and Ruby, and for the brave teachers Lisp (Racket, Clojure, etc) make excellent programming languages. Instead of forcing yourself to learn the requirements of C-like languages, you get to focus a lot more on the concepts, and a lot less on syntax issues that I see more than often enough with new students to programming.
I believe up to VB5, then in VB6 it was finally natively compiled. I had projects in VB6 that people would try to decompile, the best they got was Assembly. Unlike .NET which without external tools will give you back almost everything (except of course comments).
Its a bit more nuanced because we are all people who know varying degrees of code and have already "been there," so to speak.
To learn Python I'd argue you'd have to know a bit (read: not much) of the UNIX environment and args before you jumped in, and my difficulty with it in college was that I had only learned from compiled languages with all of the libraries pre-built for me.
However, I would have bypassed all of those difficulties if I had learned how to be a "sudoer" from the beginning.
I think going the HTML --> CSS --> Vanilla Javascript route could possibly get kids coding before they lose their first teeth. Kids are already very savvy with their mobile browsers.
BASIC was more than just the BASIC language (which wasn't particular good), it was the environment and integration with the hardware that made it a successful springboard for countless developers.
Being built into home micros was part of it, but it also included built-in switching video modes, drawing, audio, I/O, even inline assembler (not in all variants, but certainly the better ones). This creates a very effective and accessible learning curve.
Javascript is the closest modern equivalent - but the language and it's API's are too complex. A browser-based BASIC (compiling to Javascript of course), exposing all the above in a sane synchronous manner would be interesting.
> The replacement for BASIC has been clumsy at best. How do we introduce fancy GUIs, graphical animation, and ‘splosions to beginner programmers? Visual Basic? HTML/Javascript? Some random, closed source “4 kidz” programming language whose company will fold in three years? NO!!! You can’t be serious!!!
The link on "No! You can't be serious!" was to Hackety Hack, by _why_the_lucky_stiff. The language was Ruby, not a random, closed-source, "4 kidz" programming language. And it's a good language for teaching.
I believe hello world in ruby is even shorter than python (if that is what counts as a measurement here), since you can just use "p" as short of "puts", so:
It's true that Java needs boilerplate code even for "hello world" but this isn't a real issue and the IDE produces it for you. The general need for more boilerplate is a slight nuisance, which makes languages like Python and Ruby slightly better for getting started. (Though Java's ability to catch compile errors is helpful for beginners... )
One of the included batteries is a built-in Turtle graphics system. A bare Python installation is far better than the BASIC of my day. It's just much more difficult to get into since our machines don't just boot into an interpreter or even ship with one in the case of Windows.
You can still do QBasic though. There is an open-sourced implementation called QB64 [1]. QB64 is also cross-platform that can run on Windows/Linux/Mac/Android.
Javascript doesn't require setting up apache, etc. for a kid to learn like the submission says; you can just use a static html file on your file system or dropbox etc.
edit: ignore the above about apache, missed that that was in the next bullet point about PHP, not javascript
Python doesn't require Apache either. The submission doesn't suggest that it does. It only mentions Apache in reference to PHP.
In face, Javascript _does_ (until Node came along) generally require a browser, and some HTML to go with it. Python gets along just fine as a single file from the command line, much like Basic.
For kids learning programming, browsers are more generally available than commandlines with python installed. Doubly so if they want to share what they make like kids used to do with basic on floppies.
python's problem is that while it goes the distance to make the simplest possible program as simple as possible, simplicity bleeds off very quickly as you add functionality.
The shortest well behaved program, for example, looks like this:
if __name__ == "__main__":
print "Hello World!"
and the shortest program that is strictly equivalent to the java program is closer to this:
class Hello(object):
@classmethod
def main(cls):
print "Hello World!"
if __name__ == "__main__":
print "Hello World!"
Based on my experience, there's a lot people learning python who spend a lot of time at the stage where they "just don't get OO", and my opinion is that the reason is the language is bad at teaching them. It's like a submarine of complexity waiting under the simplified syntax for basic scripting.
Why is this being downvoted? Classes might not be what everybody needs but this pretending that hello world can be written in 1 line is just inviting people to write sloppy code, false advertising is what it is.
In my experience namespace pollution because things are written outside a function is a very common cause of bugs and maintenance problems in production python code. People coming from C/Java/similar think that "if" has scope but it doesn't, only functions do. If i see "main()-code" outside a function during a code review i immediately disregard that whole script.
Any program that actually does something, except just printing hello world, would more likely look like this:
> Classes might not be what everybody needs but this pretending that hello world can be written in 1 line is just inviting people to write sloppy code.
IMV, sloppy unstructured code is a fine place for many (especially very young) programmers to start, and it simplifies the onramp significantly (and, actually, for simple scripts, relatively unstructured code in python is sufficient for lots of real-world uses, too.)
if __name__ == "__main__"
...is the k of thing you need only if you are deliberately designing something to be used as both a script and a library, which there are very good reasons to do for many real world python files, but it certainly is not universally necessary. And using classes for hello world is excessive Java-ism.
IF you are going to use needless classes to do Java-esque hello world in Python, a shorter form that is equivalent to the Java is:
class Hello(object):
@staticmethod
def main():
print "Hello World!"
if __name__ == "__main__":
Hello.main()
Your version:
(1) Unnecessarily uses @classmethod instead of @staticmethod, necessitating an argument to main(). @classmethod and @staticmethod in Python are both related to Java static methods, but @staticmethod is the closest analog for Java static methods that do not depend on static member data. Just doing a one-to-one substitution of Java static to Python @classmethod indicates a lack of understanding.
(2) Doesn't actually call Hello.main() the way the python runtime does, and instead reproduces its function in the if __name__ == "__main__" block.
> Based on my experience, there's a lot people learning python who spend a lot of time at the stage where they "just don't get OO", and my opinion is that the reason is the language is bad at teaching them.
Lots of people learning Java, IME, just don't get OO for a long time, too. Obviously, they have to produce a structure with classes and methods in order to produce anything in Java, but having to use the superficial structure of OO and getting OO aren't the same thing. (If anything, being forced to use its structure for everything impairs understanding of what it is for and how to use it appropriately.)
Java "teaches" its users OOP by forcing it on them. Python provides the tools to get things done without it - that's why the learners "don't get it", because they don't need it, and they don't see it as a solution to a problem (or at least this was the case when I was learning python).
What you have there is un-pythonic. Once you have a good reason to build a class with static methods, it will most likely not look too bad.
This is the one lesson of PHP that seems to be ignored by a lot (most?) new languages. If you want your language to be popular with beginning web programmers, then provide system administrators with a dead simple way to install it. Add package, done. Then make sure it doesn't cause too much trouble or at least upgrades easily.
If it takes almost no effort to install your language and any modules that users might need, then the system administrator will just add it to the list of things to install. PHP is everywhere because its very easy.
Actually is not just about easiness, rather than safeness.
PHP historically did not come with a disposable webserver, and writing one was hard. All the focus was on stateless applications. So while the smart guys were dealing with the memory leaks of their wonderful engineered systems, PHP monkeys were able to get things done with almost no fear to bring down the server.
I remember reading that Aaron Swartz used to go to bed with his laptop in order to be able to quickly restore Reddit in the case it crashed during the night. [Citation needed]
For hosting companies of the time, the choice of the language was pretty obvious. Most of them have policies of automatically killing long-running processes even nowadays.
It's really only "easy" if you are using mod_php. If you are using PHP-FPM, FastCGI, etc, as most people do who run production PHP, then things get about as complicated as using uWSGI, mod_wsgi, etc with Python.
On that note though, getting mod_wsgi up and running with Apache is really quite simple.
You are absolutely right, strictly speaking it is the same thing. Getting a simple 'Hello World!' from the server though is a different thing but it is by no fault of Apache, Python is just not PHP when it comes to web development in the sense that you need this:
def wsgi_app(environ, start_response):
output = 'Hello World!'
status = '200 OK'
headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, headers)
yield output
# mod_wsgi need the *application* variable to serve our small app
application = wsgi_app
Adapting your wsgi script for "what? is it in a virtual env? Where? What version of Python is running on this server?" and other similar problems is not so easy.
But yes, it's a matter of an hour or two for a complete newby to complete it. It completely disappears when compared to the time it takes to develop the site, but lots and lots of people consider it the most important aspect of a platform, because it comes first.
As someone who has worked with php over 9 years, I can confirm this. I think beginners should not be, under any circumstances, suggested to start with PHP.
I shudder when thinking about the damage that showing == vs === stuff (PHP's type coercion rules, in general) to someone new to programming! It is such a waste to force someone new to learn a bunch of edge cases and weird behaviors and an endless list of php lol's that literally have zero value outside the context of PHP.
> Given any programming task, you're just going to end up with better code in pretty much any other language, especially a functional one.
This is the exact bull* that good hearted Haskell and Lisp guys have to face and fix because of arrogant people like you.
First of all, a good PHP programmer is a good programmer. End of story. You can write crystal clear code in PHP that anyone who started with C (how many I wonder?) or a C inspired language can read. Spreading information and knowledge IS FAR MORE IMPORTANT than debating the language.
Let me ask you a question, did you just happen to read that post that was recently on the front page of HN? The one that showed how much awesome is Lisp comparing to Python? How Python's creator seems to hate Lisp (functional programming)? Did you read it and got to the conclusion that since (perhaps) you are using a functional language then you are entitled to spew crap like that since you are the holder of truth?
Congratulation! PHP is worse than a functional language (you can write functional code in Python and PHP btw) and you are the winning lord of programming languages debates!
> This is the exact bull* that good hearted Haskell and Lisp guys have to face and fix because of arrogant people like you.
No. It is not. It takes a lot more effort to produce the code of same quality in php. For one thin, you have to consider that one has to keep and endless list of gotchas and edge cases (yes, all languages have these, but the list is nowhere near as long as it is in php) in mind when writing any amount of php code.
>You can write crystal clear code in PHP that anyone who started with C..
tell me, what does this code do, in php?
$a = array('1' => 'one');
What is the value of $a after this statement?
Answer: It appears that it is creating a dictionary with a string key that maps to another string value, but instead it creates a numerically indexed array with value 'one' stored at numeric index 1.
Do you call this 'Crystal clear'?
PHP is a language that breaks the principle of least surprise at every turn. Please don't say you can write crystal clear code in it, if you are actually interested in spreading information and knowledge, as you put it.
Isn't the word 'array' quite obvious that it will create an array? Since PHP 5.4 you actually have the shorthand "[]" version available but it is still obvious to anyone who is using PHP or JavaScript (though JS arrays aren't hash maps like PHP's -- you need an object for that).
But I agree, it's crystal clear for anyone with a minor PHP knowledge. For the rest it's just "clear". (It will still work calling $a['1'] with the quotes so what exactly is the issue? If you mean the drawbacks of type coercion not sure if this example is the best one.)
> Bad idea? Sure. But once you know the enemy you can deal with it
Why surround yourself with more enemies than those that inherently exist in your business logic/problem domain? The problem with PHP is all of those "no big deal tiny issues" add up to something reminiscent of death by 1000 papercuts.
I spent 5 years working with ASP (very similar to PHP especially in the ability to create spaghetti code). In PHP's defense, I wrote an eBay-like site in one night using it. I also know Lisp, some Haskell, BASIC, Pascal, spent 10 years (!) on Ruby, know Clojure, Erlang, JS...
I think I know my shit, I'm 43 and have been basically coding since I was 12 on a Commodore PET... And although PHP lets you get something up quick... It will always be a challenge to create a team-maintainable codebase with it.
PHP doesn't even pass its own test suite. And they do not realize why this is bad? This is the hallmark of hubris.
It's not "arrogance" you're seeing, man. It is the cold hard weight of experience building and maintaining large codebases for years in various languages.
PHP and CLI? Sure it has it. PHP isn't installed by default even in many of the places that Python is. I have never met a Sys Admin that uses PHP as his CLI scripting language and I would shake my head and walk away if one did.