Search Unity

I just invented a new programming language!

Discussion in 'General Discussion' started by TheGaul, Nov 8, 2019.

  1. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    My new language is for fast protyping. I call it the skeleton langauge. Suitable for this time of year! :eek::eek::eek::eek:
    Here is some pseudo-javascript:

    Code (javascript):
    1. var x=3;
    2. var y=5;
    3. var z=x+y;
    4. var s=[1,2,3,4,5];
    5. for(var k=1;k<=10;k++){
    6.   console.log( "Square of "+k+" is "+(k*k)+"\n");
    7.   if (k%2==0){
    8.      console.log(k+" is even\n");
    9.   }
    10. }
    11.  
    12. function sum(x,y){
    13.    return x+y
    14. }
    15.  
    16. t = sum(3,5)
    17.  
    18. class Animal{
    19.      var height;
    20.      Animal(h){
    21.          height=h;
    22.      }
    23.      function weight(){
    24.         return Math.pow(height,3);
    25.     }
    26. }
    27.  
    In my new language this becomes (looks better without the line numbers):
    Code (csharp):
    1. x 3
    2. y 5
    3. z x+y
    4. s [1 2 3 4 5]
    5. k 1 10
    6.   @ "Square of " k " is " k*k "\n"
    7.   k%2=0
    8.      @ k " is even\n"
    9.  
    10. sum x y->z
    11.    z x+y
    12.  
    13. t sum 3 5
    14.  
    15. Animal h :
    16.      height h
    17.      weight -> z
    18.         z height^3
    19.  
    Mainly it involves just removing as much extraneous characters as possible. It would be good as a scripting language for fast prototyping. Not really sure the best way to do while loops or more complicated for loops. To pass a function as an argument you might need to wrap it in brackets like this: (Math.sin) so it doesn't execute.
     
    Last edited: Nov 8, 2019
    Aiursrage2k and neoshaman like this.
  2. hard_code

    hard_code

    Joined:
    Aug 29, 2013
    Posts:
    238
    looks like coffeescript :)
     
  3. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    Oh yeah. :(
    But mine does away with 10% more characters! :cool:All that time you spend typing the = sign. And you can save vital seconds by not having to type in "for", "in" and "if".

    I'll call mine "black coffeescript". It's like coffee but without the added extras.

    Or maybe just "hotwaterscript".
     
    frosted and hard_code like this.
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I think you'll find you are actually increasing the mental load on the developer here, not reducing it. I'm willing to bet it will take most developers longer to read and write code without all of the extra symbols.
     
    Billy4184, vakabaka, XCPU and 6 others like this.
  5. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Wow that's incredibly readable, I didn't even had to reference the original to just get it! :D

    I was like how to support float, and 1 frame later my brain spawn:
    x 1f or x 1.0
    Which mean type is actually easy too as we can generalized

    I'm not even sure you actually need the @ for print/log when we use string
     
    TheGaul likes this.
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,154
    Plus I would think a language where your brain is forced to fill in the blanks more would lead you to become mentally tired faster working with it than a language where you have additional symbols to indicate meaning.
     
  7. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    Yes exactly. :) So you might write:
    Code (CSharp):
    1. z complex 3 4
    to create a new complex variable for example.

    It's not really designed for readability more for writability to write really really quick pieces of code. Such as printing out the first 10 square numbers.
    But actually with the indents, it's not too hard to see what's meant to be a for statement or an if statment. Well maybe a little! Here is the fibonacci code:
    Code (CSharp):
    1. fib n->m
    2.   n < 2
    3.     m n
    4.   else
    5.     m fib (n - 1) + fib (n - 2)
    (couldn't work out a nice way to get rid of the else statement :() I suppose one could write:

    Code (CSharp):
    1. fib n->m
    2.   m  n<2 ? n : fib (n - 1) + fib (n - 2)
    in this case. Well anyway it still needs work. In fact one could write this as a oneline function just as:
    Code (CSharp):
    1. fib n -> n<2 ? n : fib (n - 1) + fib (n - 2)
     
    Last edited: Nov 8, 2019
  8. Is this a joke or something? Because I don't get it.

    There is a reason why we abstracted away from ASM, why BASIC isn't the leading programming language anymore and why PHP became the leading backend script language in the '90-ies and not Perl.
     
    Ryiah, vakabaka, Antypodish and 2 others like this.
  9. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    Well the idea is, you think to yourself. What are the first 10 cube numbers? I have no time to lose. Then you just type:
    Code (CSharp):
    1. x 1 10
    2.    @ x*x*x
    And your done in 12 keystrokes. Which usually would have taken you 24. You probably don't even need the "@" symbol as suggested. A single value could just be printed out. Saving you another valuable second. I'm trying to cut it down even further.
     
    Last edited: Nov 8, 2019
  10. That's where you're wrong and you will realize it as soon as you start to write something serious in your "brand new" language.

    What people don't get when they start to code that it is not the typing what takes the time.
    Especially not in the golden era of IDEs. But this comes with experience, if you code enough you will realize that analyzing the situation, the code paths, the existing logic, the ways you can solve a particular problem takes more time than type 2-5 characters and hit enter to give the IDE the chance to do the typing for you.
     
    Last edited by a moderator: Nov 8, 2019
    Amon, elcionap, Socrates and 2 others like this.
  11. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    It's not for "serious" things. It's for fast calculations and prototyping. The fastest possible way to get from an idea in your head to the result.
     
  12. Well, good luck with that.
     
    TheGaul likes this.
  13. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    Thanks man! :)
    Here would be the Hello World program in this language:
    Code (CSharp):
    1. @ "Hello World!"
    Hmmm... having thought about it. Having a space instead of an = doesn't technically save any characters. :( But I think it is faster because the space bar is easier to find on the keyboard.
     
    Last edited: Nov 8, 2019
  14. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    I've just been having a look at CoffeeScript. It's a pretty cool language. I might even say better than Python. Wouldn't mind using this a scripting language in Unity. I wonder if this is possible.
    I suppose one would have to make a program that converts it to c#.
     
  15. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    For myself i know that despite programming for a long time, I still recoil at all the clutter wart even with modern ide that polish the original turd.

    This doesn't solve that problem but make it much more palatable. Now it can probably even be better exactly with the use if ide.

    I welcome my uncluttered overlord.
     
  16. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493


    I also have been using that, it has help me scan code faster by grouping stuff in way that actually make sense.
     
    Ryiah likes this.
  17. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    While I think its rather cool you made this, I also think its not really "scalable". As others have said you would get tired quicker and I like to think about programming as "can I do this when its 3am and I have not slept for 3 days?".

    This language is great if you are at full mental capacity but what about when your tired, struggling to concentrate due to coworker noise etc? I imagine it will get tiresome as there is a reason something like this hasnt materialised - people have made similar efforts in the past but they never catch on for exactly those reasons

    And thats before you start to think about it from a code review point of view. A lot of what you call time saving, could be seen as ambiguity, which just lengthens how long it takes to code review with another member of staff etc. "Im not sure, do you mean this or this? I read it as X but it could also be Y or Z" sort of thing
     
    Socrates likes this.
  18. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    C# is a pretty tight langauge as it is. Problems arise when people use comments, bad naming, brackets, explicit type declarations instead of 'var'. etc.

    There are too easy to write unmaintainable code in C#
     
  19. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    @mountainstream whipe is cool inventing stuff, your sample fails at very first post.

    Code based on indentations, without brackets can become quickly very messy and hard to maintain.
    Just look you very first example class. It uses double indentation. Where really should be single indentation. So you start confusing even yourself at very start.
     
    MadeFromPolygons likes this.
  20. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    Agreed! Nicely spotted!
     
  21. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    For single line blocks then brackets are just noise.

    like
    Code (CSharp):
    1. if(earlyExit) return;
    or
    Code (CSharp):
    1. if(badargument) throw new ArgumentException("...");
     
  22. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    @AndersMalmgren only difference is, C# don't cares about multiple spaces, new lines, or indentations. You can write your game equally in single line, or 1000 files.
     
  23. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Yeah, thats not my point though. C# has some things that let you write less readable code. Like brackets even though your only have one statement. Or explicit types when you have the much cleaner 'var' keyword.

    edit: plus most sane devs never codes two ; statements on the same line, so when you say line yuo mean that it ends after the first ;
     
  24. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Ugh, explicit type declarations can be very useful part of clear code. Not always, but it definitely has its place.
     
    AxPetre, Ony and vakabaka like this.
  25. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    I would say in a local scope its always better to use var, as thats the position microsoft seem to take these days, but it always feels horrible to me when I do it.
     
    vakabaka likes this.
  26. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    You cant do it outside of local scope :D

    edit: or you mean super local, like a if block?
     
  27. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    I was more talking about how you should use it instead of explicit types when inside of local scope (super local or just local, either are good), I never said that you can use it outside of local scope.
     
  28. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    If you dont think methods are local then you need to start with method extraction refactoring ;)
     
  29. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    I think you think I am saying something completely different to what I am actually saying.

    I have not said anything is or isnt local / super local scope, nor was I implying such.

    I simply said that inside of any local scope, you should be using var instead of explicit types if going in accordance with microsoft msdn style of writing c#. Stop trying to read between the lines dude
     
  30. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Personally i've never been a fan of using vars except in cases on linq queries. I like to know exactly what something is, as it can't possibly be confused as to what it is, it helps me read it, understand it and find it simpler to write my self.

    I mean if you have 200 public var variables doing all sorts of different things it can be pretty hard to determine within 0.5 seconds what something is. At least if it clearly says 'float', 'bool', 'Vector3', 'Vector2','string','Text', 'Button', etc you know what they are immediately.
     
  31. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    How could you have a public var variable?
     
  32. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    var is not possible outside methods (its the largest scope they are accepted in), so its a moot point
     
  33. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Like I said, I don't use them, so I didn't know if you could or couldn't. Just figured you'd add it so the variable would show in the inspector lol
     
  34. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    *sigh* you are really not understanding buddy. You can still use explicit types inside of a method yes? So what I am saying is, INSTEAD of doing that you should use var. Seriously man what is hard to understand about that?
     
  35. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Is there a benefit to using vars for everything inside a method? (Serious question). Like - is it faster to run (magnitudes) faster? If not, then why not settle for readability?

    This is a legit question, I really don't know, I've only ever used them for LINQ stuff.
     
  36. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    It really sounded like you though that was a too big of a scope. But then we agree. They should be used everywhere where the language support them. good :D
     
    MadeFromPolygons likes this.
  37. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    The compiler will change it to the explicit type. No difference. Its just easier to read when you dont have the type. Its just an readability improvement
     
    N1warhead likes this.
  38. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    Haha yes thats why I was getting irritated, because I knew that actually we are on the same page :D No worries! Its difficult to explain things by text without body language etc :)
     
    AndersMalmgren likes this.
  39. hard_code

    hard_code

    Joined:
    Aug 29, 2013
    Posts:
    238
    Too bad they removed UnityScript since Coffescript compiles to javascript.

    I have long thought that creating a language on top of Unity with game specific conveniences that compiles down to c# would be a cool project. Something like skookumscript.
     
  40. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    For what purpose?
    You would need learn 3 languages, to achieve the same thing.
    First some obscure language, then JS, then C#, since JS was long time on way out.
    You can always build your own interpreter, if you find it required.
     
  41. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
    I don't understand this at all. Why would var ever be easier to follow, rather than when the type is spelled-out explicitly?
     
    Ony likes this.
  42. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    Some people like work alone. That is why :)
     
    Kiwasi and Lurking-Ninja like this.
  43. hard_code

    hard_code

    Joined:
    Aug 29, 2013
    Posts:
    238
    I was half kidding about the UnityScript/javascript thing. But having used skookumscript I loved it for fast prototyping. It has all kinds of game dev conveniences builtin to the language itself. But yes it was too esoteric and it's integration with unreal was not the best.
     
  44. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I have 40 developers in my team, you?
     
  45. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Its just noise, naming, context and separation are real values
     
  46. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Don't forget with intellisense / autocomplete, typing is not a concern for most languages. Also you spend a lot more time thinking about the problem than typing at all (for real programs).

    If I made games as fast as I could type, I would be a very very rich man by now.
     
    Kiwasi and Aiursrage2k like this.
  47. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    The idea of removing type with var has nothing todo with typing, it's when the next developer comes by and need to read the code


    Edit: OK it has a bit with typing todo, with Linq and similar libraries you don't know what the return type will be, it can be a IGrouping<T> etc. And actually rich and complex domains are similar the exact type is not important
     
    Last edited: Nov 8, 2019
  48. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    As hobbyist I am one. I would love to comment more, but this thread already went too much one sided (again) in my view, so I drop it.
     
  49. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    You should comment as little as possible, only comment why you do something not how. The how is the code.
     
  50. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    Too much red wine again? Because I haven't been referring to coding at all.

    We really should get back on OP topic, if anything constructive to add.