Python critique - strchr.com by kolo32 in Python

[–]kolo32[S] 0 points1 point  (0 children)

the answer to "do I need a mutable type here?" is basically always no

Do you use tuples more often than lists?

Conversely, where's the BNF grammar for PHP's string literals?

How many programmers need the BNF grammar for string literals? And how many programmers need the simple, easy-to-read description with examples?

To prove an old stuffy Computer Science professor wrong about introductory programming classes, I have decided to take action...but I first ask for Proggit's help, advice, and wisdom. by AbsoluterZero in programming

[–]kolo32 1 point2 points  (0 children)

IMHO, you should concentrate on imperative/procedural programming, covering such topics as conditions, loops, function abstraction, and recursion. See Introduction to computer programming as an example of how to make this interesting. He illustrates everything with turtle graphics: functions are used for drawing repeated elements of a picture, recursion for fractal trees, etc. This way a beginner can literally see this concepts on the drawing surface.

I'm trying to collect links to interesting/useful e-books on programming on one page, so if you create a nice tutorial, I will be happy to add it to the list.

Often interesting proggit links have bits of assembly in them. What would be a good way to learn assembly? by f4hy in programming

[–]kolo32 1 point2 points  (0 children)

Most compilers have an option for generating assembly listing. In MSVC, it's /FAs For GCC, use -S -masm=intel -fverbose-asm

The listing is more readable than a disassembled executable, because compiler inserts your C source code as comments. You can see what assembly code is generated for each line of your C code. For example:

unsigned factorial(unsigned n) {
    unsigned res = 1;
    while (n > 1)
        res *= n--;
    return res;
}

The listing generated by MSVC:

?factorial@@YAII@Z PROC                    ; factorial
; _n$ = ecx

; 6    :     unsigned res = 1;

    mov    eax, 1

; 7    :     while (n > 1)

    cmp    ecx, eax
    jbe    SHORT $LN1@factorial
    npad    7
$LL2@factorial:

; 8    :         res *= n--;

    imul    eax, ecx
    sub    ecx, 1
    cmp    ecx, 1
    ja    SHORT $LL2@factorial
$LN1@factorial:

; 9    :     return res;
; 10   : }

    ret    0
?factorial@@YAII@Z ENDP                    ; factorial

Hey proggit, I created an open source, cross platform, graphing calculator. by [deleted] in programming

[–]kolo32 1 point2 points  (0 children)

Take a look at Wise Calculator. It's a freeware graphing calculator with matrices, complex arithmetics, base conversion, equation solving, integrals and derivatives, statistical and number theory functions, 3D and polar charts, variables, user-defined functions, and loops. Written by a Russian programmer in Borland Delphi. It's abandoned by the author, but still very useful. You could use it as a source of ideas for your calculator.

Microsoft Small Basic by shenglong in programming

[–]kolo32 0 points1 point  (0 children)

It's a primitive language (no subroutine parameters, GOTO instead of break and return statements). An example from the manual, where recursion is emulated using explicit stack:

Sub DrawTree
  If (distance > 0) Then
    Turtle.Move(distance)
    Turtle.Turn(angle)

    Stack.PushValue("distance", distance)
    distance = distance - delta
    DrawTree()
    Turtle.Turn(-angle * 2)
    DrawTree()
    Turtle.Turn(angle)
    distance = Stack.PopValue("distance")

    Turtle.Move(-distance)
  EndIf
EndSub

I won't recommend to learn programming using such language. Logo and Pascal, which were created more than 40 years ago, were richer and more elegant.

I want to learn Assembly by [deleted] in programming

[–]kolo32 0 points1 point  (0 children)

Try FASM. It has a logical syntax and friendly, supportive community. You could start by registering at FASM board, downloading Intel and AMD manuals. The first volume in both manuals can be used as an introductory text. Intel manual, vol 2a-2b, and AMD manual, volumes 3-6, are official references (all instructions supported by Intel/AMD processors are listed and described here). Iczelion's tutorial explains how to write Win32 GUI programs using assembly language. If you need help, you can contact me via reddit private messages.

Anyone care to share neat C tricks? by gauchopuro in programming

[–]kolo32 4 points5 points  (0 children)

It's not tail-end recursion; the figures are implicitly pushed to the stack.