I have a question which is a bit mundane for this ...
# thinking-together
d
I have a question which is a bit mundane for this channel, but people here are exceptionally savvy so I can't resist. Does anyone know a language with the following qualities:
Copy code
community is pragmatic-oriented, but isn't afraid of abstractions. people are actually building stuff.

static typing. ADTs. pattern matching with exhaustive checking. Decently strong type system: generics? No nulls: Option/Maybe.

well-developed ecosystems for backend web and desktop app GUIs

high performance. at least higher performance than Node.

if isn't garbage collected, whatever fills that role is safe but low overhead (mental and code)

good support for concurrency and parallelism
i
Sounds like Rust.
6
k
well-developed ecosystems for backend web and desktop app GUIs
This is probably the blocking constraint. I don't know of any language that does this, unless you consider Java to support desktop GUIs or C++ to support web services.
d
There are some native Rust UI kits. The folks behind the Xi editor (a next-gen text editor in Rust) are particularly interested in that.
👍 1
k
Yeah. But 'eco-system' is perhaps too high a bar across such a wide set of domains.
d
Ye this post was partially inspired by learning about Rust. Blockers being the ecosystem, async/await just now being done, and whether the ownership stuff is actually low-overhead enough for higher-level app development (e.g., web dev and GUIs)
it's also kinda like Go... but the type system
also kinda like OCaml... but the multicore stuff isn't there I hear. and, ecosystem
1
also, Daniel, I literally have a tab open right now for that Xi stuff 😛 et al
k
If something had everything you asked for, we'd all be using it all the time. For this stage of software's evolution, you have to choose between going with the herd vs something good.
d
is it that far-fetched? aren't all the pieces for this solved problems?
(besides ecosystem 😛)
e.g., I don't know why OCaml doesn't work with multicore but I assume it's a historical thing not a technical limitation.
a
Scala is really close, except for the
null
part. in practice, it's not a big deal. people don't use it in idiomatic Scala dependencies. unfortunately, there's currently no way to statically guarantee lack of
null
in your program. it's planned for Scala 3, but we're a year away from that.
d
@Deklan Webster "is it that far-fetched? aren't all the pieces for this solved problems?" You want a wide-spectrum, high performance language with state-of-the-art everything, but the technology also needs to be very mature and polished. For example, Rust has had the Tokio async library for several years, but it's not as nice as the async in Node, and RustAsync should address that. Rust loses points for not having RustAsync already. To get all that requires massive dev resources. It's hard for other language communities to match the dev resources behind Javascript, so that greatly limits your choices. I think the O'Caml community isn't big enough--multicore has been an issue for decades. We've mentioned Rust, C++, JVM languages and Go. Are there really any other candidates?
s
Swift.
community is pragmatic-oriented, but isn't afraid of abstractions. people are actually building stuff.
Tons of apps. People are building stuff, and if you use any Apple device, you’re also likely using their stuff.
static typing. ADTs. pattern matching with exhaustive checking. Decently strong type system: generics? No nulls: Option/Maybe.
Yes, all of that: https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html
well-developed ecosystems for backend web and desktop app GUIs
Desktop: see App Store, AppKit, UIKit for Mac, soon SwiftUI Mobile: see App Store, UIKit, soon SwiftUI Web: https://swift.org/server/ (see projects section); web might be a little rough still, Swift does come from the native world, but the server group is making good progress quickly.
high performance. at least higher performance than Node.
Don’t know about Node performance, but Swift is compiled and LLVM-based, has SIMD support, value types with copy-on-write semantics, reference types with (automatic, compiler-synthesized, deterministic) reference counting, and — although likely fast enough without dropping down to C — offers C-like unsafe APIs built-in, and easy and direct integration with C libraries. On Apple platforms several libraries exist for GPU compute, ML, and all kinds of higher-level hardware accelerated functionality. For machine learning look at Swift for TensorFlow: https://www.tensorflow.org/swift
if isn't garbage collected, whatever fills that role is safe but low overhead (mental and code)
Reference counting for reference types, fully automatic synthesized by compiler with deterministic behavior. Rust-like ownership model for tighter control in the works: https://gist.github.com/Gankro/1f79fbf2a9776302a9d4c8c0097cc40e
good support for concurrency and parallelism
Libraries: 1st party libDispatch (https://en.m.wikipedia.org/wiki/Grand_Central_Dispatch), NSOperation (Foundation), several 3rd party libs for promises, async/await, etc. Official async/await language support proposed: https://gist.github.com/lattner/429b9070918248274f25b714dcfc7619 Swift is the future that is here and just not evenly distributed. ;-) It doesn’t help that most people still think Swift is just an Apple thing. https://forums.swift.org/t/swift-windows/22458 https://github.com/apple/swift/blob/master/docs/Android.md
💡 1
k
@Stefan is it available for Linux?
s
@Kartik Agaram Linux has been officially supported from the beginning and you can download builds here: https://swift.org/download/#releases
💡 1
k
How is its state of native GUI programming on Linux, do you know?
(It definitely has the usual Gtk and Qt bindings, but that feels like cheating: https://www.reddit.com/r/swift/comments/889sgh/any_good_gui_written_in_swift_that_are_open_source)
s
I don’t think that’s cheating at all! Swift shipped with a tiny standard library and was fully dependent on old but well-matured (Objective-)C libraries — and to a large extent still is. A lot of Swift’s initial design was about accessing and integrating those APIs, also causing a lot of criticism, because of course you’d basically had a super futuristic language with all kinds of features and those APIs where using none of them. That was a pretty clever move, focusing just on the language design first instead of creating new libraries, figuring out how the features can and should be used for great API design, evolving it with the community, not even stabilizing the ABI until very recently to still make larger changes possible before locking in a lot of design decisions (which happened just now with Swift 5 and 5.1). If you find great C libraries, Swift has been designed to use them. A lot of great 3rd party libs are wrappers of C APIs that make using those more “swifty”. Naturally, the community for non-Apple platforms is smaller, so it feels more like a regular open source project there. Only where big companies — Apple for their own platforms, IBM for Server and Web, and Google for ML — threw their weight behind it, do you find amazing progress after just five years that Swift has been around for.
g
I'd be surprised if Swift takes off outside Apple platforms any time soon. There is absolutely no incentive for Apple to do it. It's similar with most company backed languages. For a long time C# was seen the same way. Basically a way to lock you into one fully supported platform and then just enough rope to convince you you'd be able to port later but in actuality not really or not without major pain. Argubly the biggest boost for C# outside of Windows platforms has been Unity but that's pretty much games only. In other areas it's still arguably nitch
d
Every time I've heard the name 'Swift' I google it and remember it's an Apple language and immediately dismiss it. It being continually brought up in convos like these makes me wonder. I have 0 Apple devices. Is it fair to say that Windows and Linux are second-class Swift citizens?
s
Yes, that’s probably fair to say. It’s funny, the requirements you listed at the top of this thread describe the language pretty well, probably better than any other language you can find at the moment. Well, a decision for a programming language is always also a decision to buy into a culture and a community, and it’s more than understandable if you dismiss it on those grounds.
👍 2
d
@Doug Moen nothing I said looks state of the art to me. the type system stuff has been around for decades. CSP/Actor model stuff too. Being higher performance than an interpreter with some JIT isn't an insane demand. Also not sure what's wide-spectrum about it.
I should add that I'm plenty interested in languages which fit all of these except the ecosystem/community part. Would be good to watch
@Stefan Yep. If only Swift were more cross-platform and inclusive
s
@Deklan Webster Can you elaborate on what you mean by “more cross-platform and inclusive”? Not a loaded question; I’m genuinely curious what Swift is missing to be perceived this way.
d
Few reasons. Culture/community like you said. Also, Windows/Linux are presumably going to be second to get everything. I'm also personally biased to be unreasonably annoyed at anything which is Apple-platform only. Windows/Linux/Android only I understand since they're cheaper and/or more globally dominant. (I know Swift isn't technically Apply-only)
btw is Swift Ubuntu-only for Linux? I read that somewhere
g
Can you elaborate on what you mean by “more cross-platform and inclusive”? Not a loaded question; I’m genuinely curious what Swift is missing to be perceived this way.
A full tool set every bit as good the new XCode with 1st class quality GUI and graphics frameworks that runs on and/or exports to Windows, Linux, Android. 4 out 5 people or more are not on Apple hardware. I'd love to learn Swift but I can't justify iOS or MacOS only at the moment. The experience might be great but I still need to ship on either Android or Windows or both. As such I'm more likely to pick a worse language if it means I can write once or closer to once. I've shipped a 4 or 5 small electron apps. I know people have strong feelings about shipping an entire browser and the JS/HTML/CSS stack but from a productivity POV it's amazing. There are open source repos that will generate mac/windows/linux binaries and/or installers in one step. The API is 99% consistent across platforms. Yes I know it's not the native UI but for many apps it's good enough. Tons of people are using the native slack up daily and enjoying it. Even 10000s of programmers on Macs are running VSCode and loving it. Anyway, I've built small per project tools with simple forms or GUIs or graph displays. I write them on Mac send them to my clients on Windows. I'd love a better language and a better environment but who's offering one that's cross platform? The only other thing I've considered because of ease of use is Unity. It's game oriented but one click will generate an app for a myriad of platforms and I know people who have used it for non-game apps just because the cross platform story works so well. It also has various kinds of live updating Sure there are things like Qt/C++ but IIRC most of them require actually having a fully setup dev environment with tons of tools installed on every target platform. Electron is pretty much just
git clone ... && npm install && npm run dist
and everything just magically happens. It's easy to see why lots of devs opt for it
👍 2
Let me also add I do a lot of web related stuff which forces me in into JS/HTML/CSS land. That momentum is probably also a big push into things like Electron. To break that cycle would likely require this better language to target front end web dev and not just the language but the UI framework as well And I want pony 😛
👍 1
d
I more or less agree with Gregg. Wrt the Electron thing, I'm saying my daily prayers that this takes off https://github.com/revery-ui/revery
s
@gman Are you saying that to be cross-platform and inclusive programming languages need a graphical IDE and graphics/UI frameworks that work on all major desktop and mobile platforms? That’s a high bar (good, we should have high bars). Which languages would you say pass that bar currently?
Electron leaves a bad taste in my mouth. I don’t like how it optimizes for developer productivity by sacrificing user experience. Also something must’ve gone horribly wrong with web technology if you have to ship a whole browser with your app. Wasn’t web supposed to work on all platforms for everyone in any browser? Open, free, standards, or something?
However, I still appreciate people pushing for Electron. As much as I appreciate people pushing against Swift. I don’t believe we’re playing a zero sum game and we need people with different opinions and perspectives to make progress. Electron sucks, I think, and that’s exactly why it pushes some people to do something and come up with better solutions. I hope it will ultimately lead to better developer productivity, which it clearly champions, in other tools and frameworks that then also demonstrate that developer productivity and user experience aren’t mutually exclusive.
@Deklan Webster Not sure I understand your question about Ubuntu. Swift ships Linux binaries for Ubuntu in lockstep with Apple platform releases. So from that perspective Linux is a first class citizen, while Windows and Android haven’t made the cut yet, although the communities around that are very active at the moment to make that happen eventually (for details see links I posted above).
k
@Stefan just to respond to an earlier question: I meant it's cheating because many languages have gtk or Qt bindings, but they never seem seamlessly integrated. Other than that I totally agree with you. The decisions Swift makes are entirely reasonable. The problems are just inhumanly hard with so many platforms all with their own idiosyncracies. Other languages deserving discussion: Pony (I noticed, @gman) and Red.
d
@Stefan Still, community-wise everything besides Apple is second-citizen. I imagine it will be that way for at least a couple years. Also, re: Electron, what I posted above is trying to fix that: Revery with ReasonML.
@Kartik Agaram Pony I've heard of and I'm interested. Never heard of Red. What's the deal there?
k
d
@Kartik Agaram very weird. Very cool. https://www.red-lang.org/2016/06/061-reactive-programming.html I was actually doing research today on languages with reactivity built-in. Coincidence. Thanks for the rec!
g
I agree 100% Electron has sucky points but like many things, it just sucks less than all the alternatives 😛 Electron gives me 2D Apis (Canvas2D) that works across all platforms, 3D Apis (WebGL) that work across all platforms, Audio playback, Video playback, JPEG, PNG, that work across all platforms. Access to the Mic and Camera. Colorful/Stylable full unicode font support with emoji support. Easily stylable UIs with 100s or 1000s of tools/frameworks out there that target it. Cross platform UI animation. Ridiculously easy networking with fetch and/or websockets. All of this works cross platform. Qt etc.. might give me UI but it doesn't give me any of the rest. Electron also gives me effectively one dev environment (electron itself and the built in dev tools) across platforms. I don't for example have to learn XCode, and Visual Studio, and something else on Linux. I personally don't care about the size of Electron and I don't think 99% of users do either. I would love it if JS was replaced with Swift both inside the page and out. I might love it if HTML/CSS was replaced with something else except for the fact there is 10x to 100x more HTML/CSS designers out there than for some new UI framework.
👍 1
Electron leaves a bad taste in my mouth. I don’t like how it optimizes for developer productivity by sacrificing user experience
I feel like that is hard to quantify. Tons of people use the slack app or the discord app or VSCode and their experience doesn't seem sacrificed. Maybe I don't know what I'm missing. You can certainly make poor experiences in Electron but you can make poor experiences with any system.
s
If the battery life of your notebook computer is two hours shorter just because you have Slack open all day, your user experience is negatively affected, whether you know why that is or not.
1
And from the cultural perspective, the one-size-fits-all and I-ignore-what-platform-you-chose-and-ship-what's-easy-for-me developer community is one that I am “personally biased to be unreasonably annoyed at”. :-) http://countercomplex.blogspot.com/2014/08/the-resource-leak-bug-of-our.html
😛 1
g
my notebook battery life might be shorter but my notebook battery life is long enough that I don't care 🙂. I have 4 instances of Chrome running (well, 4 profiles in their own windows) with 47 tabs (3 of them slack), 2 instances of VS Code, 4 terminals serving 2 dev websites and one doing a watchful build, one instance of firefox, 2 projects open in sublime merge. Blender, itunes, and slickedit. My notebook will run 4-8 hours. My biggest battery drain is working on GPU related stuff, not slack. In any case, if Apple is willing to start a team to make an open source cross browser and cross platform UI framework that runs in efficient Swift I'll seriously consider joining the team 😛 I guess Google is trying to do that with Flutter but I'm guessing Dart is not nearly as nifty as Swift. I'd also love to see or participate in a super-full stack solution (no just front-end + back-end but scaling/testing/ci/staging/deployment/etc)
d
I have a computer that was mid-high-tier a few years ago. With Firefox, VSCode, Slack, Discord, Notion, sometimes Spotify, and Calibre up I often have noticeable lag. Notice how many of these are Electron apps! I regard the "fast enough" thing similarly to the Apple-only thing. Most developer have computers faster than 90%+ of consumers in the world. Okay, it's fast enough for you, so what?
i
I'm also writing Electron apps, and I'm doing it in a way that doesn't kill battery. It's totally possible, you just can't throw every npm package under the sun into your project and think "It's not the web, so it doesn't matter what my bundle size is, what event listeners I leave active, how many requestAnimationFrame loops I have running when there's nothing animating." There's no escaping the RAM bloat, but you can definitely keep the CPU and overall energy use very low. (In my case, I'm not using any 3rd party libraries or frameworks — just "bare" Electron, Node, the Browser.. so not that bare, haha — no React, nothing running in my JS process other than code I wrote that I can control exactly when and what it runs.)
👍 1
o
@Ivan Reese you don't use any UI library/framework? You don't need some?
i
I do a lot of perf-sensitive stuff (not Electron, but: https://www.lunchboxsessions.com/explore/electrical) so I prefer to write against whatever lowest-level primitives I have available to me. I've tried a lot of UI frameworks, component libraries, etc.. never found one I like well enough to sacrifice the performance. Also, I hate dependencies breaking under me.
👍 1
❤️ 1
d
@Ivan Reese I respect the decision, although I'm curious which lightweight frameworks you've tried. Surplus? Svelte 3?
👍 1
i
@Deklan Webster I'm fond of the design of Svelte, but I haven't used it because I don't use TypeScript (yet). I'm also quite fond of Preact as a quick-and-dirty, get-the-job-done option. Also very interested in the design of thi.ng-umbrella. Not lightweight, but: when doing React, I quite liked using it via re-frame in ClojureScript. Even though I don't generally use them, I read up about pretty much every new UI framework that crosses my path — I'm always looking for techniques that'll help my browser code run faster, load quicker, etc. Never heard of Surplus, so now I'm going to go look into that!
d
@Ivan Reese Going to sleep in a sec, but real quick. Svelte doesn't support TypeScript, yet... That's actually the reason I don't use it much yet. It's just plain JS. And, Surplus is built on top of the author's reactive library called S.js. Another library called Solid uses S.js under the hood. Very much worth looking into too; it's more flexible than Surplus. Btw, this isn't in the docs, I don't think, maybe it's an easter-egg: Surplus is based on synchronous reactive programming. SRP. Surplus
i
Neat. I had thought Svelte was pure typescript, but I must be misremembering.
Backing up a bit, toward the main topic of the thread... What I like about Electron is that I can use the platform I'm most familiar with (HTML, CSS, JS, SVG, WebGL, etc) and am best equipped to do a good job of — call that dev productivity, sure, but for me (a dev team of 1) it's simply the difference between having a so-so native app, or not having one at all... and my teammates would rather use a so-so native app than have to do their work in a browser. That's just the limitations I'm personally under, and Electron is a good fit. For a team with the size and resources of Slack, it's downright negligent that they don't write first-class truly native apps for the three major platforms. Their Electron app is bloated, laggy, toxic garbage — it is a constant fixture in the "APPS USING SIGNIFICANT ENERGY" section of my battery toolbar, even when it's idle in the background... what the fuck. My electron app is never shows up there, and is a highly interactive drawing+coding tool that holds a steady 60fps when in active use, lags less while doing complex graphics than Slack lags while typing text, and immediately drops to totally inert code (no running event loops) as soon as the user lets go. You can totally make a complex Electron app that is well behaved. I also have some native apps on my Mac that, like Slack, are should be simple but also have these sorts of performance problems. You can write a bad, slow, misbehaving app using any toolkit. Electron just happens to have inherited the NPM culture of "cobble it together on top of a big heavy UI framework" and "dependencies are fine" and "just use pre-made components" and "don't learn the low-level", instead of the Obj-C/Swift/Rust/C++ culture of mechanical empathy.
❤️ 2
k
You should blog some techniques you use to create efficient Electron apps, @Ivan Reese. Would be super interesting and level up the conversation beyond knee-jerk love/hate flame wars. Maybe call it "mechanical empathy for Electron".
❤️ 1
Maybe a blog post isn't the ideal vehicle for this. Create an example app (say a todo list) with the normal way people do it, and the way you do it. Let me run both on my Mac and viscerally feel the performance difference.
❤️ 1
s
@Kartik Agaram Spoken like someone who could have a great future at GitHub as an Electron Evangelist… 😁 Seriously, these are some great suggestions! (Also a lot of work, so I totally get if @Ivan Reese has more important things to deal with.)
@Ivan Reese “mechanical empathy” — did you just make that up on the spot or is that already a thing? I love it.
What you describe matches my experience on Apple platforms. Building great apps with empathy for your users is hard on any platform (the corollary to “you can write bad apps with any toolkit”), and many developers don’t care enough about that extra effort. Even on a platform where “mechanical empathy” has a longer and stronger history, it’s shocking to see how few developers know how to use a debugger effectively and how little they know about the profiling and performance tools available to them. And let’s not even get into the less mechanical part of empathy like on-boarding, accessibility, localization, and cultural adaptation… Don’t get me wrong, I’m not talking about junior developers that don’t have much experience yet. I’m talking about the kind of veteran developer who has shipped many major apps and they clearly know their language and libraries, but then you get to meet them and ask something about performance or get to help them debugging a potential platform bug and get to see their debugging process… I wonder if that is a side effect of engineering culture, where programmers are often under ridiculous deadlines set by managers who don’t understand programming. For sure over time that normalizes into “It works well enough. Just ship it!”
i
@Kartik Agaram Well, my personal future-of-programming project is built in such a way, so when I release it that'll serve as an example. The short answer is.. any time you run an animation loop, feed information back up from the leaf nodes, letting the root loop know whether it's safe to be shut down. Then, in addition, you need any event that requires the animation loop to run to turn it back on if it's off. For me, the information I pass back up from the leaves is usually a string or symbol giving the name of the leaf node, so I can track which parts of the code still have more work to do, and which ones are done — better than just passing up
true
for more work and
false
for done. @Stefan I misremember the term — it's "Mechanical Sympathy", and it's an existing thing, not a new coinage on my part.
k
But don't block on releasing the final product. I think I'm asking for something like http://akkartik.name/post/four-repos which is just building blocks for my future of programming project at https://github.com/akkartik/mu. The whole project can often be totalizing, wanting to take over every last detail about how people program. An example repo is just an illustration of one small idea.
i
(See edited message above)