17 ms·
Erg: a statically typed language that is Python compatible
- DreamFlasher 4y agoAmazing, but... Why not done with Python syntax? And no, mypy is not a solution. Even with strictest mypy it is still possible to have errors that would have been caught with static typing.
- formerly_proven 4y agoNice.
- steezeburger 4y agoThat icon tho
- phoe-krk 4y agohttps://github.com/erg-lang/erg/blob/726b7b80fcf06c6c4099b62eacea4fd1a3f5dd76/assets/erg_logo_with_slogan.svg https://github.com/erg-lang/erg/blob/726b7b80fcf06c6c4099b62... Using a 69 as your language's logo? I actually don't think it has been done in a serious-seeming project before.
- tasty_freeze 4y agoit is actually "Erg", not 69
- phoe-krk 4y agoAs much as I enjoy the tongue-in-cheek logotyping, "Erg" is certainly not the first thing that my mind reads when looking at it.
- travisgriggs 4y agoI couldn’t bring myself to use the phrase “tongue in cheek” here. I was going to, but couldn’t.
- travisgriggs 4y agoLol. I guess I made the same mistake. /me wonders if there’s some double entendres going on here.
- Kamq 4y agoSeriousness is overrated. Have some fun with your projects
- latenightcoding 4y agoAt this point I'm open to try anything that will give me access to the python ecosystem without having to code in Python. From the FAQ it looks like Erg code gets transpiled to python bytecode.
- adenozine 4y agoFable for F# is working on something like that. a link: https://fable.io/blog/2022/2022-06-06-Snake_Island_alpha.html https://fable.io/blog/2022/2022-06-06-Snake_Island_alpha.htm...
- metadat 4y agoWhy so averse to direct Python?
- likeabbas 4y agoSlightly related question: why do people love Python so much? Or, any dynamically typed language? There's almost nothing that has frustrated me more in a professional setting than trying to figure out what some dynamically typed code is doing and ensuring I don't break anything by making changes.
- codedokode 4y agoBecause you can do a lot with little typing and there are lots of great libraries. Python is probably the best choice when you need to get something done quick or calculate something when performance is not important. It is also not an exotic functional language without loops and filled with linked lists. Also, in Python integers do not overflow, unlike in Rust, C and other buggy languages. If you name a language, with high probability Python will be better in something unless it is about performance. What I don't like: no type hints in many libraries, some libraries are not type-hint friendly, lot of unnecessary dynmamic features (like being able to patch modules in runtime) and absolutely no caring about performance and being able to compile into machine code. > trying to figure out what some dynamically typed code is doing There should be type hints.
- traverseda 4y agoNot sure why I'd want to use this, presuming I was already happy with python. Especially now that python's type hinting is more mature. Looking through the feature set the main thing it seems to provide is a type system, but with a syntax I don't like as much as python's type hinting.
- davidatbu 4y agoThis is sort of speculation on my part: The fact that static typing PEPs can't easily introduce syntactic changes to the language (I don't think there has been a syntactic change introduced because of static typing ever since Python 3.5) will really hold back Python's static typing from being ergonomic at least, and "fully capable" at the worst. I think that limitation of statically typed Python alone is enough to give this new language a chance. It's also looks like the type inference of erg will be better than the current Python checkers.
- frou_dh 4y agoI was just playing around with Python 3.10 for the first time today. I made an algebraic/sum-type (dataclasses + typing.Union), then did some structural pattern matching on a value of that type (match statement), and Mypy could tell me statically when the pattern matching wasn't exhaustive! I think it's pretty damn amazing how well Python has been able to evolve into the realm of static typing. And no unofficial superset syntax required!
- davidatbu 4y agoThat's wonderful to hear! It's been > 1 year since I used daily-drove Python, so my comments do lag behind the progress by at least a year. Maybe an unofficial superset syntax is indeed not required!!
- svetb 4y agoMypy can work really well in many cases, but we seem to get bitten by bugs on a daily/weekly basis. There are >1,000 currently open on Github [0], so it doesn't take much effort to hit one. And having the type-checker tell you that something's not valid when it actually is is a real turn-off...means that we end up with code that's riddled with "# type: ignore", which kind of defeats the point. Pylance (the VSCode built-in linter, based on Pyright I believe) tends to do a better job than Mypy, but not as easy to integrate into CI. It's a real shame that the Python ecosystem doesn't have anything nearly as robust as TypeScript. [0] https://github.com/python/mypy/issues?q=is%3Aopen+is%3Aissue+label%3Abug https://github.com/python/mypy/issues?q=is%3Aopen+is%3Aissue...
- briandw 4y agoI have so much trouble when trying to refactor projects bigger than a few hundred lines in python. If I could integrate this into Jupyter easily I'd be excited to try it out.
- aYsY4dDQ2NrcNzA 4y agoType hinting combined with PyCharm’s refactor commands work well for me. I assume the other IDEs work just as well. Are you using an IDE?
- gilch 4y agoYou do know you can statically type Python, right?
- kortex 4y agoWe have a 50kloc all-python backend, with very high (>90%) type integration (that last mile is hard). I've done pretty big (thousands of loc) refactors and it's pretty painless. Night and day compared to the pre-typed python days.
- Arbortheus 4y agoIt would be nice if someone created a typescript for python. Something that allows us to wrangle control and sanity over reams of legacy untyped python madness.
- boxed 4y agoMypy?
- tingletech 4y agowhy not use the built in typing? https://docs.python.org/3/library/typing.html https://docs.python.org/3/library/typing.html
- Reubensson 4y agoit doesnt enforce the types in any way
- isoprophlex 4y agoYou can run, for example, pre-commit checks such as mypy to enforce some semblance of sanity.
- joshuamorton 4y agoNeither does typescript. All the types are removed at runtime, it's up to you to ensure that your build process and tooling correctly validates the types. The same is true for python, and the ecosystem has really great tools for doing this.
- kortex 4y agoUse pydandic for serde/IO validation, and mypy --strict. And minimize cheating e.g. Any. I think you'll find it extremely stable and a totally different beast than usual python.
- LtWorf 4y agoI wrote typedload before pydantic was a thing. It's faster and actually works well with mypy and python's type system. Pydantic requires inheritance and requires a modified mypy because it uses types its own way rather than the python way. Oh, typedload is faster than pydantic, despite being pure python instead of an .so file.
- nope96 4y agoBut not really a pythonic syntax. Reminds me more of ruby? i.e.: > 2.times! do!:
- mattbillenstein 4y agoSame, this just seems soooo very ugly imho
- Zomatree 4y agoThis is what is putting me off the most of this, the syntax feels very unreadable for something that is meant for python, which has a very readable and open syntax, even typescript's sometimes messy typing is for the most part more readable than this
- turboponyy 4y agoTo provide some rationale, the '!' syntax distinguishes declarations from imperative constructs or effectful statements. You will see similar syntactic sugar in Haskell (do notation), F# (computation expressions), and probably others - they are often abstractions for specific monad-wrangling patterns, and won't look out of place for many in a more functional-style language.
- epgui 4y agoIs there documentation in English? The japanese[1], however wonderful a language, would be a major barrier to entry for me. [1] http://mtshiba.me/TheErgBook/ http://mtshiba.me/TheErgBook/
- tyingq 4y agohttps://erg-lang.github.io/ https://erg-lang.github.io/
- cyanydeez 4y agoWhy is the logo 69
- cpeterso 4y agoThe logo is (also) the letters E r g smooshed together
- unwind 4y agoPretty sure it's trying to be an ambigram [1] i.e. readable upside down. 1: https://en.m.wikipedia.org/wiki/Ambigram https://en.m.wikipedia.org/wiki/Ambigram
- cyanydeez 4y agoSo it's also 69
- aslilac 4y agoThis is the real question
- kortex 4y agoThis is exactly the sort of thing I've been looking for. Not sure how production-grade it is* but definitely gonna use it for some scripts and data processing. I love python, most of all its ecosystem, and use types extensively, but it still misses some things I wish it had better support for. Namely: immutability, and explicit side effects, which are both prominent features of Erg. So this is super exciting. Does anyone know if Erg code can be (ergonomically) called from python? I think that'd be the real killer feature, being able to write erg modules and pull it into the greater python ecosystem as easily as native python. * looks like the project is nary a few weeks old? Can't really dig into the git history on mobile, it freezes my browser
- gregwebs 4y agoNim is a statically typed language that is syntactically close to Python and there are some attempts at integrating the two.
- elcritch 4y agoErg looks fun for small programs. Though Erg's syntax choices seem less Pythonic than I'd expected. Interesting though, some of the idioms seem handy. Though Nim definitely can be described as a statically typed Python-compatible language! I haven't used them but https://github.com/Pebaz/nimporter https://github.com/Pebaz/nimporter https://github.com/yglukhov/nimpy https://github.com/yglukhov/nimpy both seem great. Nimporter in particular looks fantastic for writing fast python libraries. Actually come to think of it that might be the easiest way to write fast KiCad 6 plugins.. I really want to try making a native KiCad autorouter. But I don't want to figure out the C++ plugin setup and since KiCad 6 the Python APIs seem better documented and supported anyways. Problem is that Python would likely be too slow. Nimporter could be perfect. It looks really simple to setup.
- bb88 4y ago> I really want to try making a native KiCad autorouter. But I don't want to figure out the C++ plugin setup and since KiCad 6 the Python APIs seem better documented and supported anyways. So I find this to be super interesting, particularly when it comes to parts with lots of pads that one has to route. Python would let you iterate the algorithm quickly. It's far easier to optimize the big O notation of your autorouter than in C++, say. Once you're happy with the algorithm, then you can try to optimize the slow bits in C/C++. But even things like dicts in python are still going to be super fast. As far as speed up goes, there's PyPy, Nuitka, and Cython, which are all interesting. There's also a restricted version of python called RPython which PyPy uses to compile everything to C. If it's me in 2022, I'd probably go with Cython. A lot of packages uses it. It's well known, and it's (mostly) python -- mostly because it would be easier to go back and forth in python rather than switching mental contexts between Nim and C and Python. See here for the examples. https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html https://cython.readthedocs.io/en/latest/src/tutorial/cython_... Good luck with the project!
- wodenokoto 4y agoThe real seller would be to add a PyTorch and Tensorflow example.
- waitingkuo 4y agothis remind me ruby...
- rishav_sharan 4y agoAnother languages which compiles down to Python is Haxe https://haxe.org/manual/target-python-getting-started.html https://haxe.org/manual/target-python-getting-started.html If you want to use static typing with c ES6 like syntax, Haxe is amazing. Haxe also compiles down to a half a dozen more compiler targets - including C++, C#, Flahs (via OpenFL), lua etc.
- reil_convnet 4y agoCool concept. This panics for me after install. Any suggestions to make it work ? {I have Python in my path, so writing python would not return "not found" } Starting the REPL server... thread 'main' panicked at 'cannot execute python: Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." }',
- reil_convnet 4y agoFor someone stuck at this issue. This was fixed in latest version : https://github.com/erg-lang/erg/issues/8 https://github.com/erg-lang/erg/issues/8 Dont do cargo install erg , but rather build from source and this works.
- markjreed 4y agoInstalled it, and the code in the README won't even run, so I guess it's not quite ready for messing with. Looks interesting in theory, though . . .
- C-BJ 4y agoExciting language