Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm trying to discover a low-level language that is similar in how code is written in Python.

I am not familiar with all technical terms relating to programming languages, but if you can think of it in terms of how "easy" it is to understand code in Python, then that is along the lines of what I am looking for.

Of course, a low-level language is meant to handle more complex tasks, but if the language is understandable the way Python is, then that is what I am looking for.

Examples of (assumed) low-level languages that I think may or may not share similarities with Python:


Go, Rust, D, Nimrod


If the question needs more detail, I will edit it. However, I think that what I am asking can be understood implicitly, without me needing to necessarily explain every small detail.

PS. Although quite a number of the low-level languages mentioned have built-in things like concurrency, the point I am trying to make is in terms of language-comprehension/understandability.

Edit:

As pointed out by the single answer from user60561, what I am looking for is a language that provides near C-level performance with Python-style syntax.

Also, the term "low-level" is sometimes difficult to interpret, so I would rather rank what low-level is in terms of an example.

Say I want to build a performance-based, real-time, mission-critical piece of software, I would need a language that is "low" enough to manipulate many things to fine-tune performance (without going to any language below C). Some people may contest that one should then choose the best language for the task at hand, but let us assume that the enterprise allows the developers to choose from the languages I provided above (Go, Rust, Nimrod, D) and specifies that they want the most suitable low-level language, but also the low-level language that will allow the easiest portability of skills from their existing Python-developer base.

share|improve this question

closed as primarily opinion-based by Doc Brown, amon, Robert Harvey, MichaelT, Donal Fellows May 11 at 7:44

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
There are many ways things can be 'similar' (syntax style? inheritance? bindings? memory management? etc...). How do you perceive each of Go, Rust, D, and Nimrod being similar to Python? –  MichaelT May 10 at 19:19
    
What are your criteria for "language comprehension" and "understandability"? –  Doval May 10 at 19:20
9  
Honestly, the term "low-level" is nothing well defined, and it is pretty unclear what you have in mind with this, but the level of abstraction a language provides is dependent on its syntax, and the more similar a language will be to Python, the more it will be on the same level of abstraction. So your question does not make much sense to me. –  Doc Brown May 10 at 19:20
    
If you like Python, check out Cython –  Dynamic May 10 at 19:37
7  
I'd like to chime in with the comment by @DocBrown: you need to explain what you mean by low-level. Languages are sometimes referred to as low-level if they lack features and syntax that provide high-level abstractions. In that sense asking for a low-level language similar to python is like asking for a square that is similar to a circle. On the other hand low-level may also mean having access to native OS facilities and the ability to manipulate memory directly. Which sense do you mean? –  Charles E. Grant May 10 at 19:41
show 4 more comments

1 Answer 1

Nimrod

It sounds like you want Python's syntax with C's performance, which Nimrod accomplishes well.

I've been playing with Nimrod for a few months now, it's a very nice language, and although productivity can be measured in bugs submitted per hour, it is still fairly usable unless you try to do complicated things with macros or the REPL.

Please note that my experience with Python is limited, so there may be subtle mistakes in my descriptions.

Example Code

import strutils

type
  TAbc = enum
    A = -1, B = 0, C = 1
let arr = [1, 2, 3, 4]
for i, elem in arr:
  echo("Elem #$1 is $2" % [$i, $elem])
if 'g' in {'a'..'b'}:
  echo "`g` is a lowercase letter!"
discard """
Multi-line comment!
"""

proc `*`*(a, b: TAbc): TAbc =
  result = TAbc(ord(a)*ord(b))

iterator myAbcs(): TAbc =
  yield A
  yield B
  yield C

echo(A * B)
echo(`*`(A, B))
echo(A.`*`(B))

for letter in myAbcs():
  echo("Top bound: $1; low bound: $2; letter: $3".format(
       high(TAbc), TAbc.low, letter))

# Possible, not a good idea though
import macros
macro void(body: expr): stmt {.immediate.} =
  let head = body[0]
  let procname = head[0]
  var params = newSeq[PNimrodNode]()
  for node in head.children:
    case node.kind
    of nnkCommand:
      params.add(newIdentDefs(node[1], node[0]))
    else:
      continue
  params = newIdentNode("void") & params
  var inside = newSeq[PNimrodNode]()
  for i in 1..(body.len - 1):
    inside.add(body[i])
    result = newProc(procname, params, newStmtList(inside))

void abc(int a, string b){
  echo("test"),
  echo("test1"),
  echo($a),
  echo(b),
}

abc(1, "passed string")

Similarities

  • Garbage collection
  • REPL (limited though, no FFI)
  • Metaclasses
  • Syntax is very similar
    • Similar iterator syntax (yield)
    • Space-based blocks
    • Similar loops, other control flow
    • Similar exception handling
    • Similar, but slightly different type annotations
    • and, not, or, in boolean operators
  • Closures
  • Tuples (I'm not a big fan of the implementation though)
  • Raw and multiline strings
  • Portable, though not yet perfectly

Differences

  • Statically typed
  • proc instead of def
  • OOP is more cumbersome
  • No for comprehensions, but can be implemented by macros
  • Non-insignificant number of bugs at this time

Additions

share|improve this answer
    
This is exactly what I meant! Thanks for understanding me implicitly. –  Joe May 11 at 22:17
    
I don't think that OOP is more cumbersome, it is just different. You define a type/object to hold your state, and then define procedures to manipulate it. If you put your object as the first parameter of the procedure (like you do with 'self' in python clases) you can call it as you would call an object method in python: objname.func(). –  ReneSac May 13 at 2:29
    
OOP isn't the issue for me. I don't mind it. I was just looking for something that is similar in syntax to Python and 'works' almost as fast as C. Nimrod seems to be the best option for that. –  Joe May 14 at 21:48
    
@Joe: I just learned yesterday that Nimrod GC is not thread-safe yet, so you might want to restrict yourself to single threads at the moment. I would also point out that Go is nowhere close to C's performance; it's good for web-server workloads (aka, I/O) but not as efficient in heavy computations, and unlikely to ever be. My personal recommendation here would be Rust, because Mozilla and Samsung are both pushing for efficiency (it matters a lot to them). –  Matthieu M. May 24 at 10:58
    
@MatthieuM.: Thanks for that feedback. I will be monitoring Rust too. –  Joe May 25 at 15:35
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.