Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Honest question, in what sense is python a so much better choice for web development?

syntax? subjective, and it would also mean all C-likes belong in the dustbin.

performance? Why would python, as a language, be significantly more performant? It's just as dynamic.

ecosystem? JS community is huge, JS package managers are huge (even though not flawless, but nothing their python counterparts do better)

I mean I can surely imagine there's better alternatives for JS, as a language. But python...?



Not Op, but I'd like to do python/WASM because I don't do want to do C-Like languages. Sometimes you want to do some light web interactivity without major mental context switching.

For me, personally, it's a lot of effort to switch between languages. So when I'm building a web project and most of it is django/flask/python/etc, but I want something more dynamic than a HTML form post/browser reload... I need to do it in Javascript. Not that I can't javascript, I can, it's just hard to change over and I'm slow to write it. It would be a whole bunch nicer if I could just stay in the python mindset for those small pieces of code.

Do I think python is "better" for the web? No. do I think it's faster? Doubt it.

Do I think it's "better" for my use cases? Yes - And that's the power of WASM. It allows people to do what works for them.


For one thing, not being broken. Python doesn't have ("1"+1) and similar design flaws, Python doesn't need a new ECMAscript standard every year, Python has figured out modules and classes much earlier, and frankly, Python is what Javascript is only becoming after years of improvement. Really, I don't understand why we and the browser maintainers have to put up with a broken, insane language when there is a similar but much more mature and "done right" one. And as far as ecosystem, Python can kick Javascript's ass if not in quantity (though it's close) then in quality of its userbase for sure. And Python has been used onе the backend much more than JS, so it makes much more sense to unify the language and just use Python for the front-end.


I feel like almost every one of those points is highly debatable.

- New ECMA standard every year VS. new PEPs every year

- Modules and classes: cyclic dependency hell, obscure multi-import issues, __init__.py ugliness, imperative class declaration. Python only figured these things out much earlier to the extent that it has actually figured these things out.

...


> Python has figured out modules... much earlier,

You expect that to carry over to WASM environments?


I think almost any thing is better than js. At least it is popular due to its actual developer's. People use it because they like it and its ecosystem was grown by them, not force of a dumb decision in 90's or company backup. Both performance and ecosystem are not characteristics of language. they are due to being the only language is being supported in browser. (hint: I won't use python for web)

Also comparing languages based on syntax and ecosystem is not very clever idea.


what characteristics should I use to compare languages with then, if I want to be clever?


Semantic


Was going to ask in the main thread but perhaps here is a better place. For someone just starting with programming, but targetting WASM, which would be a good first programming language? Java?

In my particular case, I've been learning Python for Data Analysis for about one year, and a few months of Haskell (love Haskell so far, but my interest/job is related to data analysis and web dev). I've heard bad things about Python as first programming lang (weakly typed and bad OOP implementation).


Since Java relies on the JVM I think I'd avoid it, and any other languages that'd require running another VM on top of the WASM VM. Seems like useless stacking of technology that serves basically the same purpose. Not saying it wouldn't work and that it won't be done, but just seems kinda gross and missing-the-point.

Personally I'd also avoid anything with a fatter runtime than maybe Go or C#. If it doesn't already, I'd expect C# and .net generally to have really good WASM support, actually. And even those, unless it becomes standard to ship their runtimes with a browser, you're talking about a pretty fat package to ship before the program can even start running.

Most interpreted languages (like Python) running on WASM will probably be notably slower than Javascript running outside WASM, for the reason that they'll have similar limitations on optimizability, will have had fewer person-years put into optimization than Javascript (which has seen tons of investment from e.g. Google), and will be running on an interpreter in the WASM VM rather than a C++ (or whatever) native interpreter. And they'll have the problem of needing to ship an interpreter, similar to the runtime problems for the languages above.

For the best experience you want something fast-loading and well-performing. That means small package size and not too deeply nested in terms of abstraction on top of WASM. If you want a better experience on both fronts than JS, which has the benefit of already having its interpreter bundled with the browser and running on a native, highly optimized interpreter—IOW if you want running on WASM to actually be a win in any meaningful UX way—you'll need to look at fairly low-level languages, I think. C++ is a good bet—people are quick to shit on it, but it remains hugely important in GUI application development—or, if you're wanting something hipper, Rust, perhaps. Go or .net-family languages might be OK, future-proof-ish choices if you don't mind sacrificing load time a bit. Toss Swift in that bucket too, I guess.


Thanks! I'm still thinking if I should need to learn a 'learning language' first (Java or Python) and then move on to a low-level language or go directly to C++. I've been on Linux for years and feel quite comfortable with it, BTW. Can C++ be learned/used on Linux?


Just start coding. C++/Java/Python - whatever. The only real consideration you should have is picking something where the tool chain stays out of your way and works for you as opposed to you working for it.


I wouldn't start with C++. I did and then programmed in it for about 15 years. I liked it but looking back you spend a lot of time thinking about things that have nothing to do with the real world problems you are solving. And there are still far too many ways to do one thing. Despite modern guides etc you will still come across all these styles and they will distract you. Python is a great start. Virtually no bs, just programming. If you want static types then java or go or c# it doesn't matter. Stick to gc'd languages at the start.


> Can C++ be learned/used on Linux?

Very much yes. One of the reasons C++ is a very popular language is its portability. It compiles for most any platform.

C is kinda the "native" language of Linux, if there is such a thing, in that it's the language of its kernel and of maybe (guessing) 2/3 of the popular GUI desktop environments on it measured by usage, but C++ is also big and (another reason it's popular) interoperates very well with C.

C++ is a major language in use at Google (written under a highly restrictive style guide there, though), if that matters to you. It can be used to write modules and libraries for work on lots of other, higher-level platforms (iOS and Android, for example). It's huge to the point of nearly excluding all other players in serious video game development. It is likely to remain very relevant all over the software development field for quite a long time.

As far as a "learning language", if we're talking scripting languages I'd put Python and Javascript at the top of the list. Javascript's weird in some very un-useful ways (it is very much possible for a language to be weird in useful ways—Javascript mostly is not) but is the language of the Web, which is why it's so popular. Python's friendlier and saner despite a couple potentially-irritating quirks, and has one of the best library ecosystems around. It's a leading language in natural language processing and machine learning, mostly on the strength of that library ecosystem—much of which, as is the case with most scripting languages, is actually written in C++ or C under the hood, for performance reasons. It's also got a huge Web framework comparable to Ruby's Rails, in Django.

My considered opinion on Java is that unless you have a special need for it (Android development, for example) or intend to go all-in on the broader JVM ecosystem, it's better avoided. The strengths of the JVM diminish rapidly as one's needs and interests go beyond it—though it can do nearly anything you need, provided you accept that you'll be using some JVM-based solution to all your problems. Working in it just some of the time is kind of a pain, and it doesn't play as well with others as either traditional interpreted languages or non-VM compiled languages usually do.

If you're looking at learning a compiled, statically typed language I'd go for C, C++, or maybe—maybe—Rust these days.

My advice would be to learn how basic data structures and running programs are laid out in memory, how the stack works, and how things like method lookup tables are implemented, early on, no matter which language you're looking at, all of which are much simpler and less intimidating than one might think. It'll demystify and make obvious Object Oriented programming and recursion and some other things that can acquire an (absurd and extremely false) air of the magical in approaches that don't incorporate those things.


Speaking of C# and wasm, take a look at Blazor.

https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor


I'm not an expert, but my understanding is that with Web Assembly you essentially have to ship the whole language if you're doing dynamic languages, so it greatly inflates the size of the package the user has to download.

The one I've been looking to the most is Rust, as it compiles to a smaller size, doesn't have a GC to ship (by default), and is not C/C++. C/C++ seem to be the other common WASM languages.

Edit: Just saw you're a beginner programmer, I probably would not suggest Rust as a first language. Web Assembly in general may not be a good starting point, but if you're set C++ might be slightly better. (I tend to suggest Python as a starting language)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: