• 0

why the machine like syntax?


Question

Hi,

 

I have been programming for many years now. And I am damn good at it if I say so myself. But what I never liked in programming was the syntax we use. Why is that the compilers or the interpreters are designed to make use of {}, function etc... to distinguish between objects, functions, etc...

 

For example in JAVA you have:

class MyClass {
    String MyProp;
    Integer MyProTwo;
 
    public void hello(){
 
    }
}

Why can't we make JAVA, PHP or C++ compilers to compile or interpret syntaxes that are more elegant. For example:

class MyClass
    s:myprop
    i:myprotwo
    v:hello
          print "i'm awesome"
    end

Or

make class MyClass. Define properties myprop,myproptwo. Make function hello print "I'm awesome"

What I am aiming for is something what .NET has done. You can program .NET applications in C#, J#, C++ etc... Is it possible to have some kind of XSTL bridge, so we programmers can design our own programming syntax? :p

 

myownsynxtax -> XSTL Template -> Mapped to JAVA/C# Native syntax.

Link to comment
https://www.neowin.net/forum/topic/1162504-why-the-machine-like-syntax/
Share on other sites

21 answers to this question

Recommended Posts

  • 0

Because it adds a lot more structure to the code. I personally can't stand languages like VB because I feel like it's a lazy language. It lets you do things that I'd consider bad habit, but work perfectly fine if you do them right, like less structure, sloppy variable definitions, etc. Sure, if you do it right it works as well as anything else, but it's also easy to make a mistake that's hard to find if you ask me. But that's why there are several different languages, so you can choose what you like. If you don't like a more structured language, then don't use it. I learned programming with C and C++ though so like I said, I can't stand the more loosely structured languages, but that's just my opinion.

  • 0

Anything other than rigidly defined structures and keywords are prone to be ambiguous statements. We humans understand each other using natural language fairly well, but every word and combination of words (number of which is rising almost exponentially) still has numerous interpretations depending on context, experience and present circumstances. And so terrible misunderstandings happen, often to tragicomic extent. Even with the best learning techniques and complex actual AI machines would still fail to interpret things the right way and meanwhile waste resources on very complex AI operations. Long story short - if machines would become more human-like, they'd also err like humans.

 

And then - even with rigidly defined structures each language has many coding, naming, spacing and newline conventions that makes readability and reuse, among other things, a challenging affair. If anything, I'd ask for even more strict templates and removal of most conventions.

  • Like 3
  • 0

wrote code like that in turing.  Made it difficult to find where I went wrong with things, took a lot longer to debug.

Plus, it's a pain in the butt trying to read someone else's code when it's clear, let alone a big block of text.

  • 0

Some existing languages are very succint. Take a look at Python or F# for example. Here is the quicksort algorithm in F#:

let rec quicksort = function
   | [] -> []                         
   | first::rest -> 
        let smaller,larger = List.partition ((>=) first) rest 
        List.concat [quicksort2 smaller; [first]; quicksort2 larger]

It's in general not possible to automatically translate programming languages from one to the other because they express different concepts. C++ templates for example have no equivalent in any similar language. .NET allows for language interoperability because they all compile to a common intermediate representation (IL), but even then it's not always possible to decompile F# code to C# or vice-versa.

 

I find that succintness is not an ideal, it's more of a dial that can be turned too far in either direction. Too verbose (i.e. Visual Basic), and it gets tedious to filter out the redundant information. Too succint (i.e. Perl), and it becomes hard to understand what the code means. The C family of langages has been extremely popular because it hits a nice balance between the two.

  • Like 3
  • 0
  Quote
Why can't we make JAVA, PHP or C++ compilers to compile or interpret syntaxes that are more elegant. For example:
Well, for a start, they wouldn't be Java, PHP or C++ compilers.
 
There are languages that have a "looser" structure than C-style languages. Personally I don't much care for any of them, I like the structure/rules that define C-style languages.
  • 0
  On 02/07/2013 at 19:43, roosevelt said:

