News for hackers. Stuff that matters.
Re:WebAssembly becomes a W3C Recommendation by LessDmesg on Monday December 16, 2019 @11:56AM (#21804527)
Now if only we get a good web-oriented Python with a WASM backend, we'll finally be able to throw Javascript where it belongs: into the dustbin of history.
Re:WebAssembly becomes a W3C Recommendation by janpot on Monday December 16, 2019 @12:01PM (#21804568)
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...?

Re:WebAssembly becomes a W3C Recommendation by ShakataGaNai on Monday December 16, 2019 @12:39PM (#21805011)
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.

Re:WebAssembly becomes a W3C Recommendation by LessDmesg on Monday December 16, 2019 @12:41PM (#21805034)
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.
Re:WebAssembly becomes a W3C Recommendation by strbean on Monday December 16, 2019 @11:59PM (#21810765)
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.

...

Re:WebAssembly becomes a W3C Recommendation by wahern on Monday December 16, 2019 @09:08PM (#21809796)
> Python has figured out modules... much earlier,

You expect that to carry over to WASM environments?

Re:WebAssembly becomes a W3C Recommendation by h8hawk on Monday December 16, 2019 @01:10PM (#21805377)
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.

Re:WebAssembly becomes a W3C Recommendation by janpot on Monday December 16, 2019 @01:35PM (#21805649)
what characteristics should I use to compare languages with then, if I want to be clever?
Re:WebAssembly becomes a W3C Recommendation by h8hawk on Monday December 16, 2019 @01:40PM (#21805721)
Semantic
Re:WebAssembly becomes a W3C Recommendation by mark_thompson on Monday December 16, 2019 @02:23PM (#21806144)
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).

Re:WebAssembly becomes a W3C Recommendation by shantly on Monday December 16, 2019 @02:56PM (#21806543)
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.

Re:WebAssembly becomes a W3C Recommendation by mark_thompson on Monday December 16, 2019 @03:29PM (#21806855)
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?
Re:WebAssembly becomes a W3C Recommendation by ailideex on Monday December 16, 2019 @04:14PM (#21807273)
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.
Re:WebAssembly becomes a W3C Recommendation by discreteevent on Monday December 16, 2019 @06:11PM (#21808567)
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.
Re:WebAssembly becomes a W3C Recommendation by shantly on Monday December 16, 2019 @04:10PM (#21807231)
> 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.

Re:WebAssembly becomes a W3C Recommendation by int_19h on Monday December 16, 2019 @11:37PM (#21810621)
Speaking of C# and wasm, take a look at Blazor.

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

Re:WebAssembly becomes a W3C Recommendation by finder83 on Monday December 16, 2019 @03:25PM (#21806807)
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)

Re:WebAssembly becomes a W3C Recommendation by baja_blast on Monday December 16, 2019 @01:57PM (#21805898)
Python would be a bad choice for the web since it was not designed around events. JS was designed specifically to turn on top of a browser with an event loop to respond to events as they happen. Python would just make a slow non responsive browsing experience. Also WASM wasn't designed for "any languages goes" in mind, it was designed for lower level languages like C/Rust which have manual memory management to run high performance applications like games, and video editing tools etc.

Also as someone who uses Python regularly, Python is by no means a perfect language. I am assuming you only know Python since it's an attitude I often come across for devs who only develop in Python and believe it's the superior to every language in every way.

Re:WebAssembly becomes a W3C Recommendation by traverseda on Tuesday December 17, 2019 @12:11AM (#21810819)
Python wasn't designed around events, but using python-style async/await syntax under javascript has made my life a lot easier.
Re:WebAssembly becomes a W3C Recommendation by avbor on Monday December 16, 2019 @12:15PM (#21804732)
More work to be done, but Mozilla DID get Jupyter Notebook to run on the web with WASM.

https://hacks.mozilla.org/2019/04/pyodide-bringing-the-scien...

Re:WebAssembly becomes a W3C Recommendation by ww520 on Monday December 16, 2019 @12:58PM (#21805223)
I'd pick Javascript over Python for frontend dev in any day. Python can't even do proper lambda.
Re:WebAssembly becomes a W3C Recommendation by h8hawk on Monday December 16, 2019 @01:13PM (#21805419)
Just name it! Good luck with that.
Re:WebAssembly becomes a W3C Recommendation by sunseb on Monday December 16, 2019 @01:51PM (#21805825)
I think in the end we may have a subset of JavaScript that compiles to WebAssembly. Something like TypeScript. Something that cleans up the mess of JS and keeps the good parts.
[dead]
Re:WebAssembly becomes a W3C Recommendation by LessDmesg on Monday December 16, 2019 @12:30PM (#21804905)
What would you prefer then, Lua, with its 1-based arrays? Python is a mature, universal, versatile, insanely popular dynamic language with a nice syntax. It fits the bill perfectly.
Re:WebAssembly becomes a W3C Recommendation by saagarjha on Monday December 16, 2019 @01:54PM (#21805860)
Lua’s a great language; hating on it for 1-based indexing (it doesn’t have arrays) is somewhat petty.
Re:WebAssembly becomes a W3C Recommendation by BubRoss on Monday December 16, 2019 @12:43PM (#21805056)
If indexing arrays starting at 1 is a big problem, either the language is fantastic or you aren't challenging yourself. Programming gets a lot harder than that.
Re:WebAssembly becomes a W3C Recommendation by root_axis on Monday December 16, 2019 @01:20PM (#21805493)
Something with a static/strong type system.
Re:WebAssembly becomes a W3C Recommendation by fastball on Monday December 16, 2019 @01:32PM (#21805613)
Python has static type checking now, and has always been strongly typed.
Re:WebAssembly becomes a W3C Recommendation by LessDmesg on Monday December 16, 2019 @02:55PM (#21806523)
I'd like that too, but it's not going to work with the web dev populace. They're used to a dynamically-typed sandbox and won't switch to a full statically typed language.
Re:WebAssembly becomes a W3C Recommendation by fastball on Monday December 16, 2019 @04:52PM (#21807678)
What about TypeScript?