9 ms·
This seems like a neat project but I can’t say I ever wanted Python to be an even bigger language... Ideally we would have a Python-like that eschews unnecessar
by weberc2 8y ago
This seems like a neat project but I can’t say I ever wanted Python to be an even bigger language... Ideally we would have a Python-like that eschews unnecessary features like inheritance and much of the magic that makes Python hard to optimize (and often hard to understand), and with a type system (even an optional type system) that is better than Mypy.
I’m not 100% sure what that would look like, but I would ditch classes (and thus inheritance) for named tuples, make most things immutable by default, include enums and pattern matching (that the type system would check; I hardly see the point in dynamic pattern matching). If possible, typed code would compile to C extensions or similar. Oh, and exceptions would go away in favor of a Rust-like Result type.
- elcomet 8y agoYou should check nim out, it's a python-like language that compiles to C.
- azhenley 8y agoI also recommend looking at Nim. It has Python-like syntax but it feels very different than Python for me when using it. Stellar language though that has been getting a lot of attention!
- weberc2 8y agoThanks for the recommendations, folks. I'll take a look!
- JoBrad 8y agoWhoa - Nim seems really cool! Thanks for mentioning it. I like that it also compiles to JS, and seems to be pretty active (latest release was just on Dec 31).
- bakery2k 8y agoIsn't Nim, like Python, a large, complex language? Looking at the documentation, it seems to include a huge number of features.
- dom96 8y agoIt is a little large, yes. The creator's goal was always to create a language with a small core but a rich set of features for extending the language (metaprogramming). Nim has bloated a little and we're now trying to remove as many features as we can without annoying too many people :)
- weberc2 8y agoGlad to hear it. I've been skimming the documentation and definitely got the impression that it is a feature-rich language to put it politely :). In the words of Bjarne Stroustrup, it seems like there is a small core language that wants to get out. I imagine you could create a linter that catches uses of extraneous features and foster a culture of "Good nim code passes this linter"--you could create badges for repositories that show the percent of the code that adheres to the linter or something. Over time, you could deprecate and then remove these extraneous features.
- mattbreeden 8y agoThis is part of what turned me away from Nim, so it's good to hear that. Can you give some examples of some features you've removed recently? I notice you're not at 1.0, so are you comfortable ignoring the 'annoying too many people' part if you think there's enough of a reason to remove something?
- dom96 8y agoOne thing I can think of is the likely little known {.this.} feature, that's been removed. We definitely need to do more, and yeah, it's hard :)
- johnday 8y agoI feel like you mostly just described Haskell, no?
- weberc2 8y agoHaskell is functionally pure with a syntax that I just can't bring myself to call readable. It's also very complex--which string type do I use? Which prelude? Which compiler extensions? Which build tools? Which testing library? I think if someone went and made a Haskell-lite and really focused on polishing the experience (including a familiar syntax, simple/straightforward tooling, relaxing the functional purity requirement, etc) it would be a great advancement.
- elviejo 8y agoI agree and the closest thing I've found to a Haskell lite is F#.
- debatem1 8y agoOcaml is, imo, a pretty and not utterly impractical language as well.
- weberc2 8y agoI knew the thread would head in this direction. :) Unfortunately, those languages' syntaxes are only marginally better and they have more complexity than I care for (especially objects and inheritance).
- gmfawcett 8y agoGiven your "especially" comment -- you might be mis-remembering something about OCaml? It's true that it has these features, but in practice they are almost never used. The object system is useful if your program's design really needs open recursion / inheritance. But it's far more common to build an OCaml program using other constructs (modules and simple data types). That's not to say that there isn't any complexity in OCaml. The type system and module/functor system have a daunting number of features. But most applications stick to a much simpler subset of the language, which is quite straightforward and easy to reason about.
- giancarlostoro 8y agoEver tried out Cython? https://en.wikipedia.org/wiki/Cython https://en.wikipedia.org/wiki/Cython There's also RPython which is restrictive and what PyPy is done in. https://en.wikipedia.org/wiki/PyPy#RPython https://en.wikipedia.org/wiki/PyPy#RPython Edit: on an unrelated note, sounds like you'd love Go.
- weberc2 8y agoI'm aware of Cython and RPython. RPython is super cool but it isn't really a general purpose programming language. Cython is superficially similar to what I want, but it's always put me off; not sure why off the top of my head. I do love Go, however. :)
- nerdponx 8y agoCython is basically C in Python syntax with some convenience features. Unless you know C it's not always worth using. Without doing any "C stuff" (i.e. just writing Python and compiling with Cython) you get about a 50% speedup in tight loops; sometimes that's good enough, other times it's not. To go any faster than that, you basically need to start writing C code, using the CPython API, using Cython's badly under-documented features for doing so.
- fspeech 8y agoFor me Cython truly shines when interfacing to C++.
- baldfat 8y agoLearning C to the point where you get Cython is pretty easy. C is much easier to pick up rather than the HUGE C++. Here is a video you can watch in an afternoon that would give you the general gist and covers the basics quickly. https://www.youtube.com/watch?v=KJgsSFOSQv0 https://www.youtube.com/watch?v=KJgsSFOSQv0
- giancarlostoro 8y agoI hear you on Go. I am a Python dev at work and love Python, have dug into PEP8 and understood the tradeoffs for the sake of simplicity. Now after years of not touching Go I go back to it and it feels soooo familiar. It truly feels like a compliment to any serious Python developer to find Go. Now I got two goto languages for prototyping.
- thebooktocome 8y agoJulia is very much like this.
- dnautics 8y agosuperficially. Under the hood, though, Julia has an type-system that interacts with the compiler in a very specific way that makes it possible to write highly optimized dynamic code without the overhead of a VM (is that the right term) like python's.
- deleted 8y ago[deleted]
- BerislavLopac 8y agoThis sounds like Rust to me...
- weberc2 8y agoRust is great for lots of reasons, but it's not remotely what I think of as Pythonic. Rust has a steep learning curve and requires a much deeper understanding of memory management than Python, and it's also not much smaller.
- ehsankia 8y agoWhat's wrong with Mypy? And have you looked at Pyre/Pytype?
- weberc2 8y agoLots of small issues, some of which may have changed since I last checked. I haven't looked at Pyre/Pytype yet. These are just a handful of issues with mypy that spring to mind: * Poor syntax support in the language. E.g., you have to define TypeVars as variables in a scope outside of the unit you want to use them in, potentially conflicting with other generic functions. No clear guidance from the documentation about how the type system interprets these, either. * No recursive types; e.g., can't define a JSON type * Some callables can't be typed. I'm thinking they're those with kwargs and/or args, but I forget the particulars. * Unions aren't true ADTs; the only way to define single-value variants (e.g., "null" in a JSON type) is to do something verbose and hokey, like creating a type that can only have one value. * Lots of common libraries can't be spec'ed and therefore can't be typechecked. Things like SQLAlchemy which generate their types/classes at runtime, for example. * Generally, the implementation is buggy even for mundane cases
- make3 8y agomypy is great