Starting help for a newbie

I’m a newbie here. I write all my apps in AutoHotkey, but often I need smaller tools (Windows only) that need to be written in another language because AHK executables are too big (at least 500 kB). With the programming languages I’ve tried so far, I’ve had the big problem of missing Unicode support. So now I ended up here mainly because of the information that Go offers native Unicode support.

Could a friendly expert here show me if Go would be something for me? One tool I would need right now, for example, would be a small launcher program that would have to do the following, among other things:

  • Command line arguments, specified when starting the launcher, are to be determined:
    Launcher.exe “Arg 1” “Arg 2” …
  • The content of a binary file is to be read in as a byte string.
  • An executable is to be started with the previously determined CL arguments.
  • Note: The arguments and the name of the executables can contain Unicode characters!

My question: Is this sufficiently easy to do in Go even for a newbie? Would such a tool be smaller than 50 kB? Can someone here sketch a short demo code for such a launcher that I could start with?


PS: I have already installed Go and successfully experimented with hello.go… :wink:

Hi. If size is an issue will go be no option for you. A compiled executable will have a size in megabytes.

If you’re only in need of running on Windows maybe it would be better to learn powershell. It been build into all the latest versions of Windows and you can call any system functions. The programs will just be the size of the script.

1 Like


Powershell: In need an executable…

Yes, go links statically everything, especially its runtime (garbage collector, standard lib, etc).

A simple hello world produces a 1.9 MB executable, by applying strip I can get rid of ~0.6 MB and it shrinks to 1.3.

This is on a linux machine, I do not have a windows workstation at hands to test.

code used for this example:

package main

import "fmt"

func main() {
	fmt.Println("Hello, World!")

Where is a lot of ways to make a powershell script into an executable:

I have not used any of them so I can’t come with any recommendations. Just tested and created a helloworld script and got it compiled to a exe with the size 17kB

Thank you very much, johandalabacka!

Yes, I know these methods (PS2Exe), but this is associated with dependencies (PowerShell, .NET), which in my case should be avoided…

Either you want small binaries/scripts, but then you need to install its dependencies/RTEs or you want to have selfcontained binaries, but those get quite huge pretty fast.

1 Like

Powershell and .Net is part of any version of Windows 10 so you do not need to download anything.

Thank you, NobbZ!

Of course, but this is rather a very general view. In Freebasic my executable would be approx. 50 kB, and there are no dependencies. (Unfortunately the Unicode support is extremely bad…)

According to google, you need at least a Free Basic Runtime Environment if you want to use strings and arrays…

Also the created binary of Print "Hello, World!" does dynamically link to libc, libm, libpthread, libcursesw. and more. libpthread has a size of 150k, libm of 1.6M, libc another 2.1M. Shall I look up lib curses as well?

I’m not sure if there are tools like ldd available for windows as well, but believe me, you do have dependencies. On linux those are usually available, but still I wouldn’t rely on it in the sense that I’d say “I have no dependencies”, as there are linux systems out there that explicitely opt out from libc and use libmusl as a replacement. You need to recompile for those platforms.

Thank you, NobbZ, for your efforts to help me.

This shouldn’t be a theoretical discussion. The Launcher I am using at the moment ist written in Freebasic, its size is 57 kB, and it is definitely a standalone app (in the sense that there are no dependencies on not compiled components of Freebasic or .NET).

Can you run the program in question on a fresh windows installation? Not on a pre-installed windows that comes with all the bloat-ware, no, on a really fresh windows installation that comes without any extras?

Anyway, why do you think that actual binary size matters? On most modern systems they actually do not. Unless you do embedded I doubt that size is a valid concern.

But if the only thing you want to do is to actually automate some aspects of your system, stick to powershell or the windows script host.

And we might have told you already, but if size is really a concern for you, then go is not your go-to language.

1 Like

NobbZ, I don’t understand your effort to make the desire for a small executable look strange, but maybe you can consider that a small add-on should not be bigger than the actual app, and that there are situations where the size does matter. But…everything has been said about that.

And yes, I understand that Go is no option for my purposes.

Maybe you can just explain to me what hidden dependencies you mean when you’re tolking about “fresh Windows installations” vs. “pre-installed Windows”?

As I said already, I am speaking about runtime environements. For .Net its obviously the CLR, which comes pre-installed with every windows installation since Win 8.0 or even 7 and its also automatically updated through the Windows Update.

FreeBasic has a runtime as well, which might depend on other libraries, which again might be part of a base system or are not. I can not tell you more, as I do not have a windows available and I do not want it. You can find about DLLs referenced by your program using dependency walker, at least thats the first thing I find using google.

Of course I prefer 20 binaries sharing the same runtime installation over self contained binaries that come with the same code over and over again. At least from a users perspective. On the other hand side, as a developer who has to target systems where I can not control library installation, go is a nice language, as I know it will work on the target out of the box…

Thank you, NobbZ, for your explanation. According to my information FB has no such dependencies. If Windows functions are used, this is made by “#include once” to have access to kernel32.dll, which is part of every Windows version and installation.

Thanks to all here. Go’s Unicode support would be a great thing, but…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.