8 ms·
Show HN: The Shark Programming Language
- duped 4y agoOn my system, python3 depends on libm, libz, libc, and libexpat. That's not too many nor unreasonable. What is shark missing?
- shogundev 4y agoThe standard python distro does lift a good 27-30 MB depending on version and offers lots of optional (but generally useful) libraries. The standard shark SDK distro lifts under 13 MB and also offers some precompiled libs (mostly game and graphics related). I dont know how heavy is python with utilities stripped but shark weigths 50 KB and depends barely on libc, this includes the interpreter, compiler, linker and standard libraries like system.path and system.io. In this respect shark is very even with lua and many small-medium sized lisps. Cheers, - Shogun
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- nextlevelwizard 4y ago>Shark was born in an attempt to fix some python issues I have spotted with the years: Python is slow I constantly hear this, but are there some actual use cases where this commonly matters? Yes, yes, looping is slow in Python, but whenever someone in real life complains about Python being slow execution of the program still takes so little time that even if Python has 10 times slower it wouldn't make much of a difference. Or have I just misunderstood this completely and python actually is unusably slow for common things?
- sixstringtheory 4y agoThroughput. Of course it won't be obvious if you aren't running parallel implementations of your backend in python and C++/Rust/etc to compare your cloud billing, but 10x slower means 10x more compute requirements for the same service quality, doesn't it? And you have to pay for that. Maybe price doesn't increase linearly, but I'm sure it does increase.
- nextlevelwizard 4y agoParellelism is a good reason to not use Python since GIL is what it is. But I would argue whatever you gain back from lowered hosting expenses probably aren't worth the extra development time & costs that come with lower level languages, but yes that depends on what you are writing.
- nordsieck 4y ago> But I would argue whatever you gain back from lowered hosting expenses probably aren't worth the extra development time & costs that come with lower level languages, but yes that depends on what you are writing. I mean... I've used both python and go. And in my opinion, python doesn't really have much higher developer velocity. I'd never do web dev in C++, but Rust seems like a mixed bag. It is a bit notorious for having a steep learning curve. But once people are productive, it's arguably a higher level language than python.
- Yoric 4y ago> I'd never do web dev in C++, but Rust seems like a mixed bag. It is a bit notorious for having a steep learning curve. But once people are productive, it's arguably a higher level language than python. Having done back-end in Python, TS and Rust, my experience confirms this: Rust is a very high language once you're past the steep learning curve.
- Yoric 4y agoPossibly. However, the times are changing. There is an energy and components crisis and there are plenty of reasons to believe that it's going to grow much worse / more global. I suspect that at some point in the very near future, we'll need to relearn to code for a finite set of resources instead of just assuming that "the cloud" will solve it for a few more dollars.
- satvikpendem 4y agoWhy not use Nim instead if you want a faster Python?
- shogundev 4y agoI liked NIM btw. But shark is not about a faster python, it ofers quite a few advantages: speed, size, hackability, ambiguity and lookahead free grammar, and foremost an insane portability and repertorie of libraries to use. The shark compiler is a few thousand lines but its output can be run as python, javascript, lua, java and native. Cheers, -Shogun
- whoopdeepoo 4y agoCool, but you really need a grammar check. Pass this through chatgpt or something.
- themodelplumber 4y agoHey that looks pretty fun, thanks for sharing it & count me in, I'll try it. I like these zippy little lightweight languages that happen to have docs and SDL bindings and so on... BTW how did you arrive at the name? Edit: Running the linux build script, bit of an issue: https://pastebin.com/fHzJAFwz https://pastebin.com/fHzJAFwz
- shogundev 4y agoJust tell GCC to shut up and try again, if persistent make an issue in GH. Shark used to stand for SHAred ARKitecture, since the language can compile to lua, python and javascript using the shared architecture found in the three. Now it stands for nothing really. Edit: Typo check O _ O
- themodelplumber 4y agoOK, I think I understood your meaning, checked with GPT just in case. > The developer's suggestion to "tell GCC to shut up" means to use the appropriate flags or options to suppress the warnings or errors generated by GCC. > There isn't a specific GCC flag to ignore unexpected arguments. However, you can use the -Wno-error flag to disable the treatment of warnings as errors, which will allow the build to continue even if warnings are generated. OK, same issue flag or no flag, guess I'll file it. Wondered if there was some release or something that was more direct than the build script, thanks. Edit: filed #1
- PeterWhittaker 4y ago> Just tell GCC to shut up and try again, if persistent make an issue in GH. That seems like a cavalier approach to type warnings. Sure, it may not be an issue, most of the time, but type warnings are there to highlight/suggest potentially bad code, e.g., poorly thought out or insufficient consideration given to typing, overflows, etc. For a one-off or bit of hobby code, I'm quite happy to compile without warnings and/or to ignore whatever warnings my code generates, but for something I am sharing with others, especially releasing and hoping they will adopt, I crank the warnings to 11 and make sure compiles are clean, without pragmas.
- weatherlight 4y agoSome examples in the readme would be nice. :)
- zestyping 4y agoIntriguing! I noticed one thing in the handbook: > Care must be taken if you assign a given key to the null value: some platforms remove keys assigned to null from tables making them invisible to the in and not in operators. It is really important to specify the exact behaviour and make sure all platforms behave the same way. You can't write portable programs if the behaviour differs from platform to platform.
- shogundev 4y agoNot happening. If you compile something to Lua assigning a key to nil will erase it, python and javascript will keep it. Pheraps making a special NullObject value to fill these slots would be a good idea, but you could not interact seamlessly with the target system and probably get a speed penalty. Having the exact behavoir in all platforms is not possible in some cases, and these are the cases left 'undefined' in the handbook. Hope this clears things a bit ;) Cheers, -Shogun
- trehans 4y agoWhy not remove the ability to set a key to the null value then? Raise an error in the compiler. It seems pretty undesirable to have undefined behavior in the language, and if high performance is one of your goals, remove the ability for users to do the low performance things.
- a_t48 4y agoRaise an error or just substitute with a deletion
- fbdab103 4y agoThat was a specific call out to Lua without naming it. Definitely one of the regrettable missteps of the language.
- soulbadguy 4y ago> Imagine a programming language with the syntax of python I am not sure when the python syntax become such a beacon of quality, but that makes me genuinely sad; Especially with looking at all the other syntax (swift, kotlin, F#/ocaml, rust) out there.
- shogundev 4y agoI like swift and rust quite actually. Might make a shark VM from scratch in swift for the heck of it. :)
- cglong 4y agoI actually had someone disparage the F# syntax the other day, I guess because of its deviation from the top of the TIOBE Index :(
- aspyct 4y agoPython syntax is predictable, readable and concise. What else do you need?
- koito17 4y agoThat is not my experience having to deal with a Python codebase for the first time in my life recently. I do not enjoy attempting to understand the magical annotations everywhere, the terse, cryptic syntax of list comprehensions, random syntax trivia like array[::-1], tons of line noise in regular expressions, having to __format__ "private" symbols like this, and so on. I obviously don't have experience with Python, but the only good thing about the syntax to my eyes is the vertical space savings you gain by doing away with curly braces.
- dragonwriter 4y ago> having to __format__ “private” symbols like this, But…that’s not how you format “private” symbols in Python, conventionally; single leading underscore is; double leading is for identifiers you want mangled with classnames, and double leading and trailing is for special methods.
- robofanatic 4y agoIs there a typo in the doc? Or is “hability” a real/madeup word?
- shogundev 4y agoThere could be many, thanks for pointing it out O U O
- mkl 4y agoThere sure are. I just pasted the readme in the comment box here (so Chrome would check the spelling) and removed the correctly spelled words to leave: hability, dependences, plataforms, enviroments, aplications, writting, appart, inmediately Your original title had "realease" too.
- DasCorCor 4y agoWould you consider releasing a less powerful version of the language with a smaller binary? Like a baby version? I’d be really curious what it could do do do do do do do.
- DeathArrow 4y agoMy question is: what problems Shark solves? Do we need Python in the front-end? Why?
- shogundev 4y agoShark doesnt solves any problem you could not solve with other languages, its just better at handling a whole wide range of problems others cant solve. Have you dreamed making the frontend and backend of your site in the same language, or building the same game in PC, Mobile and Nintendo 3DS from the same codebase and just a few commands? I do, and shark is my attempt at doing it. - Shogun
- DeathArrow 4y ago> Have you dreamed making the frontend and backend of your site in the same language, or building the same game in PC, Mobile and Nintendo 3DS from the same codebase and just a few commands? I do, and shark is my attempt at doing it. Sorry, you might think that I am rude, but I am not. I quite applaud your determination and your good will to work so hard and release an usable programming language. I didn't do that. I was just wondering if a Python like language is a good fit for front-end programming. I never dreamed about using one tool for everything but it happened. Nowadays I use C#/.NET for almost everything.
- mrtweetyhack 4y ago[dead]
- oblio 4y agoPython for front ends? Sure, it's very neat. See PyTk, PyQt, etc.
- yedpodtrzitko 4y ago> Sorry, you might think that I am rude, but I am not. But you got the answer for your original question, right?
- rc_mob 4y agoCool on you for building such an ambitious project
- antibasilisk 4y ago>'shark' programming language >sharks can't write it ngmi
- sinuhe69 4y agoIf Javascript is the target and the baseline benchmark, I wonder what is the rationale not using Javascript directly? Surely, the Python syntax is not the sole motivation, isn’t it?
- yedpodtrzitko 4y agoJS has its own warts, what better way to avoid them than not going that way in first place? Plus JS is still evolving, so devs would need to play catch-up to support all the latest features.
- andsoitis 4y ago> Plus JS is still evolving … very, very slowly. What language isn’t evolving?
- pull_my_finger 4y agoI think most people would disagree with that. The ecmascript versions even changed their naming from numbered to release year reference because they wanted to move fast and acknowledge a commitment to consistent/frequent release cycle. That's why they moved from es6 naming to say es2015 etc. Compare that to something like Lua which is notoriously slow and deliberate with changes. I tend to think with JS's willingness to adopt any and every hot/contemporary programming trend and it's inability to purge anything (or "break the web"), it's unfortunately destined to age like milk, but I guess time will tell.
- nico 4y ago> Imagine a programming language with the syntax of python, the hability to run in the browser and whose package has the size and speed of lua. Welcome to… … ChatGPT
- nozzlegear 4y agoBlockchain! Er wait, wrong hype cycle.
- Yoric 4y agoNo-code!
- archfrog 4y agoAs a language purist, I'm slightly saddened by the removal of the colon to indicate the beginning of an indented block on the next line. I believe Cobra did the same and it always bogs my mind why that darned colon can't be left in peace. When you are reading line N, you already know that the next line will be indented, if there is a colon, that is. It is all about making the reading experience as pleasant and meaningful as possible. Other than that: don't mind my gripes and congrats with the project. It looks good! :-)
- snthpy 4y agoI agree with this. +1
- keithalewis 4y agoSilly wabbit, colons are for WEPLs.
- iddan 4y agoLanguage designers: PROVIDE EXAMPLES IN ANY MAIN PAGE. Thanks
- shogundev 4y agoLMAO will do, check again in some minutes. -Shogun
- teo_zero 4y agoI'm going through the handbook and some things don't seem satisfactory. Division always yelds a floating-point number, so the following doesn't work, you have to explicitly use floor(): min = time / 60 sec = time % 60 Also var x = [1, 2, 3] x[1] /= 2 It's weird that now x includes one float and 2 integers. Besides, x[1] == 1 evaluates to false because a float never equals an integer. The description of 'for' loops is not complete. For example, does range(1, 10) go from 1 to 10 or from 1 to 9? What is the value of the iteration variable after exiting the loop? The example to handle a variable number of arguments calls the function callee() with 0 to 4 arguments. So it IS possible to have functions with a variable number of parameters. What's the goal of this example, then?
- shogundev 4y agoDivision yielding always a float is a python issue, in python you would use the floor division to get integers, but you cant do the same in plain shark because other target platforms might not have it. You can disregard and ignore most floating to int conversions and checks if youre NOT targeting python. Other platforms generally have just double precision and no integers (incluiding the C and Java ones) but not happening in python. In your example x[1] == 1 yields true in any platform. So dont worry. The for loop will iterate exacly end - start times with a start of 0 if missing and finish after end - 1 has executed. Using the iteration variable after loop exit is undefined behavior, some platforms keep the last value stored like python and javascript, others will make a wild assignment to a global variable every time like lua or the C/Java editions. Functions do NOT have variable lenght calls, if you read the code a second time, what its doing is looking up an array based in arguments length, and proceeding to switch on each case. Hope this helped, will update the handbook if something is unclear. - Shogun
- snarfy 4y agoI'm a fan of Lua's implementation. I looked through this source and it seems well written. Nice job :)
- emptysongglass 4y agoIt's frowned on in HN and I don't think I've ever done it (writing a comment that's just praise) but I think this is just so cool and can't wait to try and make a 2D game with it. I think your idiosyncratic grammar is actually charming and the sign of a creative mind. Hope you don't let the negative comments get you down.