What I am aiming for is something what .NET has done. You can program .NET applications in C#, J#, C++ etc... Is it possible to have some kind of XSTL bridge, so we programmers can design our own programming syntax? :p

 

myownsynxtax -> XSTL Template -> Mapped to JAVA/C# Native syntax.

 

Go for it. You can always design your own language extensions, or make your own front-end to a compiler.

http://www.cs.cornell.edu/Projects/polyglot/

 

It's basically a source-to-source translation from one language (your creation) to Java:

your_language -> polyglot+your_extension -> pure Java

 

I have written extensions to the Java language before... added Java language support for singleton objects by adding an 'object' keyword, used instead of 'class' to make a class a singleton. Also added support for strong mobility, which is pretty cool.

You can change up the Java grammar completely, make it your own.

  • 0

{ ... } adds a new scope.  You can use that in any area actually and not just around a loop, function, or class.

 

For example:

function test() {
  System.out.println("New scope below!");
  {
     String y = "Test";
     System.out.println(y); //y is only accessible here
  }
  System.out.println(y); //Can't use y here!
}
  • 0
  On 02/07/2013 at 20:00, threetonesun said:

Just code in Python. :laugh:

 

My first thought when I saw the OP's first "more elegant" example was also "Python!" That said, I don't think that Python is as loose as the OP thinks programming languages should be.

  • 0

Work in python for a while, and you'll soon appreciate the braces!

There's only so many times you can start using an editor which uses tabs instead of spaces, only to be chasing a seemingly never-ending "IndentationError: unindent does not match any outer indentation level".

  • 0

I looked into Python and the syntaxes Python offers is just what I was looking for. I also noticed how dead simple Python makes to do certain things (e.g. reading, wrting files or connecting to db). However, in terms of reliabiity and time tested confidence... how good is Python? Java is quite strong, has years of reputation and I am confident it's not going away anytime soon if ever. How about Python... how strong is its community, development and the range of it's modules? I am pretty confident if I there is a feature that needs to be coded in JAVA, chances are its already done. Do you have the same level of confidence for Python?

 

I also looked into wxpython for the desktop GUI... but it choked on me right away. I want to use Python3, but wxpython doesn't seem to support Python 3 just yet. Kind of killed my dream of using the same language to make not just cross platform but web applications too :p

 

I wish JAVA syntaxes were like Python... life would be simpler. I am looking into Ruby as well... RoR already had me excited for a while but I abandoned it due to some of its missing features in compairson to CakePHP.

  • 0
  On 05/08/2013 at 19:20, Brian M said:

Work in python for a while, and you'll soon appreciate the braces!

There's only so many times you can start using an editor which uses tabs instead of spaces, only to be chasing a seemingly never-ending "IndentationError: unindent does not match any outer indentation level".

 

Worked in Python for a while, I now hate braces.

 

  On 13/08/2013 at 06:13, roosevelt said:

I looked into Python and the syntaxes Python offers is just what I was looking for. I also noticed how dead simple Python makes to do certain things (e.g. reading, wrting files or connecting to db). However, in terms of reliabiity and time tested confidence... how good is Python? Java is quite strong, has years of reputation and I am confident it's not going away anytime soon if ever. How about Python... how strong is its community, development and the range of it's modules? I am pretty confident if I there is a feature that needs to be coded in JAVA, chances are its already done. Do you have the same level of confidence for Python?

 

Strong. I'm actually more confident in Python's survival. Java is about 1,700 severe security exploits away from someone somewhere thinking, "Hmm, maybe we should stop using this.". For some reason the first 1,699 didn't phase anyone. In all honesty neither are going away anytime soon. You're safe with Python.

  • 0

Python has a very strong developer community and can definitely be considered mature. The official Python documentation is excellent, and many extremely useful modules ship with Python by default. If those do not suit your needs, you can find a wide variety of Python modules written by other developers.

 

On thing you should be aware of with Python is the difference between the 2.x and 3.x releases: they are intentionally incompatible. Code written for Python 2 likely will not run on Python 3 without some modification. That said, the changes are very well documented - including official documentation for porting Python 2 programs to Python 3 - and the rationale for the breakage is solid: consistency and scalability.

  • 0

By the way I am playing around with Jython... and this blew my mind:

 

from javax.swing import JFrame, JLabel

def show_message_as_window(msg):
    frame = JFrame(msg,
                   defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
                   size=(100, 100),
                   visible=True)
    frame.contentPane.add(JLabel(msg))
    
show_message_as_window("testing...")

 

:o

  • 0

You try writing in AppleScript for a while and you'll love the braces, they tried making that language "easy to use" by using lots of English terms and structure (There's nouns and verbs), but because they've based it off an actual language rather than syntax, it feels like you're reading/writing a badly written novel.

  • 0
  On 13/08/2013 at 06:13, roosevelt said:

I looked into Python and the syntaxes Python offers is just what I was looking for. I also noticed how dead simple Python makes to do certain things (e.g. reading, wrting files or connecting to db). However, in terms of reliabiity and time tested confidence... how good is Python? Java is quite strong, has years of reputation and I am confident it's not going away anytime soon if ever. How about Python... how strong is its community, development and the range of it's modules? I am pretty confident if I there is a feature that needs to be coded in JAVA, chances are its already done. Do you have the same level of confidence for Python?

Python is very mature, although in general I think dynamic languages are on their way out. More and more you see statically typed languages offer the conciseness and productivity of dynamic languages, while offering the type safety, performance and tooling benefits of static typing, i.e. F# (.NET), Scala (Java), TypeScript (Web), Go (Native), Rust (Native), Cobra (.NET), etc.; to a certain extent C# and C++ since they both have limited type inference now (var/auto).

 

Since your original point of comparison was Java, you should note that Java is as verbose and inflexible as classic imperative/OO languages go; even in something relatively similar like C# it's often possible to express the same things in much less code, due to the more powerful type system, better designed libraries and more advanced language features. Overall I think there are much more significant factors than using braces to denote scope or having to prefix methods with their accessibility and return types.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • It’s encouraging that Intel is still competing, the best they can, in the gpu space.
    • Windows 11 KB5062233/ KB5060843/ KB5062197/ KB5061090 setup, recovery updates released by Sayan Sen This week Microsoft released non-security preview updates for Windows 11 22H2 and 23H2 under KB5060826 as well as for 24H2 under KB5060829. The company also published dynamic updates alongside them. Dynamic updates bring improvements to the Windows Recovery in the form of Windows Recovery Environment (WinRE) updates, also called Safe OS updates, as well as to the Setup binaries in the form of Setup updates. These Dynamic Update packages are meant to be applied to existing Windows images prior to their deployment. These packages include fixes to Setup.exe binaries, SafeOS updates for Windows Recovery Environment, and more. Dynamic Updates also help preserve Language Pack (LP) and Features on Demand (FODs) content during the upgrade process. VBScript, for example, is currently an FOD on Windows 11 24H2. Both setup and recovery updates were released. The changelogs are given below. First up we have the Setup updates: Up next, we have the recovery updates: Microsoft notes that the Recovery updates will be downloaded and installed automatically via the Windows Update channel. The Setup updates, however, need to be downloaded and installed manually. You can avail them on Microsoft's Update Catalog website: KB5062233, KB5060843, KB5062197, and KB5061090.
    • Gaming mouse review: Keychron Lemokey G2 8K Wireless, high performance, light in weight by Robbie Khan Available in the UK and USA, the G2 is a wireless gaming mouse by Lemokey, the customised gaming peripheral arm of Keychron, a brand many readers will know well. I've checked out Keychron keyboards recently, models such as the top-tier Q6 Max, and the bargain priced B6 Pro. I never got the chance to check out the G1, but the G2 seems to put itself firmly in-between competing 8K gaming mice out there whilst coming in at a decent sum under £100/$100. The other benefit is that it uses Keychron Launcher, the web-based software that has been a staple part of Keychron keyboards for a long time now. I rate the launcher highly and have rarely had a problem with it, so it is great to see a robust piece of software being used on an affordable gaming mouse that's not only built well, but performs well, too. As it's a high performance gaming mouse with a flagship PixArt sensor, I will be comparing the G2 directly against my personal mouse, the similarly sized Pulsar Feinmann F01. Both mice are priced wildly differently, so it was interesting to compared several factors between them to see if one bests the other where it matters most, or if it just comes down to individual preferences. Let's check out the specs... Keychron Lemokey G2 SKU G2-A1 Sensor PixArt 3950 IPS 750 MCU Realtek 8762G Connectivity Bluetooth 5.1 / 2.4 GHz / Wired (type-C cable) Polling Rate Up to 8000 Hz (2.4 GHz / wired mode), 125 Hz (Bluetooth mode) Motion Sync Yes Angle Snapping Yes Acceleration 50g Cable Detachable Type-C to C Cable + Type-A to Type-C adapter Dongle Micro USB-A dongle Main switches Huano Micro Switch Switch lifespan 80 Million Clicks Battery 300 mAh Battery life 60 Hours (Under 1000Hz) 35 Hours (1000-4000Hz) 20 Hours (4000-8000Hz) Skates Teflon / PTFE Lift Off Distance 0.7 / 1.0 / 2.0 mm Material (Body and Grip) ABS Dimensions 118mm / 62.6mm / 38.2mm Tracks on glass (min. 4 mm thickness) Yes (max 1000Hz report rate) Weight 52 ± 3 g Colours Black / White Price £73.99 / $69.99 Fit and finish Made of all ABS, it certainly doesn't feel anywhere near as nice as the F01, but then again it's priced much lower, so no complaints there. To me it feels more like a previous generation Endgame/Zowie mouse, before they started to use the more grippy textured finish. It's a fine finish but how long that lasts only time will tell. With the Endgame mice I always found that the side buttons would go shiny first, and I suspect the exact same to apply here with the G2, since the size and shape of them is similar, as is the material quality. Speaking of side buttons, my personal preference is flat and large buttons, the long and pointed ones like those on the G2 shown above and GAMIAC PX71 at the bottom always felt a bit awkward to me for naturally resting a thumb on, whereas the large surface area of the ones found on the Feinmann and others like it feel more ergonomic and comfortable for long usage sessions. Pulsar Feinmann F01 (ergo shape) Lemokey G2 (ambidextrous shape) Under my 19cm hand, the G2 feels comfortable and stable for both claw and palm grip styles, though my usual style is a hybrid approach. I like to pinch a mouse with a thumb and ring finger, then articulate forward or backward movement with them to adapt to different play-styles. Both mice have a sloping back hump that works brilliantly for this and i had no problem getting comfortable with the G2 here. The underside of the G2 hides a cool feature I wish more more mice makers adopted, can you spot what it is in the photo below? That little flap at the bottom to store the USB dongle, it's convenient, especially for gamers who travel with their mice or laptop gamers. The skates applied are PTFE and cover three zones on the underside, sadly I forgot to take a photo of them before swapping them out to my preferred skates, the Wallhack Pro UWMP yellow dots. I found no problem with glide resistance on the stock skates, though find dots glide nicer overall and these yellow dots slide around like butter. Lemokey states 52g for the weight, give or take 3g, so my scales measure up perfectly here. It's not as lightweight as the Feinmann which currently is 45g, but it's still considered super-light and honestly, under the hand, this weight difference on dot skates is hard to tell apart. Gripping the G2 hard on both sides shows no obvious issues with flexing, so the internal construction is also up to scratch and exactly what i would expect in this price range. The differences start to be noticed when you are using the G2 as a combination mouse, both in gaming and desktop use. The wheel is thinner than the one on the Feinmann and other gaming mice with fat wheels. I much prefer a nice wide wheel, the diameter is also much larger as can be seen with the overhead photo above. The button tops also have a distinct difference in feel when actuating the switches. there is more of a hollow feel to the G2's tops, as well as slightly more travel post-click. the Huano switches feel and sound excellent, though, but I think the ABS contact surface on the outside could have been slightly more distinct in feel. Here is a demo of how the main switches sound, you can also hear the switch tops clap if you pay attention: Likewise the side buttons have extra play after the switches actuate, something the Feinmann and others in the higher price category don't tend to have. Features & software Aside from the usual features that all gaming mice support these days, such as Motion Sync, lift off distance and Macro, the big feature with the G2 is that is uses Keychron Launcher, the web-browser based software. All changes are stored directly onto the on-board memory, here is what the sections within it look like: I found no bugs with the implementation here, and unlike other Keychron wireless devices I have used with Launcher in the past, the G2 connects and can be customised in it over both wired and wireless. Just be aware that the firmware update option when connected via wireless will only check the dongle's firmware. To check the G2's firmware, a USB cable will need to be connected. Performance Whether on the desktop in Windows or in games, the cursor and motion performance is excellent, though this is to be expected from all modern gaming mice, regardless of price. The higher priced mice tend to have better use of high quality materials, and implementation of software and physical features. I'm currently pacing through nine games, all mixed genre, and in each of them I had no troubles quickly getting comfortable with the G2. If you're used to an Endgame XM2we sized mouse, then this will be just as familiar to you. The convenience of the DPI button at the top of the mouse instead of underside makes instant switching simpler, although the button can be remapped to do something else for those who don't care about DPI toggling. Here is a demo of the G2 playing Doom: The Dark Ages: The sensor tracking performance at 8K was perfect, aside from the few moments my physical movement on the mousepad slowed down causing some drops in the Razer mouse tracking measurement graph below: A consistent 7900-8000Hz polling was observed, though keep in mind that using such high polling rates will impact CPU performance whilst gaming. How much this affects framerates will boil down to the CPU you have. On my i7 12700KF there was no change whilst gaming, but during the measurement above I did observe 13% CPU package utilisation. In practice, though, I saw no performance difference playing at 8K versus 2K or even 1K. Battery life will drastically be impacted at 8K polling rates for obvious reasons, and whilst many prefer 4K, there is a growing trend to just stick to 2K which feels the safe middle ground of great battery performance, whilst still being suitably responsive on paper for even the most fast-paced of gaming sessions. Conclusion The Lemokey G2 has proven to be a rather excellent mouse, not just for gaming, but general use, too. Though being excellent doesn't give it any special status, as there are equally excellent mice out there that cost the same, less and even more. A buying decision will come down to individual needs, do you value the use of a browser-based software tool like Keychron Launcher? If so, then this is right up your street. Do you want something lightweight but also supports the gaming features and feel in the hand as more expensive mice? Maybe the G2 will satisfy. It's not totally perfect, nothing ever is, the thumb buttons could have been a bit wider, and the switch caps have more travel after clicking than what I am comfortable with, but otherwise this is a great mouse with features that rival the competition. The sensors on gaming mice these days isn't a key selling factor any more either, since even entry level gaming mice are capable of precision tracking and speed that was only possible on the top-tier models of the past, like many things in tech now, the point of diminishing returns has been reached, and brands have to work harder at giving us consumers a unique selling point to attract interest. I believe the G2 has at least one USP (Keychron Launcher), it also helps that it's a very comfortable mouse to use for all-day sessions.
    • Delays can happen any time and names changed, but the joke was still there to be made.
  • Recent Achievements

    • Week One Done
      Alexander 001 earned a badge
      Week One Done
    • Week One Done
      icecreamconesleeves earned a badge
      Week One Done
    • One Year In
      PAC0 earned a badge
      One Year In
    • One Month Later
      PAC0 earned a badge
      One Month Later
    • One Year In
      Shahmir Shoaib earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      564
    2. 2
      +FloatingFatMan
      187
    3. 3
      ATLien_0
      185
    4. 4
      Skyfrog
      113
    5. 5
      Xenon
      110
  • Tell a friend

    Love Neowin? Tell a friend!